From 598c7c151d619e71650dc361de8337c35aa333b2 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 28 Feb 2023 12:22:13 +0100 Subject: [PATCH 01/96] Remove some locks from progress update Removes mutex locks when updating pixel counts etc. Also, when in background mode text status updates are removed. --- intern/cycles/blender/session.cpp | 1 + intern/cycles/util/progress.h | 152 ++++++++++++++++++++---------- 2 files changed, 103 insertions(+), 50 deletions(-) diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index ab0190ad235..206cc2b49f2 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -125,6 +125,7 @@ void BlenderSession::create_session() session = new Session(session_params, scene_params); session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this)); session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this)); + session->progress.set_updates(background); session->set_pause(session_pause); /* create scene */ diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 586979d2021..7cea10bc96e 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -10,10 +10,12 @@ * update notifications from a job running in another thread. All methods * except for the constructor/destructor are thread safe. */ +#include #include "util/function.h" #include "util/string.h" #include "util/thread.h" #include "util/time.h" +#include "util/log.h" CCL_NAMESPACE_BEGIN @@ -40,6 +42,10 @@ class Progress { error = false; error_message = ""; cancel_cb = function_null; + updates = true; + update_time = true; + update_pixels = true; + update_status = true; } Progress(Progress &progress) @@ -49,14 +55,18 @@ class Progress { Progress &operator=(Progress &progress) { - thread_scoped_lock lock(progress.progress_mutex); + // Busy wait until update status is true + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress.progress_mutex); progress.get_status(status, substatus); - pixel_samples = progress.pixel_samples; - total_pixel_samples = progress.total_pixel_samples; + pixel_samples = progress.pixel_samples; //.load(); + total_pixel_samples = progress.total_pixel_samples; //.load(); current_tile_sample = progress.get_current_sample(); + update_status = true; return *this; } @@ -79,14 +89,23 @@ class Progress { cancel_message = ""; error = false; error_message = ""; + updates = true; } + void set_updates(bool updates_) { + updates = updates_; + VLOG_INFO << "Set progress updates " << (updates_? "on" : "off"); + } + /* cancel */ void set_cancel(const string &cancel_message_) { - thread_scoped_lock lock(progress_mutex); + //thread_scoped_lock lock(progress_mutex); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; cancel_message = cancel_message_; cancel = true; + update_status = true; } bool get_cancel() const @@ -97,10 +116,20 @@ class Progress { return cancel; } - string get_cancel_message() const + bool get_updates() const { - thread_scoped_lock lock(progress_mutex); - return cancel_message; + return updates; + } + + string get_cancel_message() //const + { + string msg; + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); + msg = cancel_message; + update_status = true; + return msg; } void set_cancel_callback(function function) @@ -111,12 +140,15 @@ class Progress { /* error */ void set_error(const string &error_message_) { - thread_scoped_lock lock(progress_mutex); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); error_message = error_message_; error = true; /* If error happens we also stop rendering. */ cancel_message = error_message_; cancel = true; + update_status = true; } bool get_error() const @@ -124,51 +156,61 @@ class Progress { return error; } - string get_error_message() const + string get_error_message() //const { - thread_scoped_lock lock(progress_mutex); - return error_message; + string msg; + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); + msg = error_message; + update_status = true; + return msg; } /* tile and timing information */ void set_start_time() { - thread_scoped_lock lock(progress_mutex); - - start_time = time_dt(); - end_time = 0.0; + // Busy wait until update status is true + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + start_time = /*.store(*/time_dt(); //); + end_time = 0.0; //.store(0.0); + update_status = true; } void set_render_start_time() { - thread_scoped_lock lock(progress_mutex); - - render_start_time = time_dt(); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + render_start_time = /*.store(*/ time_dt(); //); + update_status = true; } void set_time_limit(double time_limit_) { - thread_scoped_lock lock(progress_mutex); - - time_limit = time_limit_; + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + time_limit = /*.store(*/time_limit_; //); + update_status = true; } void add_skip_time(const scoped_timer &start_timer, bool only_render) { double skip_time = time_dt() - start_timer.get_start(); - render_start_time += skip_time; + double rst = render_start_time + skip_time; + render_start_time = rst; if (!only_render) { - start_time += skip_time; + double st = start_time + skip_time; + start_time = st; } } void get_time(double &total_time_, double &render_time_) const { - thread_scoped_lock lock(progress_mutex); - - double time = (end_time > 0) ? end_time : time_dt(); + double et = end_time; + double time = (et > 0) ? et : time_dt(); total_time_ = time - start_time; render_time_ = time - render_start_time; @@ -181,8 +223,6 @@ class Progress { void reset_sample() { - thread_scoped_lock lock(progress_mutex); - pixel_samples = 0; current_tile_sample = 0; rendered_tiles = 0; @@ -191,15 +231,11 @@ class Progress { void set_total_pixel_samples(uint64_t total_pixel_samples_) { - thread_scoped_lock lock(progress_mutex); - total_pixel_samples = total_pixel_samples_; } double get_progress() const { - thread_scoped_lock lock(progress_mutex); - if (pixel_samples > 0) { double progress_percent = (double)pixel_samples / (double)total_pixel_samples; if (time_limit != 0.0) { @@ -213,8 +249,6 @@ class Progress { void add_samples(uint64_t pixel_samples_, int tile_sample) { - thread_scoped_lock lock(progress_mutex); - pixel_samples += pixel_samples_; current_tile_sample = tile_sample; } @@ -227,8 +261,6 @@ class Progress { void add_finished_tile(bool denoised) { - thread_scoped_lock lock(progress_mutex); - if (denoised) { denoised_tiles++; } @@ -239,7 +271,6 @@ class Progress { int get_current_sample() const { - thread_scoped_lock lock(progress_mutex); /* Note that the value here always belongs to the last tile that updated, * so it's only useful if there is only one active tile. */ return current_tile_sample; @@ -247,13 +278,11 @@ class Progress { int get_rendered_tiles() const { - thread_scoped_lock lock(progress_mutex); return rendered_tiles; } int get_denoised_tiles() const { - thread_scoped_lock lock(progress_mutex); return denoised_tiles; } @@ -261,10 +290,14 @@ class Progress { void set_status(const string &status_, const string &substatus_ = "") { + if(updates) { - thread_scoped_lock lock(progress_mutex); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); status = status_; substatus = substatus_; + update_status = true; } set_update(); @@ -272,9 +305,13 @@ class Progress { void set_substatus(const string &substatus_) { + if(updates) { - thread_scoped_lock lock(progress_mutex); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); substatus = substatus_; + update_status = true; } set_update(); @@ -282,10 +319,13 @@ class Progress { void set_sync_status(const string &status_, const string &substatus_ = "") { - { - thread_scoped_lock lock(progress_mutex); + if(updates) { + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); sync_status = status_; sync_substatus = substatus_; + update_status = true; } set_update(); @@ -293,18 +333,22 @@ class Progress { void set_sync_substatus(const string &substatus_) { - { - thread_scoped_lock lock(progress_mutex); + if(updates) { + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + //thread_scoped_lock lock(progress_mutex); sync_substatus = substatus_; + update_status = true; } set_update(); } - void get_status(string &status_, string &substatus_) const + void get_status(string &status_, string &substatus_) // const { - thread_scoped_lock lock(progress_mutex); - + // thread_scoped_lock lock(progress_mutex); + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; if (sync_status != "") { status_ = sync_status; substatus_ = sync_substatus; @@ -313,13 +357,14 @@ class Progress { status_ = status; substatus_ = substatus; } + update_status = true; } /* callback */ void set_update() { - if (update_cb) { + if (updates && update_cb) { thread_scoped_lock lock(update_mutex); update_cb(); } @@ -331,7 +376,7 @@ class Progress { } protected: - mutable thread_mutex progress_mutex; + //mutable thread_mutex progress_mutex; mutable thread_mutex update_mutex; function update_cb; function cancel_cb; @@ -353,6 +398,10 @@ class Progress { /* End time written when render is done, so it doesn't keep increasing on redraws. */ double end_time; + std::atomic update_time; + std::atomic update_pixels; + std::atomic update_status; + string status; string substatus; @@ -364,6 +413,9 @@ class Progress { volatile bool error; string error_message; + + // Used to enable progress updates if true + bool updates; }; CCL_NAMESPACE_END -- 2.30.2 From 31bda3d61328e96defb5917134701bb54216c939 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 1 Mar 2023 13:44:14 +0100 Subject: [PATCH 02/96] Create function to update progress values locklessly --- intern/cycles/blender/session.cpp | 2 +- intern/cycles/session/session.cpp | 2 +- intern/cycles/session/session.h | 2 +- intern/cycles/util/progress.h | 235 ++++++++++++++++-------------- 4 files changed, 125 insertions(+), 116 deletions(-) diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index 206cc2b49f2..b343ef5f8ce 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -125,7 +125,7 @@ void BlenderSession::create_session() session = new Session(session_params, scene_params); session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this)); session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this)); - session->progress.set_updates(background); + session->progress.set_updates(!background); session->set_pause(session_pause); /* create scene */ diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp index 9e7e0e6e2a4..7d98cc60cd1 100644 --- a/intern/cycles/session/session.cpp +++ b/intern/cycles/session/session.cpp @@ -629,7 +629,7 @@ void Session::set_display_driver(unique_ptr driver) path_trace_->set_display_driver(move(driver)); } -double Session::get_estimated_remaining_time() const +double Session::get_estimated_remaining_time() //const { const double completed = progress.get_progress(); if (completed == 0.0) { diff --git a/intern/cycles/session/session.h b/intern/cycles/session/session.h index d431c61a5fc..6ae9a45553f 100644 --- a/intern/cycles/session/session.h +++ b/intern/cycles/session/session.h @@ -137,7 +137,7 @@ class Session { void set_output_driver(unique_ptr driver); void set_display_driver(unique_ptr driver); - double get_estimated_remaining_time() const; + double get_estimated_remaining_time(); // const; void device_free(); diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 7cea10bc96e..57c05840745 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -21,6 +21,8 @@ CCL_NAMESPACE_BEGIN class Progress { public: + using callback_type = function; + Progress() { pixel_samples = 0; @@ -55,18 +57,14 @@ class Progress { Progress &operator=(Progress &progress) { - // Busy wait until update status is true - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress.progress_mutex); + update_progress([this, &progress]() { + progress.get_status(status, substatus); - progress.get_status(status, substatus); - - pixel_samples = progress.pixel_samples; //.load(); - total_pixel_samples = progress.total_pixel_samples; //.load(); - current_tile_sample = progress.get_current_sample(); - - update_status = true; + pixel_samples = progress.pixel_samples; + total_pixel_samples = progress.total_pixel_samples; + current_tile_sample = progress.get_current_sample(); + }); + return *this; } @@ -100,12 +98,11 @@ class Progress { /* cancel */ void set_cancel(const string &cancel_message_) { - //thread_scoped_lock lock(progress_mutex); - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - cancel_message = cancel_message_; - cancel = true; - update_status = true; + update_progress([this, cancel_message_]() { + cancel_message = cancel_message_; + cancel = true; + update_status = true; + }); } bool get_cancel() const @@ -124,11 +121,9 @@ class Progress { string get_cancel_message() //const { string msg; - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - msg = cancel_message; - update_status = true; + update_progress([this, &msg]() { + msg = cancel_message; + }); return msg; } @@ -140,15 +135,13 @@ class Progress { /* error */ void set_error(const string &error_message_) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - error_message = error_message_; - error = true; - /* If error happens we also stop rendering. */ - cancel_message = error_message_; - cancel = true; - update_status = true; + update_progress([this, error_message_]() { + error_message = error_message_; + error = true; + /* If error happens we also stop rendering. */ + cancel_message = error_message_; + cancel = true; + }); } bool get_error() const @@ -156,14 +149,13 @@ class Progress { return error; } - string get_error_message() //const + string get_error_message() // const { string msg; - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - msg = error_message; - update_status = true; + update_progress([this, &msg]() { + msg = error_message; + update_status = true; + }); return msg; } @@ -171,49 +163,43 @@ class Progress { void set_start_time() { - // Busy wait until update status is true - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - start_time = /*.store(*/time_dt(); //); - end_time = 0.0; //.store(0.0); - update_status = true; + update_progress([this]() { + start_time = time_dt(); + end_time = 0.0; + }); } void set_render_start_time() { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - render_start_time = /*.store(*/ time_dt(); //); - update_status = true; + update_progress([this]() { + render_start_time = time_dt(); + }); } void set_time_limit(double time_limit_) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - time_limit = /*.store(*/time_limit_; //); - update_status = true; + update_progress([this, time_limit_]() { time_limit = time_limit_; }); } void add_skip_time(const scoped_timer &start_timer, bool only_render) { double skip_time = time_dt() - start_timer.get_start(); - double rst = render_start_time + skip_time; - render_start_time = rst; + render_start_time += skip_time; if (!only_render) { - double st = start_time + skip_time; - start_time = st; + start_time += skip_time; } } - void get_time(double &total_time_, double &render_time_) const + void get_time(double &total_time_, double &render_time_) //const { + update_progress([this, &total_time_, &render_time_](){ double et = end_time; double time = (et > 0) ? et : time_dt(); total_time_ = time - start_time; render_time_ = time - render_start_time; + }); } void set_end_time() @@ -231,26 +217,34 @@ class Progress { void set_total_pixel_samples(uint64_t total_pixel_samples_) { + update_progress([this, total_pixel_samples_](){ total_pixel_samples = total_pixel_samples_; + }); } - double get_progress() const + double get_progress() //const { - if (pixel_samples > 0) { - double progress_percent = (double)pixel_samples / (double)total_pixel_samples; - if (time_limit != 0.0) { - double time_since_render_start = time_dt() - render_start_time; - progress_percent = max(progress_percent, time_since_render_start / time_limit); + double value = 0.0; + update_progress([this, &value]() { + if (pixel_samples > 0) { + double progress_percent = (double)pixel_samples / (double)total_pixel_samples; + if (time_limit != 0.0) { + double time_since_render_start = time_dt() - render_start_time; + progress_percent = max(progress_percent, time_since_render_start / time_limit); + } + value = min(1.0, progress_percent); } - return min(1.0, progress_percent); - } - return 0.0; + }); + + return value; } void add_samples(uint64_t pixel_samples_, int tile_sample) { - pixel_samples += pixel_samples_; - current_tile_sample = tile_sample; + update_progress([this, pixel_samples_, tile_sample]() { + pixel_samples += pixel_samples_; + current_tile_sample = tile_sample; + }); } void add_samples_update(uint64_t pixel_samples_, int tile_sample) @@ -261,29 +255,43 @@ class Progress { void add_finished_tile(bool denoised) { - if (denoised) { - denoised_tiles++; - } - else { - rendered_tiles++; - } + update_progress([this, denoised]() { + if (denoised) { + denoised_tiles++; + } + else { + rendered_tiles++; + } + }); } - int get_current_sample() const + int get_current_sample() //const { + int sample; + update_progress([this, &sample]() { /* Note that the value here always belongs to the last tile that updated, * so it's only useful if there is only one active tile. */ - return current_tile_sample; + sample = current_tile_sample; + }); + return sample; } - int get_rendered_tiles() const + int get_rendered_tiles() //const { - return rendered_tiles; + int tiles; + update_progress([this, &tiles]() { + tiles = rendered_tiles; + }); + return tiles; } - int get_denoised_tiles() const + int get_denoised_tiles() //const { - return denoised_tiles; + int denoised; + update_progress([this, & denoised]() { + denoised = denoised_tiles; + }); + return denoised; } /* status messages */ @@ -292,12 +300,10 @@ class Progress { { if(updates) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - status = status_; - substatus = substatus_; - update_status = true; + update_progress([this, status_, substatus_]() { + status = status_; + substatus = substatus_; + }); } set_update(); @@ -307,11 +313,9 @@ class Progress { { if(updates) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - substatus = substatus_; - update_status = true; + update_progress([this, substatus_]() { + substatus = substatus_; + }); } set_update(); @@ -320,12 +324,10 @@ class Progress { void set_sync_status(const string &status_, const string &substatus_ = "") { if(updates) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - sync_status = status_; - sync_substatus = substatus_; - update_status = true; + update_progress([this, status_, substatus_]() { + sync_status = status_; + sync_substatus = substatus_; + }); } set_update(); @@ -334,11 +336,9 @@ class Progress { void set_sync_substatus(const string &substatus_) { if(updates) { - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - //thread_scoped_lock lock(progress_mutex); - sync_substatus = substatus_; - update_status = true; + update_progress([this, substatus_]() { + sync_substatus = substatus_; + }); } set_update(); @@ -346,18 +346,16 @@ class Progress { void get_status(string &status_, string &substatus_) // const { - // thread_scoped_lock lock(progress_mutex); - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - if (sync_status != "") { - status_ = sync_status; - substatus_ = sync_substatus; - } - else { - status_ = status; - substatus_ = substatus; - } - update_status = true; + update_progress([this, &status_, &substatus_]() { + if (sync_status != "") { + status_ = sync_status; + substatus_ = sync_substatus; + } + else { + status_ = status; + substatus_ = substatus; + } + }); } /* callback */ @@ -375,6 +373,17 @@ class Progress { update_cb = function; } + void update_progress(callback_type cb) + { + // Busy wait until update status is true + bool can_update = true; + while(!update_status.compare_exchange_weak(can_update, false)) {}; + if (cb) { + cb(); + } + update_status = true; + } + protected: //mutable thread_mutex progress_mutex; mutable thread_mutex update_mutex; -- 2.30.2 From a5efd8b5825793938f2ad3517c1fffa28181129d Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 1 Mar 2023 14:10:32 +0100 Subject: [PATCH 03/96] Update the update lock with a lockless update --- intern/cycles/util/progress.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 57c05840745..545e251687d 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -45,8 +45,7 @@ class Progress { error_message = ""; cancel_cb = function_null; updates = true; - update_time = true; - update_pixels = true; + update_call = true; update_status = true; } @@ -363,8 +362,11 @@ class Progress { void set_update() { if (updates && update_cb) { - thread_scoped_lock lock(update_mutex); + // Busy wait until update status is true + bool can_update = true; + while(!update_call.compare_exchange_weak(can_update, false)) {}; update_cb(); + update_call = true; } } @@ -386,7 +388,7 @@ class Progress { protected: //mutable thread_mutex progress_mutex; - mutable thread_mutex update_mutex; + //mutable thread_mutex update_mutex; function update_cb; function cancel_cb; @@ -407,8 +409,7 @@ class Progress { /* End time written when render is done, so it doesn't keep increasing on redraws. */ double end_time; - std::atomic update_time; - std::atomic update_pixels; + std::atomic update_call; std::atomic update_status; string status; -- 2.30.2 From bbce8a0aae3a3cd2051f7b7f650f5dd88b606174 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 3 Mar 2023 08:55:29 +0100 Subject: [PATCH 04/96] Add macro to switch from std::mutex to SpinLock Simplified the code to be more similar to the original by implementing it as a spin lock. Then added a macro to be able to switch back and forth between std::mutex and the SpinLock. --- intern/cycles/util/progress.h | 255 +++++++++++++++++++++------------- 1 file changed, 160 insertions(+), 95 deletions(-) diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 545e251687d..563cd1e7eae 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -4,6 +4,15 @@ #ifndef __UTIL_PROGRESS_H__ #define __UTIL_PROGRESS_H__ +//#define USE_SPINLOCK +#ifdef USE_SPINLOCK +#define MUTEX SpinLock +#define SCOPED_LOCK(mutex) ScopedSpinLock scopedspinlock(mutex) +#else +#define MUTEX thread_mutex +#define SCOPED_LOCK(mutex) thread_scoped_lock scopedlock(mutex) +#endif + /* Progress * * Simple class to communicate progress status messages, timing information, @@ -19,6 +28,45 @@ CCL_NAMESPACE_BEGIN +class SpinLock { +public: + SpinLock() + { + update_status = true; + }; + + void lock() + { + // Busy wait until update status is true + bool can_update = true; + while (!update_status.compare_exchange_weak(can_update, false)) { + }; + }; + + void unlock() + { + update_status = true; + }; + +private: + std::atomic update_status; +}; + +class ScopedSpinLock { +public: + ScopedSpinLock(SpinLock &spinlock) : spinlock_(spinlock) + { + spinlock_.lock(); + }; + + ~ScopedSpinLock() + { + spinlock_.unlock(); + } +private: + SpinLock &spinlock_; +}; + class Progress { public: using callback_type = function; @@ -45,8 +93,8 @@ class Progress { error_message = ""; cancel_cb = function_null; updates = true; - update_call = true; - update_status = true; + // update_call = true; + // update_status = true; } Progress(Progress &progress) @@ -56,13 +104,14 @@ class Progress { Progress &operator=(Progress &progress) { - update_progress([this, &progress]() { + SCOPED_LOCK(progress_mutex); + //update_progress([this, &progress]() { progress.get_status(status, substatus); pixel_samples = progress.pixel_samples; total_pixel_samples = progress.total_pixel_samples; current_tile_sample = progress.get_current_sample(); - }); + //}); return *this; } @@ -97,11 +146,11 @@ class Progress { /* cancel */ void set_cancel(const string &cancel_message_) { - update_progress([this, cancel_message_]() { - cancel_message = cancel_message_; - cancel = true; - update_status = true; - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this, cancel_message_]() { + cancel_message = cancel_message_; + cancel = true; + //}); } bool get_cancel() const @@ -119,11 +168,12 @@ class Progress { string get_cancel_message() //const { - string msg; - update_progress([this, &msg]() { - msg = cancel_message; - }); - return msg; + SCOPED_LOCK(progress_mutex); + //string msg; + //update_progress([this, &msg]() { + //msg = cancel_message; + //}); + return cancel_message; } void set_cancel_callback(function function) @@ -134,13 +184,14 @@ class Progress { /* error */ void set_error(const string &error_message_) { - update_progress([this, error_message_]() { - error_message = error_message_; - error = true; - /* If error happens we also stop rendering. */ - cancel_message = error_message_; - cancel = true; - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this, error_message_]() { + error_message = error_message_; + error = true; + /* If error happens we also stop rendering. */ + cancel_message = error_message_; + cancel = true; + //}); } bool get_error() const @@ -150,34 +201,39 @@ class Progress { string get_error_message() // const { - string msg; - update_progress([this, &msg]() { - msg = error_message; - update_status = true; - }); - return msg; + SCOPED_LOCK(progress_mutex); + //string msg; + //update_progress([this, &msg]() { + //msg = error_message; + //}); + return error_message; } /* tile and timing information */ void set_start_time() { - update_progress([this]() { - start_time = time_dt(); - end_time = 0.0; - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this]() { + start_time = time_dt(); + end_time = 0.0; + //}); } void set_render_start_time() { - update_progress([this]() { - render_start_time = time_dt(); - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this]() { + render_start_time = time_dt(); + //}); } void set_time_limit(double time_limit_) { - update_progress([this, time_limit_]() { time_limit = time_limit_; }); + SCOPED_LOCK(progress_mutex); + //update_progress([this, time_limit_]() { + time_limit = time_limit_; + //}); } void add_skip_time(const scoped_timer &start_timer, bool only_render) @@ -192,13 +248,14 @@ class Progress { void get_time(double &total_time_, double &render_time_) //const { - update_progress([this, &total_time_, &render_time_](){ + SCOPED_LOCK(progress_mutex); + //update_progress([this, &total_time_, &render_time_](){ double et = end_time; double time = (et > 0) ? et : time_dt(); total_time_ = time - start_time; render_time_ = time - render_start_time; - }); + //}); } void set_end_time() @@ -216,15 +273,17 @@ class Progress { void set_total_pixel_samples(uint64_t total_pixel_samples_) { - update_progress([this, total_pixel_samples_](){ + SCOPED_LOCK(progress_mutex); + //update_progress([this, total_pixel_samples_](){ total_pixel_samples = total_pixel_samples_; - }); + //}); } double get_progress() //const { + SCOPED_LOCK(progress_mutex); double value = 0.0; - update_progress([this, &value]() { + //update_progress([this, &value]() { if (pixel_samples > 0) { double progress_percent = (double)pixel_samples / (double)total_pixel_samples; if (time_limit != 0.0) { @@ -233,17 +292,18 @@ class Progress { } value = min(1.0, progress_percent); } - }); + //}); return value; } void add_samples(uint64_t pixel_samples_, int tile_sample) { - update_progress([this, pixel_samples_, tile_sample]() { + SCOPED_LOCK(progress_mutex); + //update_progress([this, pixel_samples_, tile_sample]() { pixel_samples += pixel_samples_; current_tile_sample = tile_sample; - }); + //}); } void add_samples_update(uint64_t pixel_samples_, int tile_sample) @@ -254,55 +314,59 @@ class Progress { void add_finished_tile(bool denoised) { - update_progress([this, denoised]() { + SCOPED_LOCK(progress_mutex); + //update_progress([this, denoised]() { if (denoised) { denoised_tiles++; } else { rendered_tiles++; } - }); + //}); } int get_current_sample() //const { - int sample; - update_progress([this, &sample]() { + SCOPED_LOCK(progress_mutex); + //int sample; + //update_progress([this, &sample]() { /* Note that the value here always belongs to the last tile that updated, * so it's only useful if there is only one active tile. */ - sample = current_tile_sample; - }); - return sample; + //sample = current_tile_sample; + //}); + return current_tile_sample; } int get_rendered_tiles() //const { - int tiles; - update_progress([this, &tiles]() { - tiles = rendered_tiles; - }); - return tiles; + SCOPED_LOCK(progress_mutex); + //int tiles; + //update_progress([this, &tiles]() { + // tiles = rendered_tiles; + //}); + return rendered_tiles; } int get_denoised_tiles() //const { - int denoised; - update_progress([this, & denoised]() { - denoised = denoised_tiles; - }); - return denoised; + SCOPED_LOCK(progress_mutex); + //int denoised; + //update_progress([this, & denoised]() { + // denoised = denoised_tiles; + //}); + return denoised_tiles; } /* status messages */ void set_status(const string &status_, const string &substatus_ = "") { - if(updates) - { - update_progress([this, status_, substatus_]() { + if(updates) { + SCOPED_LOCK(progress_mutex); + //update_progress([this, status_, substatus_]() { status = status_; substatus = substatus_; - }); + //}); } set_update(); @@ -310,11 +374,11 @@ class Progress { void set_substatus(const string &substatus_) { - if(updates) - { - update_progress([this, substatus_]() { + if(updates) { + SCOPED_LOCK(progress_mutex); + //update_progress([this, substatus_]() { substatus = substatus_; - }); + //}); } set_update(); @@ -323,10 +387,11 @@ class Progress { void set_sync_status(const string &status_, const string &substatus_ = "") { if(updates) { - update_progress([this, status_, substatus_]() { - sync_status = status_; - sync_substatus = substatus_; - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this, status_, substatus_]() { + sync_status = status_; + sync_substatus = substatus_; + //}); } set_update(); @@ -335,9 +400,10 @@ class Progress { void set_sync_substatus(const string &substatus_) { if(updates) { - update_progress([this, substatus_]() { - sync_substatus = substatus_; - }); + SCOPED_LOCK(progress_mutex); + //update_progress([this, substatus_]() { + sync_substatus = substatus_; + //}); } set_update(); @@ -345,7 +411,8 @@ class Progress { void get_status(string &status_, string &substatus_) // const { - update_progress([this, &status_, &substatus_]() { + SCOPED_LOCK(progress_mutex); + //update_progress([this, &status_, &substatus_]() { if (sync_status != "") { status_ = sync_status; substatus_ = sync_substatus; @@ -354,7 +421,7 @@ class Progress { status_ = status; substatus_ = substatus; } - }); + //}); } /* callback */ @@ -362,11 +429,12 @@ class Progress { void set_update() { if (updates && update_cb) { + SCOPED_LOCK(update_mutex); // Busy wait until update status is true - bool can_update = true; - while(!update_call.compare_exchange_weak(can_update, false)) {}; + //bool can_update = true; + //while(!update_call.compare_exchange_weak(can_update, false)) {}; update_cb(); - update_call = true; + //update_call = true; } } @@ -375,20 +443,20 @@ class Progress { update_cb = function; } - void update_progress(callback_type cb) - { - // Busy wait until update status is true - bool can_update = true; - while(!update_status.compare_exchange_weak(can_update, false)) {}; - if (cb) { - cb(); - } - update_status = true; - } + // void update_progress(callback_type cb) + // { + // // Busy wait until update status is true + // bool can_update = true; + // while(!update_status.compare_exchange_weak(can_update, false)) {}; + // if (cb) { + // cb(); + // } + // update_status = true; + // } protected: - //mutable thread_mutex progress_mutex; - //mutable thread_mutex update_mutex; + mutable MUTEX progress_mutex; + mutable MUTEX update_mutex; function update_cb; function cancel_cb; @@ -409,9 +477,6 @@ class Progress { /* End time written when render is done, so it doesn't keep increasing on redraws. */ double end_time; - std::atomic update_call; - std::atomic update_status; - string status; string substatus; -- 2.30.2 From 72b918a9e23f534abc71fbc069260fd7b45ad7da Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 3 Mar 2023 09:34:57 +0100 Subject: [PATCH 05/96] Adds scoped event markers Add scoped event markers to highlight code regions of interest. --- extern/cuew/include/cuew.h | 13 +++- extern/cuew/src/cuew.c | 80 +++++++++++++++++++++++ intern/cycles/device/cuda/device.cpp | 8 ++- intern/cycles/device/cuda/device_impl.cpp | 8 +++ intern/cycles/device/cuda/device_impl.h | 2 + intern/cycles/device/device.h | 35 ++++++++++ intern/cycles/scene/geometry.cpp | 16 ++++- 7 files changed, 156 insertions(+), 6 deletions(-) diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h index 5979f48e43d..66a5c66a8d0 100644 --- a/extern/cuew/include/cuew.h +++ b/extern/cuew/include/cuew.h @@ -886,9 +886,11 @@ typedef enum { } nvrtcResult; typedef struct _nvrtcProgram* nvrtcProgram; - - +// FRL_CGR /* Function types. */ +typedef void CUDAAPI tnvtxRangePushA(const char *msg); +typedef void CUDAAPI tnvtxRangePop(); +// FRL_CGR typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuInit(unsigned int Flags); @@ -1130,6 +1132,8 @@ typedef nvrtcResult CUDAAPI tnvrtcGetLoweredName(nvrtcProgram prog, const char* /* Function declarations. */ +extern tnvtxRangePushA *nvtxRangePushA; +extern tnvtxRangePop *nvtxRangePop; extern tcuGetErrorString *cuGetErrorString; extern tcuGetErrorName *cuGetErrorName; extern tcuInit *cuInit; @@ -1378,7 +1382,10 @@ enum { enum { CUEW_INIT_CUDA = 1, - CUEW_INIT_NVRTC = 2 +// FRL_CGR + CUEW_INIT_NVRTC = 2, + CUEW_INIT_NVTX = 4, +// FRL_CGR }; int cuewInit(cuuint32_t flags); diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index 9eba9306323..ba1aee4ba96 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -66,10 +66,22 @@ typedef void* DynamicLibrary; _LIBRARY_FIND_CHECKED(nvrtc_lib, name) #define NVRTC_LIBRARY_FIND(name) _LIBRARY_FIND(nvrtc_lib, name) +// FRL_CGR +#define NVTX_LIBRARY_FIND_CHECKED(name) \ + _LIBRARY_FIND_CHECKED(nvrtc_lib, name) +#define NVTX_LIBRARY_FIND(name) _LIBRARY_FIND(nvtx_lib, name) +// FRL_CGR + static DynamicLibrary cuda_lib; static DynamicLibrary nvrtc_lib; +static DynamicLibrary nvtx_lib; /* Function definitions. */ +// FRL_CGR +tnvtxRangePushA *nvtxRangePushA; +tnvtxRangePop *nvtxRangePop; +// FRL_CGR + tcuGetErrorString *cuGetErrorString; tcuGetErrorName *cuGetErrorName; tcuInit *cuInit; @@ -611,6 +623,16 @@ static int cuewCudaInit(void) { return result; } +// FRL_CGR +static void cuewExitNvtx(void) { + if (nvrtc_lib != NULL) { + /* Ignore errors. */ + dynamic_library_close(nvtx_lib); + nvtx_lib = NULL; + } +} +// FRL_CGR + static void cuewExitNvrtc(void) { if (nvrtc_lib != NULL) { /* Ignore errors. */ @@ -681,6 +703,56 @@ static int cuewNvrtcInit(void) { return result; } +// FRL_CGR +static int cuewNvtxInit(void) { + /* Library paths. */ +#ifdef _WIN32 + /* Expected in c:/windows/system or similar, no path needed. */ + const char *nvtc_paths[] = {"nvToolsExt64_101_0.dll", + NULL}; +#elif defined(__APPLE__) + /* Default installation path. */ + const char *nvtx_paths[] = {"/usr/local/cuda/lib/libnvToolsExt.dylib", NULL}; +#else + const char *nvtx_paths[] = {"libnvToolsExt.so", +# if defined(__x86_64__) || defined(_M_X64) + "/usr/local/cuda/lib64/libnvToolsExt.so", +#else + "/usr/local/cuda/lib/libnvToolsExt.so", +#endif + NULL}; +#endif + static int nvtx_initialized = 0; + static int result = 0; + int error; + + if (nvtx_initialized) { + return result; + } + + nvtx_initialized = 1; + + error = atexit(cuewExitNvtx); + if (error) { + result = CUEW_ERROR_ATEXIT_FAILED; + return result; + } + + /* Load library. */ + nvtx_lib = dynamic_library_open_find(nvtx_paths); + + if (nvtx_lib == NULL) { + result = CUEW_ERROR_OPEN_FAILED; + return result; + } + + NVTX_LIBRARY_FIND(nvtxRangePushA); + NVTX_LIBRARY_FIND(nvtxRangePop); + + result = CUEW_SUCCESS; + return result; +} +// FRL_CGR int cuewInit(cuuint32_t flags) { int result = CUEW_SUCCESS; @@ -698,6 +770,14 @@ int cuewInit(cuuint32_t flags) { return result; } } +// FRL_CGR + if(flags & CUEW_INIT_NVTX) { + result = cuewNvtxInit(); + if(result != CUEW_SUCCESS) { + return result; + } + } +// FRL_CGR return result; } diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index 5a213c45b71..ef2cfcd72be 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -27,7 +27,13 @@ bool device_cuda_init() return result; initialized = true; - int cuew_result = cuewInit(CUEW_INIT_CUDA); + // FRL_CGR + int flags = CUEW_INIT_CUDA; +#ifdef USE_SCOPED_MARKER + flags |= CUEW_INIT_NVTX; +#endif + int cuew_result = cuewInit(flags); + // FRL_CGR if (cuew_result == CUEW_SUCCESS) { VLOG_INFO << "CUEW initialization succeeded"; if (CUDADevice::have_precompiled_kernels()) { diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index c19a0ade332..0901e2ffd41 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -987,7 +987,15 @@ int CUDADevice::get_device_default_attribute(CUdevice_attribute attribute, int d } return value; } +// FRL_CGR +void CUDADevice::push_marker(const string name) { + nvtxRangePushA(name.c_str()); +} +void CUDADevice::pop_marker() { + nvtxRangePop(); +} +// FRL_CGR CCL_NAMESPACE_END #endif diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index c8cd9bbdac5..2711504074f 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -100,6 +100,8 @@ class CUDADevice : public GPUDevice { int get_num_multiprocessors(); int get_max_num_threads_per_multiprocessor(); + virtual void push_marker(const string name) override; + virtual void pop_marker() override; protected: bool get_device_attribute(CUdevice_attribute attribute, int *value); int get_device_default_attribute(CUdevice_attribute attribute, int default_value); diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index a8b5e0842f4..4d30b339f69 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -216,6 +216,16 @@ class Device { { return 0; } + // FRL_CGR END + + // FRL_CGR BEGIN + virtual void push_marker(const string) { + } + + virtual void pop_marker() { + } + + // FRL_CGR END /* Called after kernel texture setup, and prior to integrator state setup. */ virtual void optimize_for_scene(Scene * /*scene*/) @@ -309,6 +319,31 @@ class Device { static uint devices_initialized_mask; }; +// FRL_CGR +class ScopedMarker { +private: + Device *_device; +public: + ScopedMarker(Device *p_device, const string name) { + _device = p_device; + _device->push_marker(name.c_str() + std::to_string(p_device->info.num)); + } + + ~ScopedMarker() { + _device->pop_marker(); + } +}; + +#define USE_SCOPED_MARKER +#ifndef SCOPED_MARKER +# ifdef USE_SCOPED_MARKER +# define SCOPED_MARKER(device, msg) ScopedMarker scoped_marker(device, msg) +# else +# define SCOPED_MARKER(device, msg) +# endif +#endif +// FRL_CGR + /* Device, which is GPU, with some common functionality for GPU backends */ class GPUDevice : public Device { protected: diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index a9981a2e222..c39712d9d5f 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -702,6 +702,7 @@ void GeometryManager::device_update_attributes(Device *device, Scene *scene, Progress &progress) { + SCOPED_MARKER(device, "GeometryManager::device_update_attributes"); progress.set_status("Updating Mesh", "Computing attributes"); /* gather per mesh requested attributes. as meshes may have multiple @@ -1042,11 +1043,12 @@ void GeometryManager::geom_calc_offset(Scene *scene, BVHLayout bvh_layout) } } -void GeometryManager::device_update_mesh(Device *, +void GeometryManager::device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress) { + SCOPED_MARKER(device, "GeometryManager::device_update_mesh"); /* Count. */ size_t vert_size = 0; size_t tri_size = 0; @@ -1769,6 +1771,7 @@ void GeometryManager::device_update(Device *device, Scene *scene, Progress &progress) { + SCOPED_MARKER(device, "GeometryManager::device_update"); if (!need_update()) return; @@ -1784,7 +1787,8 @@ void GeometryManager::device_update(Device *device, scene->update_stats->geometry.times.add_entry({"device_update (normals)", time}); } }); - + { + SCOPED_MARKER(device, "Update face and vertex normals"); foreach (Geometry *geom, scene->geometry) { if (geom->is_modified()) { if ((geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME)) { @@ -1820,6 +1824,7 @@ void GeometryManager::device_update(Device *device, } } } + } } if (progress.get_cancel()) { @@ -1828,6 +1833,7 @@ void GeometryManager::device_update(Device *device, /* Tessellate meshes that are using subdivision */ if (total_tess_needed) { + SCOPED_MARKER(device, "Tesselate"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1877,6 +1883,7 @@ void GeometryManager::device_update(Device *device, /* Update images needed for true displacement. */ bool old_need_object_flags_update = false; if (true_displacement_used || curve_shadow_transparency_used) { + SCOPED_MARKER(device, "Update displacement images"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1925,6 +1932,7 @@ void GeometryManager::device_update(Device *device, size_t num_bvh = 0; { + SCOPED_MARKER(device, "displace and shadow transp"); /* Copy constant data needed by shader evaluation. */ device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); @@ -1990,6 +1998,7 @@ void GeometryManager::device_update(Device *device, bool need_update_scene_bvh = (scene->bvh == nullptr || (update_flags & (TRANSFORM_MODIFIED | VISIBILITY_MODIFIED)) != 0); { + SCOPED_MARKER(device, "Build Object BVH"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry({"device_update (build object BVHs)", time}); @@ -2025,6 +2034,7 @@ void GeometryManager::device_update(Device *device, /* Update objects. */ { + SCOPED_MARKER(device, "compute bounds"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time}); @@ -2040,6 +2050,7 @@ void GeometryManager::device_update(Device *device, } if (need_update_scene_bvh) { + SCOPED_MARKER(device, "update scene BVH"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); @@ -2123,6 +2134,7 @@ void GeometryManager::device_update(Device *device, void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free) { + SCOPED_MARKER(device, "GeometryManager::device_free"); dscene->bvh_nodes.free_if_need_realloc(force_free); dscene->bvh_leaf_nodes.free_if_need_realloc(force_free); dscene->object_node.free_if_need_realloc(force_free); -- 2.30.2 From 0f5e6ed93e6d2dfdce8b76ea98e26766464ecedc Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 3 Mar 2023 14:59:10 +0100 Subject: [PATCH 06/96] Refactor geometry update allow for easier parallel updates --- intern/cycles/bvh/bvh.cpp | 4 +- intern/cycles/bvh/bvh.h | 6 + intern/cycles/bvh/embree.cpp | 8 +- intern/cycles/bvh/embree.h | 5 +- intern/cycles/bvh/multi.cpp | 35 +- intern/cycles/bvh/multi.h | 10 +- intern/cycles/device/cpu/device_impl.cpp | 13 +- intern/cycles/device/cpu/device_impl.h | 3 +- intern/cycles/device/cuda/device_impl.cpp | 56 +- intern/cycles/device/cuda/device_impl.h | 8 +- intern/cycles/device/device.cpp | 29 +- intern/cycles/device/device.h | 27 +- intern/cycles/device/dummy/device.cpp | 4 + intern/cycles/device/hip/device_impl.cpp | 42 +- intern/cycles/device/hip/device_impl.h | 4 +- intern/cycles/device/memory.cpp | 23 +- intern/cycles/device/memory.h | 81 +- intern/cycles/device/metal/device_impl.h | 6 +- intern/cycles/device/metal/device_impl.mm | 50 +- intern/cycles/device/multi/device.cpp | 227 ++-- intern/cycles/device/optix/device_impl.cpp | 16 +- intern/cycles/device/optix/device_impl.h | 3 +- intern/cycles/scene/CMakeLists.txt | 1 + intern/cycles/scene/geometry.cpp | 1428 +++++++------------- intern/cycles/scene/geometry.h | 131 +- intern/cycles/scene/object.cpp | 20 +- intern/cycles/scene/object.h | 2 +- intern/cycles/scene/scene.cpp | 74 +- intern/cycles/scene/scene.h | 9 + intern/cycles/scene/shader.cpp | 4 +- intern/cycles/scene/svm.cpp | 4 + 31 files changed, 1171 insertions(+), 1162 deletions(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 2a7bbfe968b..9f6968aea32 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -84,7 +84,7 @@ BVH *BVH::create(const BVHParams ¶ms, return new BVH2(params, geometry, objects); case BVH_LAYOUT_EMBREE: #ifdef WITH_EMBREE - return new BVHEmbree(params, geometry, objects); + return new BVHEmbree(params, geometry, objects, device); #else break; #endif @@ -106,7 +106,7 @@ BVH *BVH::create(const BVHParams ¶ms, case BVH_LAYOUT_MULTI_METAL: case BVH_LAYOUT_MULTI_OPTIX_EMBREE: case BVH_LAYOUT_MULTI_METAL_EMBREE: - return new BVHMulti(params, geometry, objects); + return new BVHMulti(params, geometry, objects, device); case BVH_LAYOUT_NONE: case BVH_LAYOUT_ALL: break; diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 19ebf7f68ba..3541fe98dc8 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -74,6 +74,12 @@ class BVH { { } + virtual BVH *get_device_bvh(const Device *) + { + return this; + }; + virtual void set_device_bvh(const Device *, BVH *){}; + virtual void replace_geometry(const vector &geometry, const vector &objects) { diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp index a4efb565306..ef7442a2569 100644 --- a/intern/cycles/bvh/embree.cpp +++ b/intern/cycles/bvh/embree.cpp @@ -91,11 +91,13 @@ static bool rtc_progress_func(void *user_ptr, const double n) BVHEmbree::BVHEmbree(const BVHParams ¶ms_, const vector &geometry_, - const vector &objects_) + const vector &objects_, + const Device *device_) : BVH(params_, geometry_, objects_), scene(NULL), rtc_device(NULL), - build_quality(RTC_BUILD_QUALITY_REFIT) + build_quality(RTC_BUILD_QUALITY_REFIT), + device(device_) { SIMD_SET_FLUSH_TO_ZERO; } @@ -191,7 +193,7 @@ void BVHEmbree::add_object(Object *ob, int i) void BVHEmbree::add_instance(Object *ob, int i) { - BVHEmbree *instance_bvh = (BVHEmbree *)(ob->get_geometry()->bvh); + BVHEmbree *instance_bvh = (BVHEmbree *)(ob->get_geometry()->bvh->get_device_bvh(device)); assert(instance_bvh != NULL); const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1; diff --git a/intern/cycles/bvh/embree.h b/intern/cycles/bvh/embree.h index 1e8401bfb7c..f041417a7a1 100644 --- a/intern/cycles/bvh/embree.h +++ b/intern/cycles/bvh/embree.h @@ -21,6 +21,7 @@ CCL_NAMESPACE_BEGIN class Hair; class Mesh; class PointCloud; +class Device; class BVHEmbree : public BVH { public: @@ -33,7 +34,8 @@ class BVHEmbree : public BVH { friend class BVH; BVHEmbree(const BVHParams ¶ms, const vector &geometry, - const vector &objects); + const vector &objects, + const Device *device); virtual ~BVHEmbree(); void add_object(Object *ob, int i); @@ -51,6 +53,7 @@ class BVHEmbree : public BVH { RTCDevice rtc_device; enum RTCBuildQuality build_quality; + const Device *device; }; CCL_NAMESPACE_END diff --git a/intern/cycles/bvh/multi.cpp b/intern/cycles/bvh/multi.cpp index d9ee2fce966..79c6ee94722 100644 --- a/intern/cycles/bvh/multi.cpp +++ b/intern/cycles/bvh/multi.cpp @@ -2,16 +2,20 @@ * Copyright 2020-2022 Blender Foundation. */ #include "bvh/multi.h" - +#include "device/device.h" #include "util/foreach.h" CCL_NAMESPACE_BEGIN BVHMulti::BVHMulti(const BVHParams ¶ms_, const vector &geometry_, - const vector &objects_) - : BVH(params_, geometry_, objects_) + const vector &objects_, + const Device *device_) + : BVH(params_, geometry_, objects_), device(device_) { + // Resize the sub-bvh container to match the number of devices + int n = device->get_num_devices(); + sub_bvhs.resize(n); } BVHMulti::~BVHMulti() @@ -21,6 +25,31 @@ BVHMulti::~BVHMulti() } } +BVH *BVHMulti::get_device_bvh(const Device *subdevice) +{ + int id = device->device_number(subdevice); + resize_sub_bvhs_if_needed(id); + return sub_bvhs[id]; +} + +void BVHMulti::set_device_bvh(const Device *subdevice, BVH *bvh) +{ + int id = device->device_number(subdevice); + resize_sub_bvhs_if_needed(id); + sub_bvhs[id] = bvh; +}; + +/** + * Resize the sub_bvh array if it is not big enough + * to hold a device with the given id. + */ +void BVHMulti::resize_sub_bvhs_if_needed(int id) +{ + if ((id != -1) && (id >= sub_bvhs.size())) { + sub_bvhs.resize(id + 1, NULL); + } +} + void BVHMulti::replace_geometry(const vector &geometry, const vector &objects) { diff --git a/intern/cycles/bvh/multi.h b/intern/cycles/bvh/multi.h index aafbfae19e0..380247ced99 100644 --- a/intern/cycles/bvh/multi.h +++ b/intern/cycles/bvh/multi.h @@ -13,15 +13,21 @@ class BVHMulti : public BVH { public: vector sub_bvhs; + virtual BVH *get_device_bvh(const Device *device) override; + virtual void set_device_bvh(const Device *sub_device, BVH *bvh) override; protected: friend class BVH; BVHMulti(const BVHParams ¶ms, const vector &geometry, - const vector &objects); + const vector &objects, + const Device *device); virtual ~BVHMulti(); + const Device *device; + void resize_sub_bvhs_if_needed(int id); + virtual void replace_geometry(const vector &geometry, - const vector &objects); + const vector &objects) override; }; CCL_NAMESPACE_END diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index 3d0f3195f74..1c2cb5e8f83 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -149,6 +149,15 @@ void CPUDevice::mem_copy_to(device_memory &mem) } } +void CPUDevice::mem_copy_to(device_memory &mem, size_t, size_t offset) +{ + /* size (2n param) is not used as this does not actually copy anything + * as the original host memory is used as is. The device + * memory is the same memory. + */ + mem_copy_to(mem); +} + void CPUDevice::mem_copy_from( device_memory & /*mem*/, size_t /*y*/, size_t /*w*/, size_t /*h*/, size_t /*elem*/) { @@ -256,7 +265,7 @@ void CPUDevice::tex_free(device_texture &mem) } } -void CPUDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) +void CPUDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { #ifdef WITH_EMBREE if (bvh->params.bvh_layout == BVH_LAYOUT_EMBREE || @@ -276,7 +285,7 @@ void CPUDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) } else #endif - Device::build_bvh(bvh, progress, refit); + Device::build_bvh(bvh, dscene, progress, refit); } void *CPUDevice::get_guiding_device() const diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index cbc78d3247a..e0b8dbe298e 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -60,6 +60,7 @@ class CPUDevice : public Device { virtual void mem_alloc(device_memory &mem) override; virtual void mem_copy_to(device_memory &mem) override; + virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; virtual void mem_copy_from( device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; virtual void mem_zero(device_memory &mem) override; @@ -76,7 +77,7 @@ class CPUDevice : public Device { void tex_alloc(device_texture &mem); void tex_free(device_texture &mem); - void build_bvh(BVH *bvh, Progress &progress, bool refit) override; + void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override; void *get_guiding_device() const override; diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index 0901e2ffd41..ced82841c98 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -544,11 +544,29 @@ bool CUDADevice::transform_host_pointer(void *&device_pointer, void *&shared_poi return true; } -void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) +void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) { const CUDAContextScope scope(this); - cuda_assert(cuMemcpyHtoD((CUdeviceptr)device_pointer, host_pointer, size)); + cuda_assert(cuMemcpyHtoD((CUdeviceptr)device_pointer + offset, + reinterpret_cast(host_pointer) + offset, + size)); +} + +void CUDADevice::host_mem_alloc(size_t size, int aligment, void **p_mem) { + CUDAContextScope scope(this); + CUresult result = cuMemAllocHost(p_mem, size); + if(result != CUDA_SUCCESS) { + char const * err_msg = NULL; + cuGetErrorString(result, &err_msg); + fprintf(stderr, "CUDA Runtime Error: %s\n", err_msg); + assert("unable to allocate memory."); + } +} + +void CUDADevice::host_mem_free(void *p_mem) { + CUDAContextScope scope(this); + cuMemFreeHost(p_mem); } void CUDADevice::mem_alloc(device_memory &mem) @@ -567,8 +585,14 @@ void CUDADevice::mem_alloc(device_memory &mem) void CUDADevice::mem_copy_to(device_memory &mem) { if (mem.type == MEM_GLOBAL) { - global_free(mem); - global_alloc(mem); + // FRL_CGR + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } + else { + generic_copy_to(mem); + } } else if (mem.type == MEM_TEXTURE) { tex_free((device_texture &)mem); @@ -582,6 +606,30 @@ void CUDADevice::mem_copy_to(device_memory &mem) } } +void CUDADevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) +{ + if (mem.type == MEM_GLOBAL) { + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } + else { + generic_copy_to(mem, size, offset); + } + } + else if (mem.type == MEM_TEXTURE) { + tex_free((device_texture &)mem); + tex_alloc((device_texture &)mem); + } + else { + if (!mem.device_pointer) { + generic_alloc(mem); + } + generic_copy_to(mem, size, offset); + } +} +// FRL_CGR + void CUDADevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) { if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) { diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index 2711504074f..eaabeed5f43 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -69,12 +69,16 @@ class CUDADevice : public GPUDevice { virtual bool alloc_host(void *&shared_pointer, size_t size) override; virtual void free_host(void *shared_pointer) override; virtual bool transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; - virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) override; - + virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; + void host_mem_alloc(size_t size, int aligment, void **p_mem) override; + void host_mem_free(void *p_mem) override; + void mem_alloc(device_memory &mem) override; void mem_copy_to(device_memory &mem) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; void mem_zero(device_memory &mem) override; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 5dc0919031f..f7ba4794b70 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -49,7 +49,7 @@ Device::~Device() noexcept(false) { } -void Device::build_bvh(BVH *bvh, Progress &progress, bool refit) +void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { assert(bvh->params.bvh_layout == BVH_LAYOUT_BVH2); @@ -452,6 +452,14 @@ void *Device::get_cpu_osl_memory() return nullptr; } +void Device::host_mem_alloc(size_t size, int alignment, void **p_mem) { + *p_mem = util_aligned_malloc(size, alignment); +} + +void Device::host_mem_free(void *p_mem) { + util_aligned_free(p_mem); +} + GPUDevice::~GPUDevice() noexcept(false) { } @@ -762,10 +770,27 @@ void GPUDevice::generic_copy_to(device_memory &mem) * copy data from mem.host_pointer. */ thread_scoped_lock lock(device_mem_map_mutex); if (!device_mem_map[&mem].use_mapped_host || mem.host_pointer != mem.shared_pointer) { - copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size()); + copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size(), 0); } } +// FRL_CGR +void GPUDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) +{ + if (!mem.host_pointer || !mem.device_pointer) { + return; + } + + /* If use_mapped_host of mem is false, the current device only uses device memory allocated by + * cuMemAlloc regardless of mem.host_pointer and mem.shared_pointer, and should copy data from + * mem.host_pointer. */ + thread_scoped_lock lock(device_mem_map_mutex); + if (!device_mem_map[&mem].use_mapped_host || mem.host_pointer != mem.shared_pointer) { + copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size(), offset); + } +} +// FRL_CGR + /* DeviceInfo */ CCL_NAMESPACE_END diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 360e4b78524..48763c4baaf 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -7,7 +7,7 @@ #include #include "bvh/params.h" - +#include "scene/scene.h" #include "device/denoise.h" #include "device/memory.h" @@ -139,6 +139,11 @@ class Device { /* noexcept needed to silence TBB warning. */ virtual ~Device() noexcept(false); + virtual int get_num_devices() const + { + return 1; + } + /* info */ DeviceInfo info; virtual const string &error_message() @@ -206,26 +211,27 @@ class Device { virtual void *get_cpu_osl_memory(); /* acceleration structure building */ - virtual void build_bvh(BVH *bvh, Progress &progress, bool refit); + virtual void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit); /* OptiX specific destructor. */ virtual void release_optix_bvh(BVH * /*bvh*/){}; /* multi device */ - virtual int device_number(Device * /*sub_device*/) + virtual int device_number(const Device * /*sub_device*/) const { return 0; } - // FRL_CGR END - // FRL_CGR BEGIN virtual void push_marker(const string) { } virtual void pop_marker() { } - // FRL_CGR END + virtual device_ptr find_matching_mem(device_ptr key, Device * /*sub*/) + { + return key; + } /* Called after kernel texture setup, and prior to integrator state setup. */ virtual void optimize_for_scene(Scene * /*scene*/) @@ -300,8 +306,11 @@ class Device { friend class DeviceServer; friend class device_memory; + virtual void host_mem_alloc(size_t size, int alignment, void **p_mem); + virtual void host_mem_free(void *p_mem); virtual void mem_alloc(device_memory &mem) = 0; virtual void mem_copy_to(device_memory &mem) = 0; + virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) = 0; virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) = 0; virtual void mem_zero(device_memory &mem) = 0; virtual void mem_free(device_memory &mem) = 0; @@ -411,7 +420,8 @@ class GPUDevice : public Device { virtual GPUDevice::Mem *generic_alloc(device_memory &mem, size_t pitch_padding = 0); virtual void generic_free(device_memory &mem); virtual void generic_copy_to(device_memory &mem); - + void generic_copy_to(device_memory &mem, size_t size, size_t offset); + /* total - amount of device memory, free - amount of available device memory */ virtual void get_device_memory_info(size_t &total, size_t &free) = 0; @@ -427,8 +437,7 @@ class GPUDevice : public Device { * is host buffer, allocated in `alloc_host`. The function should `true`, if such * address transformation is possible and `false` otherwise. */ virtual bool transform_host_pointer(void *&device_pointer, void *&shared_pointer) = 0; - - virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) = 0; + virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) = 0; }; CCL_NAMESPACE_END diff --git a/intern/cycles/device/dummy/device.cpp b/intern/cycles/device/dummy/device.cpp index 7a2a9f64fbe..1ed5dbafb3d 100644 --- a/intern/cycles/device/dummy/device.cpp +++ b/intern/cycles/device/dummy/device.cpp @@ -35,6 +35,10 @@ class DummyDevice : public Device { { } + virtual void mem_copy_to(device_memory &, size_t, size_t) override + { + } + virtual void mem_copy_from(device_memory &, size_t, size_t, size_t, size_t) override { } diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index 010470c23ae..daa452a3ff1 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -507,11 +507,16 @@ bool HIPDevice::transform_host_pointer(void *&device_pointer, void *&shared_poin return true; } -void HIPDevice::copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) +void HIPDevice::copy_host_to_device(void *device_pointer, + void *host_pointer, + size_t size, + size_t offset) { const HIPContextScope scope(this); - hip_assert(hipMemcpyHtoD((hipDeviceptr_t)device_pointer, host_pointer, size)); + hip_assert(hipMemcpyHtoD((hipDeviceptr_t)device_pointer + offset, + reinterpret_cast(host_pointer) + offset, + size)); } void HIPDevice::mem_alloc(device_memory &mem) @@ -530,8 +535,13 @@ void HIPDevice::mem_alloc(device_memory &mem) void HIPDevice::mem_copy_to(device_memory &mem) { if (mem.type == MEM_GLOBAL) { - global_free(mem); - global_alloc(mem); + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } + else { + generic_copy_to(mem); + } } else if (mem.type == MEM_TEXTURE) { tex_free((device_texture &)mem); @@ -545,6 +555,30 @@ void HIPDevice::mem_copy_to(device_memory &mem) } } +void HIPDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) +{ + if (mem.type == MEM_GLOBAL) { + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } + else { + generic_copy_to(mem, size, offset); + } + } + else if (mem.type == MEM_TEXTURE) { + tex_free((device_texture &)mem); + tex_alloc((device_texture &)mem); + } + else { + if (!mem.device_pointer) { + generic_alloc(mem); + } + generic_copy_to(mem, size, offset); + } +} +// FRL_CGR END + void HIPDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) { if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) { diff --git a/intern/cycles/device/hip/device_impl.h b/intern/cycles/device/hip/device_impl.h index 6039827e58e..a9819706baf 100644 --- a/intern/cycles/device/hip/device_impl.h +++ b/intern/cycles/device/hip/device_impl.h @@ -62,12 +62,14 @@ class HIPDevice : public GPUDevice { virtual bool alloc_host(void *&shared_pointer, size_t size) override; virtual void free_host(void *shared_pointer) override; virtual bool transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; - virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size) override; + virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; void mem_alloc(device_memory &mem) override; void mem_copy_to(device_memory &mem) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; void mem_zero(device_memory &mem) override; diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index 40cf2573cfb..0e2be3cf32c 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -27,7 +27,8 @@ device_memory::device_memory(Device *device, const char *name, MemoryType type) original_device_size(0), original_device(0), need_realloc_(false), - modified(false) + modified(false), + shared_mem(false) { } @@ -43,7 +44,8 @@ void *device_memory::host_alloc(size_t size) return 0; } - void *ptr = util_aligned_malloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES); + void *ptr = NULL; + device->host_mem_alloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES, &ptr); if (ptr) { util_guarded_mem_alloc(size); @@ -57,10 +59,9 @@ void *device_memory::host_alloc(size_t size) void device_memory::host_free() { - if (host_pointer) { + if ((host_pointer != 0) && !shared_mem) { util_guarded_mem_free(memory_size()); - util_aligned_free((void *)host_pointer); - host_pointer = 0; + device->host_mem_free(host_pointer); } } @@ -70,6 +71,11 @@ void device_memory::device_alloc() device->mem_alloc(*this); } +device_ptr device_memory::get_device_ptr(Device *dev) const +{ + return device->find_matching_mem(device_pointer, dev); +} + void device_memory::device_free() { if (device_pointer) { @@ -84,6 +90,13 @@ void device_memory::device_copy_to() } } +void device_memory::device_copy_to(size_t size, size_t offset) +{ + if (host_pointer) { + device->mem_copy_to(*this, size, offset); + } +} + void device_memory::device_copy_from(size_t y, size_t w, size_t h, size_t elem) { assert(type != MEM_TEXTURE && type != MEM_READ_ONLY && type != MEM_GLOBAL); diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index 57b07be408d..793bdb6d351 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -170,6 +170,12 @@ template<> struct device_type_traits { static_assert(sizeof(packed_float3) == num_elements * datatype_size(data_type)); }; +template<> struct device_type_traits { + static const DataType data_type = TYPE_UINT; + static const size_t num_elements = 3; + static_assert(sizeof(packed_float3) == num_elements * datatype_size(data_type)); +}; + template<> struct device_type_traits { static const DataType data_type = TYPE_FLOAT; static const size_t num_elements = 4; @@ -248,6 +254,8 @@ class device_memory { bool is_resident(Device *sub_device) const; + device_ptr get_device_ptr(Device *dev) const; + protected: friend class Device; friend class GPUDevice; @@ -279,6 +287,7 @@ class device_memory { void device_alloc(); void device_free(); void device_copy_to(); + void device_copy_to(size_t size, size_t offset); void device_copy_from(size_t y, size_t w, size_t h, size_t elem); void device_zero(); @@ -289,6 +298,7 @@ class device_memory { Device *original_device; bool need_realloc_; bool modified; + bool shared_mem; }; /* Device Only Memory @@ -369,17 +379,68 @@ template class device_vector : public device_memory { assert(data_elements > 0); } + device_vector(Device *device, + const char *name, + void *p_mem, + size_t width, + size_t height, + size_t depth, + MemoryType type) + : device_memory(device, name, type) + { + data_type = device_type_traits::data_type; + data_elements = device_type_traits::num_elements; + modified = true; + need_realloc_ = true; + assign_mem(p_mem, width, height, depth); + + assert(data_elements > 0); + } + virtual ~device_vector() { free(); } + /* Host memory assignment. */ + T *assign_mem(const device_vector &src) + { + return assign_mem(src.host_pointer, src.data_width, src.data_height, src.data_depth); + } + + T *assign_mem(const device_vector *p_src) + { + return assign_mem( + p_src->host_pointer, p_src->data_width, p_src->data_height, p_src->data_depth); + } + + T *assign_mem(void *p_mem, size_t width, size_t height = 0, size_t depth = 0) + { + size_t new_size = size(width, height, depth); + + host_free(); + if (new_size > data_size) { + device_free(); + // host_pointer = host_alloc(sizeof(T) * new_size); + modified = true; + assert(device_pointer == 0); + } + host_pointer = p_mem; + // FRL_CGR + shared_mem = true; + data_size = new_size; + data_width = width; + data_height = height; + data_depth = depth; + + return data(); + } + /* Host memory allocation. */ T *alloc(size_t width, size_t height = 0, size_t depth = 0) { size_t new_size = size(width, height, depth); - - if (new_size != data_size) { + if (new_size > data_size) { device_free(); host_free(); host_pointer = host_alloc(sizeof(T) * new_size); @@ -522,6 +583,22 @@ template class device_vector : public device_memory { } } + void copy_to_device(size_t size, size_t offset) + { + if (data_size != 0) { + assert(size <= data_size); + device_copy_to(size, offset); + } + } + void copy_to_device_if_modified(size_t size, size_t offset) + { + if (!modified) { + return; + } + + copy_to_device(size, offset); + } + void copy_to_device_if_modified() { if (!modified) { diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 4bbe576af2e..821c4c41cd1 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -134,7 +134,7 @@ class MetalDevice : public Device { virtual unique_ptr gpu_queue_create() override; - virtual void build_bvh(BVH *bvh, Progress &progress, bool refit) override; + virtual void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override; virtual void optimize_for_scene(Scene *scene) override; @@ -149,12 +149,16 @@ class MetalDevice : public Device { void generic_copy_to(device_memory &mem); + void generic_copy_to(device_memory &mem, size_t size, size_t offset); + void generic_free(device_memory &mem); void mem_alloc(device_memory &mem) override; void mem_copy_to(device_memory &mem) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_from(device_memory &mem) { mem_copy_from(mem, -1, -1, -1, -1); diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index 67c2fdeebf5..8668cb3807b 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -752,6 +752,23 @@ MetalDevice::MetalMem *MetalDevice::generic_alloc(device_memory &mem) return mmem; } +void MetalDevice::generic_copy_to(device_memory &mem, size_t size, +size_t offset) +{ + if (!mem.host_pointer || !mem.device_pointer) { + return; + } + + std::lock_guard lock(metal_mem_map_mutex); + if (!metal_mem_map.at(&mem)->use_UMA || mem.host_pointer != mem.shared_pointer) { + MetalMem &mmem = *metal_mem_map.at(&mem); + memcpy(mmem.hostPtr, mem.host_pointer, mem.memory_size()); + if (mmem.mtlBuffer.storageMode == MTLStorageModeManaged) { + [mmem.mtlBuffer didModifyRange:NSMakeRange(offset, size)]; + } + } +} + void MetalDevice::generic_copy_to(device_memory &mem) { if (!mem.host_pointer || !mem.device_pointer) { @@ -824,11 +841,36 @@ void MetalDevice::mem_alloc(device_memory &mem) } } +void MetalDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) +{ + if (mem.type == MEM_GLOBAL) { + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } + else { + generic_copy_to(mem, size, offset); + } + } + else if (mem.type == MEM_TEXTURE) { + tex_free((device_texture &)mem); + tex_alloc((device_texture &)mem); + } + else { + if (!mem.device_pointer) { + generic_alloc(mem); + } + generic_copy_to(mem, size, offset); + } +} + void MetalDevice::mem_copy_to(device_memory &mem) { if (mem.type == MEM_GLOBAL) { - global_free(mem); - global_alloc(mem); + if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + global_free(mem); + global_alloc(mem); + } } else if (mem.type == MEM_TEXTURE) { tex_free((device_texture &)mem); @@ -1341,10 +1383,10 @@ void MetalDevice::flush_delayed_free_list() delayed_free_list.clear(); } -void MetalDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) +void MetalDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { - Device::build_bvh(bvh, progress, refit); + Device::build_bvh(bvh, dscene, progress, refit); return; } diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 9605c6a7538..40b4442562c 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -18,6 +18,7 @@ #include "util/log.h" #include "util/map.h" #include "util/time.h" +#include "util/tbb.h" CCL_NAMESPACE_BEGIN @@ -30,7 +31,10 @@ class MultiDevice : public Device { int peer_island_index = -1; }; - list devices; + // Switch from list to a vector to make the parallel_for easily map to the integer id. + // Also id now could be used to access the real device pointer more quickly. Also, since + // the vector reallocates the memory on resize the sub-devices are stored as pointers. + vector devices; device_ptr unique_key; vector> peer_islands; @@ -40,28 +44,35 @@ class MultiDevice : public Device { foreach (const DeviceInfo &subinfo, info.multi_devices) { /* Always add CPU devices at the back since GPU devices can change * host memory pointers, which CPU uses as device pointer. */ - SubDevice *sub; + SubDevice *sub = new SubDevice; if (subinfo.type == DEVICE_CPU) { - devices.emplace_back(); - sub = &devices.back(); + devices.emplace_back(sub); } else { - devices.emplace_front(); - sub = &devices.front(); + devices.emplace_back(sub); + // find first CPU device and swop it with the new device + // to keep the CPU devices at the end of the vector. + int last = devices.size() - 1; + int o = last; + while ((o > 0) && (devices[o - 1]->device->info.type == DEVICE_CPU)) { + o--; + }; + if (o != last) { + std::swap(devices[last], devices[o]); + } + sub = devices[o]; } - /* The pointer to 'sub->stats' will stay valid even after new devices - * are added, since 'devices' is a linked list. */ sub->device = Device::create(subinfo, sub->stats, profiler); } /* Build a list of peer islands for the available render devices */ - foreach (SubDevice &sub, devices) { + foreach (SubDevice *sub, devices) { /* First ensure that every device is in at least once peer island */ - if (sub.peer_island_index < 0) { + if (sub->peer_island_index < 0) { peer_islands.emplace_back(); - sub.peer_island_index = (int)peer_islands.size() - 1; - peer_islands[sub.peer_island_index].push_back(&sub); + sub->peer_island_index = (int)peer_islands.size() - 1; + peer_islands[sub->peer_island_index].push_back(sub); } if (!info.has_peer_memory) { @@ -69,12 +80,12 @@ class MultiDevice : public Device { } /* Second check peer access between devices and fill up the islands accordingly */ - foreach (SubDevice &peer_sub, devices) { - if (peer_sub.peer_island_index < 0 && - peer_sub.device->info.type == sub.device->info.type && - peer_sub.device->check_peer_access(sub.device)) { - peer_sub.peer_island_index = sub.peer_island_index; - peer_islands[sub.peer_island_index].push_back(&peer_sub); + foreach (SubDevice *peer_sub, devices) { + if (peer_sub->peer_island_index < 0 && + peer_sub->device->info.type == sub->device->info.type && + peer_sub->device->check_peer_access(sub->device)) { + peer_sub->peer_island_index = sub->peer_island_index; + peer_islands[sub->peer_island_index].push_back(peer_sub); } } } @@ -82,16 +93,23 @@ class MultiDevice : public Device { ~MultiDevice() { - foreach (SubDevice &sub, devices) - delete sub.device; + foreach (SubDevice *sub, devices) { + delete sub->device; + delete sub; + } + } + + int get_num_devices() const override + { + return devices.size(); } const string &error_message() override { error_msg.clear(); - foreach (SubDevice &sub, devices) - error_msg += sub.device->error_message(); + foreach (SubDevice *sub, devices) + error_msg += sub->device->error_message(); return error_msg; } @@ -100,8 +118,8 @@ class MultiDevice : public Device { { BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL; BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE; - foreach (const SubDevice &sub_device, devices) { - BVHLayoutMask device_bvh_layout_mask = sub_device.device->get_bvh_layout_mask(); + foreach (const SubDevice *sub_device, devices) { + BVHLayoutMask device_bvh_layout_mask = sub_device->device->get_bvh_layout_mask(); bvh_layout_mask &= device_bvh_layout_mask; bvh_layout_mask_all |= device_bvh_layout_mask; } @@ -131,8 +149,8 @@ class MultiDevice : public Device { bool load_kernels(const uint kernel_features) override { - foreach (SubDevice &sub, devices) - if (!sub.device->load_kernels(kernel_features)) + foreach (SubDevice *sub, devices) + if (!sub->device->load_kernels(kernel_features)) return false; return true; @@ -140,18 +158,18 @@ class MultiDevice : public Device { bool load_osl_kernels() override { - foreach (SubDevice &sub, devices) - if (!sub.device->load_osl_kernels()) + foreach (SubDevice *sub, devices) + if (!sub->device->load_osl_kernels()) return false; return true; } - void build_bvh(BVH *bvh, Progress &progress, bool refit) override +void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override { /* Try to build and share a single acceleration structure, if possible */ if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) { - devices.back().device->build_bvh(bvh, progress, refit); + devices.back()->device->build_bvh(bvh, dscene, progress, refit); return; } @@ -163,82 +181,71 @@ class MultiDevice : public Device { BVHMulti *const bvh_multi = static_cast(bvh); bvh_multi->sub_bvhs.resize(devices.size()); - vector geom_bvhs; - geom_bvhs.reserve(bvh->geometry.size()); - foreach (Geometry *geom, bvh->geometry) { - geom_bvhs.push_back(static_cast(geom->bvh)); - } - /* Broadcast acceleration structure build to all render devices */ - size_t i = 0; - foreach (SubDevice &sub, devices) { - /* Change geometry BVH pointers to the sub BVH */ - for (size_t k = 0; k < bvh->geometry.size(); ++k) { - bvh->geometry[k]->bvh = geom_bvhs[k]->sub_bvhs[i]; - } + parallel_for(size_t(0), devices.size(), [this, &bvh_multi, &dscene, refit, &progress](size_t id) { + // WL: Pointer translation is removed as it is not thread safe. Instead a new method is added + // to retrieve the real device pointer. + SubDevice *sub = devices[id]; - if (!bvh_multi->sub_bvhs[i]) { - BVHParams params = bvh->params; - if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) + if (!bvh_multi->sub_bvhs[id]) { + BVHParams params = bvh_multi->params; + if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) params.bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) params.bvh_layout = BVH_LAYOUT_METAL; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - params.bvh_layout = sub.device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : - BVH_LAYOUT_EMBREE; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - params.bvh_layout = sub.device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : - BVH_LAYOUT_EMBREE; + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + params.bvh_layout = sub->device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : + BVH_LAYOUT_EMBREE; + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + params.bvh_layout = sub->device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : + BVH_LAYOUT_EMBREE; /* Skip building a bottom level acceleration structure for non-instanced geometry on Embree * (since they are put into the top level directly, see bvh_embree.cpp) */ if (!params.top_level && params.bvh_layout == BVH_LAYOUT_EMBREE && - !bvh->geometry[0]->is_instanced()) { - i++; - continue; + !bvh_multi->geometry[0]->is_instanced()) { + } + else { + bvh_multi->sub_bvhs[id] = BVH::create( + params, bvh_multi->geometry, bvh_multi->objects, sub->device); } - - bvh_multi->sub_bvhs[i] = BVH::create(params, bvh->geometry, bvh->objects, sub.device); } - - sub.device->build_bvh(bvh_multi->sub_bvhs[i], progress, refit); - i++; - } - - /* Change geometry BVH pointers back to the multi BVH. */ - for (size_t k = 0; k < bvh->geometry.size(); ++k) { - bvh->geometry[k]->bvh = geom_bvhs[k]; - } + if (bvh_multi->sub_bvhs[id]) { + sub->device->build_bvh(bvh_multi->sub_bvhs[id], dscene, progress, refit); + } + }); } virtual void *get_cpu_osl_memory() override { /* Always return the OSL memory of the CPU device (this works since the constructor above * guarantees that CPU devices are always added to the back). */ - if (devices.size() > 1 && devices.back().device->info.type != DEVICE_CPU) { + if (devices.size() > 1 && devices.back()->device->info.type != DEVICE_CPU) { return NULL; } - return devices.back().device->get_cpu_osl_memory(); + + return devices.back()->device->get_cpu_osl_memory(); } bool is_resident(device_ptr key, Device *sub_device) override { - foreach (SubDevice &sub, devices) { - if (sub.device == sub_device) { + foreach (SubDevice *sub, devices) { + if (sub->device == sub_device) { return find_matching_mem_device(key, sub)->device == sub_device; } } return false; } - SubDevice *find_matching_mem_device(device_ptr key, SubDevice &sub) + SubDevice *find_matching_mem_device(device_ptr key, SubDevice *sub) { - assert(key != 0 && (sub.peer_island_index >= 0 || sub.ptr_map.find(key) != sub.ptr_map.end())); + assert(key != 0 && + (sub->peer_island_index >= 0 || sub->ptr_map.find(key) != sub->ptr_map.end())); /* Get the memory owner of this key (first try current device, then peer devices) */ - SubDevice *owner_sub = ⊂ + SubDevice *owner_sub = sub; if (owner_sub->ptr_map.find(key) == owner_sub->ptr_map.end()) { - foreach (SubDevice *island_sub, peer_islands[sub.peer_island_index]) { + foreach (SubDevice *island_sub, peer_islands[sub->peer_island_index]) { if (island_sub != owner_sub && island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) { owner_sub = island_sub; @@ -263,7 +270,18 @@ class MultiDevice : public Device { return owner_sub; } - inline device_ptr find_matching_mem(device_ptr key, SubDevice &sub) + inline device_ptr find_matching_mem(device_ptr key, Device *dev) override + { + device_ptr ptr = 0; + foreach (SubDevice *sub, devices) { + if (sub->device == dev) { + return find_matching_mem_device(key, sub)->ptr_map[key]; + } + } + return ptr; + } + + inline device_ptr find_matching_mem(device_ptr key, SubDevice *sub) { return find_matching_mem_device(key, sub)->ptr_map[key]; } @@ -320,12 +338,43 @@ class MultiDevice : public Device { stats.mem_alloc(mem.device_size - existing_size); } + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override + { + device_ptr existing_key = mem.device_pointer; + device_ptr key = (existing_key) ? existing_key : unique_key++; + size_t existing_size = mem.device_size; + + /* The tile buffers are allocated on each device (see below), so copy to all of them */ + foreach (const vector &island, peer_islands) { + SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); + mem.device = owner_sub->device; + mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; + mem.device_size = existing_size; + + owner_sub->device->mem_copy_to(mem); + owner_sub->ptr_map[key] = mem.device_pointer; + + if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) { + /* Need to create texture objects and update pointer in kernel globals on all devices */ + foreach (SubDevice *island_sub, island) { + if (island_sub != owner_sub) { + island_sub->device->mem_copy_to(mem, size, offset); + } + } + } + } + + mem.device = this; + mem.device_pointer = key; + stats.mem_alloc(mem.device_size - existing_size); + } + void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override { device_ptr key = mem.device_pointer; size_t i = 0, sub_h = h / devices.size(); - foreach (SubDevice &sub, devices) { + foreach (SubDevice *sub, devices) { size_t sy = y + i * sub_h; size_t sh = (i == (size_t)devices.size() - 1) ? h - sub_h * i : sub_h; @@ -369,7 +418,7 @@ class MultiDevice : public Device { /* Free memory that was allocated for all devices (see above) on each device */ foreach (const vector &island, peer_islands) { - SubDevice *owner_sub = find_matching_mem_device(key, *island.front()); + SubDevice *owner_sub = find_matching_mem_device(key, island.front()); mem.device = owner_sub->device; mem.device_pointer = owner_sub->ptr_map[key]; mem.device_size = existing_size; @@ -387,24 +436,26 @@ class MultiDevice : public Device { } } - mem.device = this; - mem.device_pointer = 0; - mem.device_size = 0; - stats.mem_free(existing_size); + if (mem.device_pointer) { + mem.device = this; + mem.device_pointer = 0; + mem.device_size = 0; + stats.mem_free(existing_size); + } } void const_copy_to(const char *name, void *host, size_t size) override { - foreach (SubDevice &sub, devices) - sub.device->const_copy_to(name, host, size); + foreach (SubDevice *sub, devices) + sub->device->const_copy_to(name, host, size); } - int device_number(Device *sub_device) override + int device_number(const Device *sub_device) const override { int i = 0; - foreach (SubDevice &sub, devices) { - if (sub.device == sub_device) + for (const SubDevice *sub : devices) { + if (sub->device == sub_device) return i; i++; } @@ -414,8 +465,8 @@ class MultiDevice : public Device { virtual void foreach_device(const function &callback) override { - foreach (SubDevice &sub, devices) { - sub.device->foreach_device(callback); + foreach (SubDevice *sub, devices) { + sub->device->foreach_device(callback); } } }; diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index 06589140ad9..fa1609f54d5 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -97,6 +97,11 @@ OptiXDevice::OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profile /* Allocate launch parameter buffer memory on device. */ launch_params.alloc_to_device(1); + + optixDeviceContextGetProperty(context, + OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID, + &max_num_instances, + sizeof(max_num_instances)); } OptiXDevice::~OptiXDevice() @@ -1056,7 +1061,7 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, return !have_error(); } -void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) +void OptiXDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { const bool use_fast_trace_bvh = (bvh->params.bvh_type == BVH_TYPE_STATIC); @@ -1388,18 +1393,11 @@ void OptiXDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) } else { unsigned int num_instances = 0; - unsigned int max_num_instances = 0xFFFFFFFF; bvh_optix->as_data->free(); bvh_optix->traversable_handle = 0; bvh_optix->motion_transform_data->free(); - optixDeviceContextGetProperty(context, - OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID, - &max_num_instances, - sizeof(max_num_instances)); - /* Do not count first bit, which is used to distinguish instanced and non-instanced objects. */ - max_num_instances >>= 1; if (bvh->objects.size() > max_num_instances) { progress.set_error( "Failed to build OptiX acceleration structure because there are too many instances"); @@ -1635,7 +1633,7 @@ void OptiXDevice::update_launch_params(size_t offset, void *data, size_t data_si { const CUDAContextScope scope(this); - cuda_assert(cuMemcpyHtoD(launch_params.device_pointer + offset, data, data_size)); + cuda_assert(cuMemcpyHtoD(launch_params.get_device_ptr(this) + offset, data, data_size)); } CCL_NAMESPACE_END diff --git a/intern/cycles/device/optix/device_impl.h b/intern/cycles/device/optix/device_impl.h index 5ecbeb41640..b65e429c0fd 100644 --- a/intern/cycles/device/optix/device_impl.h +++ b/intern/cycles/device/optix/device_impl.h @@ -84,6 +84,7 @@ class OptiXDevice : public CUDADevice { vector>> delayed_free_bvh_memory; thread_mutex delayed_free_bvh_mutex; + unsigned int max_num_instances = 0xFFFFFFFF; public: OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler); ~OptiXDevice(); @@ -101,7 +102,7 @@ class OptiXDevice : public CUDADevice { const OptixBuildInput &build_input, uint16_t num_motion_steps); - void build_bvh(BVH *bvh, Progress &progress, bool refit) override; + void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override; void release_optix_bvh(BVH *bvh) override; void free_bvh_memory_delayed(); diff --git a/intern/cycles/scene/CMakeLists.txt b/intern/cycles/scene/CMakeLists.txt index 759a25ab7cb..cf83bd9c431 100644 --- a/intern/cycles/scene/CMakeLists.txt +++ b/intern/cycles/scene/CMakeLists.txt @@ -17,6 +17,7 @@ set(SRC constant_fold.cpp film.cpp geometry.cpp + geometry_additions.cpp hair.cpp image.cpp image_oiio.cpp diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index c39712d9d5f..50a614ba118 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -189,64 +189,17 @@ void Geometry::compute_bvh(Device *device, size_t n, size_t total) { + SCOPED_MARKER(device,"Geometry::compute_bvh"); if (progress->get_cancel()) - return; - - compute_bounds(); + return; const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, device->get_bvh_layout_mask()); if (need_build_bvh(bvh_layout)) { - string msg = "Updating Geometry BVH "; - if (name.empty()) - msg += string_printf("%u/%u", (uint)(n + 1), (uint)total); - else - msg += string_printf("%s %u/%u", name.c_str(), (uint)(n + 1), (uint)total); - - Object object; - - /* Ensure all visibility bits are set at the geometry level BVH. In - * the object level BVH is where actual visibility is tested. */ - object.set_is_shadow_catcher(true); - object.set_visibility(~0); - - object.set_geometry(this); - - vector geometry; - geometry.push_back(this); - vector objects; - objects.push_back(&object); - - if (bvh && !need_update_rebuild) { - progress->set_status(msg, "Refitting BVH"); - - bvh->replace_geometry(geometry, objects); - - device->build_bvh(bvh, *progress, true); - } - else { - progress->set_status(msg, "Building BVH"); - - BVHParams bparams; - bparams.use_spatial_split = params->use_bvh_spatial_split; - bparams.use_compact_structure = params->use_bvh_compact_structure; - bparams.bvh_layout = bvh_layout; - bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && - params->use_bvh_unaligned_nodes; - bparams.num_motion_triangle_steps = params->num_bvh_time_steps; - bparams.num_motion_curve_steps = params->num_bvh_time_steps; - bparams.num_motion_point_steps = params->num_bvh_time_steps; - bparams.bvh_type = params->bvh_type; - bparams.curve_subdivisions = params->curve_subdivisions(); - - delete bvh; - bvh = BVH::create(bparams, geometry, objects, device); - MEM_GUARDED_CALL(progress, device->build_bvh, bvh, *progress, false); - } + BVH *sub_bvh = bvh->get_device_bvh(device); + GeometryManager::device_update_sub_bvh( + device, dscene, bvh, sub_bvh, !need_update_rebuild, n, total, progress); } - - need_update_rebuild = false; - need_update_bvh_for_offset = false; } bool Geometry::has_motion_blur() const @@ -497,45 +450,14 @@ void GeometryManager::update_svm_attributes(Device *, } /* copy to device */ - dscene->attributes_map.copy_to_device(); -} - -static void update_attribute_element_size(Geometry *geom, - Attribute *mattr, - AttributePrimitive prim, - size_t *attr_float_size, - size_t *attr_float2_size, - size_t *attr_float3_size, - size_t *attr_float4_size, - size_t *attr_uchar4_size) -{ - if (mattr) { - size_t size = mattr->element_size(geom, prim); - - if (mattr->element == ATTR_ELEMENT_VOXEL) { - /* pass */ - } - else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { - *attr_uchar4_size += size; - } - else if (mattr->type == TypeDesc::TypeFloat) { - *attr_float_size += size; - } - else if (mattr->type == TypeFloat2) { - *attr_float2_size += size; - } - else if (mattr->type == TypeDesc::TypeMatrix) { - *attr_float4_size += size * 4; - } - else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { - *attr_float4_size += size; - } - else { - *attr_float3_size += size; - } - } + /* Copy moved to device_update_attributes */ + dscene->attributes_map.tag_modified(); } +/* + * Copies the attribute data into the buffers and records + * the offsets + */ void GeometryManager::update_attribute_element_offset(Geometry *geom, device_vector &attr_float, size_t &attr_float_offset, @@ -638,6 +560,13 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom, float3 *data = mattr->data_float3(); offset = attr_float3_offset; + // Records where the motion vertices are in the attribute array + // so that they can be used later to reference the data when building + // the BVHs. + if (mattr->std == ATTR_STD_MOTION_VERTEX_POSITION) { + geom->motion_key_offset = offset; + } + assert(attr_float3.size() >= offset + size); if (mattr->modified) { for (size_t k = 0; k < size; k++) { @@ -697,630 +626,123 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom, } } +/* + * Copies the attribute buffer data to the devices + */ void GeometryManager::device_update_attributes(Device *device, DeviceScene *dscene, - Scene *scene, + const AttributeSizes *sizes, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_attributes"); - progress.set_status("Updating Mesh", "Computing attributes"); - - /* gather per mesh requested attributes. as meshes may have multiple - * shaders assigned, this merges the requested attributes that have - * been set per shader by the shader manager */ - vector geom_attributes(scene->geometry.size()); - - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - - geom->index = i; - scene->need_global_attributes(geom_attributes[i]); - - foreach (Node *node, geom->get_used_shaders()) { - Shader *shader = static_cast(node); - geom_attributes[i].add(shader->attributes); - } - - if (geom->is_hair() && static_cast(geom)->need_shadow_transparency()) { - geom_attributes[i].add(ATTR_STD_SHADOW_TRANSPARENCY); - } - } - - /* convert object attributes to use the same data structures as geometry ones */ - vector object_attributes(scene->objects.size()); - vector object_attribute_values; - - object_attribute_values.reserve(scene->objects.size()); - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - Geometry *geom = object->geometry; - size_t geom_idx = geom->index; - - assert(geom_idx < scene->geometry.size() && scene->geometry[geom_idx] == geom); - - object_attribute_values.push_back(AttributeSet(geom, ATTR_PRIM_GEOMETRY)); - - AttributeRequestSet &geom_requests = geom_attributes[geom_idx]; - AttributeRequestSet &attributes = object_attributes[i]; - AttributeSet &values = object_attribute_values[i]; - - for (size_t j = 0; j < object->attributes.size(); j++) { - ParamValue ¶m = object->attributes[j]; - - /* add attributes that are requested and not already handled by the mesh */ - if (geom_requests.find(param.name()) && !geom->attributes.find(param.name())) { - attributes.add(param.name()); - - Attribute *attr = values.add(param.name(), param.type(), ATTR_ELEMENT_OBJECT); - assert(param.datasize() == attr->buffer.size()); - memcpy(attr->buffer.data(), param.data(), param.datasize()); - } - } - } - - /* mesh attribute are stored in a single array per data type. here we fill - * those arrays, and set the offset and element type to create attribute - * maps next */ - - /* Pre-allocate attributes to avoid arrays re-allocation which would - * take 2x of overall attribute memory usage. - */ - size_t attr_float_size = 0; - size_t attr_float2_size = 0; - size_t attr_float3_size = 0; - size_t attr_float4_size = 0; - size_t attr_uchar4_size = 0; - - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - AttributeRequestSet &attributes = geom_attributes[i]; - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = geom->attributes.find(req); - - update_attribute_element_size(geom, - attr, - ATTR_PRIM_GEOMETRY, - &attr_float_size, - &attr_float2_size, - &attr_float3_size, - &attr_float4_size, - &attr_uchar4_size); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - Attribute *subd_attr = mesh->subd_attributes.find(req); - - update_attribute_element_size(mesh, - subd_attr, - ATTR_PRIM_SUBD, - &attr_float_size, - &attr_float2_size, - &attr_float3_size, - &attr_float4_size, - &attr_uchar4_size); - } - } - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - - foreach (Attribute &attr, object_attribute_values[i].attributes) { - update_attribute_element_size(object->geometry, - &attr, - ATTR_PRIM_GEOMETRY, - &attr_float_size, - &attr_float2_size, - &attr_float3_size, - &attr_float4_size, - &attr_uchar4_size); - } - } - - dscene->attributes_float.alloc(attr_float_size); - dscene->attributes_float2.alloc(attr_float2_size); - dscene->attributes_float3.alloc(attr_float3_size); - dscene->attributes_float4.alloc(attr_float4_size); - dscene->attributes_uchar4.alloc(attr_uchar4_size); - - /* The order of those flags needs to match that of AttrKernelDataType. */ - const bool attributes_need_realloc[AttrKernelDataType::NUM] = { - dscene->attributes_float.need_realloc(), - dscene->attributes_float2.need_realloc(), - dscene->attributes_float3.need_realloc(), - dscene->attributes_float4.need_realloc(), - dscene->attributes_uchar4.need_realloc(), - }; - - size_t attr_float_offset = 0; - size_t attr_float2_offset = 0; - size_t attr_float3_offset = 0; - size_t attr_float4_offset = 0; - size_t attr_uchar4_offset = 0; - - /* Fill in attributes. */ - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - AttributeRequestSet &attributes = geom_attributes[i]; - - /* todo: we now store std and name attributes from requests even if - * they actually refer to the same mesh attributes, optimize */ - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = geom->attributes.find(req); - - if (attr) { - /* force a copy if we need to reallocate all the data */ - attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; - } - - update_attribute_element_offset(geom, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - attr, - ATTR_PRIM_GEOMETRY, - req.type, - req.desc); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - Attribute *subd_attr = mesh->subd_attributes.find(req); - - if (subd_attr) { - /* force a copy if we need to reallocate all the data */ - subd_attr->modified |= attributes_need_realloc[Attribute::kernel_type(*subd_attr)]; - } - - update_attribute_element_offset(mesh, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - subd_attr, - ATTR_PRIM_SUBD, - req.subd_type, - req.subd_desc); - } - - if (progress.get_cancel()) - return; - } - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - AttributeRequestSet &attributes = object_attributes[i]; - AttributeSet &values = object_attribute_values[i]; - - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = values.find(req); - - if (attr) { - attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; - } - - update_attribute_element_offset(object->geometry, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - attr, - ATTR_PRIM_GEOMETRY, - req.type, - req.desc); - - /* object attributes don't care about subdivision */ - req.subd_type = req.type; - req.subd_desc = req.desc; - - if (progress.get_cancel()) - return; - } - } - - /* create attribute lookup maps */ - if (scene->shader_manager->use_osl()) - update_osl_globals(device, scene); - - update_svm_attributes(device, dscene, scene, geom_attributes, object_attributes); - - if (progress.get_cancel()) - return; - - /* copy to device */ progress.set_status("Updating Mesh", "Copying Attributes to device"); + /* copy svm attributes to device */ + { + SCOPED_MARKER(device, "copy attribute_map"); + dscene->attributes_map.copy_to_device_if_modified(); + } - dscene->attributes_float.copy_to_device_if_modified(); - dscene->attributes_float2.copy_to_device_if_modified(); - dscene->attributes_float3.copy_to_device_if_modified(); - dscene->attributes_float4.copy_to_device_if_modified(); - dscene->attributes_uchar4.copy_to_device_if_modified(); + { + SCOPED_MARKER(device, "copy attributes_float"); + dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); + } + { + SCOPED_MARKER(device, "copy attributes_float2"); + dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); + } + { + SCOPED_MARKER(device, "copy attributes_float3"); + dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); + } - if (progress.get_cancel()) - return; + { + SCOPED_MARKER(device, "copy attributes_float4"); + dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); + } + { + SCOPED_MARKER(device, "copy attributes_uchar4"); + dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); + } /* After mesh attributes and patch tables have been copied to device memory, * we need to update offsets in the objects. */ - scene->object_manager->device_update_geom_offsets(device, dscene, scene); -} - -void GeometryManager::geom_calc_offset(Scene *scene, BVHLayout bvh_layout) -{ - size_t vert_size = 0; - size_t tri_size = 0; - - size_t curve_size = 0; - size_t curve_key_size = 0; - size_t curve_segment_size = 0; - - size_t point_size = 0; - - size_t patch_size = 0; - size_t face_size = 0; - size_t corner_size = 0; - - foreach (Geometry *geom, scene->geometry) { - bool prim_offset_changed = false; - - if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { - Mesh *mesh = static_cast(geom); - - prim_offset_changed = (mesh->prim_offset != tri_size); - - mesh->vert_offset = vert_size; - mesh->prim_offset = tri_size; - - mesh->patch_offset = patch_size; - mesh->face_offset = face_size; - mesh->corner_offset = corner_size; - - vert_size += mesh->verts.size(); - tri_size += mesh->num_triangles(); - - if (mesh->get_num_subd_faces()) { - Mesh::SubdFace last = mesh->get_subd_face(mesh->get_num_subd_faces() - 1); - patch_size += (last.ptex_offset + last.num_ptex_faces()) * 8; - - /* patch tables are stored in same array so include them in patch_size */ - if (mesh->patch_table) { - mesh->patch_table_offset = patch_size; - patch_size += mesh->patch_table->total_size(); - } - } - - face_size += mesh->get_num_subd_faces(); - corner_size += mesh->subd_face_corners.size(); - } - else if (geom->is_hair()) { - Hair *hair = static_cast(geom); - - prim_offset_changed = (hair->curve_segment_offset != curve_segment_size); - hair->curve_key_offset = curve_key_size; - hair->curve_segment_offset = curve_segment_size; - hair->prim_offset = curve_size; - - curve_size += hair->num_curves(); - curve_key_size += hair->get_curve_keys().size(); - curve_segment_size += hair->num_segments(); - } - else if (geom->is_pointcloud()) { - PointCloud *pointcloud = static_cast(geom); - - prim_offset_changed = (pointcloud->prim_offset != point_size); - - pointcloud->prim_offset = point_size; - point_size += pointcloud->num_points(); - } - - if (prim_offset_changed) { - /* Need to rebuild BVH in OptiX, since refit only allows modified mesh data there */ - const bool has_optix_bvh = bvh_layout == BVH_LAYOUT_OPTIX || - bvh_layout == BVH_LAYOUT_MULTI_OPTIX || - bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE; - geom->need_update_rebuild |= has_optix_bvh; - geom->need_update_bvh_for_offset = true; - } + { + SCOPED_MARKER(device, "copy objects"); + dscene->objects.copy_to_device_if_modified(); } } +/** + * This copies the data to the devices if they have been modified + */ void GeometryManager::device_update_mesh(Device *device, DeviceScene *dscene, - Scene *scene, + const GeometrySizes *p_sizes, Progress &progress) { SCOPED_MARKER(device, "GeometryManager::device_update_mesh"); - /* Count. */ - size_t vert_size = 0; - size_t tri_size = 0; - - size_t curve_key_size = 0; - size_t curve_size = 0; - size_t curve_segment_size = 0; - - size_t point_size = 0; - - size_t patch_size = 0; - - foreach (Geometry *geom, scene->geometry) { - if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { - Mesh *mesh = static_cast(geom); - - vert_size += mesh->verts.size(); - tri_size += mesh->num_triangles(); - - if (mesh->get_num_subd_faces()) { - Mesh::SubdFace last = mesh->get_subd_face(mesh->get_num_subd_faces() - 1); - patch_size += (last.ptex_offset + last.num_ptex_faces()) * 8; - - /* patch tables are stored in same array so include them in patch_size */ - if (mesh->patch_table) { - mesh->patch_table_offset = patch_size; - patch_size += mesh->patch_table->total_size(); - } + progress.set_status("Updating Mesh", "Copying Mesh to device"); + { + SCOPED_MARKER(device, "copy packed data to device"); + if (p_sizes->tri_size != 0) { + SCOPED_MARKER(device, "copy mesh data"); + { + SCOPED_MARKER(device, "copy tri_verts"); + dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); } - } - else if (geom->is_hair()) { - Hair *hair = static_cast(geom); - - curve_key_size += hair->get_curve_keys().size(); - curve_size += hair->num_curves(); - curve_segment_size += hair->num_segments(); - } - else if (geom->is_pointcloud()) { - PointCloud *pointcloud = static_cast(geom); - point_size += pointcloud->num_points(); - } - } - - /* Fill in all the arrays. */ - if (tri_size != 0) { - /* normals */ - progress.set_status("Updating Mesh", "Computing normals"); - - packed_float3 *tri_verts = dscene->tri_verts.alloc(vert_size); - uint *tri_shader = dscene->tri_shader.alloc(tri_size); - packed_float3 *vnormal = dscene->tri_vnormal.alloc(vert_size); - packed_uint3 *tri_vindex = dscene->tri_vindex.alloc(tri_size); - uint *tri_patch = dscene->tri_patch.alloc(tri_size); - float2 *tri_patch_uv = dscene->tri_patch_uv.alloc(vert_size); - - const bool copy_all_data = dscene->tri_shader.need_realloc() || - dscene->tri_vindex.need_realloc() || - dscene->tri_vnormal.need_realloc() || - dscene->tri_patch.need_realloc() || - dscene->tri_patch_uv.need_realloc(); - - foreach (Geometry *geom, scene->geometry) { - if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { - Mesh *mesh = static_cast(geom); - - if (mesh->shader_is_modified() || mesh->smooth_is_modified() || - mesh->triangles_is_modified() || copy_all_data) { - mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); - } - - if (mesh->verts_is_modified() || copy_all_data) { - mesh->pack_normals(&vnormal[mesh->vert_offset]); - } - - if (mesh->verts_is_modified() || mesh->triangles_is_modified() || - mesh->vert_patch_uv_is_modified() || copy_all_data) { - mesh->pack_verts(&tri_verts[mesh->vert_offset], - &tri_vindex[mesh->prim_offset], - &tri_patch[mesh->prim_offset], - &tri_patch_uv[mesh->vert_offset]); - } - - if (progress.get_cancel()) - return; + { + SCOPED_MARKER(device, "copy tri_shader"); + dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); + } + { + SCOPED_MARKER(device, "copy tri_vnormal"); + dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); + } + { + SCOPED_MARKER(device, "copy tri_vindex"); + dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); + } + { + SCOPED_MARKER(device, "copy tri_patch"); + dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); + } + { + SCOPED_MARKER(device, "copy tri_patch_uv"); + dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); } } - /* vertex coordinates */ - progress.set_status("Updating Mesh", "Copying Mesh to device"); - - dscene->tri_verts.copy_to_device_if_modified(); - dscene->tri_shader.copy_to_device_if_modified(); - dscene->tri_vnormal.copy_to_device_if_modified(); - dscene->tri_vindex.copy_to_device_if_modified(); - dscene->tri_patch.copy_to_device_if_modified(); - dscene->tri_patch_uv.copy_to_device_if_modified(); - } - - if (curve_segment_size != 0) { - progress.set_status("Updating Mesh", "Copying Curves to device"); - - float4 *curve_keys = dscene->curve_keys.alloc(curve_key_size); - KernelCurve *curves = dscene->curves.alloc(curve_size); - KernelCurveSegment *curve_segments = dscene->curve_segments.alloc(curve_segment_size); - - const bool copy_all_data = dscene->curve_keys.need_realloc() || - dscene->curves.need_realloc() || - dscene->curve_segments.need_realloc(); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_hair()) { - Hair *hair = static_cast(geom); - - bool curve_keys_co_modified = hair->curve_radius_is_modified() || - hair->curve_keys_is_modified(); - bool curve_data_modified = hair->curve_shader_is_modified() || - hair->curve_first_key_is_modified(); - - if (!curve_keys_co_modified && !curve_data_modified && !copy_all_data) { - continue; - } - - hair->pack_curves(scene, - &curve_keys[hair->curve_key_offset], - &curves[hair->prim_offset], - &curve_segments[hair->curve_segment_offset]); - if (progress.get_cancel()) - return; - } + if (p_sizes->curve_segment_size != 0) { + SCOPED_MARKER(device, "copy hair"); + dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); + dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); + dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); } - dscene->curve_keys.copy_to_device_if_modified(); - dscene->curves.copy_to_device_if_modified(); - dscene->curve_segments.copy_to_device_if_modified(); - } - - if (point_size != 0) { - progress.set_status("Updating Mesh", "Copying Point clouds to device"); - - float4 *points = dscene->points.alloc(point_size); - uint *points_shader = dscene->points_shader.alloc(point_size); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_pointcloud()) { - PointCloud *pointcloud = static_cast(geom); - pointcloud->pack( - scene, &points[pointcloud->prim_offset], &points_shader[pointcloud->prim_offset]); - if (progress.get_cancel()) - return; - } + if (p_sizes->point_size != 0) { + SCOPED_MARKER(device, "copy points"); + dscene->points.copy_to_device(p_sizes->point_size, 0); + dscene->points_shader.copy_to_device(p_sizes->point_size, 0); } - dscene->points.copy_to_device(); - dscene->points_shader.copy_to_device(); - } - - if (patch_size != 0 && dscene->patches.need_realloc()) { - progress.set_status("Updating Mesh", "Copying Patches to device"); - - uint *patch_data = dscene->patches.alloc(patch_size); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - mesh->pack_patches(&patch_data[mesh->patch_offset]); - - if (mesh->patch_table) { - mesh->patch_table->copy_adjusting_offsets(&patch_data[mesh->patch_table_offset], - mesh->patch_table_offset); - } - - if (progress.get_cancel()) - return; - } + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + SCOPED_MARKER(device, "copy patches"); + dscene->patches.copy_to_device(p_sizes->patch_size, 0); } - - dscene->patches.copy_to_device(); } } void GeometryManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, + bool can_refit, + size_t n, + size_t total, Progress &progress) { - /* bvh build */ - progress.set_status("Updating Scene BVH", "Building"); - - BVHParams bparams; - bparams.top_level = true; - bparams.bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, - device->get_bvh_layout_mask()); - bparams.use_spatial_split = scene->params.use_bvh_spatial_split; - bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && - scene->params.use_bvh_unaligned_nodes; - bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; - bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; - bparams.num_motion_point_steps = scene->params.num_bvh_time_steps; - bparams.bvh_type = scene->params.bvh_type; - bparams.curve_subdivisions = scene->params.curve_subdivisions(); - - VLOG_INFO << "Using " << bvh_layout_name(bparams.bvh_layout) << " layout."; - - const bool can_refit = scene->bvh != nullptr && - (bparams.bvh_layout == BVHLayout::BVH_LAYOUT_OPTIX || - bparams.bvh_layout == BVHLayout::BVH_LAYOUT_METAL); - BVH *bvh = scene->bvh; - if (!scene->bvh) { - bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); - } - - device->build_bvh(bvh, progress, can_refit); - - if (progress.get_cancel()) { - return; - } - - const bool has_bvh2_layout = (bparams.bvh_layout == BVH_LAYOUT_BVH2); - - PackedBVH pack; - if (has_bvh2_layout) { - pack = std::move(static_cast(bvh)->pack); - } - else { - pack.root_index = -1; - } - - /* copy to device */ - progress.set_status("Updating Scene BVH", "Copying BVH to device"); - - /* When using BVH2, we always have to copy/update the data as its layout is dependent on the - * BVH's leaf nodes which may be different when the objects or vertices move. */ - - if (pack.nodes.size()) { - dscene->bvh_nodes.steal_data(pack.nodes); - dscene->bvh_nodes.copy_to_device(); - } - if (pack.leaf_nodes.size()) { - dscene->bvh_leaf_nodes.steal_data(pack.leaf_nodes); - dscene->bvh_leaf_nodes.copy_to_device(); - } - if (pack.object_node.size()) { - dscene->object_node.steal_data(pack.object_node); - dscene->object_node.copy_to_device(); - } - if (pack.prim_type.size()) { - dscene->prim_type.steal_data(pack.prim_type); - dscene->prim_type.copy_to_device(); - } - if (pack.prim_visibility.size()) { - dscene->prim_visibility.steal_data(pack.prim_visibility); - dscene->prim_visibility.copy_to_device(); - } - if (pack.prim_index.size()) { - dscene->prim_index.steal_data(pack.prim_index); - dscene->prim_index.copy_to_device(); - } - if (pack.prim_object.size()) { - dscene->prim_object.steal_data(pack.prim_object); - dscene->prim_object.copy_to_device(); - } - if (pack.prim_time.size()) { - dscene->prim_time.steal_data(pack.prim_time); - dscene->prim_time.copy_to_device(); - } - - dscene->data.bvh.root = pack.root_index; - dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0); - dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions(); - /* The scene handle is set in 'CPUDevice::const_copy_to' and 'OptiXDevice::const_copy_to' */ - dscene->data.device_bvh = 0; + BVH *sub_bvh = scene->bvh->get_device_bvh(device); + GeometryManager::device_update_sub_bvh( + device, dscene, bvh, sub_bvh, can_refit, n, total, &progress); } /* Set of flags used to help determining what data has been modified or needs reallocation, so we @@ -1415,6 +837,7 @@ static void update_attribute_realloc_flags(uint32_t &device_update_flags, void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Progress &progress) { + SCOPED_MARKER(device, "GeometryManager::device_update_preprocess"); if (!need_update() && !need_flags_update) { return; } @@ -1672,6 +1095,7 @@ void GeometryManager::device_update_displacement_images(Device *device, Scene *scene, Progress &progress) { + SCOPED_MARKER(device, "device_update_displacement_images"); progress.set_status("Updating Displacement Images"); TaskPool pool; ImageManager *image_manager = scene->image_manager; @@ -1766,74 +1190,243 @@ void GeometryManager::device_update_volume_images(Device *device, Scene *scene, pool.wait_work(); } -void GeometryManager::device_update(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) +/* + * Updates the vertex normals and adds the undisplaced attributes to the + * mesh if they are not already present for all geometries. It marks any + * geometry that must be rebuilt. It also determines if any displacement + * or shadow transparancy occurs in the scene. + */ +void GeometryManager::preTessDispNormalAndVerticesSetup(Device *device, + Scene *scene, + bool &true_displacement_used, + bool &curve_shadow_transparency_used, + size_t &total_tess_needed) { - SCOPED_MARKER(device, "GeometryManager::device_update"); - if (!need_update()) - return; + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (normals)", time}); + } + }); - VLOG_INFO << "Total " << scene->geometry.size() << " meshes."; + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, + device->get_bvh_layout_mask()); - bool true_displacement_used = false; - bool curve_shadow_transparency_used = false; - size_t total_tess_needed = 0; + // Calculate and/or gather mesh vertex normals and undisplaced vertices + // also determines if tesselation, displacement or shadow transparency is needed. + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified()) { + SCOPED_MARKER(device, "add modified mesh"); + if ((geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME)) { + Mesh *mesh = static_cast(geom); + /* Update normals. */ + { + SCOPED_MARKER(device, "add vertex normals"); + mesh->add_vertex_normals(); + } + if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) { + mesh->add_undisplaced(); + } + /* Test if we need tessellation. */ + if (mesh->need_tesselation()) { + total_tess_needed++; + } + /* Test if we need displacement. */ + if (mesh->has_true_displacement()) { + true_displacement_used = true; + } + } + else if (geom->geometry_type == Geometry::HAIR) { + Hair *hair = static_cast(geom); + if (hair->need_shadow_transparency()) { + curve_shadow_transparency_used = true; + } + } + } + if (geom->need_update_bvh_for_offset) { + /* Need to rebuild BVH in OptiX, since refit only allows modified mesh data there */ + const bool has_optix_bvh = bvh_layout == BVH_LAYOUT_OPTIX || + bvh_layout == BVH_LAYOUT_MULTI_OPTIX || + bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE; + geom->need_update_rebuild |= has_optix_bvh; + geom->need_update_bvh_for_offset = true; + } + else { + geom->need_update_bvh_for_offset = false; + } + } +} + +/* + * Uploads the mesh data to the device and then builds or refits the BVH + * using the uploaded data. + */ +void GeometryManager::deviceDataXferAndBVHUpdate(int idx, + Scene *scene, + DeviceScene *dscene, + GeometrySizes &sizes, + AttributeSizes &attrib_sizes, + const BVHLayout bvh_layout, + size_t num_bvh, + double *mesh_times, + double *attrib_times, + double *bvh_times, + Progress &progress) +{ + DeviceScene *sub_dscene = scene->dscenes[idx]; + sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; + // WL:Get the device to use for this DeviceScene from one of the buffers + Device *sub_device = sub_dscene->tri_verts.device; + SCOPED_MARKER(sub_device, "parallel update device"); + // WL: Assign the host_pointers to the sub_dscene so that they access + // the correct data + device_update_host_pointers(sub_device, dscene, sub_dscene, &sizes); + + // WL: Upload geometry and attribute buffers to the device { - scoped_callback_timer timer([scene](double time) { + SCOPED_MARKER(sub_device, "copy mesh to device"); + scoped_callback_timer timer([scene, idx, &mesh_times](double time) { if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (normals)", time}); + // Save copy mesh to device duration for later logging + mesh_times[idx] = time; } }); - { - SCOPED_MARKER(device, "Update face and vertex normals"); + device_update_mesh(sub_device, sub_dscene, &sizes, progress); + } + + { + SCOPED_MARKER(sub_device, "copy attributes to device"); + scoped_callback_timer timer([scene, idx, &attrib_times](double time) { + if (scene->update_stats) { + attrib_times[idx] = time; + } + }); + device_update_attributes(sub_device, sub_dscene, &attrib_sizes, progress); + } + + device_scene_clear_modified(sub_dscene); + { + SCOPED_MARKER(sub_device, "Parallel BVH building"); + scoped_callback_timer timer([scene, idx, &bvh_times](double time) { + if (scene->update_stats) { + bvh_times[idx] = time; + } + }); + size_t i = 0; foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified()) { - if ((geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME)) { - Mesh *mesh = static_cast(geom); - - /* Update normals. */ - mesh->add_face_normals(); - mesh->add_vertex_normals(); - - if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) { - mesh->add_undisplaced(); - } - - /* Test if we need tessellation. */ - if (mesh->need_tesselation()) { - total_tess_needed++; - } - - /* Test if we need displacement. */ - if (mesh->has_true_displacement()) { - true_displacement_used = true; - } - } - else if (geom->geometry_type == Geometry::HAIR) { - Hair *hair = static_cast(geom); - if (hair->need_shadow_transparency()) { - curve_shadow_transparency_used = true; - } - } - - if (progress.get_cancel()) { - return; + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + geom->compute_bvh(sub_device, sub_dscene, &scene->params, &progress, i, num_bvh); + if (geom->need_build_bvh(bvh_layout)) { + i++; } } } + } +} + +/* + * Calculates the bounds for any modified geometry and + * then updates the objects bounds from the geometry. + */ +void GeometryManager::updateObjectBounds(Scene *scene) +{ + SCOPED_MARKER(scene->device, "update objects"); + + Scene::MotionType need_motion = scene->need_motion(); + bool motion_blur = need_motion == Scene::MOTION_BLUR; + + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time}); + } + }); + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified()) { + geom->compute_bounds(); + } + } + foreach (Object *object, scene->objects) { + object->compute_bounds(motion_blur); + } +} + +/* + * Creates a new BVH for the geometry if it is needed otherwise + * it determines if the BVH can be refitted. It also counts + * the number of BVH that need to be built. + */ +size_t GeometryManager::createObjectBVHs(Device *device, + DeviceScene *dscene, + Scene *scene, + const BVHLayout bvh_layout, + bool &need_update_scene_bvh) +{ + SCOPED_MARKER(device, "update object BVH preprocess"); + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (object BVHs preprocess)", time}); + } + }); + size_t num_bvh = 0; + + if (scene->geometry.size() > object_pool.size()) { + object_pool.resize(scene->geometry.size()); + } + + // Create BVH structures where needed + { + SCOPED_MARKER(device, "create BVH structures"); + int id = 0; + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + need_update_scene_bvh = true; + Object *object = &object_pool[id]; + geom->create_new_bvh_if_needed(object, device, dscene, &scene->params); + if (geom->need_build_bvh(bvh_layout)) { + num_bvh++; + } + } + id++; } } - if (progress.get_cancel()) { - return; - } + return num_bvh; +} +/* + * Prepares scene BVH for building or refitting. Then builds or refits the scene + * BVH for all the devices. + */ +void GeometryManager::updateSceneBVHs(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + SCOPED_MARKER(device, "update scene BVH"); + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); + } + }); + + bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); + foreach (DeviceScene *sub_dscene, scene->dscenes) { + Device *sub_device = sub_dscene->tri_verts.device; + SCOPED_MARKER(sub_device, "Build Scene BVH"); + device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); + } + device_update_bvh_postprocess(device, dscene, scene, progress); +} + +/* + * Tesselates any modified object that requires it. + */ +void GeometryManager::tesselate(Scene *scene, size_t total_tess_needed, Progress &progress) +{ /* Tessellate meshes that are using subdivision */ if (total_tess_needed) { - SCOPED_MARKER(device, "Tesselate"); + SCOPED_MARKER(scene->device, "Tesselate"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1846,150 +1439,116 @@ void GeometryManager::device_update(Device *device, dicing_camera->get_full_height()); dicing_camera->update(scene); - size_t i = 0; + int geom_count = 0; foreach (Geometry *geom, scene->geometry) { if (!(geom->is_modified() && geom->is_mesh())) { continue; } - + SCOPED_MARKER(scene->device, "tesselate mesh"); Mesh *mesh = static_cast(geom); if (mesh->need_tesselation()) { string msg = "Tessellating "; if (mesh->name == "") - msg += string_printf("%u/%u", (uint)(i + 1), (uint)total_tess_needed); + msg += string_printf("%u/%u", (uint)(geom_count + 1), (uint)total_tess_needed); else msg += string_printf( - "%s %u/%u", mesh->name.c_str(), (uint)(i + 1), (uint)total_tess_needed); + "%s %u/%u", mesh->name.c_str(), (uint)(geom_count + 1), (uint)total_tess_needed); progress.set_status("Updating Mesh", msg); mesh->subd_params->camera = dicing_camera; DiagSplit dsplit(*mesh->subd_params); mesh->tessellate(&dsplit); - - i++; - - if (progress.get_cancel()) { - return; - } } + geom_count++; } if (progress.get_cancel()) { return; } } +} - /* Update images needed for true displacement. */ - bool old_need_object_flags_update = false; - if (true_displacement_used || curve_shadow_transparency_used) { - SCOPED_MARKER(device, "Update displacement images"); - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: load images)", time}); - } - }); - device_update_displacement_images(device, scene, progress); - old_need_object_flags_update = scene->object_manager->need_flags_update; - scene->object_manager->device_update_flags(device, dscene, scene, progress, false); - } +void GeometryManager::device_update(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + // WL: This method works as follows: + // 1. Calculate vertex normals and gather undisplaced vertices + // 2. Tesselate mesh if needed + // 3. Compute object bounds + // 4. fill attribute buffers + // 5. fill geometry buffers + // ----DEVICE SPECIFIC BEGIN---- + // 6. copy attribute buffers to device + // 7. copy geometry buffers to device + // --- only run on the first device --- + // 8. displace meshes and calculate shadow transparency if needed + // ----DEVICE SPECIFIC END---- + // 9. if displacement or shadow transparency then refill buffers and re-upload + // ----START OF MIXED DEVICE AND HOST CODE---- + // 10. build geometry BVHs + // 11. build scene BVH + // ----HOST SPECIFIC BELOW THIS POINT + // 12. Remove modified or update tags + SCOPED_MARKER(device, "GeometryManager::device_update"); + if (!need_update()) + return; + VLOG_INFO << "Total " << scene->geometry.size() << " meshes."; + + bool true_displacement_used = false; + bool curve_shadow_transparency_used = false; + size_t total_tess_needed = 0; + + preTessDispNormalAndVerticesSetup( + device, scene, true_displacement_used, curve_shadow_transparency_used, total_tess_needed); + + tesselate(scene, total_tess_needed, progress); + + GeometrySizes sizes; + geom_calc_offset(scene, &sizes); + + // Gather the requests attributes for filling out the attribute and geometry buffers + vector geom_attributes(scene->geometry.size()); + vector object_attributes(scene->objects.size()); + vector object_attribute_values; + AttributeSizes attrib_sizes; + + progress.set_status("Updating Mesh", "Computing attributes"); + gather_attributes( + scene, geom_attributes, object_attributes, object_attribute_values, &attrib_sizes); /* Device update. */ device_free(device, dscene, false); - const BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, - device->get_bvh_layout_mask()); - geom_calc_offset(scene, bvh_layout); - if (true_displacement_used || curve_shadow_transparency_used) { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: copy meshes to device)", time}); - } - }); - device_update_mesh(device, dscene, scene, progress); - } - if (progress.get_cancel()) { - return; - } - - { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (attributes)", time}); - } - }); - device_update_attributes(device, dscene, scene, progress); - if (progress.get_cancel()) { - return; - } - } + device_update_attributes_preprocess(device, + dscene, + scene, + geom_attributes, + object_attributes, + object_attribute_values, + &attrib_sizes, + progress); + device_update_mesh_preprocess(device, dscene, scene, &sizes, progress); /* Update displacement and hair shadow transparency. */ - bool displacement_done = false; - bool curve_shadow_transparency_done = false; - size_t num_bvh = 0; + if (curve_shadow_transparency_used || true_displacement_used) { + displacement_and_curve_shadow_transparency( + scene, + device, + dscene, + &sizes, + &attrib_sizes, + geom_attributes, + object_attributes, + object_attribute_values, + progress); + } { - SCOPED_MARKER(device, "displace and shadow transp"); - /* Copy constant data needed by shader evaluation. */ - device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); - - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); - } - }); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified()) { - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - if (displace(device, scene, mesh, progress)) { - displacement_done = true; - } - } - else if (geom->geometry_type == Geometry::HAIR) { - Hair *hair = static_cast(geom); - if (hair->update_shadow_transparency(device, scene, progress)) { - curve_shadow_transparency_done = true; - } - } - } - - if (geom->is_modified() || geom->need_update_bvh_for_offset) { - if (geom->need_build_bvh(bvh_layout)) { - num_bvh++; - } - } - - if (progress.get_cancel()) { - return; - } - } + updateObjectBounds(scene); } - - if (progress.get_cancel()) { - return; - } - - /* Device re-update after displacement. */ - if (displacement_done || curve_shadow_transparency_done) { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: attributes)", time}); - } - }); - device_free(device, dscene, false); - - device_update_attributes(device, dscene, scene, progress); - if (progress.get_cancel()) { - return; - } - } - /* Update the BVH even when there is no geometry so the kernel's BVH data is still valid, * especially when removing all of the objects during interactive renders. * Also update the BVH if the transformations change, we cannot rely on tagging the Geometry @@ -1997,139 +1556,79 @@ void GeometryManager::device_update(Device *device, * change. */ bool need_update_scene_bvh = (scene->bvh == nullptr || (update_flags & (TRANSFORM_MODIFIED | VISIBILITY_MODIFIED)) != 0); - { - SCOPED_MARKER(device, "Build Object BVH"); - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (build object BVHs)", time}); - } - }); - TaskPool pool; + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, + device->get_bvh_layout_mask()); + dscene->data.bvh.bvh_layout = bvh_layout; - size_t i = 0; - foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified() || geom->need_update_bvh_for_offset) { - need_update_scene_bvh = true; - pool.push(function_bind( - &Geometry::compute_bvh, geom, device, dscene, &scene->params, &progress, i, num_bvh)); - if (geom->need_build_bvh(bvh_layout)) { - i++; - } - } - } - - TaskPool::Summary summary; - pool.wait_work(&summary); - VLOG_WORK << "Objects BVH build pool statistics:\n" << summary.full_report(); - } - - foreach (Shader *shader, scene->shaders) { - shader->need_update_uvs = false; - shader->need_update_attribute = false; - shader->need_update_displacement = false; - } - - Scene::MotionType need_motion = scene->need_motion(); - bool motion_blur = need_motion == Scene::MOTION_BLUR; - - /* Update objects. */ - { - SCOPED_MARKER(device, "compute bounds"); - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time}); - } - }); - foreach (Object *object, scene->objects) { - object->compute_bounds(motion_blur); - } - } - - if (progress.get_cancel()) { - return; - } - - if (need_update_scene_bvh) { - SCOPED_MARKER(device, "update scene BVH"); - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); - } - }); - device_update_bvh(device, dscene, scene, progress); - if (progress.get_cancel()) { - return; - } - } - - /* Always set BVH layout again after displacement where it was set to none, - * to avoid ray-tracing at that stage. */ - dscene->data.bvh.bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, - device->get_bvh_layout_mask()); + size_t num_bvh = createObjectBVHs(device, dscene, scene, bvh_layout, need_update_scene_bvh); { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (copy meshes to device)", time}); + SCOPED_MARKER(device, "device update"); + // WL: Parallel upload the geometry data to the devices and + // calculate or refit the BVHs + size_t n_scenes = scene->dscenes.size(); + double mesh_times[n_scenes]; + double attrib_times[n_scenes]; + double bvh_times[n_scenes]; + + tbb::parallel_for(size_t(0), + n_scenes, + [this, + true_displacement_used, + curve_shadow_transparency_used, + scene, + dscene, + &sizes, + &attrib_sizes, + bvh_layout, + num_bvh, + &mesh_times, + &attrib_times, + &bvh_times, + &progress](const size_t idx) { + deviceDataXferAndBVHUpdate(idx, + scene, + dscene, + sizes, + attrib_sizes, + bvh_layout, + num_bvh, + mesh_times, + attrib_times, + bvh_times, + progress); + }); // WL: End of parallel data upload and BVH refit/creation + + if (scene->update_stats) { + double max_mesh_time = 0.0f; + double max_attrib_time = 0.0f; + double max_bvh_time = 0.0f; + for (size_t i = 0; i < n_scenes; i++) { + max_mesh_time = max(max_mesh_time, mesh_times[i]); + max_attrib_time = max(max_attrib_time, attrib_times[i]); + max_bvh_time = max(max_bvh_time, bvh_times[i]); } - }); - device_update_mesh(device, dscene, scene, progress); - if (progress.get_cancel()) { - return; + scene->update_stats->geometry.times.add_entry( + {"device_update (copy meshes to device)", max_mesh_time}); + scene->update_stats->geometry.times.add_entry( + {"device_update (attributes)", max_attrib_time}); + scene->update_stats->geometry.times.add_entry( + {"device_update (build object BVHs)", max_bvh_time}); } - } - if (true_displacement_used) { - /* Re-tag flags for update, so they're re-evaluated - * for meshes with correct bounding boxes. - * - * This wouldn't cause wrong results, just true - * displacement might be less optimal to calculate. - */ - scene->object_manager->need_flags_update = old_need_object_flags_update; - } - - /* unset flags */ - - foreach (Geometry *geom, scene->geometry) { - geom->clear_modified(); - geom->attributes.clear_modified(); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - mesh->subd_attributes.clear_modified(); - } - } + // WL: Build scene BVH + if (need_update_scene_bvh) { + updateSceneBVHs(device, dscene, scene, progress); + } // WL: End of scene BVH generation + } // WL: End of device update + /* END OF DEVICE SPECIFIC CODE:BELOW THIS POINT IS HOST SIDE CODE + What follows is mainly code to clear update or modified + tags now that all the updates have been performed. */ + clearGeometryUpdateAndModifiedTags(scene); + clearShaderUpdateTags(scene); update_flags = UPDATE_NONE; - - dscene->bvh_nodes.clear_modified(); - dscene->bvh_leaf_nodes.clear_modified(); - dscene->object_node.clear_modified(); - dscene->prim_type.clear_modified(); - dscene->prim_visibility.clear_modified(); - dscene->prim_index.clear_modified(); - dscene->prim_object.clear_modified(); - dscene->prim_time.clear_modified(); - dscene->tri_verts.clear_modified(); - dscene->tri_shader.clear_modified(); - dscene->tri_vindex.clear_modified(); - dscene->tri_patch.clear_modified(); - dscene->tri_vnormal.clear_modified(); - dscene->tri_patch_uv.clear_modified(); - dscene->curves.clear_modified(); - dscene->curve_keys.clear_modified(); - dscene->curve_segments.clear_modified(); - dscene->points.clear_modified(); - dscene->points_shader.clear_modified(); - dscene->patches.clear_modified(); - dscene->attributes_map.clear_modified(); - dscene->attributes_float.clear_modified(); - dscene->attributes_float2.clear_modified(); - dscene->attributes_float3.clear_modified(); - dscene->attributes_float4.clear_modified(); - dscene->attributes_uchar4.clear_modified(); + device_scene_clear_modified(dscene); } void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free) @@ -2162,9 +1661,6 @@ void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool forc dscene->attributes_float4.free_if_need_realloc(force_free); dscene->attributes_uchar4.free_if_need_realloc(force_free); - /* Signal for shaders like displacement not to do ray tracing. */ - dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; - #ifdef WITH_OSL OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory(); diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 8a1bdc33a6f..585909788bd 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -28,6 +28,7 @@ class Scene; class SceneParams; class Shader; class Volume; +class Object; struct PackedBVH; /* Geometry @@ -70,6 +71,7 @@ class Geometry : public Node { BVH *bvh; size_t attr_map_offset; size_t prim_offset; + size_t motion_key_offset; /* Shader Properties */ bool has_volume; /* Set in the device_update_flags(). */ @@ -106,6 +108,10 @@ class Geometry : public Node { int motion_step(float time) const; /* BVH */ + void create_new_bvh_if_needed(Object *object, + Device *device, + DeviceScene *dscene, + SceneParams *params); void compute_bvh(Device *device, DeviceScene *dscene, SceneParams *params, @@ -159,6 +165,37 @@ class Geometry : public Node { void tag_bvh_update(bool rebuild); }; +// FRL_CGR BEGIN +/* Geometry Sizes */ +struct GeometrySizes { + size_t vert_size; + size_t tri_size; + + size_t curve_size; + size_t curve_key_size; + size_t curve_segment_size; + + size_t point_size; + + size_t patch_size; + size_t face_size; + size_t corner_size; + + size_t *num_geometries; + size_t *vert_offsets; + size_t *motion_vert_offsets; +}; + +struct AttributeSizes { + size_t attr_float_size; + size_t attr_float2_size; + size_t attr_float3_size; + size_t attr_float4_size; + size_t attr_uchar4_size; +}; + +// FRL_CGR END + /* Geometry Manager */ class GeometryManager { @@ -209,10 +246,45 @@ class GeometryManager { void tag_update(Scene *scene, uint32_t flag); bool need_update() const; + void device_scene_clear_modified(DeviceScene *dscene); /* Statistics */ void collect_statistics(const Scene *scene, RenderStats *stats); + size_t createObjectBVHs(Device *device, + DeviceScene *dscene, + Scene *scene, + const BVHLayout bvh_layout, + bool &need_update_scene_bvh); + void updateSceneBVHs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); + void clearShaderUpdateTags(Scene *scene); + void clearGeometryUpdateAndModifiedTags(Scene *scene); + void deviceDataXferAndBVHUpdate(int idx, + Scene *scene, + DeviceScene *dscene, + GeometrySizes &sizes, + AttributeSizes &attrib_sizes, + const BVHLayout bvh_layout, + size_t num_bvh, + double *mesh_times, + double *attrib_times, + double *bvh_times, + Progress &progress); + void updateObjectBounds(Scene *scene); + void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress); + void preTessDispNormalAndVerticesSetup(Device *device, + Scene *scene, + bool &true_displacement_used, + bool &curve_shadow_transparency_used, + size_t &total_tess_needed); + static void device_update_sub_bvh(Device *device, + DeviceScene *dscene, + BVH *bvh, + BVH *sub_bvh, + bool can_refit, + size_t n, + size_t total, + Progress *progress); protected: bool displace(Device *device, Scene *scene, Mesh *mesh, Progress &progress); @@ -227,24 +299,75 @@ class GeometryManager { vector &object_attributes); /* Compute verts/triangles/curves offsets in global arrays. */ - void geom_calc_offset(Scene *scene, BVHLayout bvh_layout); + void geom_calc_offset(Scene *scene, GeometrySizes *sizes); + void attrib_calc_sizes(Scene *scene, + AttributeSizes *p_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values); void device_update_object(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); - void device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); + void device_update_mesh_preprocess( + Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *sizes, Progress &progress); + void device_update_mesh(Device *device, + DeviceScene *dscene, + /*Scene *scene,*/ const GeometrySizes *sizes, + Progress &progress); + void device_update_host_pointers(Device *device, + DeviceScene *dscene, + DeviceScene *sub_dscene, + GeometrySizes *p_sizes); + bool displacement_and_curve_shadow_transparency(Scene *scene, + Device *device, + DeviceScene *dscene, + GeometrySizes *sizes, + AttributeSizes *attrib_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + Progress &progress); + void gather_attributes(Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes); + bool device_update_attributes_preprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes, + Progress &progress); void device_update_attributes(Device *device, DeviceScene *dscene, - Scene *scene, + const AttributeSizes *sizes, Progress &progress); - void device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); + bool device_update_bvh_preprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress); + void device_update_bvh(Device *device, + DeviceScene *dscene, + Scene *scene, + bool can_refit, + size_t n, + size_t total, + Progress &progress); + void device_update_bvh_postprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress); void device_update_displacement_images(Device *device, Scene *scene, Progress &progress); void device_update_volume_images(Device *device, Scene *scene, Progress &progress); private: + vector object_pool; static void update_attribute_element_offset(Geometry *geom, device_vector &attr_float, size_t &attr_float_offset, diff --git a/intern/cycles/scene/object.cpp b/intern/cycles/scene/object.cpp index dc98389575a..ac580f7cf2a 100644 --- a/intern/cycles/scene/object.cpp +++ b/intern/cycles/scene/object.cpp @@ -660,11 +660,8 @@ void ObjectManager::device_update_transforms(DeviceScene *dscene, Scene *scene, } }); - if (progress.get_cancel()) { - return; - } - - dscene->objects.copy_to_device_if_modified(); + /* Moved copy to GeometryManager::device_update + for better control over updating */ if (state.need_motion == Scene::MOTION_PASS) { dscene->object_motion_pass.copy_to_device(); } @@ -677,7 +674,6 @@ void ObjectManager::device_update_transforms(DeviceScene *dscene, Scene *scene, dscene->data.bvh.have_points = state.have_points; dscene->data.bvh.have_volumes = state.have_volumes; - dscene->objects.clear_modified(); dscene->object_motion_pass.clear_modified(); dscene->object_motion.clear_modified(); } @@ -861,16 +857,16 @@ void ObjectManager::device_update_flags( dscene->object_volume_step.clear_modified(); } -void ObjectManager::device_update_geom_offsets(Device *, DeviceScene *dscene, Scene *scene) +bool ObjectManager::device_update_geom_offsets(Device *, DeviceScene *dscene, Scene *scene) { + bool update = false; + if (dscene->objects.size() == 0) { - return; + return update; } KernelObject *kobjects = dscene->objects.data(); - bool update = false; - foreach (Object *object, scene->objects) { Geometry *geom = object->geometry; @@ -902,8 +898,10 @@ void ObjectManager::device_update_geom_offsets(Device *, DeviceScene *dscene, Sc } if (update) { - dscene->objects.copy_to_device(); + /* Moved to copy to device_update_attributes */ + dscene->objects.tag_modified(); } + return update; } void ObjectManager::device_free(Device *, DeviceScene *dscene, bool force_free) diff --git a/intern/cycles/scene/object.h b/intern/cycles/scene/object.h index c41f1416180..9927b5da84e 100644 --- a/intern/cycles/scene/object.h +++ b/intern/cycles/scene/object.h @@ -155,7 +155,7 @@ class ObjectManager { Scene *scene, Progress &progress, bool bounds_valid = true); - void device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene); + bool device_update_geom_offsets(Device *device, DeviceScene *dscene, Scene *scene); void device_free(Device *device, DeviceScene *dscene, bool force_free); diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index e4552713a9d..d7d04a8fbd4 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -33,6 +33,18 @@ CCL_NAMESPACE_BEGIN +/* + * checks the progress for if a cancel has been requested and also + * the device to see if an error has occurred. + */ +bool Scene::progressErrorCheck(Progress &progress, Device *device) { + bool status = false; + if (!background && progress.get_updates()) { + status = progress.get_cancel(); + } + return status || ((device != NULL) && device->have_error()); +} + DeviceScene::DeviceScene(Device *device) : bvh_nodes(device, "bvh_nodes", MEM_GLOBAL), bvh_leaf_nodes(device, "bvh_leaf_nodes", MEM_GLOBAL), @@ -102,6 +114,12 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) /* TODO(sergey): Check if it's indeed optimal value for the split kernel. */ max_closure_global(1) { + /* Create a DeviceScene for each device */ + device->foreach_device([this](Device *sub_device) { + DeviceScene *sub_dscene = new DeviceScene(sub_device); + this->dscenes.push_back(sub_dscene); + memset((void *)&sub_dscene->data, 0, sizeof(sub_dscene->data)); + }); memset((void *)&dscene.data, 0, sizeof(dscene.data)); shader_manager = ShaderManager::create( @@ -129,6 +147,9 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) Scene::~Scene() { + foreach (DeviceScene *sub_scene, dscenes) { + delete sub_scene; + } free_memory(true); } @@ -227,6 +248,8 @@ void Scene::device_update(Device *device_, Progress &progress) if (!device) device = device_; + SCOPED_MARKER(device,"Scene::device_update"); + bool print_stats = need_data_update(); if (update_stats) { @@ -264,8 +287,7 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Shaders"); shader_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } procedural_manager->update(this, progress); @@ -275,14 +297,12 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Background"); background->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Camera"); camera->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } geometry_manager->device_update_preprocess(device, this, progress); @@ -292,80 +312,67 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Objects"); object_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Particle Systems"); particle_system_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Meshes"); geometry_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Objects Flags"); object_manager->device_update_flags(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; - + if(progressErrorCheck(progress, device)) { return; } + progress.set_status("Updating Primitive Offsets"); object_manager->device_update_prim_offsets(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Images"); image_manager->device_update(device, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Camera Volume"); camera->device_update_volume(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Lookup Tables"); lookup_tables->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Lights"); light_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Integrator"); integrator->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Film"); film->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Lookup Tables"); lookup_tables->device_update(device, &dscene, this); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } progress.set_status("Updating Baking"); bake_manager->device_update(device, &dscene, this, progress); - if (progress.get_cancel() || device->have_error()) - return; + if(progressErrorCheck(progress, device)) { return; } if (device->have_error() == false) { dscene.data.volume_stack_size = get_volume_stack_size(); @@ -577,6 +584,7 @@ void Scene::update_kernel_features() bool Scene::update(Progress &progress) { + SCOPED_MARKER(device, "Scene::update"); if (!need_update()) { return false; } diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index c2face0b40d..862c4ca264a 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -246,6 +246,9 @@ class Scene : public NodeOwner { Device *device; DeviceScene dscene; + /* Stores a DeviceScene for each sub-device */ + std::vector dscenes; + /* parameters */ SceneParams params; @@ -330,6 +333,12 @@ class Scene : public NodeOwner { template void delete_nodes(const set &nodes, const NodeOwner *owner); protected: + /* + * checks the progress for if a cancel has been requested and also + * the device to see if an error has occurred. + */ + bool progressErrorCheck(Progress &progress, Device *device); + /* Check if some heavy data worth logging was updated. * Mainly used to suppress extra annoying logging. */ diff --git a/intern/cycles/scene/shader.cpp b/intern/cycles/scene/shader.cpp index dfd86f82bb6..663b9ea63d4 100644 --- a/intern/cycles/scene/shader.cpp +++ b/intern/cycles/scene/shader.cpp @@ -451,6 +451,7 @@ void ShaderManager::device_update(Device *device, Scene *scene, Progress &progress) { + SCOPED_MARKER(device,"ShaderManager::device_update"); if (!need_update()) { return; } @@ -470,11 +471,12 @@ void ShaderManager::device_update(Device *device, device_update_specific(device, dscene, scene, progress); } -void ShaderManager::device_update_common(Device * /*device*/, +void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Scene *scene, Progress & /*progress*/) { + SCOPED_MARKER(device, "ShaderManager::device_update_common"); dscene->shaders.free(); if (scene->shaders.size() == 0) diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index 0a71ed962b0..42285910e19 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -128,6 +128,9 @@ void SVMShaderManager::device_update_specific(Device *device, } /* Copy the nodes of each shader into the correct location. */ + { + SCOPED_MARKER(device,"copy shader node"); + // FRL_CGR_END svm_nodes += num_shaders; for (int i = 0; i < num_shaders; i++) { int shader_size = shader_svm_nodes[i].size() - 1; @@ -139,6 +142,7 @@ void SVMShaderManager::device_update_specific(Device *device, if (progress.get_cancel()) { return; } + } dscene->svm_nodes.copy_to_device(); -- 2.30.2 From fdd1c856e4ad8dbf9ebe4b98ac48286f38eef70e Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 7 Mar 2023 09:05:23 +0100 Subject: [PATCH 07/96] Add file that was forgotten --- intern/cycles/scene/geometry_additions.cpp | 1057 ++++++++++++++++++++ 1 file changed, 1057 insertions(+) create mode 100644 intern/cycles/scene/geometry_additions.cpp diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp new file mode 100644 index 00000000000..e65c9f0429e --- /dev/null +++ b/intern/cycles/scene/geometry_additions.cpp @@ -0,0 +1,1057 @@ +// FRL_CGR BEGIN +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#include "bvh/bvh.h" +#include "bvh/bvh2.h" + +#include "device/device.h" + +#include "scene/attribute.h" +#include "scene/camera.h" +#include "scene/geometry.h" +#include "scene/hair.h" +#include "scene/light.h" +#include "scene/mesh.h" +#include "scene/object.h" +#include "scene/pointcloud.h" +#include "scene/scene.h" +#include "scene/shader.h" +#include "scene/shader_nodes.h" +#include "scene/stats.h" +#include "scene/volume.h" + +#include "subd/patch_table.h" +#include "subd/split.h" + +#include "kernel/osl/globals.h" + +#include "util/foreach.h" +#include "util/log.h" +#include "util/progress.h" +#include "util/task.h" +CCL_NAMESPACE_BEGIN + +/* + * Clears all tags used to indicate the the shader needs to be updated. + */ +void GeometryManager::clearShaderUpdateTags(Scene *scene) +{ + /* unset flags */ + foreach (Shader *shader, scene->shaders) { + shader->need_update_uvs = false; + shader->need_update_attribute = false; + shader->need_update_displacement = false; + } +} + +/* + * Clears all tags used to indicate the the geometry needs to be updated + * or has been modified. + */ +void GeometryManager::clearGeometryUpdateAndModifiedTags(Scene *scene) +{ + // Clear update tags + SCOPED_MARKER(scene->device, "clear BVH update tags"); + foreach (Geometry *geom, scene->geometry) { + // Clear update indicators + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + geom->need_update_rebuild = false; + geom->need_update_bvh_for_offset = false; + } + + // Clear modified tags + geom->clear_modified(); + geom->attributes.clear_modified(); + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + mesh->subd_attributes.clear_modified(); + } + } +} + +/* + * Clears the modified tags for all elements of the device scene + */ +void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) +{ + dscene->bvh_nodes.clear_modified(); + dscene->bvh_leaf_nodes.clear_modified(); + dscene->object_node.clear_modified(); + dscene->prim_type.clear_modified(); + dscene->prim_visibility.clear_modified(); + dscene->prim_index.clear_modified(); + dscene->prim_object.clear_modified(); + dscene->prim_time.clear_modified(); + dscene->tri_verts.clear_modified(); + dscene->tri_shader.clear_modified(); + dscene->tri_vindex.clear_modified(); + dscene->tri_patch.clear_modified(); + dscene->tri_vnormal.clear_modified(); + dscene->tri_patch_uv.clear_modified(); + dscene->curves.clear_modified(); + dscene->curve_keys.clear_modified(); + dscene->curve_segments.clear_modified(); + dscene->points.clear_modified(); + dscene->points_shader.clear_modified(); + dscene->patches.clear_modified(); + dscene->attributes_map.clear_modified(); + dscene->attributes_float.clear_modified(); + dscene->attributes_float2.clear_modified(); + dscene->attributes_float3.clear_modified(); + dscene->attributes_float4.clear_modified(); + dscene->attributes_uchar4.clear_modified(); + dscene->objects.clear_modified(); + dscene->attributes_map.clear_modified(); +} + +/* + * Packs the attribute buffers and records the sizes and offsets using + * the attribute sets + */ +bool GeometryManager::device_update_attributes_preprocess( + Device *device, + DeviceScene *dscene, + Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes, + Progress &progress) +{ + SCOPED_MARKER(device, "GeometryManager::device_update_attributes"); + bool update_obj_offsets = false; + + progress.set_status("Updating Mesh", "Computing attributes"); + + // SHOULD NOT ALLOC ONLY ALLOC IF MORE SPACE IS NEEDED + dscene->attributes_float.alloc(sizes->attr_float_size); + dscene->attributes_float2.alloc(sizes->attr_float2_size); + dscene->attributes_float3.alloc(sizes->attr_float3_size); + dscene->attributes_float4.alloc(sizes->attr_float4_size); + dscene->attributes_uchar4.alloc(sizes->attr_uchar4_size); + + /* The order of those flags needs to match that of AttrKernelDataType. */ + const bool attributes_need_realloc[AttrKernelDataType::NUM] = { + dscene->attributes_float.need_realloc(), + dscene->attributes_float2.need_realloc(), + dscene->attributes_float3.need_realloc(), + dscene->attributes_float4.need_realloc(), + dscene->attributes_uchar4.need_realloc(), + }; + + size_t attr_float_offset = 0; + size_t attr_float2_offset = 0; + size_t attr_float3_offset = 0; + size_t attr_float4_offset = 0; + size_t attr_uchar4_offset = 0; + + /* Fill in attributes. */ + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + AttributeRequestSet &attributes = geom_attributes[i]; + + /* todo: we now store std and name attributes from requests even if + * they actually refer to the same mesh attributes, optimize */ + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = geom->attributes.find(req); + + if (attr) { + /* force a copy if we need to reallocate all the data */ + attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; + } + + update_attribute_element_offset(geom, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + attr, + ATTR_PRIM_GEOMETRY, + req.type, + req.desc); + + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + Attribute *subd_attr = mesh->subd_attributes.find(req); + + if (subd_attr) { + /* force a copy if we need to reallocate all the data */ + subd_attr->modified |= attributes_need_realloc[Attribute::kernel_type(*subd_attr)]; + } + + update_attribute_element_offset(mesh, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + subd_attr, + ATTR_PRIM_SUBD, + req.subd_type, + req.subd_desc); + } + + // if (progress.get_cancel()) + // return update_obj_offsets; + } + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + AttributeRequestSet &attributes = object_attributes[i]; + AttributeSet &values = object_attribute_values[i]; + + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = values.find(req); + + if (attr) { + attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; + } + + update_attribute_element_offset(object->geometry, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + attr, + ATTR_PRIM_GEOMETRY, + req.type, + req.desc); + + /* object attributes don't care about subdivision */ + req.subd_type = req.type; + req.subd_desc = req.desc; + } + } + + /* create attribute lookup maps */ + if (scene->shader_manager->use_osl()) + update_osl_globals(device, scene); + + update_svm_attributes(device, dscene, scene, geom_attributes, object_attributes); + + update_obj_offsets = scene->object_manager->device_update_geom_offsets(device, dscene, scene); + + return update_obj_offsets; +} + +/** + * Packs the geometry data into the device scene. That is it fills out + * the geometry buffers + */ +void GeometryManager::device_update_mesh_preprocess( + Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *p_sizes, Progress &progress) +{ + SCOPED_MARKER(device, "GeometryManager::device_update_mesh_preprocess"); + /* Fill in all the arrays. */ + if (p_sizes->tri_size != 0) { + /* normals */ + progress.set_status("Updating Mesh", "Computing mesh"); + + packed_float3 *tri_verts = dscene->tri_verts.alloc(p_sizes->vert_size); + uint *tri_shader = dscene->tri_shader.alloc(p_sizes->tri_size); + packed_float3 *vnormal = dscene->tri_vnormal.alloc(p_sizes->vert_size); + packed_uint3 *tri_vindex = dscene->tri_vindex.alloc(p_sizes->tri_size); + uint *tri_patch = dscene->tri_patch.alloc(p_sizes->tri_size); + float2 *tri_patch_uv = dscene->tri_patch_uv.alloc(p_sizes->vert_size); + + const bool copy_all_data = dscene->tri_shader.need_realloc() || + dscene->tri_vindex.need_realloc() || + dscene->tri_vnormal.need_realloc() || + dscene->tri_patch.need_realloc() || + dscene->tri_patch_uv.need_realloc(); + + foreach (Geometry *geom, scene->geometry) { + if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { + Mesh *mesh = static_cast(geom); + + if (mesh->shader_is_modified() || mesh->smooth_is_modified() || + mesh->triangles_is_modified() || copy_all_data) { + SCOPED_MARKER(scene->device, "Mesh:pack_shaders"); + mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); + } + + if (mesh->verts_is_modified() || copy_all_data) { + SCOPED_MARKER(scene->device, "Mesh:pack_normals"); + mesh->pack_normals(&vnormal[mesh->vert_offset]); + } + + if (mesh->verts_is_modified() || mesh->triangles_is_modified() || + mesh->vert_patch_uv_is_modified() || copy_all_data) { + SCOPED_MARKER(scene->device, "Mesh:pack_vertices"); + mesh->pack_verts(&tri_verts[mesh->vert_offset], + &tri_vindex[mesh->prim_offset], + &tri_patch[mesh->prim_offset], + &tri_patch_uv[mesh->vert_offset]); + } + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->curve_segment_size != 0) { + progress.set_status("Updating Mesh", "Computing curves"); + + float4 *curve_keys = dscene->curve_keys.alloc(p_sizes->curve_key_size); + KernelCurve *curves = dscene->curves.alloc(p_sizes->curve_size); + KernelCurveSegment *curve_segments = dscene->curve_segments.alloc(p_sizes->curve_segment_size); + + const bool copy_all_data = dscene->curve_keys.need_realloc() || + dscene->curves.need_realloc() || + dscene->curve_segments.need_realloc(); + + foreach (Geometry *geom, scene->geometry) { + if (geom->is_hair()) { + Hair *hair = static_cast(geom); + + bool curve_keys_co_modified = hair->curve_radius_is_modified() || + hair->curve_keys_is_modified(); + bool curve_data_modified = hair->curve_shader_is_modified() || + hair->curve_first_key_is_modified(); + + if (!curve_keys_co_modified && !curve_data_modified && !copy_all_data) { + continue; + } + + hair->pack_curves(scene, + &curve_keys[hair->curve_key_offset], + &curves[hair->prim_offset], + &curve_segments[hair->curve_segment_offset]); + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->point_size != 0) { + progress.set_status("Updating Mesh", "Computing point clouds"); + + float4 *points = dscene->points.alloc(p_sizes->point_size); + uint *points_shader = dscene->points_shader.alloc(p_sizes->point_size); + + foreach (Geometry *geom, scene->geometry) { + if (geom->is_pointcloud()) { + PointCloud *pointcloud = static_cast(geom); + pointcloud->pack( + scene, &points[pointcloud->prim_offset], &points_shader[pointcloud->prim_offset]); + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + progress.set_status("Updating Mesh", "Computing patches"); + + uint *patch_data = dscene->patches.alloc(p_sizes->patch_size); + foreach (Geometry *geom, scene->geometry) { + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + mesh->pack_patches(&patch_data[mesh->patch_offset]); + + if (mesh->patch_table) { + mesh->patch_table->copy_adjusting_offsets(&patch_data[mesh->patch_table_offset], + mesh->patch_table_offset); + } + + // if (progress.get_cancel()) + // return; + } + } + } +} + +/* + * Assigns the host pointers to the sub-devicescenes so + * that they all have the same data sources + */ +void GeometryManager::device_update_host_pointers(Device *device, + DeviceScene *dscene, + DeviceScene *sub_dscene, + GeometrySizes *p_sizes) +{ + SCOPED_MARKER(device, "update host_pointers"); + if (p_sizes->tri_size != 0) { + if (dscene->tri_verts.is_modified()) { + sub_dscene->tri_verts.assign_mem(dscene->tri_verts); + sub_dscene->tri_verts.tag_modified(); + } + { + if (dscene->tri_shader.is_modified()) { + sub_dscene->tri_shader.assign_mem(dscene->tri_shader); + sub_dscene->tri_shader.tag_modified(); + } + } + { + if (dscene->tri_vnormal.is_modified()) { + sub_dscene->tri_vnormal.assign_mem(dscene->tri_vnormal); + sub_dscene->tri_vnormal.tag_modified(); + } + } + { + if (dscene->tri_vindex.is_modified()) { + sub_dscene->tri_vindex.assign_mem(dscene->tri_vindex); + sub_dscene->tri_vindex.tag_modified(); + } + } + { + if (dscene->tri_patch.is_modified()) { + sub_dscene->tri_patch.assign_mem(dscene->tri_patch); + sub_dscene->tri_patch.tag_modified(); + } + } + { + if (dscene->tri_patch_uv.is_modified()) { + sub_dscene->tri_patch_uv.assign_mem(dscene->tri_patch_uv); + sub_dscene->tri_patch_uv.tag_modified(); + } + } + } + + if (p_sizes->curve_segment_size != 0) { + if (dscene->curve_keys.is_modified()) { + sub_dscene->curve_keys.assign_mem(dscene->curve_keys); + sub_dscene->curve_keys.tag_modified(); + } + + if (dscene->curves.is_modified()) { + sub_dscene->curves.assign_mem(dscene->curves); + sub_dscene->curves.tag_modified(); + } + + if (dscene->curve_segments.is_modified()) { + sub_dscene->curve_segments.assign_mem(dscene->curve_segments); + } + } + + if (p_sizes->point_size != 0) { + SCOPED_MARKER(device, "copy points"); + // TODO: Why does this not check the modified tag? + sub_dscene->points.assign_mem(dscene->points); + // sub_dscene->points.tag_modified(); + + sub_dscene->points_shader.assign_mem(dscene->points_shader); + // sub_dscene->points_shader.tag_modified(); + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + sub_dscene->patches.assign_mem(dscene->patches); + } + + // Update the Attributes + if (dscene->attributes_map.is_modified()) { + sub_dscene->attributes_map.assign_mem(dscene->attributes_map); + sub_dscene->attributes_map.tag_modified(); + } + if (dscene->attributes_float.is_modified()) { + sub_dscene->attributes_float.assign_mem(dscene->attributes_float); + sub_dscene->attributes_float.tag_modified(); + } + if (dscene->attributes_float2.is_modified()) { + sub_dscene->attributes_float2.assign_mem(dscene->attributes_float2); + sub_dscene->attributes_float2.tag_modified(); + } + if (dscene->attributes_float3.is_modified()) { + sub_dscene->attributes_float3.assign_mem(dscene->attributes_float3); + sub_dscene->attributes_float3.tag_modified(); + } + if (dscene->attributes_float4.is_modified()) { + sub_dscene->attributes_float4.assign_mem(dscene->attributes_float4); + sub_dscene->attributes_float4.tag_modified(); + } + if (dscene->attributes_uchar4.is_modified()) { + sub_dscene->attributes_uchar4.assign_mem(dscene->attributes_uchar4); + sub_dscene->attributes_uchar4.tag_modified(); + } + if (dscene->objects.is_modified()) { + sub_dscene->objects.assign_mem(dscene->objects); + sub_dscene->objects.tag_modified(); + } +} + +/* + * Records all the geometry buffer sizes for later use + */ +void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) +{ + // Zero sizes + p_sizes->vert_size = 0; + p_sizes->tri_size = 0; + + p_sizes->curve_size = 0; + p_sizes->curve_key_size = 0; + p_sizes->curve_segment_size = 0; + + p_sizes->point_size = 0; + + p_sizes->patch_size = 0; + p_sizes->face_size = 0; + p_sizes->corner_size = 0; + + // Write the buffer offsets to the geometries and increment the sizes + foreach (Geometry *geom, scene->geometry) { + bool prim_offset_changed = false; + if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { + Mesh *mesh = static_cast(geom); + + prim_offset_changed = (mesh->prim_offset != p_sizes->tri_size); + + mesh->vert_offset = p_sizes->vert_size; + mesh->prim_offset = p_sizes->tri_size; + + mesh->patch_offset = p_sizes->patch_size; + mesh->face_offset = p_sizes->face_size; + mesh->corner_offset = p_sizes->corner_size; + + p_sizes->vert_size += mesh->verts.size(); + // WL: Store extra index set for motion blur + if(mesh->get_use_motion_blur()) { + p_sizes->tri_size += 2*mesh->num_triangles(); + } else { + p_sizes->tri_size += mesh->num_triangles(); + } + + if (mesh->get_num_subd_faces()) { + Mesh::SubdFace last = mesh->get_subd_face(mesh->get_num_subd_faces() - 1); + p_sizes->patch_size += (last.ptex_offset + last.num_ptex_faces()) * 8; + + /* patch tables are stored in same array so include them in patch_size */ + if (mesh->patch_table) { + mesh->patch_table_offset = p_sizes->patch_size; + p_sizes->patch_size += mesh->patch_table->total_size(); + } + } + + p_sizes->face_size += mesh->get_num_subd_faces(); + p_sizes->corner_size += mesh->subd_face_corners.size(); + } + else if (geom->is_hair()) { + Hair *hair = static_cast(geom); + + prim_offset_changed = (hair->curve_segment_offset != p_sizes->curve_segment_size); + hair->curve_key_offset = p_sizes->curve_key_size; + hair->curve_segment_offset = p_sizes->curve_segment_size; + hair->prim_offset = p_sizes->curve_size; + + p_sizes->curve_size += hair->num_curves(); + p_sizes->curve_key_size += hair->get_curve_keys().size(); + p_sizes->curve_segment_size += hair->num_segments(); + } + else if (geom->is_pointcloud()) { + PointCloud *pointcloud = static_cast(geom); + + prim_offset_changed = (pointcloud->prim_offset != p_sizes->point_size); + + pointcloud->prim_offset = p_sizes->point_size; + p_sizes->point_size += pointcloud->num_points(); + } + // Used to determine if the BVH needs to be recalculated + // as the buffer offsets have been altered. + geom->need_update_bvh_for_offset = prim_offset_changed; + } +} + +/* + * Records the sizes of the attribute buffers + */ +static void update_attribute_element_size(Geometry *geom, + Attribute *mattr, + AttributePrimitive prim, + size_t *attr_float_size, + size_t *attr_float2_size, + size_t *attr_float3_size, + size_t *attr_float4_size, + size_t *attr_uchar4_size) +{ + if (mattr) { + size_t size = mattr->element_size(geom, prim); + + if (mattr->element == ATTR_ELEMENT_VOXEL) { + /* pass */ + } + else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { + *attr_uchar4_size += size; + } + else if (mattr->type == TypeDesc::TypeFloat) { + *attr_float_size += size; + } + else if (mattr->type == TypeFloat2) { + *attr_float2_size += size; + } + else if (mattr->type == TypeDesc::TypeMatrix) { + *attr_float4_size += size * 4; + } + else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { + *attr_float4_size += size; + } + else { + *attr_float3_size += size; + } + } +} + +/* + * Records all the attribute buffer sizes for all the attribute buffers for later use + */ +void GeometryManager::attrib_calc_sizes(Scene *scene, + AttributeSizes *p_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values) +{ + p_sizes->attr_float_size = 0; + p_sizes->attr_float2_size = 0; + p_sizes->attr_float3_size = 0; + p_sizes->attr_float4_size = 0; + p_sizes->attr_uchar4_size = 0; + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + AttributeRequestSet &attributes = geom_attributes[i]; + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = geom->attributes.find(req); + + update_attribute_element_size(geom, + attr, + ATTR_PRIM_GEOMETRY, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + Attribute *subd_attr = mesh->subd_attributes.find(req); + + update_attribute_element_size(mesh, + subd_attr, + ATTR_PRIM_SUBD, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + } + } + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + + foreach (Attribute &attr, object_attribute_values[i].attributes) { + update_attribute_element_size(object->geometry, + &attr, + ATTR_PRIM_GEOMETRY, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + } + } +} + +/* + * Records the set of attributes used by the objects + */ +void GeometryManager::gather_attributes(Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes) +{ + geom_attributes.clear(); + object_attributes.clear(); + object_attribute_values.clear(); + + /* gather per mesh requested attributes. as meshes may have multiple + * shaders assigned, this merges the requested attributes that have + * been set per shader by the shader manager */ + geom_attributes.resize(scene->geometry.size()); + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + + geom->index = i; + scene->need_global_attributes(geom_attributes[i]); + + foreach (Node *node, geom->get_used_shaders()) { + Shader *shader = static_cast(node); + geom_attributes[i].add(shader->attributes); + } + + if (geom->is_hair() && static_cast(geom)->need_shadow_transparency()) { + geom_attributes[i].add(ATTR_STD_SHADOW_TRANSPARENCY); + } + } + + /* convert object attributes to use the same data structures as geometry ones */ + object_attributes.resize(scene->objects.size()); + object_attribute_values.reserve(scene->objects.size()); + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + Geometry *geom = object->geometry; + size_t geom_idx = geom->index; + + assert(geom_idx < scene->geometry.size() && scene->geometry[geom_idx] == geom); + + object_attribute_values.push_back(AttributeSet(geom, ATTR_PRIM_GEOMETRY)); + + AttributeRequestSet &geom_requests = geom_attributes[geom_idx]; + AttributeRequestSet &attributes = object_attributes[i]; + AttributeSet &values = object_attribute_values[i]; + + for (size_t j = 0; j < object->attributes.size(); j++) { + ParamValue ¶m = object->attributes[j]; + + /* add attributes that are requested and not already handled by the mesh */ + if (geom_requests.find(param.name()) && !geom->attributes.find(param.name())) { + attributes.add(param.name()); + + Attribute *attr = values.add(param.name(), param.type(), ATTR_ELEMENT_OBJECT); + assert(param.datasize() == attr->buffer.size()); + memcpy(attr->buffer.data(), param.data(), param.datasize()); + } + } + } + + /* Geometry attributes are stored in a single array per data type. Here determine the + * sizes of those buffers. + */ + attrib_calc_sizes(scene, sizes, geom_attributes, object_attributes, object_attribute_values); +} + +void GeometryManager::device_update_bvh_postprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + SCOPED_MARKER(device, "GeometryManager::device_update_bvh_postprocess"); + BVH *bvh = scene->bvh; + + // FIXME: The below should be in the Device parallel_for and also the preprocess host code + const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); + + PackedBVH pack; + if (has_bvh2_layout) { + pack = std::move(static_cast(bvh)->pack); + } + else { + pack.root_index = -1; + } + + /* copy to device */ + /* When using BVH2, we always have to copy/update the data as its layout is dependent on the + * BVH's leaf nodes which may be different when the objects or vertices move. */ + + if (pack.nodes.size()) { + dscene->bvh_nodes.steal_data(pack.nodes); + dscene->bvh_nodes.copy_to_device(); + } + if (pack.leaf_nodes.size()) { + dscene->bvh_leaf_nodes.steal_data(pack.leaf_nodes); + dscene->bvh_leaf_nodes.copy_to_device(); + } + if (pack.object_node.size()) { + dscene->object_node.steal_data(pack.object_node); + dscene->object_node.copy_to_device(); + } + if (pack.prim_type.size()) { + dscene->prim_type.steal_data(pack.prim_type); + dscene->prim_type.copy_to_device(); + } + if (pack.prim_visibility.size()) { + dscene->prim_visibility.steal_data(pack.prim_visibility); + dscene->prim_visibility.copy_to_device(); + } + if (pack.prim_index.size()) { + dscene->prim_index.steal_data(pack.prim_index); + dscene->prim_index.copy_to_device(); + } + if (pack.prim_object.size()) { + dscene->prim_object.steal_data(pack.prim_object); + dscene->prim_object.copy_to_device(); + } + if (pack.prim_time.size()) { + dscene->prim_time.steal_data(pack.prim_time); + dscene->prim_time.copy_to_device(); + } + + dscene->data.bvh.root = pack.root_index; + dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0); + dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions(); + /* The scene handle is set in 'CPUDevice::const_copy_to' and 'OptiXDevice::const_copy_to' */ + // EDIT: Edit for merge + // dscene->data.bvh.scene = 0; + dscene->data.device_bvh = 0; +} + +void Geometry::create_new_bvh_if_needed(Object *object, + Device *device, + DeviceScene *dscene, + SceneParams *params) +{ + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, + device->get_bvh_layout_mask()); + if (need_build_bvh(bvh_layout)) { + /* Ensure all visibility bits are set at the geometry level BVH. In + * the object level BVH is where actual visibility is tested. */ + object->set_is_shadow_catcher(true); + object->set_visibility(~0); + + object->set_geometry(this); + + vector geometry; + geometry.push_back(this); + vector objects; + objects.push_back(object); + + if (bvh && !need_update_rebuild) { + bvh->replace_geometry(geometry, objects); + } + else { + if (bvh != NULL) { + delete bvh; + } + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, + device->get_bvh_layout_mask()); + + BVHParams bparams; + bparams.use_spatial_split = params->use_bvh_spatial_split; + bparams.use_compact_structure = params->use_bvh_compact_structure; + bparams.bvh_layout = bvh_layout; + bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && + params->use_bvh_unaligned_nodes; + bparams.num_motion_triangle_steps = params->num_bvh_time_steps; + bparams.num_motion_curve_steps = params->num_bvh_time_steps; + bparams.num_motion_point_steps = params->num_bvh_time_steps; + bparams.bvh_type = params->bvh_type; + bparams.curve_subdivisions = params->curve_subdivisions(); + bvh = BVH::create(bparams, geometry, objects, device); + need_update_rebuild = true; + } + } +} + +void GeometryManager::device_update_sub_bvh(Device *device, + DeviceScene *dscene, + BVH *bvh, + BVH *sub_bvh, + bool can_refit, + size_t n, + size_t total, + Progress *progress) +{ + string msg = "Updating Geometry BVH"; + + // Is this a multi-bvh? + if (sub_bvh && can_refit) { + progress->set_status(msg, "Refitting BVH"); + // Don't redo the setup if this is not a sub-bvh + if (sub_bvh != bvh) { + sub_bvh->replace_geometry(bvh->geometry, bvh->objects); + // sub_bvh->geometry = bvh->geometry; + // sub_bvh->objects = bvh->objects; + } + } + else { + progress->set_status(msg, "Building BVH"); + // Don't redo the setup if this is not a sub-bvh + if (sub_bvh != bvh) { + // Yes, so setup the device specific sub_bvh in the multi-bvh. + BVHParams bparams = bvh->params; + // Set the layout to the correct one for the device + if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) + bparams.bvh_layout = BVH_LAYOUT_OPTIX; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) + bparams.bvh_layout = BVH_LAYOUT_METAL; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + bparams.bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : + BVH_LAYOUT_EMBREE; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + bparams.bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : + BVH_LAYOUT_EMBREE; + if (sub_bvh != NULL) { + delete sub_bvh; + } + sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device); + bvh->set_device_bvh(device, sub_bvh); + } + can_refit = false; + } + device->build_bvh(sub_bvh, dscene, *progress, can_refit); +} + +bool GeometryManager::device_update_bvh_preprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + /* bvh build */ + + BVHParams bparams; + bparams.top_level = true; + bparams.bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, + device->get_bvh_layout_mask()); + bparams.use_spatial_split = scene->params.use_bvh_spatial_split; + bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && + scene->params.use_bvh_unaligned_nodes; + bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; + bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; + bparams.num_motion_point_steps = scene->params.num_bvh_time_steps; + bparams.bvh_type = scene->params.bvh_type; + bparams.curve_subdivisions = scene->params.curve_subdivisions(); + + VLOG_INFO << "Using " << bvh_layout_name(bparams.bvh_layout) << " layout."; + + const bool can_refit = scene->bvh != nullptr && + (bparams.bvh_layout == BVHLayout::BVH_LAYOUT_OPTIX || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_METAL || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_OPTIX || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_METAL); + + BVH *bvh = scene->bvh; + if (!scene->bvh) { + // TODO: Store device BVHs in a vector instead of just 1 + bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); + } + + return can_refit; +} + +bool GeometryManager::displacement_and_curve_shadow_transparency( + Scene *scene, + Device *device, + DeviceScene *dscene, + GeometrySizes *sizes, + AttributeSizes *attrib_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + Progress &progress) +{ + SCOPED_MARKER(device, "Displacement & Hair transparency"); + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); + } + }); + /* Signal for shaders like displacement not to do ray tracing. */ + dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; + scene->object_manager->device_update_flags(device, dscene, scene, progress, false); + + bool displacement_done = false; + bool curve_shadow_transparency_done = false; + { + // WL: Need to upload the attribute and mesh buffers for dispacement. + // WL: Evaluate these on a single device (anyone will do, so use the first) + { + // WL: Could break this out across all the devices as + // the results are read back to the host. For now, the computations + // are done on the first device. + DeviceScene *sub_dscene = scene->dscenes.front(); + Device *sub_device = sub_dscene->tri_verts.device; + { + SCOPED_MARKER(device, "copy mesh to device for displacement"); + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: copy meshes to device)", time}); + } + }); + device_update_host_pointers(sub_device, dscene, sub_dscene, sizes); + device_update_attributes(sub_device, sub_dscene, attrib_sizes, progress); + device_update_mesh(sub_device, sub_dscene, sizes, progress); + } + { + /* Copy constant data needed by shader evaluation. */ + SCOPED_MARKER(device, "copy constant data for hair and displacement"); + sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); + } + + foreach (Geometry *geom, scene->geometry) { + /* Update images needed for true displacement. */ + { + SCOPED_MARKER(device, "upload images for displacement"); + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: load images)", time}); + } + }); + device_update_displacement_images(sub_device, scene, progress); + } + + if (geom->is_modified()) { + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + if (displace(sub_device, scene, mesh, progress)) { + displacement_done = true; + } + } + else if (geom->geometry_type == Geometry::HAIR) { + Hair *hair = static_cast(geom); + if (hair->update_shadow_transparency(sub_device, scene, progress)) { + curve_shadow_transparency_done = true; + } + } + } + } + } + + //>>>>>HOST SIDE CODE BEGINS + // WL: Some host side code here as the mesh and attributes need to be + // recalculated after displacement and shadow transparency + /* Device re-update after displacement. */ + if (displacement_done || curve_shadow_transparency_done) { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: attributes)", time}); + } + }); + + // WL: Need to redo host side filling out the attribute and mesh buffers as these may have + // changed. Hair adds a new attribute buffer and displace updates the mesh. + geom_calc_offset(scene, sizes); + gather_attributes( + scene, geom_attributes, object_attributes, object_attribute_values, attrib_sizes); + device_free(device, dscene, false); + device_update_attributes_preprocess(device, + dscene, + scene, + geom_attributes, + object_attributes, + object_attribute_values, + attrib_sizes, + progress); + device_update_mesh_preprocess(device, dscene, scene, sizes, progress); + } + //>>>>>>HOST SIDE CODE ENDS + } + + return scene->object_manager->need_flags_update; +} +CCL_NAMESPACE_END +// FRL_CGR END -- 2.30.2 From 2183d70e9d363ac25783aa5f0d99806a9a03caa0 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 14 Mar 2023 12:00:33 +0100 Subject: [PATCH 08/96] Move scene BVH update into parallel_for The scen BVH update was outside the parallel for this moves it inside the parallel_for so it can be performed in parallel also. --- intern/cycles/scene/geometry.cpp | 57 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 50a614ba118..e718d7c3fbc 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1474,24 +1474,6 @@ void GeometryManager::device_update(Device *device, Scene *scene, Progress &progress) { - // WL: This method works as follows: - // 1. Calculate vertex normals and gather undisplaced vertices - // 2. Tesselate mesh if needed - // 3. Compute object bounds - // 4. fill attribute buffers - // 5. fill geometry buffers - // ----DEVICE SPECIFIC BEGIN---- - // 6. copy attribute buffers to device - // 7. copy geometry buffers to device - // --- only run on the first device --- - // 8. displace meshes and calculate shadow transparency if needed - // ----DEVICE SPECIFIC END---- - // 9. if displacement or shadow transparency then refill buffers and re-upload - // ----START OF MIXED DEVICE AND HOST CODE---- - // 10. build geometry BVHs - // 11. build scene BVH - // ----HOST SPECIFIC BELOW THIS POINT - // 12. Remove modified or update tags SCOPED_MARKER(device, "GeometryManager::device_update"); if (!need_update()) return; @@ -1561,15 +1543,20 @@ void GeometryManager::device_update(Device *device, dscene->data.bvh.bvh_layout = bvh_layout; size_t num_bvh = createObjectBVHs(device, dscene, scene, bvh_layout, need_update_scene_bvh); - + bool can_refit; + { + SCOPED_MARKER(device, "update scene BVH"); + can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); + } { SCOPED_MARKER(device, "device update"); - // WL: Parallel upload the geometry data to the devices and + // Parallel upload the geometry data to the devices and // calculate or refit the BVHs size_t n_scenes = scene->dscenes.size(); double mesh_times[n_scenes]; double attrib_times[n_scenes]; - double bvh_times[n_scenes]; + double object_bvh_times[n_scenes]; + double scene_bvh_times[n_scenes]; tbb::parallel_for(size_t(0), n_scenes, @@ -1582,9 +1569,11 @@ void GeometryManager::device_update(Device *device, &attrib_sizes, bvh_layout, num_bvh, + can_refit, &mesh_times, &attrib_times, - &bvh_times, + &object_bvh_times, + &scene_bvh_times, &progress](const size_t idx) { deviceDataXferAndBVHUpdate(idx, scene, @@ -1595,25 +1584,39 @@ void GeometryManager::device_update(Device *device, num_bvh, mesh_times, attrib_times, - bvh_times, + object_bvh_times, progress); - }); // WL: End of parallel data upload and BVH refit/creation + { + DeviceScene *sub_dscene = scene->dscenes[idx]; + Device *sub_device = sub_dscene->tri_verts.device; + SCOPED_MARKER(sub_device, "Build Scene BVH"); + scoped_callback_timer timer([scene, idx, &scene_bvh_times](double time) { + if (scene->update_stats) { + scene_bvh_times[idx] = time; + }}); + device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); + } + }); // WL: End of parallel data upload and BVH refit/creation if (scene->update_stats) { double max_mesh_time = 0.0f; double max_attrib_time = 0.0f; - double max_bvh_time = 0.0f; + double max_object_bvh_time = 0.0f; + double max_scene_bvh_time = 0.0f; for (size_t i = 0; i < n_scenes; i++) { max_mesh_time = max(max_mesh_time, mesh_times[i]); max_attrib_time = max(max_attrib_time, attrib_times[i]); - max_bvh_time = max(max_bvh_time, bvh_times[i]); + max_object_bvh_time = max(max_object_bvh_time, object_bvh_times[i]); + max_scene_bvh_time = max(max_scene_bvh_time, scene_bvh_times[i]); } scene->update_stats->geometry.times.add_entry( {"device_update (copy meshes to device)", max_mesh_time}); scene->update_stats->geometry.times.add_entry( {"device_update (attributes)", max_attrib_time}); scene->update_stats->geometry.times.add_entry( - {"device_update (build object BVHs)", max_bvh_time}); + {"device_update (build object BVHs)", max_object_bvh_time}); + scene->update_stats->geometry.times.add_entry( + {"device_update (build scene BVH)", max_scene_bvh_time}); } // WL: Build scene BVH -- 2.30.2 From 5c56f518eb264dbfed496ef2ec9c8df73e1107f3 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 13 Mar 2023 18:29:48 +0100 Subject: [PATCH 09/96] FIX: Preallocate timer arrays in scene The Windows build failed as the timers were using a dynamic array. This has been changed to use an heap array which is allocated with the scene instead. --- intern/cycles/scene/geometry.cpp | 35 ++++++++++++-------------------- intern/cycles/scene/scene.cpp | 14 +++++++++++++ intern/cycles/scene/scene.h | 6 ++++++ 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index e718d7c3fbc..82772df5517 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1270,7 +1270,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, size_t num_bvh, double *mesh_times, double *attrib_times, - double *bvh_times, + double *object_bvh_times, Progress &progress) { DeviceScene *sub_dscene = scene->dscenes[idx]; @@ -1307,9 +1307,9 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, device_scene_clear_modified(sub_dscene); { SCOPED_MARKER(sub_device, "Parallel BVH building"); - scoped_callback_timer timer([scene, idx, &bvh_times](double time) { + scoped_callback_timer timer([scene, idx, &object_bvh_times](double time) { if (scene->update_stats) { - bvh_times[idx] = time; + object_bvh_times[idx] = time; } }); size_t i = 0; @@ -1549,15 +1549,10 @@ void GeometryManager::device_update(Device *device, can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); } { + size_t n_scenes = scene->dscenes.size(); SCOPED_MARKER(device, "device update"); // Parallel upload the geometry data to the devices and // calculate or refit the BVHs - size_t n_scenes = scene->dscenes.size(); - double mesh_times[n_scenes]; - double attrib_times[n_scenes]; - double object_bvh_times[n_scenes]; - double scene_bvh_times[n_scenes]; - tbb::parallel_for(size_t(0), n_scenes, [this, @@ -1570,10 +1565,6 @@ void GeometryManager::device_update(Device *device, bvh_layout, num_bvh, can_refit, - &mesh_times, - &attrib_times, - &object_bvh_times, - &scene_bvh_times, &progress](const size_t idx) { deviceDataXferAndBVHUpdate(idx, scene, @@ -1582,17 +1573,17 @@ void GeometryManager::device_update(Device *device, attrib_sizes, bvh_layout, num_bvh, - mesh_times, - attrib_times, - object_bvh_times, + scene->mesh_times, + scene->attrib_times, + scene->object_bvh_times, progress); { DeviceScene *sub_dscene = scene->dscenes[idx]; Device *sub_device = sub_dscene->tri_verts.device; SCOPED_MARKER(sub_device, "Build Scene BVH"); - scoped_callback_timer timer([scene, idx, &scene_bvh_times](double time) { + scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - scene_bvh_times[idx] = time; + scene->scene_bvh_times[idx] = time; }}); device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); } @@ -1604,10 +1595,10 @@ void GeometryManager::device_update(Device *device, double max_object_bvh_time = 0.0f; double max_scene_bvh_time = 0.0f; for (size_t i = 0; i < n_scenes; i++) { - max_mesh_time = max(max_mesh_time, mesh_times[i]); - max_attrib_time = max(max_attrib_time, attrib_times[i]); - max_object_bvh_time = max(max_object_bvh_time, object_bvh_times[i]); - max_scene_bvh_time = max(max_scene_bvh_time, scene_bvh_times[i]); + max_mesh_time = max(max_mesh_time, scene->mesh_times[i]); + max_attrib_time = max(max_attrib_time, scene->attrib_times[i]); + max_object_bvh_time = max(max_object_bvh_time, scene->object_bvh_times[i]); + max_scene_bvh_time = max(max_scene_bvh_time, scene->scene_bvh_times[i]); } scene->update_stats->geometry.times.add_entry( {"device_update (copy meshes to device)", max_mesh_time}); diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index d7d04a8fbd4..4d9fb1736de 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -122,6 +122,13 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) }); memset((void *)&dscene.data, 0, sizeof(dscene.data)); + /* Stats time logging allocate memory to store times for each device */ + size_t device_count = this->dscenes.size(); + mesh_times = new double[device_count]; + attrib_times = new double[device_count]; + object_bvh_times = new double[device_count]; + scene_bvh_times = new double[device_count]; + shader_manager = ShaderManager::create( device->info.has_osl ? params.shadingsystem : SHADINGSYSTEM_SVM, device); @@ -150,6 +157,13 @@ Scene::~Scene() foreach (DeviceScene *sub_scene, dscenes) { delete sub_scene; } + + /* free stats data */ + delete[] mesh_times; + delete[] attrib_times; + delete[] object_bvh_times; + delete[] scene_bvh_times; + free_memory(true); } diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index d41a2d45628..9f931d801e6 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -249,6 +249,12 @@ class Scene : public NodeOwner { /* Stores a DeviceScene for each sub-device */ std::vector dscenes; + /* Stats time logging */ + double *mesh_times; + double *attrib_times; + double *object_bvh_times; + double *scene_bvh_times; + /* parameters */ SceneParams params; -- 2.30.2 From cba4d732e2c7d3ae6a2782a8be453ad545e7b11d Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 14 Mar 2023 12:57:20 +0100 Subject: [PATCH 10/96] Remove stats params from deviceDataXferAndBVHUpdate The stats parameters are now contained in the Scene class and no longer need to be passed as a parameter. --- intern/cycles/scene/geometry.cpp | 18 ++++++------------ intern/cycles/scene/geometry.h | 3 --- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 82772df5517..e463ab8c6fe 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1268,9 +1268,6 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, - double *mesh_times, - double *attrib_times, - double *object_bvh_times, Progress &progress) { DeviceScene *sub_dscene = scene->dscenes[idx]; @@ -1285,10 +1282,10 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, // WL: Upload geometry and attribute buffers to the device { SCOPED_MARKER(sub_device, "copy mesh to device"); - scoped_callback_timer timer([scene, idx, &mesh_times](double time) { + scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { // Save copy mesh to device duration for later logging - mesh_times[idx] = time; + scene->mesh_times[idx] = time; } }); device_update_mesh(sub_device, sub_dscene, &sizes, progress); @@ -1296,9 +1293,9 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, { SCOPED_MARKER(sub_device, "copy attributes to device"); - scoped_callback_timer timer([scene, idx, &attrib_times](double time) { + scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - attrib_times[idx] = time; + scene->attrib_times[idx] = time; } }); device_update_attributes(sub_device, sub_dscene, &attrib_sizes, progress); @@ -1307,9 +1304,9 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, device_scene_clear_modified(sub_dscene); { SCOPED_MARKER(sub_device, "Parallel BVH building"); - scoped_callback_timer timer([scene, idx, &object_bvh_times](double time) { + scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - object_bvh_times[idx] = time; + scene->object_bvh_times[idx] = time; } }); size_t i = 0; @@ -1573,9 +1570,6 @@ void GeometryManager::device_update(Device *device, attrib_sizes, bvh_layout, num_bvh, - scene->mesh_times, - scene->attrib_times, - scene->object_bvh_times, progress); { DeviceScene *sub_dscene = scene->dscenes[idx]; diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 585909788bd..a2ad768619c 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -266,9 +266,6 @@ class GeometryManager { AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, - double *mesh_times, - double *attrib_times, - double *bvh_times, Progress &progress); void updateObjectBounds(Scene *scene); void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress); -- 2.30.2 From 665a0e84b2aa035b56559db7df027a7aa05f48fb Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 14 Mar 2023 13:30:43 +0100 Subject: [PATCH 11/96] Move scne BVH upload into deviceDataXferAndBVHUpdate To simplify the code and make it easier to read this moves the scene BVH upload into the deviceDataXferAndBVHUpdate method. --- intern/cycles/scene/geometry.cpp | 45 ++++++++++++++++++-------------- intern/cycles/scene/geometry.h | 2 ++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index e463ab8c6fe..03b322beca1 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1268,6 +1268,8 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, + bool can_refit, + bool need_update_scene_bvh, Progress &progress) { DeviceScene *sub_dscene = scene->dscenes[idx]; @@ -1319,6 +1321,16 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, } } } + + if(need_update_scene_bvh) { + SCOPED_MARKER(sub_device, "Build Scene BVH"); + scoped_callback_timer timer([scene, idx](double time) { + if (scene->update_stats) { + scene->scene_bvh_times[idx] = time; + } + }); + device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); + } } /* @@ -1540,10 +1552,10 @@ void GeometryManager::device_update(Device *device, dscene->data.bvh.bvh_layout = bvh_layout; size_t num_bvh = createObjectBVHs(device, dscene, scene, bvh_layout, need_update_scene_bvh); - bool can_refit; - { + bool can_refit_scene_bvh = true; + if(need_update_scene_bvh) { SCOPED_MARKER(device, "update scene BVH"); - can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); + can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); } { size_t n_scenes = scene->dscenes.size(); @@ -1561,7 +1573,8 @@ void GeometryManager::device_update(Device *device, &attrib_sizes, bvh_layout, num_bvh, - can_refit, + can_refit_scene_bvh, + need_update_scene_bvh, &progress](const size_t idx) { deviceDataXferAndBVHUpdate(idx, scene, @@ -1570,19 +1583,13 @@ void GeometryManager::device_update(Device *device, attrib_sizes, bvh_layout, num_bvh, - progress); - { - DeviceScene *sub_dscene = scene->dscenes[idx]; - Device *sub_device = sub_dscene->tri_verts.device; - SCOPED_MARKER(sub_device, "Build Scene BVH"); - scoped_callback_timer timer([scene, idx](double time) { - if (scene->update_stats) { - scene->scene_bvh_times[idx] = time; - }}); - device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); - } + can_refit_scene_bvh, + need_update_scene_bvh, + progress); }); // WL: End of parallel data upload and BVH refit/creation - + if (need_update_scene_bvh) { + device_update_bvh_postprocess(device, dscene, scene, progress); + } if (scene->update_stats) { double max_mesh_time = 0.0f; double max_attrib_time = 0.0f; @@ -1605,9 +1612,9 @@ void GeometryManager::device_update(Device *device, } // WL: Build scene BVH - if (need_update_scene_bvh) { - updateSceneBVHs(device, dscene, scene, progress); - } // WL: End of scene BVH generation + // if (need_update_scene_bvh) { + // updateSceneBVHs(device, dscene, scene, progress); + // } // WL: End of scene BVH generation } // WL: End of device update /* END OF DEVICE SPECIFIC CODE:BELOW THIS POINT IS HOST SIDE CODE diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index a2ad768619c..39ddb66de98 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -266,6 +266,8 @@ class GeometryManager { AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, + bool can_refit, + bool need_update_scene_bvh, Progress &progress); void updateObjectBounds(Scene *scene); void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress); -- 2.30.2 From 532479e569b888bdb7500b046c63e55cab87d9c1 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 14 Mar 2023 15:01:04 +0100 Subject: [PATCH 12/96] Move BVH2 device data update inside parallel_for --- intern/cycles/device/memory.h | 11 +++ intern/cycles/scene/geometry.cpp | 3 +- intern/cycles/scene/geometry.h | 1 + intern/cycles/scene/geometry_additions.cpp | 99 ++++++++++++---------- 4 files changed, 68 insertions(+), 46 deletions(-) diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index 793bdb6d351..7d906f1820f 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -414,6 +414,17 @@ template class device_vector : public device_memory { p_src->host_pointer, p_src->data_width, p_src->data_height, p_src->data_depth); } + T *assign_mem(array &src) + { + return assign_mem(src.data(), src.size()); + } + + T *assign_mem(array *p_src) + { + return assign_mem( + p_src->data(), p_src->size()); + } + T *assign_mem(void *p_mem, size_t width, size_t height = 0, size_t depth = 0) { size_t new_size = size(width, height, depth); diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 03b322beca1..345426cc783 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1330,6 +1330,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, } }); device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); + device_update_bvh2(sub_device, sub_dscene, scene, progress); } } @@ -1586,7 +1587,7 @@ void GeometryManager::device_update(Device *device, can_refit_scene_bvh, need_update_scene_bvh, progress); - }); // WL: End of parallel data upload and BVH refit/creation + }); if (need_update_scene_bvh) { device_update_bvh_postprocess(device, dscene, scene, progress); } diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 39ddb66de98..2296788cde6 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -313,6 +313,7 @@ class GeometryManager { DeviceScene *dscene, /*Scene *scene,*/ const GeometrySizes *sizes, Progress &progress); + void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_update_host_pointers(Device *device, DeviceScene *dscene, DeviceScene *sub_dscene, diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index e65c9f0429e..af15102b0ec 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -742,6 +742,54 @@ void GeometryManager::gather_attributes(Scene *scene, attrib_calc_sizes(scene, sizes, geom_attributes, object_attributes, object_attribute_values); } +void GeometryManager::device_update_bvh2(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + SCOPED_MARKER(device, "GeometryManager::device_update_bvh2"); + BVH *bvh = scene->bvh; + if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { + BVH2 *bvh2 = static_cast(bvh); + + /* When using BVH2, we always have to copy/update the data as its layout is dependent on + * the BVH's leaf nodes which may be different when the objects or vertices move. */ + + if (bvh2->pack.nodes.size()) { + dscene->bvh_nodes.assign_mem(bvh2->pack.nodes); + dscene->bvh_nodes.copy_to_device(); + } + if (bvh2->pack.leaf_nodes.size()) { + dscene->bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes); + dscene->bvh_leaf_nodes.copy_to_device(); + } + if (bvh2->pack.object_node.size()) { + dscene->object_node.assign_mem(bvh2->pack.object_node); + dscene->object_node.copy_to_device(); + } + if (bvh2->pack.prim_type.size()) { + dscene->prim_type.assign_mem(bvh2->pack.prim_type); + dscene->prim_type.copy_to_device(); + } + if (bvh2->pack.prim_visibility.size()) { + dscene->prim_visibility.assign_mem(bvh2->pack.prim_visibility); + dscene->prim_visibility.copy_to_device(); + } + if (bvh2->pack.prim_index.size()) { + dscene->prim_index.assign_mem(bvh2->pack.prim_index); + dscene->prim_index.copy_to_device(); + } + if (bvh2->pack.prim_object.size()) { + dscene->prim_object.assign_mem(bvh2->pack.prim_object); + dscene->prim_object.copy_to_device(); + } + if (bvh2->pack.prim_time.size()) { + dscene->prim_time.assign_mem(bvh2->pack.prim_time); + dscene->prim_time.copy_to_device(); + } + } +} + void GeometryManager::device_update_bvh_postprocess(Device *device, DeviceScene *dscene, Scene *scene, @@ -750,60 +798,21 @@ void GeometryManager::device_update_bvh_postprocess(Device *device, SCOPED_MARKER(device, "GeometryManager::device_update_bvh_postprocess"); BVH *bvh = scene->bvh; - // FIXME: The below should be in the Device parallel_for and also the preprocess host code const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); - PackedBVH pack; + //PackedBVH pack; if (has_bvh2_layout) { - pack = std::move(static_cast(bvh)->pack); + BVH2 *bvh2 = static_cast(scene->bvh); + //pack = std::move(static_cast(bvh)->pack); + dscene->data.bvh.root = bvh2->pack.root_index; } else { - pack.root_index = -1; + //pack.root_index = -1; + dscene->data.bvh.root = -1; } - /* copy to device */ - /* When using BVH2, we always have to copy/update the data as its layout is dependent on the - * BVH's leaf nodes which may be different when the objects or vertices move. */ - - if (pack.nodes.size()) { - dscene->bvh_nodes.steal_data(pack.nodes); - dscene->bvh_nodes.copy_to_device(); - } - if (pack.leaf_nodes.size()) { - dscene->bvh_leaf_nodes.steal_data(pack.leaf_nodes); - dscene->bvh_leaf_nodes.copy_to_device(); - } - if (pack.object_node.size()) { - dscene->object_node.steal_data(pack.object_node); - dscene->object_node.copy_to_device(); - } - if (pack.prim_type.size()) { - dscene->prim_type.steal_data(pack.prim_type); - dscene->prim_type.copy_to_device(); - } - if (pack.prim_visibility.size()) { - dscene->prim_visibility.steal_data(pack.prim_visibility); - dscene->prim_visibility.copy_to_device(); - } - if (pack.prim_index.size()) { - dscene->prim_index.steal_data(pack.prim_index); - dscene->prim_index.copy_to_device(); - } - if (pack.prim_object.size()) { - dscene->prim_object.steal_data(pack.prim_object); - dscene->prim_object.copy_to_device(); - } - if (pack.prim_time.size()) { - dscene->prim_time.steal_data(pack.prim_time); - dscene->prim_time.copy_to_device(); - } - - dscene->data.bvh.root = pack.root_index; dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0); dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions(); - /* The scene handle is set in 'CPUDevice::const_copy_to' and 'OptiXDevice::const_copy_to' */ - // EDIT: Edit for merge - // dscene->data.bvh.scene = 0; dscene->data.device_bvh = 0; } -- 2.30.2 From 3fb101d2baadd44655223b00f8d40cf25024f98d Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 14 Mar 2023 16:24:32 +0100 Subject: [PATCH 13/96] Clean up code comments --- intern/cycles/scene/geometry.cpp | 16 ++++------------ intern/cycles/scene/geometry_additions.cpp | 15 ++++++--------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 345426cc783..eef3073c084 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1274,14 +1274,14 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, { DeviceScene *sub_dscene = scene->dscenes[idx]; sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; - // WL:Get the device to use for this DeviceScene from one of the buffers + // Get the device to use for this DeviceScene from one of the buffers Device *sub_device = sub_dscene->tri_verts.device; SCOPED_MARKER(sub_device, "parallel update device"); - // WL: Assign the host_pointers to the sub_dscene so that they access + // Assign the host_pointers to the sub_dscene so that they access // the correct data device_update_host_pointers(sub_device, dscene, sub_dscene, &sizes); - // WL: Upload geometry and attribute buffers to the device + // Upload geometry and attribute buffers to the device { SCOPED_MARKER(sub_device, "copy mesh to device"); scoped_callback_timer timer([scene, idx](double time) { @@ -1611,16 +1611,8 @@ void GeometryManager::device_update(Device *device, scene->update_stats->geometry.times.add_entry( {"device_update (build scene BVH)", max_scene_bvh_time}); } + } - // WL: Build scene BVH - // if (need_update_scene_bvh) { - // updateSceneBVHs(device, dscene, scene, progress); - // } // WL: End of scene BVH generation - } // WL: End of device update - - /* END OF DEVICE SPECIFIC CODE:BELOW THIS POINT IS HOST SIDE CODE - What follows is mainly code to clear update or modified - tags now that all the updates have been performed. */ clearGeometryUpdateAndModifiedTags(scene); clearShaderUpdateTags(scene); update_flags = UPDATE_NONE; diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index af15102b0ec..080d855acaa 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -523,7 +523,7 @@ void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) mesh->corner_offset = p_sizes->corner_size; p_sizes->vert_size += mesh->verts.size(); - // WL: Store extra index set for motion blur + // Store extra index set for motion blur if(mesh->get_use_motion_blur()) { p_sizes->tri_size += 2*mesh->num_triangles(); } else { @@ -942,7 +942,6 @@ bool GeometryManager::device_update_bvh_preprocess(Device *device, BVH *bvh = scene->bvh; if (!scene->bvh) { - // TODO: Store device BVHs in a vector instead of just 1 bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); } @@ -973,10 +972,10 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( bool displacement_done = false; bool curve_shadow_transparency_done = false; { - // WL: Need to upload the attribute and mesh buffers for dispacement. - // WL: Evaluate these on a single device (anyone will do, so use the first) + // Need to upload the attribute and mesh buffers for dispacement. + // Evaluate these on a single device (anyone will do, so use the first) { - // WL: Could break this out across all the devices as + // Could break this out across all the devices as // the results are read back to the host. For now, the computations // are done on the first device. DeviceScene *sub_dscene = scene->dscenes.front(); @@ -1029,8 +1028,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( } } - //>>>>>HOST SIDE CODE BEGINS - // WL: Some host side code here as the mesh and attributes need to be + // Some host side code here as the mesh and attributes need to be // recalculated after displacement and shadow transparency /* Device re-update after displacement. */ if (displacement_done || curve_shadow_transparency_done) { @@ -1041,7 +1039,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( } }); - // WL: Need to redo host side filling out the attribute and mesh buffers as these may have + // Need to redo host side filling out the attribute and mesh buffers as these may have // changed. Hair adds a new attribute buffer and displace updates the mesh. geom_calc_offset(scene, sizes); gather_attributes( @@ -1057,7 +1055,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( progress); device_update_mesh_preprocess(device, dscene, scene, sizes, progress); } - //>>>>>>HOST SIDE CODE ENDS } return scene->object_manager->need_flags_update; -- 2.30.2 From b5e12fa1cc6ab8cb3eebd00703105ce0f7e95d5c Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 16 Mar 2023 15:55:56 +0100 Subject: [PATCH 14/96] Remove some more comments --- intern/cycles/device/cuda/device.cpp | 4 ++-- intern/cycles/device/cuda/device_impl.cpp | 6 ++---- intern/cycles/device/device.cpp | 2 -- intern/cycles/device/device.h | 2 -- intern/cycles/device/hip/device_impl.cpp | 1 - intern/cycles/device/memory.h | 1 - intern/cycles/scene/geometry.h | 3 --- intern/cycles/scene/geometry_additions.cpp | 2 -- intern/cycles/scene/svm.cpp | 22 +++++++++++----------- 9 files changed, 15 insertions(+), 28 deletions(-) diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index ef2cfcd72be..17e9c2ff020 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -27,13 +27,13 @@ bool device_cuda_init() return result; initialized = true; - // FRL_CGR + int flags = CUEW_INIT_CUDA; #ifdef USE_SCOPED_MARKER flags |= CUEW_INIT_NVTX; #endif int cuew_result = cuewInit(flags); - // FRL_CGR + if (cuew_result == CUEW_SUCCESS) { VLOG_INFO << "CUEW initialization succeeded"; if (CUDADevice::have_precompiled_kernels()) { diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index ced82841c98..6684c5a19d1 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -585,7 +585,6 @@ void CUDADevice::mem_alloc(device_memory &mem) void CUDADevice::mem_copy_to(device_memory &mem) { if (mem.type == MEM_GLOBAL) { - // FRL_CGR if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { global_free(mem); global_alloc(mem); @@ -628,7 +627,6 @@ void CUDADevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) generic_copy_to(mem, size, offset); } } -// FRL_CGR void CUDADevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) { @@ -1035,7 +1033,7 @@ int CUDADevice::get_device_default_attribute(CUdevice_attribute attribute, int d } return value; } -// FRL_CGR + void CUDADevice::push_marker(const string name) { nvtxRangePushA(name.c_str()); } @@ -1043,7 +1041,7 @@ void CUDADevice::push_marker(const string name) { void CUDADevice::pop_marker() { nvtxRangePop(); } -// FRL_CGR + CCL_NAMESPACE_END #endif diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index f7ba4794b70..e9f32f55ae8 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -774,7 +774,6 @@ void GPUDevice::generic_copy_to(device_memory &mem) } } -// FRL_CGR void GPUDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) { if (!mem.host_pointer || !mem.device_pointer) { @@ -789,7 +788,6 @@ void GPUDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size(), offset); } } -// FRL_CGR /* DeviceInfo */ diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 83845b90ee4..b46c942827e 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -328,7 +328,6 @@ class Device { static uint devices_initialized_mask; }; -// FRL_CGR class ScopedMarker { private: Device *_device; @@ -351,7 +350,6 @@ public: # define SCOPED_MARKER(device, msg) # endif #endif -// FRL_CGR /* Device, which is GPU, with some common functionality for GPU backends */ class GPUDevice : public Device { diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index daa452a3ff1..6764a40aac5 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -577,7 +577,6 @@ void HIPDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) generic_copy_to(mem, size, offset); } } -// FRL_CGR END void HIPDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) { diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index 7d906f1820f..370f4e94e66 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -437,7 +437,6 @@ template class device_vector : public device_memory { assert(device_pointer == 0); } host_pointer = p_mem; - // FRL_CGR shared_mem = true; data_size = new_size; data_width = width; diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 2296788cde6..c9572900356 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -165,7 +165,6 @@ class Geometry : public Node { void tag_bvh_update(bool rebuild); }; -// FRL_CGR BEGIN /* Geometry Sizes */ struct GeometrySizes { size_t vert_size; @@ -194,8 +193,6 @@ struct AttributeSizes { size_t attr_uchar4_size; }; -// FRL_CGR END - /* Geometry Manager */ class GeometryManager { diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index 080d855acaa..75a9db853fd 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -1,4 +1,3 @@ -// FRL_CGR BEGIN /* SPDX-License-Identifier: Apache-2.0 * Copyright 2011-2022 Blender Foundation */ @@ -1060,4 +1059,3 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( return scene->object_manager->need_flags_update; } CCL_NAMESPACE_END -// FRL_CGR END diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index 42285910e19..723e5c3ac4b 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -129,19 +129,19 @@ void SVMShaderManager::device_update_specific(Device *device, /* Copy the nodes of each shader into the correct location. */ { - SCOPED_MARKER(device,"copy shader node"); - // FRL_CGR_END - svm_nodes += num_shaders; - for (int i = 0; i < num_shaders; i++) { - int shader_size = shader_svm_nodes[i].size() - 1; + SCOPED_MARKER(device, "copy shader node"); - memcpy(svm_nodes, &shader_svm_nodes[i][1], sizeof(int4) * shader_size); - svm_nodes += shader_size; - } + svm_nodes += num_shaders; + for (int i = 0; i < num_shaders; i++) { + int shader_size = shader_svm_nodes[i].size() - 1; - if (progress.get_cancel()) { - return; - } + memcpy(svm_nodes, &shader_svm_nodes[i][1], sizeof(int4) * shader_size); + svm_nodes += shader_size; + } + + if (progress.get_cancel()) { + return; + } } dscene->svm_nodes.copy_to_device(); -- 2.30.2 From a875bc9e45008890e4d7d2fe2dea319fa4dfd216 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 16 Mar 2023 15:59:16 +0100 Subject: [PATCH 15/96] Remove comments from cuew --- extern/cuew/include/cuew.h | 6 ++---- extern/cuew/src/cuew.c | 12 ++---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h index 66a5c66a8d0..30ca6e9fb93 100644 --- a/extern/cuew/include/cuew.h +++ b/extern/cuew/include/cuew.h @@ -886,11 +886,11 @@ typedef enum { } nvrtcResult; typedef struct _nvrtcProgram* nvrtcProgram; -// FRL_CGR + /* Function types. */ typedef void CUDAAPI tnvtxRangePushA(const char *msg); typedef void CUDAAPI tnvtxRangePop(); -// FRL_CGR + typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuInit(unsigned int Flags); @@ -1382,10 +1382,8 @@ enum { enum { CUEW_INIT_CUDA = 1, -// FRL_CGR CUEW_INIT_NVRTC = 2, CUEW_INIT_NVTX = 4, -// FRL_CGR }; int cuewInit(cuuint32_t flags); diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index ba1aee4ba96..771bf28e1a5 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -66,21 +66,18 @@ typedef void* DynamicLibrary; _LIBRARY_FIND_CHECKED(nvrtc_lib, name) #define NVRTC_LIBRARY_FIND(name) _LIBRARY_FIND(nvrtc_lib, name) -// FRL_CGR #define NVTX_LIBRARY_FIND_CHECKED(name) \ _LIBRARY_FIND_CHECKED(nvrtc_lib, name) #define NVTX_LIBRARY_FIND(name) _LIBRARY_FIND(nvtx_lib, name) -// FRL_CGR static DynamicLibrary cuda_lib; static DynamicLibrary nvrtc_lib; static DynamicLibrary nvtx_lib; /* Function definitions. */ -// FRL_CGR + tnvtxRangePushA *nvtxRangePushA; tnvtxRangePop *nvtxRangePop; -// FRL_CGR tcuGetErrorString *cuGetErrorString; tcuGetErrorName *cuGetErrorName; @@ -623,7 +620,6 @@ static int cuewCudaInit(void) { return result; } -// FRL_CGR static void cuewExitNvtx(void) { if (nvrtc_lib != NULL) { /* Ignore errors. */ @@ -631,7 +627,6 @@ static void cuewExitNvtx(void) { nvtx_lib = NULL; } } -// FRL_CGR static void cuewExitNvrtc(void) { if (nvrtc_lib != NULL) { @@ -703,7 +698,6 @@ static int cuewNvrtcInit(void) { return result; } -// FRL_CGR static int cuewNvtxInit(void) { /* Library paths. */ #ifdef _WIN32 @@ -752,7 +746,6 @@ static int cuewNvtxInit(void) { result = CUEW_SUCCESS; return result; } -// FRL_CGR int cuewInit(cuuint32_t flags) { int result = CUEW_SUCCESS; @@ -770,14 +763,13 @@ int cuewInit(cuuint32_t flags) { return result; } } -// FRL_CGR + if(flags & CUEW_INIT_NVTX) { result = cuewNvtxInit(); if(result != CUEW_SUCCESS) { return result; } } -// FRL_CGR return result; } -- 2.30.2 From 717b7a9b6ff1823b17a89f737db396a2b1d938aa Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 17 Mar 2023 16:01:14 +0100 Subject: [PATCH 16/96] Remove profiling interval markers from geometry update --- extern/cuew/include/cuew.h | 8 +- extern/cuew/src/cuew.c | 72 ---------- intern/cycles/device/cuda/device.cpp | 4 +- intern/cycles/device/cuda/device_impl.cpp | 8 -- intern/cycles/device/cuda/device_impl.h | 2 - intern/cycles/device/device.h | 31 +---- intern/cycles/scene/geometry.cpp | 151 +++++---------------- intern/cycles/scene/geometry_additions.cpp | 16 --- intern/cycles/scene/scene.cpp | 3 - intern/cycles/scene/shader.cpp | 2 - intern/cycles/scene/svm.cpp | 20 ++- 11 files changed, 48 insertions(+), 269 deletions(-) diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h index 30ca6e9fb93..49b230d505c 100644 --- a/extern/cuew/include/cuew.h +++ b/extern/cuew/include/cuew.h @@ -888,9 +888,6 @@ typedef enum { typedef struct _nvrtcProgram* nvrtcProgram; /* Function types. */ -typedef void CUDAAPI tnvtxRangePushA(const char *msg); -typedef void CUDAAPI tnvtxRangePop(); - typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuInit(unsigned int Flags); @@ -1132,8 +1129,6 @@ typedef nvrtcResult CUDAAPI tnvrtcGetLoweredName(nvrtcProgram prog, const char* /* Function declarations. */ -extern tnvtxRangePushA *nvtxRangePushA; -extern tnvtxRangePop *nvtxRangePop; extern tcuGetErrorString *cuGetErrorString; extern tcuGetErrorName *cuGetErrorName; extern tcuInit *cuInit; @@ -1382,8 +1377,7 @@ enum { enum { CUEW_INIT_CUDA = 1, - CUEW_INIT_NVRTC = 2, - CUEW_INIT_NVTX = 4, + CUEW_INIT_NVRTC = 2 }; int cuewInit(cuuint32_t flags); diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index 771bf28e1a5..8ab6670de9e 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -66,19 +66,11 @@ typedef void* DynamicLibrary; _LIBRARY_FIND_CHECKED(nvrtc_lib, name) #define NVRTC_LIBRARY_FIND(name) _LIBRARY_FIND(nvrtc_lib, name) -#define NVTX_LIBRARY_FIND_CHECKED(name) \ - _LIBRARY_FIND_CHECKED(nvrtc_lib, name) -#define NVTX_LIBRARY_FIND(name) _LIBRARY_FIND(nvtx_lib, name) - static DynamicLibrary cuda_lib; static DynamicLibrary nvrtc_lib; static DynamicLibrary nvtx_lib; /* Function definitions. */ - -tnvtxRangePushA *nvtxRangePushA; -tnvtxRangePop *nvtxRangePop; - tcuGetErrorString *cuGetErrorString; tcuGetErrorName *cuGetErrorName; tcuInit *cuInit; @@ -620,14 +612,6 @@ static int cuewCudaInit(void) { return result; } -static void cuewExitNvtx(void) { - if (nvrtc_lib != NULL) { - /* Ignore errors. */ - dynamic_library_close(nvtx_lib); - nvtx_lib = NULL; - } -} - static void cuewExitNvrtc(void) { if (nvrtc_lib != NULL) { /* Ignore errors. */ @@ -698,55 +682,6 @@ static int cuewNvrtcInit(void) { return result; } -static int cuewNvtxInit(void) { - /* Library paths. */ -#ifdef _WIN32 - /* Expected in c:/windows/system or similar, no path needed. */ - const char *nvtc_paths[] = {"nvToolsExt64_101_0.dll", - NULL}; -#elif defined(__APPLE__) - /* Default installation path. */ - const char *nvtx_paths[] = {"/usr/local/cuda/lib/libnvToolsExt.dylib", NULL}; -#else - const char *nvtx_paths[] = {"libnvToolsExt.so", -# if defined(__x86_64__) || defined(_M_X64) - "/usr/local/cuda/lib64/libnvToolsExt.so", -#else - "/usr/local/cuda/lib/libnvToolsExt.so", -#endif - NULL}; -#endif - static int nvtx_initialized = 0; - static int result = 0; - int error; - - if (nvtx_initialized) { - return result; - } - - nvtx_initialized = 1; - - error = atexit(cuewExitNvtx); - if (error) { - result = CUEW_ERROR_ATEXIT_FAILED; - return result; - } - - /* Load library. */ - nvtx_lib = dynamic_library_open_find(nvtx_paths); - - if (nvtx_lib == NULL) { - result = CUEW_ERROR_OPEN_FAILED; - return result; - } - - NVTX_LIBRARY_FIND(nvtxRangePushA); - NVTX_LIBRARY_FIND(nvtxRangePop); - - result = CUEW_SUCCESS; - return result; -} - int cuewInit(cuuint32_t flags) { int result = CUEW_SUCCESS; @@ -764,13 +699,6 @@ int cuewInit(cuuint32_t flags) { } } - if(flags & CUEW_INIT_NVTX) { - result = cuewNvtxInit(); - if(result != CUEW_SUCCESS) { - return result; - } - } - return result; } diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index 17e9c2ff020..e3dd1a1285f 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -29,9 +29,7 @@ bool device_cuda_init() initialized = true; int flags = CUEW_INIT_CUDA; -#ifdef USE_SCOPED_MARKER - flags |= CUEW_INIT_NVTX; -#endif + int cuew_result = cuewInit(flags); if (cuew_result == CUEW_SUCCESS) { diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index 6684c5a19d1..5c788ac8afc 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -1034,14 +1034,6 @@ int CUDADevice::get_device_default_attribute(CUdevice_attribute attribute, int d return value; } -void CUDADevice::push_marker(const string name) { - nvtxRangePushA(name.c_str()); -} - -void CUDADevice::pop_marker() { - nvtxRangePop(); -} - CCL_NAMESPACE_END #endif diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index eaabeed5f43..57b63cab88b 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -104,8 +104,6 @@ class CUDADevice : public GPUDevice { int get_num_multiprocessors(); int get_max_num_threads_per_multiprocessor(); - virtual void push_marker(const string name) override; - virtual void pop_marker() override; protected: bool get_device_attribute(CUdevice_attribute attribute, int *value); int get_device_default_attribute(CUdevice_attribute attribute, int default_value); diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b46c942827e..6ddacc13932 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -221,13 +221,7 @@ class Device { { return 0; } - - virtual void push_marker(const string) { - } - - virtual void pop_marker() { - } - + virtual device_ptr find_matching_mem(device_ptr key, Device * /*sub*/) { return key; @@ -328,29 +322,6 @@ class Device { static uint devices_initialized_mask; }; -class ScopedMarker { -private: - Device *_device; -public: - ScopedMarker(Device *p_device, const string name) { - _device = p_device; - _device->push_marker(name.c_str() + std::to_string(p_device->info.num)); - } - - ~ScopedMarker() { - _device->pop_marker(); - } -}; - -#define USE_SCOPED_MARKER -#ifndef SCOPED_MARKER -# ifdef USE_SCOPED_MARKER -# define SCOPED_MARKER(device, msg) ScopedMarker scoped_marker(device, msg) -# else -# define SCOPED_MARKER(device, msg) -# endif -#endif - /* Device, which is GPU, with some common functionality for GPU backends */ class GPUDevice : public Device { protected: diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index eef3073c084..25179b7614f 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -189,7 +189,6 @@ void Geometry::compute_bvh(Device *device, size_t n, size_t total) { - SCOPED_MARKER(device,"Geometry::compute_bvh"); if (progress->get_cancel()) return; @@ -636,39 +635,13 @@ void GeometryManager::device_update_attributes(Device *device, { progress.set_status("Updating Mesh", "Copying Attributes to device"); /* copy svm attributes to device */ - { - SCOPED_MARKER(device, "copy attribute_map"); - dscene->attributes_map.copy_to_device_if_modified(); - } - - { - SCOPED_MARKER(device, "copy attributes_float"); - dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); - } - { - SCOPED_MARKER(device, "copy attributes_float2"); - dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); - } - { - SCOPED_MARKER(device, "copy attributes_float3"); - dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); - } - - { - SCOPED_MARKER(device, "copy attributes_float4"); - dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); - } - { - SCOPED_MARKER(device, "copy attributes_uchar4"); - dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); - } - - /* After mesh attributes and patch tables have been copied to device memory, - * we need to update offsets in the objects. */ - { - SCOPED_MARKER(device, "copy objects"); - dscene->objects.copy_to_device_if_modified(); - } + dscene->attributes_map.copy_to_device_if_modified(); + dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); + dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); + dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); + dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); + dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); + dscene->objects.copy_to_device_if_modified(); } /** @@ -679,55 +652,29 @@ void GeometryManager::device_update_mesh(Device *device, const GeometrySizes *p_sizes, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_mesh"); progress.set_status("Updating Mesh", "Copying Mesh to device"); - { - SCOPED_MARKER(device, "copy packed data to device"); - if (p_sizes->tri_size != 0) { - SCOPED_MARKER(device, "copy mesh data"); - { - SCOPED_MARKER(device, "copy tri_verts"); - dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); - } - { - SCOPED_MARKER(device, "copy tri_shader"); - dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); - } - { - SCOPED_MARKER(device, "copy tri_vnormal"); - dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); - } - { - SCOPED_MARKER(device, "copy tri_vindex"); - dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); - } - { - SCOPED_MARKER(device, "copy tri_patch"); - dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); - } - { - SCOPED_MARKER(device, "copy tri_patch_uv"); - dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); - } - } + if (p_sizes->tri_size != 0) { + dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); + dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); + dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); + } - if (p_sizes->curve_segment_size != 0) { - SCOPED_MARKER(device, "copy hair"); - dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); - dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); - dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); - } + if (p_sizes->curve_segment_size != 0) { + dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); + dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); + dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); + } - if (p_sizes->point_size != 0) { - SCOPED_MARKER(device, "copy points"); - dscene->points.copy_to_device(p_sizes->point_size, 0); - dscene->points_shader.copy_to_device(p_sizes->point_size, 0); - } + if (p_sizes->point_size != 0) { + dscene->points.copy_to_device(p_sizes->point_size, 0); + dscene->points_shader.copy_to_device(p_sizes->point_size, 0); + } - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - SCOPED_MARKER(device, "copy patches"); - dscene->patches.copy_to_device(p_sizes->patch_size, 0); - } + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + dscene->patches.copy_to_device(p_sizes->patch_size, 0); } } @@ -837,7 +784,6 @@ static void update_attribute_realloc_flags(uint32_t &device_update_flags, void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_preprocess"); if (!need_update() && !need_flags_update) { return; } @@ -1095,7 +1041,6 @@ void GeometryManager::device_update_displacement_images(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "device_update_displacement_images"); progress.set_status("Updating Displacement Images"); TaskPool pool; ImageManager *image_manager = scene->image_manager; @@ -1215,15 +1160,12 @@ void GeometryManager::preTessDispNormalAndVerticesSetup(Device *device, // also determines if tesselation, displacement or shadow transparency is needed. foreach (Geometry *geom, scene->geometry) { if (geom->is_modified()) { - SCOPED_MARKER(device, "add modified mesh"); if ((geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME)) { Mesh *mesh = static_cast(geom); /* Update normals. */ - { - SCOPED_MARKER(device, "add vertex normals"); - mesh->add_vertex_normals(); - } + mesh->add_vertex_normals(); + if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) { mesh->add_undisplaced(); } @@ -1276,14 +1218,12 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; // Get the device to use for this DeviceScene from one of the buffers Device *sub_device = sub_dscene->tri_verts.device; - SCOPED_MARKER(sub_device, "parallel update device"); // Assign the host_pointers to the sub_dscene so that they access // the correct data device_update_host_pointers(sub_device, dscene, sub_dscene, &sizes); // Upload geometry and attribute buffers to the device { - SCOPED_MARKER(sub_device, "copy mesh to device"); scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { // Save copy mesh to device duration for later logging @@ -1294,7 +1234,6 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, } { - SCOPED_MARKER(sub_device, "copy attributes to device"); scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { scene->attrib_times[idx] = time; @@ -1305,7 +1244,6 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, device_scene_clear_modified(sub_dscene); { - SCOPED_MARKER(sub_device, "Parallel BVH building"); scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { scene->object_bvh_times[idx] = time; @@ -1323,7 +1261,6 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, } if(need_update_scene_bvh) { - SCOPED_MARKER(sub_device, "Build Scene BVH"); scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { scene->scene_bvh_times[idx] = time; @@ -1340,8 +1277,6 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, */ void GeometryManager::updateObjectBounds(Scene *scene) { - SCOPED_MARKER(scene->device, "update objects"); - Scene::MotionType need_motion = scene->need_motion(); bool motion_blur = need_motion == Scene::MOTION_BLUR; @@ -1371,7 +1306,6 @@ size_t GeometryManager::createObjectBVHs(Device *device, const BVHLayout bvh_layout, bool &need_update_scene_bvh) { - SCOPED_MARKER(device, "update object BVH preprocess"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1385,20 +1319,17 @@ size_t GeometryManager::createObjectBVHs(Device *device, } // Create BVH structures where needed - { - SCOPED_MARKER(device, "create BVH structures"); - int id = 0; - foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified() || geom->need_update_bvh_for_offset) { - need_update_scene_bvh = true; - Object *object = &object_pool[id]; - geom->create_new_bvh_if_needed(object, device, dscene, &scene->params); - if (geom->need_build_bvh(bvh_layout)) { - num_bvh++; - } + int id = 0; + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + need_update_scene_bvh = true; + Object *object = &object_pool[id]; + geom->create_new_bvh_if_needed(object, device, dscene, &scene->params); + if (geom->need_build_bvh(bvh_layout)) { + num_bvh++; } - id++; } + id++; } return num_bvh; @@ -1413,7 +1344,6 @@ void GeometryManager::updateSceneBVHs(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "update scene BVH"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); @@ -1423,7 +1353,6 @@ void GeometryManager::updateSceneBVHs(Device *device, bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); foreach (DeviceScene *sub_dscene, scene->dscenes) { Device *sub_device = sub_dscene->tri_verts.device; - SCOPED_MARKER(sub_device, "Build Scene BVH"); device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); } device_update_bvh_postprocess(device, dscene, scene, progress); @@ -1436,7 +1365,6 @@ void GeometryManager::tesselate(Scene *scene, size_t total_tess_needed, Progress { /* Tessellate meshes that are using subdivision */ if (total_tess_needed) { - SCOPED_MARKER(scene->device, "Tesselate"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1454,7 +1382,6 @@ void GeometryManager::tesselate(Scene *scene, size_t total_tess_needed, Progress if (!(geom->is_modified() && geom->is_mesh())) { continue; } - SCOPED_MARKER(scene->device, "tesselate mesh"); Mesh *mesh = static_cast(geom); if (mesh->need_tesselation()) { string msg = "Tessellating "; @@ -1484,7 +1411,6 @@ void GeometryManager::device_update(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update"); if (!need_update()) return; @@ -1555,12 +1481,10 @@ void GeometryManager::device_update(Device *device, size_t num_bvh = createObjectBVHs(device, dscene, scene, bvh_layout, need_update_scene_bvh); bool can_refit_scene_bvh = true; if(need_update_scene_bvh) { - SCOPED_MARKER(device, "update scene BVH"); can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); } { size_t n_scenes = scene->dscenes.size(); - SCOPED_MARKER(device, "device update"); // Parallel upload the geometry data to the devices and // calculate or refit the BVHs tbb::parallel_for(size_t(0), @@ -1621,7 +1545,6 @@ void GeometryManager::device_update(Device *device, void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free) { - SCOPED_MARKER(device, "GeometryManager::device_free"); dscene->bvh_nodes.free_if_need_realloc(force_free); dscene->bvh_leaf_nodes.free_if_need_realloc(force_free); dscene->object_node.free_if_need_realloc(force_free); diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index 75a9db853fd..4cd98054058 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -51,7 +51,6 @@ void GeometryManager::clearShaderUpdateTags(Scene *scene) void GeometryManager::clearGeometryUpdateAndModifiedTags(Scene *scene) { // Clear update tags - SCOPED_MARKER(scene->device, "clear BVH update tags"); foreach (Geometry *geom, scene->geometry) { // Clear update indicators if (geom->is_modified() || geom->need_update_bvh_for_offset) { @@ -118,7 +117,6 @@ bool GeometryManager::device_update_attributes_preprocess( AttributeSizes *sizes, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_attributes"); bool update_obj_offsets = false; progress.set_status("Updating Mesh", "Computing attributes"); @@ -259,7 +257,6 @@ bool GeometryManager::device_update_attributes_preprocess( void GeometryManager::device_update_mesh_preprocess( Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *p_sizes, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_mesh_preprocess"); /* Fill in all the arrays. */ if (p_sizes->tri_size != 0) { /* normals */ @@ -284,18 +281,15 @@ void GeometryManager::device_update_mesh_preprocess( if (mesh->shader_is_modified() || mesh->smooth_is_modified() || mesh->triangles_is_modified() || copy_all_data) { - SCOPED_MARKER(scene->device, "Mesh:pack_shaders"); mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); } if (mesh->verts_is_modified() || copy_all_data) { - SCOPED_MARKER(scene->device, "Mesh:pack_normals"); mesh->pack_normals(&vnormal[mesh->vert_offset]); } if (mesh->verts_is_modified() || mesh->triangles_is_modified() || mesh->vert_patch_uv_is_modified() || copy_all_data) { - SCOPED_MARKER(scene->device, "Mesh:pack_vertices"); mesh->pack_verts(&tri_verts[mesh->vert_offset], &tri_vindex[mesh->prim_offset], &tri_patch[mesh->prim_offset], @@ -388,7 +382,6 @@ void GeometryManager::device_update_host_pointers(Device *device, DeviceScene *sub_dscene, GeometrySizes *p_sizes) { - SCOPED_MARKER(device, "update host_pointers"); if (p_sizes->tri_size != 0) { if (dscene->tri_verts.is_modified()) { sub_dscene->tri_verts.assign_mem(dscene->tri_verts); @@ -443,7 +436,6 @@ void GeometryManager::device_update_host_pointers(Device *device, } if (p_sizes->point_size != 0) { - SCOPED_MARKER(device, "copy points"); // TODO: Why does this not check the modified tag? sub_dscene->points.assign_mem(dscene->points); // sub_dscene->points.tag_modified(); @@ -746,7 +738,6 @@ void GeometryManager::device_update_bvh2(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_bvh2"); BVH *bvh = scene->bvh; if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { BVH2 *bvh2 = static_cast(bvh); @@ -794,7 +785,6 @@ void GeometryManager::device_update_bvh_postprocess(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device, "GeometryManager::device_update_bvh_postprocess"); BVH *bvh = scene->bvh; const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); @@ -958,7 +948,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( vector &object_attribute_values, Progress &progress) { - SCOPED_MARKER(device, "Displacement & Hair transparency"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); @@ -980,7 +969,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( DeviceScene *sub_dscene = scene->dscenes.front(); Device *sub_device = sub_dscene->tri_verts.device; { - SCOPED_MARKER(device, "copy mesh to device for displacement"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -991,16 +979,12 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( device_update_attributes(sub_device, sub_dscene, attrib_sizes, progress); device_update_mesh(sub_device, sub_dscene, sizes, progress); } - { /* Copy constant data needed by shader evaluation. */ - SCOPED_MARKER(device, "copy constant data for hair and displacement"); sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); - } foreach (Geometry *geom, scene->geometry) { /* Update images needed for true displacement. */ { - SCOPED_MARKER(device, "upload images for displacement"); scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 4d9fb1736de..f2b11f5785f 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -262,8 +262,6 @@ void Scene::device_update(Device *device_, Progress &progress) if (!device) device = device_; - SCOPED_MARKER(device,"Scene::device_update"); - bool print_stats = need_data_update(); if (update_stats) { @@ -598,7 +596,6 @@ void Scene::update_kernel_features() bool Scene::update(Progress &progress) { - SCOPED_MARKER(device, "Scene::update"); if (!need_update()) { return false; } diff --git a/intern/cycles/scene/shader.cpp b/intern/cycles/scene/shader.cpp index 12a042367cf..70264ebaab0 100644 --- a/intern/cycles/scene/shader.cpp +++ b/intern/cycles/scene/shader.cpp @@ -461,7 +461,6 @@ void ShaderManager::device_update(Device *device, Scene *scene, Progress &progress) { - SCOPED_MARKER(device,"ShaderManager::device_update"); if (!need_update()) { return; } @@ -486,7 +485,6 @@ void ShaderManager::device_update_common(Device *device, Scene *scene, Progress & /*progress*/) { - SCOPED_MARKER(device, "ShaderManager::device_update_common"); dscene->shaders.free(); if (scene->shaders.size() == 0) diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index 723e5c3ac4b..0a71ed962b0 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -128,20 +128,16 @@ void SVMShaderManager::device_update_specific(Device *device, } /* Copy the nodes of each shader into the correct location. */ - { - SCOPED_MARKER(device, "copy shader node"); + svm_nodes += num_shaders; + for (int i = 0; i < num_shaders; i++) { + int shader_size = shader_svm_nodes[i].size() - 1; - svm_nodes += num_shaders; - for (int i = 0; i < num_shaders; i++) { - int shader_size = shader_svm_nodes[i].size() - 1; + memcpy(svm_nodes, &shader_svm_nodes[i][1], sizeof(int4) * shader_size); + svm_nodes += shader_size; + } - memcpy(svm_nodes, &shader_svm_nodes[i][1], sizeof(int4) * shader_size); - svm_nodes += shader_size; - } - - if (progress.get_cancel()) { - return; - } + if (progress.get_cancel()) { + return; } dscene->svm_nodes.copy_to_device(); -- 2.30.2 From 042bf244098db0d9451e3666a4735be488771ba6 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 21 Mar 2023 15:52:47 +0100 Subject: [PATCH 17/96] Remove cuew changes. --- extern/cuew/include/cuew.h | 1 + extern/cuew/src/cuew.c | 2 +- intern/cycles/device/cuda/device.cpp | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h index 49b230d505c..5979f48e43d 100644 --- a/extern/cuew/include/cuew.h +++ b/extern/cuew/include/cuew.h @@ -887,6 +887,7 @@ typedef enum { typedef struct _nvrtcProgram* nvrtcProgram; + /* Function types. */ typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr); diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index 8ab6670de9e..9eba9306323 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -68,7 +68,6 @@ typedef void* DynamicLibrary; static DynamicLibrary cuda_lib; static DynamicLibrary nvrtc_lib; -static DynamicLibrary nvtx_lib; /* Function definitions. */ tcuGetErrorString *cuGetErrorString; @@ -682,6 +681,7 @@ static int cuewNvrtcInit(void) { return result; } + int cuewInit(cuuint32_t flags) { int result = CUEW_SUCCESS; diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index e3dd1a1285f..1b55bfac719 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -28,10 +28,7 @@ bool device_cuda_init() initialized = true; - int flags = CUEW_INIT_CUDA; - - int cuew_result = cuewInit(flags); - + int cuew_result = cuewInit(CUEW_INIT_CUDA); if (cuew_result == CUEW_SUCCESS) { VLOG_INFO << "CUEW initialization succeeded"; if (CUDADevice::have_precompiled_kernels()) { -- 2.30.2 From fcb3bd5854833c0c64287906934d7a73781984ba Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 21 Mar 2023 15:54:22 +0100 Subject: [PATCH 18/96] Adds comment to describe the find_matching_mem method --- intern/cycles/device/device.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 1564b0d011e..79a8383a845 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -221,7 +221,8 @@ class Device { { return 0; } - + + /* This gets the memory pointer for the given device given the virtual device pointer */ virtual device_ptr find_matching_mem(device_ptr key, Device * /*sub*/) { return key; -- 2.30.2 From 7bf80f2b77519e5bde1afe25554decf1ef527b35 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 21 Mar 2023 15:56:17 +0100 Subject: [PATCH 19/96] Clean up code and simplify 1. Switch to use auto for DeviceScene 2. use parallel_for instead of tbb::parallel_for 3. rename n_scenes num_scenes --- intern/cycles/scene/geometry.cpp | 46 ++++++++++++-------------------- intern/cycles/scene/scene.cpp | 2 +- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 25179b7614f..f36d9d26831 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1214,7 +1214,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, bool need_update_scene_bvh, Progress &progress) { - DeviceScene *sub_dscene = scene->dscenes[idx]; + auto sub_dscene = scene->dscenes[idx]; sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; // Get the device to use for this DeviceScene from one of the buffers Device *sub_device = sub_dscene->tri_verts.device; @@ -1351,7 +1351,7 @@ void GeometryManager::updateSceneBVHs(Device *device, }); bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); - foreach (DeviceScene *sub_dscene, scene->dscenes) { + foreach (auto sub_dscene, scene->dscenes) { Device *sub_device = sub_dscene->tri_verts.device; device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); } @@ -1484,34 +1484,22 @@ void GeometryManager::device_update(Device *device, can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); } { - size_t n_scenes = scene->dscenes.size(); + size_t num_scenes = scene->dscenes.size(); // Parallel upload the geometry data to the devices and // calculate or refit the BVHs - tbb::parallel_for(size_t(0), - n_scenes, - [this, - true_displacement_used, - curve_shadow_transparency_used, - scene, - dscene, - &sizes, - &attrib_sizes, - bvh_layout, - num_bvh, - can_refit_scene_bvh, - need_update_scene_bvh, - &progress](const size_t idx) { - deviceDataXferAndBVHUpdate(idx, - scene, - dscene, - sizes, - attrib_sizes, - bvh_layout, - num_bvh, - can_refit_scene_bvh, - need_update_scene_bvh, - progress); - }); + parallel_for( + size_t(0), num_scenes, [=, this, &sizes, &attrib_sizes, &progress](const size_t idx) { + deviceDataXferAndBVHUpdate(idx, + scene, + dscene, + sizes, + attrib_sizes, + bvh_layout, + num_bvh, + can_refit_scene_bvh, + need_update_scene_bvh, + progress); + }); if (need_update_scene_bvh) { device_update_bvh_postprocess(device, dscene, scene, progress); } @@ -1520,7 +1508,7 @@ void GeometryManager::device_update(Device *device, double max_attrib_time = 0.0f; double max_object_bvh_time = 0.0f; double max_scene_bvh_time = 0.0f; - for (size_t i = 0; i < n_scenes; i++) { + for (size_t i = 0; i < num_scenes; i++) { max_mesh_time = max(max_mesh_time, scene->mesh_times[i]); max_attrib_time = max(max_attrib_time, scene->attrib_times[i]); max_object_bvh_time = max(max_object_bvh_time, scene->object_bvh_times[i]); diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index f2b11f5785f..fe8ea30440c 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -116,7 +116,7 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) { /* Create a DeviceScene for each device */ device->foreach_device([this](Device *sub_device) { - DeviceScene *sub_dscene = new DeviceScene(sub_device); + auto sub_dscene = new DeviceScene(sub_device); this->dscenes.push_back(sub_dscene); memset((void *)&sub_dscene->data, 0, sizeof(sub_dscene->data)); }); -- 2.30.2 From 01e96490f124a60d0241d7ecb6e88add1818801a Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 22 Mar 2023 09:28:28 +0100 Subject: [PATCH 20/96] Change params for host_mem_alloc to host_mem_alloc(size_t size, int aligment) The parameters for host_mem_alloc were changed to `host_mem_alloc(size_t size, int aligment) from host_mem_alloc(size_t size, int aligment, void **p_mem) --- intern/cycles/device/cuda/device_impl.cpp | 7 +++++-- intern/cycles/device/cuda/device_impl.h | 2 +- intern/cycles/device/device.cpp | 4 ++-- intern/cycles/device/device.h | 2 +- intern/cycles/device/memory.cpp | 3 +-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index ca75315cc77..83e9c0a13bd 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -552,15 +552,18 @@ void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, s size)); } -void CUDADevice::host_mem_alloc(size_t size, int aligment, void **p_mem) { +void *CUDADevice::host_mem_alloc(size_t size, int aligment) { + void *p_mem = NULL; CUDAContextScope scope(this); - CUresult result = cuMemAllocHost(p_mem, size); + CUresult result = cuMemAllocHost(&p_mem, size); if(result != CUDA_SUCCESS) { char const * err_msg = NULL; cuGetErrorString(result, &err_msg); fprintf(stderr, "CUDA Runtime Error: %s\n", err_msg); assert("unable to allocate memory."); } + + return p_mem; } void CUDADevice::host_mem_free(void *p_mem) { diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index baa314b333d..864f8b29b4d 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -71,7 +71,7 @@ class CUDADevice : public GPUDevice { virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; - void host_mem_alloc(size_t size, int aligment, void **p_mem) override; + void *host_mem_alloc(size_t size, int aligment) override; void host_mem_free(void *p_mem) override; void mem_alloc(device_memory &mem) override; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index a98594e7ad6..1ae719c6047 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -452,8 +452,8 @@ void *Device::get_cpu_osl_memory() return nullptr; } -void Device::host_mem_alloc(size_t size, int alignment, void **p_mem) { - *p_mem = util_aligned_malloc(size, alignment); +void *Device::host_mem_alloc(size_t size, int alignment) { + return util_aligned_malloc(size, alignment); } void Device::host_mem_free(void *p_mem) { diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 79a8383a845..b2f515ed68b 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -301,7 +301,7 @@ class Device { friend class DeviceServer; friend class device_memory; - virtual void host_mem_alloc(size_t size, int alignment, void **p_mem); + virtual void *host_mem_alloc(size_t size, int alignment); virtual void host_mem_free(void *p_mem); virtual void mem_alloc(device_memory &mem) = 0; virtual void mem_copy_to(device_memory &mem) = 0; diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index 0e2be3cf32c..b6ab6d35ae7 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -44,8 +44,7 @@ void *device_memory::host_alloc(size_t size) return 0; } - void *ptr = NULL; - device->host_mem_alloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES, &ptr); + void *ptr = device->host_mem_alloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES); if (ptr) { util_guarded_mem_alloc(size); -- 2.30.2 From 4e1469b8bb7a9c7d81a8b1606164cfd01fae55b3 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 22 Mar 2023 11:15:24 +0100 Subject: [PATCH 21/96] Only build the BVH2 BVH once Ensures that only 1 BVH2 BVH is built for each object or scene. This is done using lock to aquire the BVH2 and other threads can skip the building if it is for an object. However, for the top level BVH all threads wait on the TLAS to be finished. --- intern/cycles/bvh/bvh.h | 2 +- intern/cycles/bvh/bvh2.h | 6 ++++ intern/cycles/device/device.cpp | 34 +++++++++++++++++++--- intern/cycles/scene/geometry.cpp | 5 +++- intern/cycles/scene/geometry_additions.cpp | 3 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 3541fe98dc8..bbc48a02a9e 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -65,7 +65,7 @@ class BVH { BVHParams params; vector geometry; vector objects; - + bool built; static BVH *create(const BVHParams ¶ms, const vector &geometry, const vector &objects, diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index 78837edcb2c..83e7bda986a 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -10,6 +10,7 @@ #include "util/types.h" #include "util/vector.h" +#include "util/thread.h" CCL_NAMESPACE_BEGIN @@ -32,6 +33,11 @@ struct BVHStackEntry { */ class BVH2 : public BVH { public: + /* The BVH2 needs to be build only once these + are used to ensure that it the case. */ + thread_mutex build_mutex; + thread_condition_variable build_cv; + void build(Progress &progress, Stats *stats); void refit(Progress &progress); diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 1ae719c6047..3432ec5d8d9 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -52,13 +52,39 @@ Device::~Device() noexcept(false) void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { assert(bvh->params.bvh_layout == BVH_LAYOUT_BVH2); - BVH2 *const bvh2 = static_cast(bvh); - if (refit) { - bvh2->refit(progress); + thread_scoped_lock build_lock(bvh2->build_mutex, std::try_to_lock); + if (build_lock) { + /* Has the BVH already been built */ + if (!bvh->built) { + /* Build the BVH */ + VLOG_INFO << "Performing BVH2 build."; + + if (refit) { + bvh2->refit(progress); + } + else { + bvh2->build(progress, &stats); + } + bvh->built = true; + VLOG_INFO << "done building BVH2"; + } + else { + VLOG_INFO << "BVH2 Already built"; + } + bvh2->build_cv.notify_all(); } else { - bvh2->build(progress, &stats); + /* Only need to wait for the top level BVH otherwise + this thread can skip on the the next object */ + if (bvh2->params.top_level) { + /* wait for BVH build to complete before proceeding */ + VLOG_INFO << "Waiting on BVH2 build."; + bvh2->build_cv.wait(build_lock); + VLOG_INFO << "done waiting on BVH2 build"; + } else { + VLOG_INFO << "Skipping BVH2 build."; + } } } diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index f36d9d26831..80d56386a45 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1222,7 +1222,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, // the correct data device_update_host_pointers(sub_device, dscene, sub_dscene, &sizes); - // Upload geometry and attribute buffers to the device + /* Upload geometry and attribute buffers to the device */ { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { @@ -1250,6 +1250,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, } }); size_t i = 0; + /* Build the Object BVHs */ foreach (Geometry *geom, scene->geometry) { if (geom->is_modified() || geom->need_update_bvh_for_offset) { geom->compute_bvh(sub_device, sub_dscene, &scene->params, &progress, i, num_bvh); @@ -1266,6 +1267,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, scene->scene_bvh_times[idx] = time; } }); + /* Build the scene BVH */ device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); device_update_bvh2(sub_device, sub_dscene, scene, progress); } @@ -1485,6 +1487,7 @@ void GeometryManager::device_update(Device *device, } { size_t num_scenes = scene->dscenes.size(); + VLOG_INFO << "Rendering using " << num_scenes << " devices"; // Parallel upload the geometry data to the devices and // calculate or refit the BVHs parallel_for( diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index 4cd98054058..dfc8ef6dda8 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -933,7 +933,8 @@ bool GeometryManager::device_update_bvh_preprocess(Device *device, if (!scene->bvh) { bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); } - + /* Mark BVH as having not been built yet */ + bvh->built = false; return can_refit; } -- 2.30.2 From 6795ee2f71ceea50ba7a97fef8cb529ff8a95588 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 22 Mar 2023 12:34:21 +0100 Subject: [PATCH 22/96] Only wait on condition_variable if mutex is locked. --- intern/cycles/device/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 3432ec5d8d9..a716a0cf361 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -80,7 +80,7 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r if (bvh2->params.top_level) { /* wait for BVH build to complete before proceeding */ VLOG_INFO << "Waiting on BVH2 build."; - bvh2->build_cv.wait(build_lock); + bvh2->build_cv.wait(build_lock, [=]() { return !(bvh2->built); }); VLOG_INFO << "done waiting on BVH2 build"; } else { VLOG_INFO << "Skipping BVH2 build."; -- 2.30.2 From 6e0875b729ac1dd1e9ae4e799696e926c9f9fd2a Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 23 Mar 2023 16:00:32 +0100 Subject: [PATCH 23/96] Only build a BVH2 BVH once Basically checks if the BVH2 BVH has been built or is being built. Then when building the top level BVH2 BVH all devices that use it wait for the one that is building it to finish before continuing. --- intern/cycles/bvh/bvh.cpp | 2 +- intern/cycles/bvh/bvh.h | 1 + intern/cycles/bvh/bvh2.cpp | 2 +- intern/cycles/device/device.cpp | 17 +++++++++-------- intern/cycles/scene/geometry.cpp | 3 +-- intern/cycles/scene/geometry.h | 2 +- intern/cycles/scene/geometry_additions.cpp | 15 ++++++++++++--- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 9f6968aea32..d367141132e 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -70,7 +70,7 @@ BVHLayout BVHParams::best_bvh_layout(BVHLayout requested_layout, BVHLayoutMask s BVH::BVH(const BVHParams ¶ms_, const vector &geometry_, const vector &objects_) - : params(params_), geometry(geometry_), objects(objects_) + : params(params_), geometry(geometry_), objects(objects_), built(false) { } diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index bbc48a02a9e..037a8fbaa9a 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -85,6 +85,7 @@ class BVH { { this->geometry = geometry; this->objects = objects; + this->built = false; } protected: diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index cd1d51d19ec..83c05356492 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -36,7 +36,7 @@ BVH2::BVH2(const BVHParams ¶ms_, void BVH2::build(Progress &progress, Stats *) { - progress.set_substatus("Building BVH"); + progress.set_substatus("Building BVH2 BVH"); /* build nodes */ BVHBuild bvh_build(objects, diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index a716a0cf361..845e6d0be42 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -58,7 +58,7 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r /* Has the BVH already been built */ if (!bvh->built) { /* Build the BVH */ - VLOG_INFO << "Performing BVH2 build."; + VLOG_INFO << std::this_thread::get_id() << ": Performing BVH2 build."; if (refit) { bvh2->refit(progress); @@ -67,23 +67,24 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r bvh2->build(progress, &stats); } bvh->built = true; - VLOG_INFO << "done building BVH2"; + VLOG_INFO << std::this_thread::get_id() << ": done building BVH2"; } else { - VLOG_INFO << "BVH2 Already built"; + VLOG_INFO << std::this_thread::get_id() << ": BVH2 Already built"; } bvh2->build_cv.notify_all(); } else { /* Only need to wait for the top level BVH otherwise - this thread can skip on the the next object */ + this thread can skip on to the next object */ if (bvh2->params.top_level) { + //thread_scoped_lock build_wait_lock(bvh2->build_mutex); /* wait for BVH build to complete before proceeding */ - VLOG_INFO << "Waiting on BVH2 build."; - bvh2->build_cv.wait(build_lock, [=]() { return !(bvh2->built); }); - VLOG_INFO << "done waiting on BVH2 build"; + VLOG_INFO << std::this_thread::get_id() << ": Waiting on BVH2 build."; + bvh2->build_cv.wait(build_lock/*wait_lock*/, [=]() { return (bvh2->built); }); + VLOG_INFO << std::this_thread::get_id() << ": done waiting on BVH2 build"; } else { - VLOG_INFO << "Skipping BVH2 build."; + VLOG_INFO << std::this_thread::get_id() << ": Skipping BVH2 build."; } } } diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 80d56386a45..1701c1f12a5 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1326,8 +1326,7 @@ size_t GeometryManager::createObjectBVHs(Device *device, if (geom->is_modified() || geom->need_update_bvh_for_offset) { need_update_scene_bvh = true; Object *object = &object_pool[id]; - geom->create_new_bvh_if_needed(object, device, dscene, &scene->params); - if (geom->need_build_bvh(bvh_layout)) { + if(geom->create_new_bvh_if_needed(object, device, dscene, &scene->params)) { num_bvh++; } } diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index c9572900356..35b6b8cba62 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -108,7 +108,7 @@ class Geometry : public Node { int motion_step(float time) const; /* BVH */ - void create_new_bvh_if_needed(Object *object, + bool create_new_bvh_if_needed(Object *object, Device *device, DeviceScene *dscene, SceneParams *params); diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index dfc8ef6dda8..54b397b68f6 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -805,11 +805,12 @@ void GeometryManager::device_update_bvh_postprocess(Device *device, dscene->data.device_bvh = 0; } -void Geometry::create_new_bvh_if_needed(Object *object, +bool Geometry::create_new_bvh_if_needed(Object *object, Device *device, DeviceScene *dscene, SceneParams *params) { + bool status = false; const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, device->get_bvh_layout_mask()); if (need_build_bvh(bvh_layout)) { @@ -849,7 +850,10 @@ void Geometry::create_new_bvh_if_needed(Object *object, bvh = BVH::create(bparams, geometry, objects, device); need_update_rebuild = true; } + status = true; } + + return status; } void GeometryManager::device_update_sub_bvh(Device *device, @@ -893,8 +897,13 @@ void GeometryManager::device_update_sub_bvh(Device *device, if (sub_bvh != NULL) { delete sub_bvh; } - sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device); - bvh->set_device_bvh(device, sub_bvh); + VLOG_INFO << "Sub-BVH using layout " << bvh_layout_name(bparams.bvh_layout) << " from layout " << bvh_layout_name(bvh->params.bvh_layout); + /* BVH2 should not have a sub-bvh as only 1 is built on the CPU */ + assert(bparams.bvh_layout != BVH_LAYOUT_BVH2); + if(bparams.bvh_layout != BVH_LAYOUT_BVH2) { + sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device); + bvh->set_device_bvh(device, sub_bvh); + } } can_refit = false; } -- 2.30.2 From c952e5d15913b238819219d1e4f6f53a51dfd26c Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 27 Mar 2023 17:53:59 +0200 Subject: [PATCH 24/96] FIX: Fix memory leak when using more than 1 device The mult-device set the device pointer for the device_memory as it iterated through the devices. However, it did not restore the original pointer to the device if the device_ptr (pointer to the memory buffer) was 0 which it always is after a mem_free. --- intern/cycles/device/multi/device.cpp | 70 ++++++++++++++++++++------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 40b4442562c..09adfefff56 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -414,35 +414,71 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov void mem_free(device_memory &mem) override { device_ptr key = mem.device_pointer; - size_t existing_size = mem.device_size; + /* key is zero if the pointer is NULL */ + if (key != 0) { + size_t existing_size = mem.device_size; - /* Free memory that was allocated for all devices (see above) on each device */ - foreach (const vector &island, peer_islands) { - SubDevice *owner_sub = find_matching_mem_device(key, island.front()); - mem.device = owner_sub->device; - mem.device_pointer = owner_sub->ptr_map[key]; - mem.device_size = existing_size; + /* Free memory that was allocated for all devices (see above) on each device */ + foreach (const vector &island, peer_islands) { + SubDevice *owner_sub = find_matching_mem_device(key, island.front()); + mem.device = owner_sub->device; + mem.device_pointer = owner_sub->ptr_map[key]; + mem.device_size = existing_size; + owner_sub->device->mem_free(mem); + owner_sub->ptr_map.erase(owner_sub->ptr_map.find(key)); - owner_sub->device->mem_free(mem); - owner_sub->ptr_map.erase(owner_sub->ptr_map.find(key)); - - if (mem.type == MEM_TEXTURE) { - /* Free texture objects on all devices */ - foreach (SubDevice *island_sub, island) { - if (island_sub != owner_sub) { - island_sub->device->mem_free(mem); + if (mem.type == MEM_TEXTURE) { + /* Free texture objects on all devices */ + foreach (SubDevice *island_sub, island) { + if (island_sub != owner_sub) { + island_sub->device->mem_free(mem); + } } } } - } - if (mem.device_pointer) { + /* restore the device */ mem.device = this; + + /* NULL the pointer and size and update the memory tracking */ mem.device_pointer = 0; mem.device_size = 0; stats.mem_free(existing_size); } } + + // void mem_free(device_memory &mem) override + // { + // device_ptr key = mem.device_pointer; + // size_t existing_size = mem.device_size; + + // /* Free memory that was allocated for all devices (see above) on each device */ + // foreach (const vector &island, peer_islands) { + // SubDevice *owner_sub = find_matching_mem_device(key, island.front()); + // mem.device = owner_sub->device; + // mem.device_pointer = owner_sub->ptr_map[key]; + // mem.device_size = existing_size; + + // owner_sub->device->mem_free(mem); + // owner_sub->ptr_map.erase(owner_sub->ptr_map.find(key)); + + // if (mem.type == MEM_TEXTURE) { + // /* Free texture objects on all devices */ + // foreach (SubDevice *island_sub, island) { + // if (island_sub != owner_sub) { + // island_sub->device->mem_free(mem); + // } + // } + // } + // } + + // if (mem.device_pointer) { + // mem.device = this; + // mem.device_pointer = 0; + // mem.device_size = 0; + // stats.mem_free(existing_size); + // } + // } void const_copy_to(const char *name, void *host, size_t size) override { -- 2.30.2 From 3a566ccee46169dbf34799704436cff6dee131cd Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 28 Mar 2023 13:23:31 +0200 Subject: [PATCH 25/96] FIX: Using the Optix BVH for the NVidia device Optix device was using the multi-bvh as the Optix BVH which was causing the device to have the wrong handles for the objects. --- intern/cycles/device/optix/device_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index cbd00bfe12e..36c8acf5418 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -1433,7 +1433,7 @@ void OptiXDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, b continue; } - BVHOptiX *const blas = static_cast(ob->get_geometry()->bvh); + BVHOptiX *const blas = static_cast(ob->get_geometry()->bvh->get_device_bvh(this)); OptixTraversableHandle handle = blas->traversable_handle; if (handle == 0) { continue; -- 2.30.2 From b0345701a05f36d5731a5e130a2a5f164bc3ff8d Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 9 Mar 2023 09:12:41 +0100 Subject: [PATCH 26/96] FIX:Use the headless flag to switch on/off progress updates Don't do progress updates when in headless mode. Previously the background flag was used but this is also used for F12 render. Which needs the updates. --- intern/cycles/blender/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index b343ef5f8ce..198312a6b0a 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -125,7 +125,7 @@ void BlenderSession::create_session() session = new Session(session_params, scene_params); session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this)); session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this)); - session->progress.set_updates(!background); + session->progress.set_updates(!headless); session->set_pause(session_pause); /* create scene */ -- 2.30.2 From d59a30b4a09ce8012181482962d3e3cd701790e1 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 28 Mar 2023 14:52:12 +0200 Subject: [PATCH 27/96] FIX: Lock mutex before using condition variable waiting on BVH build Mutex needs to be locked before using the condition variable can be used. This adds a scoped lock to ensure it is locked before waiting on the condition_variable. --- intern/cycles/device/device.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 845e6d0be42..ba281f414e1 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -78,10 +78,10 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r /* Only need to wait for the top level BVH otherwise this thread can skip on to the next object */ if (bvh2->params.top_level) { - //thread_scoped_lock build_wait_lock(bvh2->build_mutex); + thread_scoped_lock build_wait_lock(bvh2->build_mutex); /* wait for BVH build to complete before proceeding */ VLOG_INFO << std::this_thread::get_id() << ": Waiting on BVH2 build."; - bvh2->build_cv.wait(build_lock/*wait_lock*/, [=]() { return (bvh2->built); }); + bvh2->build_cv.wait(build_wait_lock, [=]() { return (bvh2->built); }); VLOG_INFO << std::this_thread::get_id() << ": done waiting on BVH2 build"; } else { VLOG_INFO << std::this_thread::get_id() << ": Skipping BVH2 build."; -- 2.30.2 From b75f6ad788ace369db3cb83af753d81a0329f149 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 29 Mar 2023 10:09:35 +0200 Subject: [PATCH 28/96] FIX: Make sure top level BVH is built after all other BVHs The top level BVH can only be built once all the other (bottom level) BVHs are completed. --- intern/cycles/device/device.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index ba281f414e1..1c06ad372c3 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -53,13 +53,24 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r { assert(bvh->params.bvh_layout == BVH_LAYOUT_BVH2); BVH2 *const bvh2 = static_cast(bvh); + static std::atomic building{0}; + /* Top level BVH2 build must wait on all other BVH2 builds to finish + otherwise the top level BVH2 will not have all the correct data + */ + if(bvh2->params.top_level) { + thread_scoped_lock build_wait_lock(bvh2->build_mutex); + /* Wait for other BVH2 builds to complete before proceeding */ + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Waiting on other BVH2 builds."; + bvh2->build_cv.wait(build_wait_lock, [=]() { return (building == 0); }); + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Done waiting on other BVH2 builds"; + } thread_scoped_lock build_lock(bvh2->build_mutex, std::try_to_lock); if (build_lock) { - /* Has the BVH already been built */ + /* Has the BVH already been built? */ if (!bvh->built) { + building++; /* Build the BVH */ - VLOG_INFO << std::this_thread::get_id() << ": Performing BVH2 build."; - + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Performing BVH2 build."; if (refit) { bvh2->refit(progress); } @@ -67,10 +78,11 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r bvh2->build(progress, &stats); } bvh->built = true; - VLOG_INFO << std::this_thread::get_id() << ": done building BVH2"; + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Done building BVH2"; + building--; } else { - VLOG_INFO << std::this_thread::get_id() << ": BVH2 Already built"; + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " BVH2 Already built"; } bvh2->build_cv.notify_all(); } @@ -80,11 +92,11 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r if (bvh2->params.top_level) { thread_scoped_lock build_wait_lock(bvh2->build_mutex); /* wait for BVH build to complete before proceeding */ - VLOG_INFO << std::this_thread::get_id() << ": Waiting on BVH2 build."; + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Waiting on BVH2 build."; bvh2->build_cv.wait(build_wait_lock, [=]() { return (bvh2->built); }); - VLOG_INFO << std::this_thread::get_id() << ": done waiting on BVH2 build"; + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Done waiting on BVH2 build"; } else { - VLOG_INFO << std::this_thread::get_id() << ": Skipping BVH2 build."; + VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Skipping BVH2 build."; } } } -- 2.30.2 From a27247e28ff58cec59ac32e99d434fd6c0627af7 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 6 Apr 2023 11:07:20 +0200 Subject: [PATCH 29/96] Refactor geometry.cpp and geometry_additions.cpp This breaks up the geometry.cpp and geometry_additions.cpp into the following files: - geometry.cpp - geometry_mesh.cpp - geometry_attributes.cpp - geometry_bvh.cpp so as to organise the code into more manageable pieces. --- intern/cycles/scene/CMakeLists.txt | 4 +- intern/cycles/scene/geometry.cpp | 909 +++++++++----------- intern/cycles/scene/geometry.h | 32 + intern/cycles/scene/geometry_additions.cpp | 648 -------------- intern/cycles/scene/geometry_attributes.cpp | 716 +++++++++++++++ intern/cycles/scene/geometry_bvh.cpp | 325 +++++++ intern/cycles/scene/geometry_mesh.cpp | 192 +++++ 7 files changed, 1659 insertions(+), 1167 deletions(-) create mode 100644 intern/cycles/scene/geometry_attributes.cpp create mode 100644 intern/cycles/scene/geometry_bvh.cpp create mode 100644 intern/cycles/scene/geometry_mesh.cpp diff --git a/intern/cycles/scene/CMakeLists.txt b/intern/cycles/scene/CMakeLists.txt index cf83bd9c431..e0be20a6f7f 100644 --- a/intern/cycles/scene/CMakeLists.txt +++ b/intern/cycles/scene/CMakeLists.txt @@ -17,7 +17,9 @@ set(SRC constant_fold.cpp film.cpp geometry.cpp - geometry_additions.cpp + geometry_mesh.cpp + geometry_bvh.cpp + geometry_attributes.cpp hair.cpp image.cpp image_oiio.cpp diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 503703a80d1..b4e21b5f01d 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -280,448 +280,27 @@ void GeometryManager::update_osl_globals(Device *device, Scene *scene) #endif } -/* Generate a normal attribute map entry from an attribute descriptor. */ -static void emit_attribute_map_entry(AttributeMap *attr_map, - size_t index, - uint64_t id, - TypeDesc type, - const AttributeDescriptor &desc) + +static void update_attribute_realloc_flags(uint32_t &device_update_flags, + const AttributeSet &attributes) { - attr_map[index].id = id; - attr_map[index].element = desc.element; - attr_map[index].offset = as_uint(desc.offset); - - if (type == TypeDesc::TypeFloat) - attr_map[index].type = NODE_ATTR_FLOAT; - else if (type == TypeDesc::TypeMatrix) - attr_map[index].type = NODE_ATTR_MATRIX; - else if (type == TypeFloat2) - attr_map[index].type = NODE_ATTR_FLOAT2; - else if (type == TypeFloat4) - attr_map[index].type = NODE_ATTR_FLOAT4; - else if (type == TypeRGBA) - attr_map[index].type = NODE_ATTR_RGBA; - else - attr_map[index].type = NODE_ATTR_FLOAT3; - - attr_map[index].flags = desc.flags; -} - -/* Generate an attribute map end marker, optionally including a link to another map. - * Links are used to connect object attribute maps to mesh attribute maps. */ -static void emit_attribute_map_terminator(AttributeMap *attr_map, - size_t index, - bool chain, - uint chain_link) -{ - for (int j = 0; j < ATTR_PRIM_TYPES; j++) { - attr_map[index + j].id = ATTR_STD_NONE; - attr_map[index + j].element = chain; /* link is valid flag */ - attr_map[index + j].offset = chain ? chain_link + j : 0; /* link to the correct sub-entry */ - attr_map[index + j].type = 0; - attr_map[index + j].flags = 0; + if (attributes.modified(AttrKernelDataType::FLOAT)) { + device_update_flags |= ATTR_FLOAT_NEEDS_REALLOC; + } + if (attributes.modified(AttrKernelDataType::FLOAT2)) { + device_update_flags |= ATTR_FLOAT2_NEEDS_REALLOC; + } + if (attributes.modified(AttrKernelDataType::FLOAT3)) { + device_update_flags |= ATTR_FLOAT3_NEEDS_REALLOC; + } + if (attributes.modified(AttrKernelDataType::FLOAT4)) { + device_update_flags |= ATTR_FLOAT4_NEEDS_REALLOC; + } + if (attributes.modified(AttrKernelDataType::UCHAR4)) { + device_update_flags |= ATTR_UCHAR4_NEEDS_REALLOC; } } -/* Generate all necessary attribute map entries from the attribute request. */ -static void emit_attribute_mapping( - AttributeMap *attr_map, size_t index, uint64_t id, AttributeRequest &req, Geometry *geom) -{ - emit_attribute_map_entry(attr_map, index, id, req.type, req.desc); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - if (mesh->get_num_subd_faces()) { - emit_attribute_map_entry(attr_map, index + 1, id, req.subd_type, req.subd_desc); - } - } -} - -void GeometryManager::update_svm_attributes(Device *, - DeviceScene *dscene, - Scene *scene, - vector &geom_attributes, - vector &object_attributes) -{ - /* for SVM, the attributes_map table is used to lookup the offset of an - * attribute, based on a unique shader attribute id. */ - - /* compute array stride */ - size_t attr_map_size = 0; - - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - geom->attr_map_offset = attr_map_size; - -#ifdef WITH_OSL - size_t attr_count = 0; - foreach (AttributeRequest &req, geom_attributes[i].requests) { - if (req.std != ATTR_STD_NONE && - scene->shader_manager->get_attribute_id(req.std) != (uint64_t)req.std) - attr_count += 2; - else - attr_count += 1; - } -#else - const size_t attr_count = geom_attributes[i].size(); -#endif - - attr_map_size += (attr_count + 1) * ATTR_PRIM_TYPES; - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - - /* only allocate a table for the object if it actually has attributes */ - if (object_attributes[i].size() == 0) { - object->attr_map_offset = 0; - } - else { - object->attr_map_offset = attr_map_size; - attr_map_size += (object_attributes[i].size() + 1) * ATTR_PRIM_TYPES; - } - } - - if (attr_map_size == 0) - return; - - if (!dscene->attributes_map.need_realloc()) { - return; - } - - /* create attribute map */ - AttributeMap *attr_map = dscene->attributes_map.alloc(attr_map_size); - memset(attr_map, 0, dscene->attributes_map.size() * sizeof(*attr_map)); - - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - AttributeRequestSet &attributes = geom_attributes[i]; - - /* set geometry attributes */ - size_t index = geom->attr_map_offset; - - foreach (AttributeRequest &req, attributes.requests) { - uint64_t id; - if (req.std == ATTR_STD_NONE) - id = scene->shader_manager->get_attribute_id(req.name); - else - id = scene->shader_manager->get_attribute_id(req.std); - - emit_attribute_mapping(attr_map, index, id, req, geom); - index += ATTR_PRIM_TYPES; - -#ifdef WITH_OSL - /* Some standard attributes are explicitly referenced via their standard ID, so add those - * again in case they were added under a different attribute ID. */ - if (req.std != ATTR_STD_NONE && id != (uint64_t)req.std) { - emit_attribute_mapping(attr_map, index, (uint64_t)req.std, req, geom); - index += ATTR_PRIM_TYPES; - } -#endif - } - - emit_attribute_map_terminator(attr_map, index, false, 0); - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - AttributeRequestSet &attributes = object_attributes[i]; - - /* set object attributes */ - if (attributes.size() > 0) { - size_t index = object->attr_map_offset; - - foreach (AttributeRequest &req, attributes.requests) { - uint64_t id; - if (req.std == ATTR_STD_NONE) - id = scene->shader_manager->get_attribute_id(req.name); - else - id = scene->shader_manager->get_attribute_id(req.std); - - emit_attribute_mapping(attr_map, index, id, req, object->geometry); - index += ATTR_PRIM_TYPES; - } - - emit_attribute_map_terminator(attr_map, index, true, object->geometry->attr_map_offset); - } - } - - /* copy to device */ - /* Copy moved to device_update_attributes */ - dscene->attributes_map.tag_modified(); -} - -/* - * Copies the attribute data into the buffers and records - * the offsets - */ -void GeometryManager::update_attribute_element_offset(Geometry *geom, - device_vector &attr_float, - size_t &attr_float_offset, - device_vector &attr_float2, - size_t &attr_float2_offset, - device_vector &attr_float3, - size_t &attr_float3_offset, - device_vector &attr_float4, - size_t &attr_float4_offset, - device_vector &attr_uchar4, - size_t &attr_uchar4_offset, - Attribute *mattr, - AttributePrimitive prim, - TypeDesc &type, - AttributeDescriptor &desc) -{ - if (mattr) { - /* store element and type */ - desc.element = mattr->element; - desc.flags = mattr->flags; - type = mattr->type; - - /* store attribute data in arrays */ - size_t size = mattr->element_size(geom, prim); - - AttributeElement &element = desc.element; - int &offset = desc.offset; - - if (mattr->element == ATTR_ELEMENT_VOXEL) { - /* store slot in offset value */ - ImageHandle &handle = mattr->data_voxel(); - offset = handle.svm_slot(); - } - else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { - uchar4 *data = mattr->data_uchar4(); - offset = attr_uchar4_offset; - - assert(attr_uchar4.size() >= offset + size); - if (mattr->modified) { - for (size_t k = 0; k < size; k++) { - attr_uchar4[offset + k] = data[k]; - } - attr_uchar4.tag_modified(); - } - attr_uchar4_offset += size; - } - else if (mattr->type == TypeDesc::TypeFloat) { - float *data = mattr->data_float(); - offset = attr_float_offset; - - assert(attr_float.size() >= offset + size); - if (mattr->modified) { - for (size_t k = 0; k < size; k++) { - attr_float[offset + k] = data[k]; - } - attr_float.tag_modified(); - } - attr_float_offset += size; - } - else if (mattr->type == TypeFloat2) { - float2 *data = mattr->data_float2(); - offset = attr_float2_offset; - - assert(attr_float2.size() >= offset + size); - if (mattr->modified) { - for (size_t k = 0; k < size; k++) { - attr_float2[offset + k] = data[k]; - } - attr_float2.tag_modified(); - } - attr_float2_offset += size; - } - else if (mattr->type == TypeDesc::TypeMatrix) { - Transform *tfm = mattr->data_transform(); - offset = attr_float4_offset; - - assert(attr_float4.size() >= offset + size * 3); - if (mattr->modified) { - for (size_t k = 0; k < size * 3; k++) { - attr_float4[offset + k] = (&tfm->x)[k]; - } - attr_float4.tag_modified(); - } - attr_float4_offset += size * 3; - } - else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { - float4 *data = mattr->data_float4(); - offset = attr_float4_offset; - - assert(attr_float4.size() >= offset + size); - if (mattr->modified) { - for (size_t k = 0; k < size; k++) { - attr_float4[offset + k] = data[k]; - } - attr_float4.tag_modified(); - } - attr_float4_offset += size; - } - else { - float3 *data = mattr->data_float3(); - offset = attr_float3_offset; - - // Records where the motion vertices are in the attribute array - // so that they can be used later to reference the data when building - // the BVHs. - if (mattr->std == ATTR_STD_MOTION_VERTEX_POSITION) { - geom->motion_key_offset = offset; - } - - assert(attr_float3.size() >= offset + size); - if (mattr->modified) { - for (size_t k = 0; k < size; k++) { - attr_float3[offset + k] = data[k]; - } - attr_float3.tag_modified(); - } - attr_float3_offset += size; - } - - /* mesh vertex/curve index is global, not per object, so we sneak - * a correction for that in here */ - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - if (mesh->subdivision_type == Mesh::SUBDIVISION_CATMULL_CLARK && - desc.flags & ATTR_SUBDIVIDED) { - /* Indices for subdivided attributes are retrieved - * from patch table so no need for correction here. */ - } - else if (element == ATTR_ELEMENT_VERTEX) - offset -= mesh->vert_offset; - else if (element == ATTR_ELEMENT_VERTEX_MOTION) - offset -= mesh->vert_offset; - else if (element == ATTR_ELEMENT_FACE) { - if (prim == ATTR_PRIM_GEOMETRY) - offset -= mesh->prim_offset; - else - offset -= mesh->face_offset; - } - else if (element == ATTR_ELEMENT_CORNER || element == ATTR_ELEMENT_CORNER_BYTE) { - if (prim == ATTR_PRIM_GEOMETRY) - offset -= 3 * mesh->prim_offset; - else - offset -= mesh->corner_offset; - } - } - else if (geom->is_hair()) { - Hair *hair = static_cast(geom); - if (element == ATTR_ELEMENT_CURVE) - offset -= hair->prim_offset; - else if (element == ATTR_ELEMENT_CURVE_KEY) - offset -= hair->curve_key_offset; - else if (element == ATTR_ELEMENT_CURVE_KEY_MOTION) - offset -= hair->curve_key_offset; - } - else if (geom->is_pointcloud()) { - if (element == ATTR_ELEMENT_VERTEX) - offset -= geom->prim_offset; - else if (element == ATTR_ELEMENT_VERTEX_MOTION) - offset -= geom->prim_offset; - } - } - else { - /* attribute not found */ - desc.element = ATTR_ELEMENT_NONE; - desc.offset = 0; - } -} - -/* - * Copies the attribute buffer data to the devices - */ -void GeometryManager::device_update_attributes(Device *device, - DeviceScene *dscene, - const AttributeSizes *sizes, - Progress &progress) -{ - progress.set_status("Updating Mesh", "Copying Attributes to device"); - /* copy svm attributes to device */ - dscene->attributes_map.copy_to_device_if_modified(); - dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); - dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); - dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); - dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); - dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); - dscene->objects.copy_to_device_if_modified(); -} - -/** - * This copies the data to the devices if they have been modified - */ -void GeometryManager::device_update_mesh(Device *device, - DeviceScene *dscene, - const GeometrySizes *p_sizes, - Progress &progress) -{ - progress.set_status("Updating Mesh", "Copying Mesh to device"); - if (p_sizes->tri_size != 0) { - dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); - dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); - dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); - } - - if (p_sizes->curve_segment_size != 0) { - dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); - dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); - dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); - } - - if (p_sizes->point_size != 0) { - dscene->points.copy_to_device(p_sizes->point_size, 0); - dscene->points_shader.copy_to_device(p_sizes->point_size, 0); - } - - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - dscene->patches.copy_to_device(p_sizes->patch_size, 0); - } -} - -void GeometryManager::device_update_bvh(Device *device, - DeviceScene *dscene, - Scene *scene, - bool can_refit, - size_t n, - size_t total, - Progress &progress) -{ - BVH *bvh = scene->bvh; - BVH *sub_bvh = scene->bvh->get_device_bvh(device); - GeometryManager::device_update_sub_bvh( - device, dscene, bvh, sub_bvh, can_refit, n, total, &progress); -} - -/* Set of flags used to help determining what data has been modified or needs reallocation, so we - * can decide which device data to free or update. */ -enum { - DEVICE_CURVE_DATA_MODIFIED = (1 << 0), - DEVICE_MESH_DATA_MODIFIED = (1 << 1), - DEVICE_POINT_DATA_MODIFIED = (1 << 2), - - ATTR_FLOAT_MODIFIED = (1 << 3), - ATTR_FLOAT2_MODIFIED = (1 << 4), - ATTR_FLOAT3_MODIFIED = (1 << 5), - ATTR_FLOAT4_MODIFIED = (1 << 6), - ATTR_UCHAR4_MODIFIED = (1 << 7), - - CURVE_DATA_NEED_REALLOC = (1 << 8), - MESH_DATA_NEED_REALLOC = (1 << 9), - POINT_DATA_NEED_REALLOC = (1 << 10), - - ATTR_FLOAT_NEEDS_REALLOC = (1 << 11), - ATTR_FLOAT2_NEEDS_REALLOC = (1 << 12), - ATTR_FLOAT3_NEEDS_REALLOC = (1 << 13), - ATTR_FLOAT4_NEEDS_REALLOC = (1 << 14), - - ATTR_UCHAR4_NEEDS_REALLOC = (1 << 15), - - ATTRS_NEED_REALLOC = (ATTR_FLOAT_NEEDS_REALLOC | ATTR_FLOAT2_NEEDS_REALLOC | - ATTR_FLOAT3_NEEDS_REALLOC | ATTR_FLOAT4_NEEDS_REALLOC | - ATTR_UCHAR4_NEEDS_REALLOC), - DEVICE_MESH_DATA_NEEDS_REALLOC = (MESH_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), - DEVICE_POINT_DATA_NEEDS_REALLOC = (POINT_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), - DEVICE_CURVE_DATA_NEEDS_REALLOC = (CURVE_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), -}; - static void update_device_flags_attribute(uint32_t &device_update_flags, const AttributeSet &attributes) { @@ -760,26 +339,6 @@ static void update_device_flags_attribute(uint32_t &device_update_flags, } } -static void update_attribute_realloc_flags(uint32_t &device_update_flags, - const AttributeSet &attributes) -{ - if (attributes.modified(AttrKernelDataType::FLOAT)) { - device_update_flags |= ATTR_FLOAT_NEEDS_REALLOC; - } - if (attributes.modified(AttrKernelDataType::FLOAT2)) { - device_update_flags |= ATTR_FLOAT2_NEEDS_REALLOC; - } - if (attributes.modified(AttrKernelDataType::FLOAT3)) { - device_update_flags |= ATTR_FLOAT3_NEEDS_REALLOC; - } - if (attributes.modified(AttrKernelDataType::FLOAT4)) { - device_update_flags |= ATTR_FLOAT4_NEEDS_REALLOC; - } - if (attributes.modified(AttrKernelDataType::UCHAR4)) { - device_update_flags |= ATTR_UCHAR4_NEEDS_REALLOC; - } -} - void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Progress &progress) { if (!need_update() && !need_flags_update) { @@ -1295,67 +854,7 @@ void GeometryManager::updateObjectBounds(Scene *scene) } } -/* - * Creates a new BVH for the geometry if it is needed otherwise - * it determines if the BVH can be refitted. It also counts - * the number of BVH that need to be built. - */ -size_t GeometryManager::createObjectBVHs(Device *device, - DeviceScene *dscene, - Scene *scene, - const BVHLayout bvh_layout, - bool &need_update_scene_bvh) -{ - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (object BVHs preprocess)", time}); - } - }); - size_t num_bvh = 0; - if (scene->geometry.size() > object_pool.size()) { - object_pool.resize(scene->geometry.size()); - } - - // Create BVH structures where needed - int id = 0; - foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified() || geom->need_update_bvh_for_offset) { - need_update_scene_bvh = true; - Object *object = &object_pool[id]; - if(geom->create_new_bvh_if_needed(object, device, dscene, &scene->params)) { - num_bvh++; - } - } - id++; - } - - return num_bvh; -} - -/* - * Prepares scene BVH for building or refitting. Then builds or refits the scene - * BVH for all the devices. - */ -void GeometryManager::updateSceneBVHs(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); - } - }); - - bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); - foreach (auto sub_dscene, scene->dscenes) { - Device *sub_device = sub_dscene->tri_verts.device; - device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); - } - device_update_bvh_postprocess(device, dscene, scene, progress); -} /* * Tesselates any modified object that requires it. @@ -1595,4 +1094,378 @@ void GeometryManager::collect_statistics(const Scene *scene, RenderStats *stats) } } +/* + * Clears all tags used to indicate the the shader needs to be updated. + */ +void GeometryManager::clearShaderUpdateTags(Scene *scene) +{ + /* unset flags */ + foreach (Shader *shader, scene->shaders) { + shader->need_update_uvs = false; + shader->need_update_attribute = false; + shader->need_update_displacement = false; + } +} + +/* + * Clears all tags used to indicate the the geometry needs to be updated + * or has been modified. + */ +void GeometryManager::clearGeometryUpdateAndModifiedTags(Scene *scene) +{ + // Clear update tags + foreach (Geometry *geom, scene->geometry) { + // Clear update indicators + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + geom->need_update_rebuild = false; + geom->need_update_bvh_for_offset = false; + } + + // Clear modified tags + geom->clear_modified(); + geom->attributes.clear_modified(); + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + mesh->subd_attributes.clear_modified(); + } + } +} + +/* + * Clears the modified tags for all elements of the device scene + */ +void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) +{ + dscene->bvh_nodes.clear_modified(); + dscene->bvh_leaf_nodes.clear_modified(); + dscene->object_node.clear_modified(); + dscene->prim_type.clear_modified(); + dscene->prim_visibility.clear_modified(); + dscene->prim_index.clear_modified(); + dscene->prim_object.clear_modified(); + dscene->prim_time.clear_modified(); + dscene->tri_verts.clear_modified(); + dscene->tri_shader.clear_modified(); + dscene->tri_vindex.clear_modified(); + dscene->tri_patch.clear_modified(); + dscene->tri_vnormal.clear_modified(); + dscene->tri_patch_uv.clear_modified(); + dscene->curves.clear_modified(); + dscene->curve_keys.clear_modified(); + dscene->curve_segments.clear_modified(); + dscene->points.clear_modified(); + dscene->points_shader.clear_modified(); + dscene->patches.clear_modified(); + dscene->attributes_map.clear_modified(); + dscene->attributes_float.clear_modified(); + dscene->attributes_float2.clear_modified(); + dscene->attributes_float3.clear_modified(); + dscene->attributes_float4.clear_modified(); + dscene->attributes_uchar4.clear_modified(); + dscene->objects.clear_modified(); + dscene->attributes_map.clear_modified(); +} + + + + + +/* + * Assigns the host pointers to the sub-devicescenes so + * that they all have the same data sources + */ +void GeometryManager::device_update_host_pointers(Device *device, + DeviceScene *dscene, + DeviceScene *sub_dscene, + GeometrySizes *p_sizes) +{ + if (p_sizes->tri_size != 0) { + if (dscene->tri_verts.is_modified()) { + sub_dscene->tri_verts.assign_mem(dscene->tri_verts); + sub_dscene->tri_verts.tag_modified(); + } + { + if (dscene->tri_shader.is_modified()) { + sub_dscene->tri_shader.assign_mem(dscene->tri_shader); + sub_dscene->tri_shader.tag_modified(); + } + } + { + if (dscene->tri_vnormal.is_modified()) { + sub_dscene->tri_vnormal.assign_mem(dscene->tri_vnormal); + sub_dscene->tri_vnormal.tag_modified(); + } + } + { + if (dscene->tri_vindex.is_modified()) { + sub_dscene->tri_vindex.assign_mem(dscene->tri_vindex); + sub_dscene->tri_vindex.tag_modified(); + } + } + { + if (dscene->tri_patch.is_modified()) { + sub_dscene->tri_patch.assign_mem(dscene->tri_patch); + sub_dscene->tri_patch.tag_modified(); + } + } + { + if (dscene->tri_patch_uv.is_modified()) { + sub_dscene->tri_patch_uv.assign_mem(dscene->tri_patch_uv); + sub_dscene->tri_patch_uv.tag_modified(); + } + } + } + + if (p_sizes->curve_segment_size != 0) { + if (dscene->curve_keys.is_modified()) { + sub_dscene->curve_keys.assign_mem(dscene->curve_keys); + sub_dscene->curve_keys.tag_modified(); + } + + if (dscene->curves.is_modified()) { + sub_dscene->curves.assign_mem(dscene->curves); + sub_dscene->curves.tag_modified(); + } + + if (dscene->curve_segments.is_modified()) { + sub_dscene->curve_segments.assign_mem(dscene->curve_segments); + } + } + + if (p_sizes->point_size != 0) { + // TODO: Why does this not check the modified tag? + sub_dscene->points.assign_mem(dscene->points); + // sub_dscene->points.tag_modified(); + + sub_dscene->points_shader.assign_mem(dscene->points_shader); + // sub_dscene->points_shader.tag_modified(); + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + sub_dscene->patches.assign_mem(dscene->patches); + } + + // Update the Attributes + if (dscene->attributes_map.is_modified()) { + sub_dscene->attributes_map.assign_mem(dscene->attributes_map); + sub_dscene->attributes_map.tag_modified(); + } + if (dscene->attributes_float.is_modified()) { + sub_dscene->attributes_float.assign_mem(dscene->attributes_float); + sub_dscene->attributes_float.tag_modified(); + } + if (dscene->attributes_float2.is_modified()) { + sub_dscene->attributes_float2.assign_mem(dscene->attributes_float2); + sub_dscene->attributes_float2.tag_modified(); + } + if (dscene->attributes_float3.is_modified()) { + sub_dscene->attributes_float3.assign_mem(dscene->attributes_float3); + sub_dscene->attributes_float3.tag_modified(); + } + if (dscene->attributes_float4.is_modified()) { + sub_dscene->attributes_float4.assign_mem(dscene->attributes_float4); + sub_dscene->attributes_float4.tag_modified(); + } + if (dscene->attributes_uchar4.is_modified()) { + sub_dscene->attributes_uchar4.assign_mem(dscene->attributes_uchar4); + sub_dscene->attributes_uchar4.tag_modified(); + } + if (dscene->objects.is_modified()) { + sub_dscene->objects.assign_mem(dscene->objects); + sub_dscene->objects.tag_modified(); + } +} + +/* + * Records all the geometry buffer sizes for later use + */ +void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) +{ + // Zero sizes + p_sizes->vert_size = 0; + p_sizes->tri_size = 0; + + p_sizes->curve_size = 0; + p_sizes->curve_key_size = 0; + p_sizes->curve_segment_size = 0; + + p_sizes->point_size = 0; + + p_sizes->patch_size = 0; + p_sizes->face_size = 0; + p_sizes->corner_size = 0; + + // Write the buffer offsets to the geometries and increment the sizes + foreach (Geometry *geom, scene->geometry) { + bool prim_offset_changed = false; + if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { + Mesh *mesh = static_cast(geom); + + prim_offset_changed = (mesh->prim_offset != p_sizes->tri_size); + + mesh->vert_offset = p_sizes->vert_size; + mesh->prim_offset = p_sizes->tri_size; + + mesh->patch_offset = p_sizes->patch_size; + mesh->face_offset = p_sizes->face_size; + mesh->corner_offset = p_sizes->corner_size; + + p_sizes->vert_size += mesh->verts.size(); + // Store extra index set for motion blur + if(mesh->get_use_motion_blur()) { + p_sizes->tri_size += 2*mesh->num_triangles(); + } else { + p_sizes->tri_size += mesh->num_triangles(); + } + + if (mesh->get_num_subd_faces()) { + Mesh::SubdFace last = mesh->get_subd_face(mesh->get_num_subd_faces() - 1); + p_sizes->patch_size += (last.ptex_offset + last.num_ptex_faces()) * 8; + + /* patch tables are stored in same array so include them in patch_size */ + if (mesh->patch_table) { + mesh->patch_table_offset = p_sizes->patch_size; + p_sizes->patch_size += mesh->patch_table->total_size(); + } + } + + p_sizes->face_size += mesh->get_num_subd_faces(); + p_sizes->corner_size += mesh->subd_face_corners.size(); + } + else if (geom->is_hair()) { + Hair *hair = static_cast(geom); + + prim_offset_changed = (hair->curve_segment_offset != p_sizes->curve_segment_size); + hair->curve_key_offset = p_sizes->curve_key_size; + hair->curve_segment_offset = p_sizes->curve_segment_size; + hair->prim_offset = p_sizes->curve_size; + + p_sizes->curve_size += hair->num_curves(); + p_sizes->curve_key_size += hair->get_curve_keys().size(); + p_sizes->curve_segment_size += hair->num_segments(); + } + else if (geom->is_pointcloud()) { + PointCloud *pointcloud = static_cast(geom); + + prim_offset_changed = (pointcloud->prim_offset != p_sizes->point_size); + + pointcloud->prim_offset = p_sizes->point_size; + p_sizes->point_size += pointcloud->num_points(); + } + // Used to determine if the BVH needs to be recalculated + // as the buffer offsets have been altered. + geom->need_update_bvh_for_offset = prim_offset_changed; + } +} + +/** + * Performs displacement and calculates shadow transparency for + * objects that require it. + */ +bool GeometryManager::displacement_and_curve_shadow_transparency( + Scene *scene, + Device *device, + DeviceScene *dscene, + GeometrySizes *sizes, + AttributeSizes *attrib_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + Progress &progress) +{ + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); + } + }); + /* Signal for shaders like displacement not to do ray tracing. */ + dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; + scene->object_manager->device_update_flags(device, dscene, scene, progress, false); + + bool displacement_done = false; + bool curve_shadow_transparency_done = false; + { + // Need to upload the attribute and mesh buffers for dispacement. + // Evaluate these on a single device (anyone will do, so use the first) + { + // Could break this out across all the devices as + // the results are read back to the host. For now, the computations + // are done on the first device. + DeviceScene *sub_dscene = scene->dscenes.front(); + Device *sub_device = sub_dscene->tri_verts.device; + { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: copy meshes to device)", time}); + } + }); + device_update_host_pointers(sub_device, dscene, sub_dscene, sizes); + device_update_attributes(sub_device, sub_dscene, attrib_sizes, progress); + device_update_mesh(sub_device, sub_dscene, sizes, progress); + } + /* Copy constant data needed by shader evaluation. */ + sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); + + foreach (Geometry *geom, scene->geometry) { + /* Update images needed for true displacement. */ + { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: load images)", time}); + } + }); + device_update_displacement_images(sub_device, scene, progress); + } + + if (geom->is_modified()) { + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + if (displace(sub_device, scene, mesh, progress)) { + displacement_done = true; + } + } + else if (geom->geometry_type == Geometry::HAIR) { + Hair *hair = static_cast(geom); + if (hair->update_shadow_transparency(sub_device, scene, progress)) { + curve_shadow_transparency_done = true; + } + } + } + } + } + + // Some host side code here as the mesh and attributes need to be + // recalculated after displacement and shadow transparency + /* Device re-update after displacement. */ + if (displacement_done || curve_shadow_transparency_done) { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: attributes)", time}); + } + }); + + // Need to redo host side filling out the attribute and mesh buffers as these may have + // changed. Hair adds a new attribute buffer and displace updates the mesh. + geom_calc_offset(scene, sizes); + gather_attributes( + scene, geom_attributes, object_attributes, object_attribute_values, attrib_sizes); + device_free(device, dscene, false); + device_update_attributes_preprocess(device, + dscene, + scene, + geom_attributes, + object_attributes, + object_attribute_values, + attrib_sizes, + progress); + device_update_mesh_preprocess(device, dscene, scene, sizes, progress); + } + } + + return scene->object_manager->need_flags_update; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 35b6b8cba62..e1893d1b8d0 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -31,6 +31,38 @@ class Volume; class Object; struct PackedBVH; +/* Set of flags used to help determining what data has been modified or needs reallocation, so we + * can decide which device data to free or update. */ +enum { + DEVICE_CURVE_DATA_MODIFIED = (1 << 0), + DEVICE_MESH_DATA_MODIFIED = (1 << 1), + DEVICE_POINT_DATA_MODIFIED = (1 << 2), + + ATTR_FLOAT_MODIFIED = (1 << 3), + ATTR_FLOAT2_MODIFIED = (1 << 4), + ATTR_FLOAT3_MODIFIED = (1 << 5), + ATTR_FLOAT4_MODIFIED = (1 << 6), + ATTR_UCHAR4_MODIFIED = (1 << 7), + + CURVE_DATA_NEED_REALLOC = (1 << 8), + MESH_DATA_NEED_REALLOC = (1 << 9), + POINT_DATA_NEED_REALLOC = (1 << 10), + + ATTR_FLOAT_NEEDS_REALLOC = (1 << 11), + ATTR_FLOAT2_NEEDS_REALLOC = (1 << 12), + ATTR_FLOAT3_NEEDS_REALLOC = (1 << 13), + ATTR_FLOAT4_NEEDS_REALLOC = (1 << 14), + + ATTR_UCHAR4_NEEDS_REALLOC = (1 << 15), + + ATTRS_NEED_REALLOC = (ATTR_FLOAT_NEEDS_REALLOC | ATTR_FLOAT2_NEEDS_REALLOC | + ATTR_FLOAT3_NEEDS_REALLOC | ATTR_FLOAT4_NEEDS_REALLOC | + ATTR_UCHAR4_NEEDS_REALLOC), + DEVICE_MESH_DATA_NEEDS_REALLOC = (MESH_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), + DEVICE_POINT_DATA_NEEDS_REALLOC = (POINT_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), + DEVICE_CURVE_DATA_NEEDS_REALLOC = (CURVE_DATA_NEED_REALLOC | ATTRS_NEED_REALLOC), +}; + /* Geometry * * Base class for geometric types like Mesh and Hair. */ diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp index 54b397b68f6..13f331a4e51 100644 --- a/intern/cycles/scene/geometry_additions.cpp +++ b/intern/cycles/scene/geometry_additions.cpp @@ -103,275 +103,9 @@ void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) dscene->attributes_map.clear_modified(); } -/* - * Packs the attribute buffers and records the sizes and offsets using - * the attribute sets - */ -bool GeometryManager::device_update_attributes_preprocess( - Device *device, - DeviceScene *dscene, - Scene *scene, - vector &geom_attributes, - vector &object_attributes, - vector &object_attribute_values, - AttributeSizes *sizes, - Progress &progress) -{ - bool update_obj_offsets = false; - progress.set_status("Updating Mesh", "Computing attributes"); - // SHOULD NOT ALLOC ONLY ALLOC IF MORE SPACE IS NEEDED - dscene->attributes_float.alloc(sizes->attr_float_size); - dscene->attributes_float2.alloc(sizes->attr_float2_size); - dscene->attributes_float3.alloc(sizes->attr_float3_size); - dscene->attributes_float4.alloc(sizes->attr_float4_size); - dscene->attributes_uchar4.alloc(sizes->attr_uchar4_size); - /* The order of those flags needs to match that of AttrKernelDataType. */ - const bool attributes_need_realloc[AttrKernelDataType::NUM] = { - dscene->attributes_float.need_realloc(), - dscene->attributes_float2.need_realloc(), - dscene->attributes_float3.need_realloc(), - dscene->attributes_float4.need_realloc(), - dscene->attributes_uchar4.need_realloc(), - }; - - size_t attr_float_offset = 0; - size_t attr_float2_offset = 0; - size_t attr_float3_offset = 0; - size_t attr_float4_offset = 0; - size_t attr_uchar4_offset = 0; - - /* Fill in attributes. */ - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - AttributeRequestSet &attributes = geom_attributes[i]; - - /* todo: we now store std and name attributes from requests even if - * they actually refer to the same mesh attributes, optimize */ - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = geom->attributes.find(req); - - if (attr) { - /* force a copy if we need to reallocate all the data */ - attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; - } - - update_attribute_element_offset(geom, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - attr, - ATTR_PRIM_GEOMETRY, - req.type, - req.desc); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - Attribute *subd_attr = mesh->subd_attributes.find(req); - - if (subd_attr) { - /* force a copy if we need to reallocate all the data */ - subd_attr->modified |= attributes_need_realloc[Attribute::kernel_type(*subd_attr)]; - } - - update_attribute_element_offset(mesh, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - subd_attr, - ATTR_PRIM_SUBD, - req.subd_type, - req.subd_desc); - } - - // if (progress.get_cancel()) - // return update_obj_offsets; - } - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - AttributeRequestSet &attributes = object_attributes[i]; - AttributeSet &values = object_attribute_values[i]; - - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = values.find(req); - - if (attr) { - attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; - } - - update_attribute_element_offset(object->geometry, - dscene->attributes_float, - attr_float_offset, - dscene->attributes_float2, - attr_float2_offset, - dscene->attributes_float3, - attr_float3_offset, - dscene->attributes_float4, - attr_float4_offset, - dscene->attributes_uchar4, - attr_uchar4_offset, - attr, - ATTR_PRIM_GEOMETRY, - req.type, - req.desc); - - /* object attributes don't care about subdivision */ - req.subd_type = req.type; - req.subd_desc = req.desc; - } - } - - /* create attribute lookup maps */ - if (scene->shader_manager->use_osl()) - update_osl_globals(device, scene); - - update_svm_attributes(device, dscene, scene, geom_attributes, object_attributes); - - update_obj_offsets = scene->object_manager->device_update_geom_offsets(device, dscene, scene); - - return update_obj_offsets; -} - -/** - * Packs the geometry data into the device scene. That is it fills out - * the geometry buffers - */ -void GeometryManager::device_update_mesh_preprocess( - Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *p_sizes, Progress &progress) -{ - /* Fill in all the arrays. */ - if (p_sizes->tri_size != 0) { - /* normals */ - progress.set_status("Updating Mesh", "Computing mesh"); - - packed_float3 *tri_verts = dscene->tri_verts.alloc(p_sizes->vert_size); - uint *tri_shader = dscene->tri_shader.alloc(p_sizes->tri_size); - packed_float3 *vnormal = dscene->tri_vnormal.alloc(p_sizes->vert_size); - packed_uint3 *tri_vindex = dscene->tri_vindex.alloc(p_sizes->tri_size); - uint *tri_patch = dscene->tri_patch.alloc(p_sizes->tri_size); - float2 *tri_patch_uv = dscene->tri_patch_uv.alloc(p_sizes->vert_size); - - const bool copy_all_data = dscene->tri_shader.need_realloc() || - dscene->tri_vindex.need_realloc() || - dscene->tri_vnormal.need_realloc() || - dscene->tri_patch.need_realloc() || - dscene->tri_patch_uv.need_realloc(); - - foreach (Geometry *geom, scene->geometry) { - if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { - Mesh *mesh = static_cast(geom); - - if (mesh->shader_is_modified() || mesh->smooth_is_modified() || - mesh->triangles_is_modified() || copy_all_data) { - mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); - } - - if (mesh->verts_is_modified() || copy_all_data) { - mesh->pack_normals(&vnormal[mesh->vert_offset]); - } - - if (mesh->verts_is_modified() || mesh->triangles_is_modified() || - mesh->vert_patch_uv_is_modified() || copy_all_data) { - mesh->pack_verts(&tri_verts[mesh->vert_offset], - &tri_vindex[mesh->prim_offset], - &tri_patch[mesh->prim_offset], - &tri_patch_uv[mesh->vert_offset]); - } - // if (progress.get_cancel()) - // return; - } - } - } - - if (p_sizes->curve_segment_size != 0) { - progress.set_status("Updating Mesh", "Computing curves"); - - float4 *curve_keys = dscene->curve_keys.alloc(p_sizes->curve_key_size); - KernelCurve *curves = dscene->curves.alloc(p_sizes->curve_size); - KernelCurveSegment *curve_segments = dscene->curve_segments.alloc(p_sizes->curve_segment_size); - - const bool copy_all_data = dscene->curve_keys.need_realloc() || - dscene->curves.need_realloc() || - dscene->curve_segments.need_realloc(); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_hair()) { - Hair *hair = static_cast(geom); - - bool curve_keys_co_modified = hair->curve_radius_is_modified() || - hair->curve_keys_is_modified(); - bool curve_data_modified = hair->curve_shader_is_modified() || - hair->curve_first_key_is_modified(); - - if (!curve_keys_co_modified && !curve_data_modified && !copy_all_data) { - continue; - } - - hair->pack_curves(scene, - &curve_keys[hair->curve_key_offset], - &curves[hair->prim_offset], - &curve_segments[hair->curve_segment_offset]); - // if (progress.get_cancel()) - // return; - } - } - } - - if (p_sizes->point_size != 0) { - progress.set_status("Updating Mesh", "Computing point clouds"); - - float4 *points = dscene->points.alloc(p_sizes->point_size); - uint *points_shader = dscene->points_shader.alloc(p_sizes->point_size); - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_pointcloud()) { - PointCloud *pointcloud = static_cast(geom); - pointcloud->pack( - scene, &points[pointcloud->prim_offset], &points_shader[pointcloud->prim_offset]); - // if (progress.get_cancel()) - // return; - } - } - } - - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - progress.set_status("Updating Mesh", "Computing patches"); - - uint *patch_data = dscene->patches.alloc(p_sizes->patch_size); - foreach (Geometry *geom, scene->geometry) { - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - mesh->pack_patches(&patch_data[mesh->patch_offset]); - - if (mesh->patch_table) { - mesh->patch_table->copy_adjusting_offsets(&patch_data[mesh->patch_table_offset], - mesh->patch_table_offset); - } - - // if (progress.get_cancel()) - // return; - } - } - } -} /* * Assigns the host pointers to the sub-devicescenes so @@ -561,391 +295,9 @@ void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) } } -/* - * Records the sizes of the attribute buffers - */ -static void update_attribute_element_size(Geometry *geom, - Attribute *mattr, - AttributePrimitive prim, - size_t *attr_float_size, - size_t *attr_float2_size, - size_t *attr_float3_size, - size_t *attr_float4_size, - size_t *attr_uchar4_size) -{ - if (mattr) { - size_t size = mattr->element_size(geom, prim); - if (mattr->element == ATTR_ELEMENT_VOXEL) { - /* pass */ - } - else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { - *attr_uchar4_size += size; - } - else if (mattr->type == TypeDesc::TypeFloat) { - *attr_float_size += size; - } - else if (mattr->type == TypeFloat2) { - *attr_float2_size += size; - } - else if (mattr->type == TypeDesc::TypeMatrix) { - *attr_float4_size += size * 4; - } - else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { - *attr_float4_size += size; - } - else { - *attr_float3_size += size; - } - } -} -/* - * Records all the attribute buffer sizes for all the attribute buffers for later use - */ -void GeometryManager::attrib_calc_sizes(Scene *scene, - AttributeSizes *p_sizes, - vector &geom_attributes, - vector &object_attributes, - vector &object_attribute_values) -{ - p_sizes->attr_float_size = 0; - p_sizes->attr_float2_size = 0; - p_sizes->attr_float3_size = 0; - p_sizes->attr_float4_size = 0; - p_sizes->attr_uchar4_size = 0; - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - AttributeRequestSet &attributes = geom_attributes[i]; - foreach (AttributeRequest &req, attributes.requests) { - Attribute *attr = geom->attributes.find(req); - - update_attribute_element_size(geom, - attr, - ATTR_PRIM_GEOMETRY, - &(p_sizes->attr_float_size), - &(p_sizes->attr_float2_size), - &(p_sizes->attr_float3_size), - &(p_sizes->attr_float4_size), - &(p_sizes->attr_uchar4_size)); - - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - Attribute *subd_attr = mesh->subd_attributes.find(req); - - update_attribute_element_size(mesh, - subd_attr, - ATTR_PRIM_SUBD, - &(p_sizes->attr_float_size), - &(p_sizes->attr_float2_size), - &(p_sizes->attr_float3_size), - &(p_sizes->attr_float4_size), - &(p_sizes->attr_uchar4_size)); - } - } - } - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - - foreach (Attribute &attr, object_attribute_values[i].attributes) { - update_attribute_element_size(object->geometry, - &attr, - ATTR_PRIM_GEOMETRY, - &(p_sizes->attr_float_size), - &(p_sizes->attr_float2_size), - &(p_sizes->attr_float3_size), - &(p_sizes->attr_float4_size), - &(p_sizes->attr_uchar4_size)); - } - } -} - -/* - * Records the set of attributes used by the objects - */ -void GeometryManager::gather_attributes(Scene *scene, - vector &geom_attributes, - vector &object_attributes, - vector &object_attribute_values, - AttributeSizes *sizes) -{ - geom_attributes.clear(); - object_attributes.clear(); - object_attribute_values.clear(); - - /* gather per mesh requested attributes. as meshes may have multiple - * shaders assigned, this merges the requested attributes that have - * been set per shader by the shader manager */ - geom_attributes.resize(scene->geometry.size()); - - for (size_t i = 0; i < scene->geometry.size(); i++) { - Geometry *geom = scene->geometry[i]; - - geom->index = i; - scene->need_global_attributes(geom_attributes[i]); - - foreach (Node *node, geom->get_used_shaders()) { - Shader *shader = static_cast(node); - geom_attributes[i].add(shader->attributes); - } - - if (geom->is_hair() && static_cast(geom)->need_shadow_transparency()) { - geom_attributes[i].add(ATTR_STD_SHADOW_TRANSPARENCY); - } - } - - /* convert object attributes to use the same data structures as geometry ones */ - object_attributes.resize(scene->objects.size()); - object_attribute_values.reserve(scene->objects.size()); - - for (size_t i = 0; i < scene->objects.size(); i++) { - Object *object = scene->objects[i]; - Geometry *geom = object->geometry; - size_t geom_idx = geom->index; - - assert(geom_idx < scene->geometry.size() && scene->geometry[geom_idx] == geom); - - object_attribute_values.push_back(AttributeSet(geom, ATTR_PRIM_GEOMETRY)); - - AttributeRequestSet &geom_requests = geom_attributes[geom_idx]; - AttributeRequestSet &attributes = object_attributes[i]; - AttributeSet &values = object_attribute_values[i]; - - for (size_t j = 0; j < object->attributes.size(); j++) { - ParamValue ¶m = object->attributes[j]; - - /* add attributes that are requested and not already handled by the mesh */ - if (geom_requests.find(param.name()) && !geom->attributes.find(param.name())) { - attributes.add(param.name()); - - Attribute *attr = values.add(param.name(), param.type(), ATTR_ELEMENT_OBJECT); - assert(param.datasize() == attr->buffer.size()); - memcpy(attr->buffer.data(), param.data(), param.datasize()); - } - } - } - - /* Geometry attributes are stored in a single array per data type. Here determine the - * sizes of those buffers. - */ - attrib_calc_sizes(scene, sizes, geom_attributes, object_attributes, object_attribute_values); -} - -void GeometryManager::device_update_bvh2(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - BVH *bvh = scene->bvh; - if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { - BVH2 *bvh2 = static_cast(bvh); - - /* When using BVH2, we always have to copy/update the data as its layout is dependent on - * the BVH's leaf nodes which may be different when the objects or vertices move. */ - - if (bvh2->pack.nodes.size()) { - dscene->bvh_nodes.assign_mem(bvh2->pack.nodes); - dscene->bvh_nodes.copy_to_device(); - } - if (bvh2->pack.leaf_nodes.size()) { - dscene->bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes); - dscene->bvh_leaf_nodes.copy_to_device(); - } - if (bvh2->pack.object_node.size()) { - dscene->object_node.assign_mem(bvh2->pack.object_node); - dscene->object_node.copy_to_device(); - } - if (bvh2->pack.prim_type.size()) { - dscene->prim_type.assign_mem(bvh2->pack.prim_type); - dscene->prim_type.copy_to_device(); - } - if (bvh2->pack.prim_visibility.size()) { - dscene->prim_visibility.assign_mem(bvh2->pack.prim_visibility); - dscene->prim_visibility.copy_to_device(); - } - if (bvh2->pack.prim_index.size()) { - dscene->prim_index.assign_mem(bvh2->pack.prim_index); - dscene->prim_index.copy_to_device(); - } - if (bvh2->pack.prim_object.size()) { - dscene->prim_object.assign_mem(bvh2->pack.prim_object); - dscene->prim_object.copy_to_device(); - } - if (bvh2->pack.prim_time.size()) { - dscene->prim_time.assign_mem(bvh2->pack.prim_time); - dscene->prim_time.copy_to_device(); - } - } -} - -void GeometryManager::device_update_bvh_postprocess(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - BVH *bvh = scene->bvh; - - const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); - - //PackedBVH pack; - if (has_bvh2_layout) { - BVH2 *bvh2 = static_cast(scene->bvh); - //pack = std::move(static_cast(bvh)->pack); - dscene->data.bvh.root = bvh2->pack.root_index; - } - else { - //pack.root_index = -1; - dscene->data.bvh.root = -1; - } - - dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0); - dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions(); - dscene->data.device_bvh = 0; -} - -bool Geometry::create_new_bvh_if_needed(Object *object, - Device *device, - DeviceScene *dscene, - SceneParams *params) -{ - bool status = false; - const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, - device->get_bvh_layout_mask()); - if (need_build_bvh(bvh_layout)) { - /* Ensure all visibility bits are set at the geometry level BVH. In - * the object level BVH is where actual visibility is tested. */ - object->set_is_shadow_catcher(true); - object->set_visibility(~0); - - object->set_geometry(this); - - vector geometry; - geometry.push_back(this); - vector objects; - objects.push_back(object); - - if (bvh && !need_update_rebuild) { - bvh->replace_geometry(geometry, objects); - } - else { - if (bvh != NULL) { - delete bvh; - } - const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, - device->get_bvh_layout_mask()); - - BVHParams bparams; - bparams.use_spatial_split = params->use_bvh_spatial_split; - bparams.use_compact_structure = params->use_bvh_compact_structure; - bparams.bvh_layout = bvh_layout; - bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && - params->use_bvh_unaligned_nodes; - bparams.num_motion_triangle_steps = params->num_bvh_time_steps; - bparams.num_motion_curve_steps = params->num_bvh_time_steps; - bparams.num_motion_point_steps = params->num_bvh_time_steps; - bparams.bvh_type = params->bvh_type; - bparams.curve_subdivisions = params->curve_subdivisions(); - bvh = BVH::create(bparams, geometry, objects, device); - need_update_rebuild = true; - } - status = true; - } - - return status; -} - -void GeometryManager::device_update_sub_bvh(Device *device, - DeviceScene *dscene, - BVH *bvh, - BVH *sub_bvh, - bool can_refit, - size_t n, - size_t total, - Progress *progress) -{ - string msg = "Updating Geometry BVH"; - - // Is this a multi-bvh? - if (sub_bvh && can_refit) { - progress->set_status(msg, "Refitting BVH"); - // Don't redo the setup if this is not a sub-bvh - if (sub_bvh != bvh) { - sub_bvh->replace_geometry(bvh->geometry, bvh->objects); - // sub_bvh->geometry = bvh->geometry; - // sub_bvh->objects = bvh->objects; - } - } - else { - progress->set_status(msg, "Building BVH"); - // Don't redo the setup if this is not a sub-bvh - if (sub_bvh != bvh) { - // Yes, so setup the device specific sub_bvh in the multi-bvh. - BVHParams bparams = bvh->params; - // Set the layout to the correct one for the device - if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) - bparams.bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) - bparams.bvh_layout = BVH_LAYOUT_METAL; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - bparams.bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : - BVH_LAYOUT_EMBREE; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - bparams.bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : - BVH_LAYOUT_EMBREE; - if (sub_bvh != NULL) { - delete sub_bvh; - } - VLOG_INFO << "Sub-BVH using layout " << bvh_layout_name(bparams.bvh_layout) << " from layout " << bvh_layout_name(bvh->params.bvh_layout); - /* BVH2 should not have a sub-bvh as only 1 is built on the CPU */ - assert(bparams.bvh_layout != BVH_LAYOUT_BVH2); - if(bparams.bvh_layout != BVH_LAYOUT_BVH2) { - sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device); - bvh->set_device_bvh(device, sub_bvh); - } - } - can_refit = false; - } - device->build_bvh(sub_bvh, dscene, *progress, can_refit); -} - -bool GeometryManager::device_update_bvh_preprocess(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - /* bvh build */ - - BVHParams bparams; - bparams.top_level = true; - bparams.bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, - device->get_bvh_layout_mask()); - bparams.use_spatial_split = scene->params.use_bvh_spatial_split; - bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && - scene->params.use_bvh_unaligned_nodes; - bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; - bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; - bparams.num_motion_point_steps = scene->params.num_bvh_time_steps; - bparams.bvh_type = scene->params.bvh_type; - bparams.curve_subdivisions = scene->params.curve_subdivisions(); - - VLOG_INFO << "Using " << bvh_layout_name(bparams.bvh_layout) << " layout."; - - const bool can_refit = scene->bvh != nullptr && - (bparams.bvh_layout == BVHLayout::BVH_LAYOUT_OPTIX || - bparams.bvh_layout == BVHLayout::BVH_LAYOUT_METAL || - bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_OPTIX || - bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_METAL); - - BVH *bvh = scene->bvh; - if (!scene->bvh) { - bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); - } - /* Mark BVH as having not been built yet */ - bvh->built = false; - return can_refit; -} bool GeometryManager::displacement_and_curve_shadow_transparency( Scene *scene, diff --git a/intern/cycles/scene/geometry_attributes.cpp b/intern/cycles/scene/geometry_attributes.cpp new file mode 100644 index 00000000000..b10b4fd390c --- /dev/null +++ b/intern/cycles/scene/geometry_attributes.cpp @@ -0,0 +1,716 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#include "bvh/bvh.h" +#include "bvh/bvh2.h" + +#include "device/device.h" + +#include "scene/attribute.h" +#include "scene/camera.h" +#include "scene/geometry.h" +#include "scene/hair.h" +#include "scene/light.h" +#include "scene/mesh.h" +#include "scene/object.h" +#include "scene/pointcloud.h" +#include "scene/scene.h" +#include "scene/shader.h" +#include "scene/shader_nodes.h" +#include "scene/stats.h" +#include "scene/volume.h" + +#include "subd/patch_table.h" +#include "subd/split.h" + +#include "kernel/osl/globals.h" + +#include "util/foreach.h" +#include "util/log.h" +#include "util/progress.h" +#include "util/task.h" + +CCL_NAMESPACE_BEGIN + +/* Generate a normal attribute map entry from an attribute descriptor. */ +static void emit_attribute_map_entry(AttributeMap *attr_map, + size_t index, + uint64_t id, + TypeDesc type, + const AttributeDescriptor &desc) +{ + attr_map[index].id = id; + attr_map[index].element = desc.element; + attr_map[index].offset = as_uint(desc.offset); + + if (type == TypeDesc::TypeFloat) + attr_map[index].type = NODE_ATTR_FLOAT; + else if (type == TypeDesc::TypeMatrix) + attr_map[index].type = NODE_ATTR_MATRIX; + else if (type == TypeFloat2) + attr_map[index].type = NODE_ATTR_FLOAT2; + else if (type == TypeFloat4) + attr_map[index].type = NODE_ATTR_FLOAT4; + else if (type == TypeRGBA) + attr_map[index].type = NODE_ATTR_RGBA; + else + attr_map[index].type = NODE_ATTR_FLOAT3; + + attr_map[index].flags = desc.flags; +} + +/* Generate an attribute map end marker, optionally including a link to another map. + * Links are used to connect object attribute maps to mesh attribute maps. */ +static void emit_attribute_map_terminator(AttributeMap *attr_map, + size_t index, + bool chain, + uint chain_link) +{ + for (int j = 0; j < ATTR_PRIM_TYPES; j++) { + attr_map[index + j].id = ATTR_STD_NONE; + attr_map[index + j].element = chain; /* link is valid flag */ + attr_map[index + j].offset = chain ? chain_link + j : 0; /* link to the correct sub-entry */ + attr_map[index + j].type = 0; + attr_map[index + j].flags = 0; + } +} + +/* Generate all necessary attribute map entries from the attribute request. */ +static void emit_attribute_mapping( + AttributeMap *attr_map, size_t index, uint64_t id, AttributeRequest &req, Geometry *geom) +{ + emit_attribute_map_entry(attr_map, index, id, req.type, req.desc); + + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + if (mesh->get_num_subd_faces()) { + emit_attribute_map_entry(attr_map, index + 1, id, req.subd_type, req.subd_desc); + } + } +} + +void GeometryManager::update_svm_attributes(Device *, + DeviceScene *dscene, + Scene *scene, + vector &geom_attributes, + vector &object_attributes) +{ + /* for SVM, the attributes_map table is used to lookup the offset of an + * attribute, based on a unique shader attribute id. */ + + /* compute array stride */ + size_t attr_map_size = 0; + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + geom->attr_map_offset = attr_map_size; + +#ifdef WITH_OSL + size_t attr_count = 0; + foreach (AttributeRequest &req, geom_attributes[i].requests) { + if (req.std != ATTR_STD_NONE && + scene->shader_manager->get_attribute_id(req.std) != (uint64_t)req.std) + attr_count += 2; + else + attr_count += 1; + } +#else + const size_t attr_count = geom_attributes[i].size(); +#endif + + attr_map_size += (attr_count + 1) * ATTR_PRIM_TYPES; + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + + /* only allocate a table for the object if it actually has attributes */ + if (object_attributes[i].size() == 0) { + object->attr_map_offset = 0; + } + else { + object->attr_map_offset = attr_map_size; + attr_map_size += (object_attributes[i].size() + 1) * ATTR_PRIM_TYPES; + } + } + + if (attr_map_size == 0) + return; + + if (!dscene->attributes_map.need_realloc()) { + return; + } + + /* create attribute map */ + AttributeMap *attr_map = dscene->attributes_map.alloc(attr_map_size); + memset(attr_map, 0, dscene->attributes_map.size() * sizeof(*attr_map)); + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + AttributeRequestSet &attributes = geom_attributes[i]; + + /* set geometry attributes */ + size_t index = geom->attr_map_offset; + + foreach (AttributeRequest &req, attributes.requests) { + uint64_t id; + if (req.std == ATTR_STD_NONE) + id = scene->shader_manager->get_attribute_id(req.name); + else + id = scene->shader_manager->get_attribute_id(req.std); + + emit_attribute_mapping(attr_map, index, id, req, geom); + index += ATTR_PRIM_TYPES; + +#ifdef WITH_OSL + /* Some standard attributes are explicitly referenced via their standard ID, so add those + * again in case they were added under a different attribute ID. */ + if (req.std != ATTR_STD_NONE && id != (uint64_t)req.std) { + emit_attribute_mapping(attr_map, index, (uint64_t)req.std, req, geom); + index += ATTR_PRIM_TYPES; + } +#endif + } + + emit_attribute_map_terminator(attr_map, index, false, 0); + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + AttributeRequestSet &attributes = object_attributes[i]; + + /* set object attributes */ + if (attributes.size() > 0) { + size_t index = object->attr_map_offset; + + foreach (AttributeRequest &req, attributes.requests) { + uint64_t id; + if (req.std == ATTR_STD_NONE) + id = scene->shader_manager->get_attribute_id(req.name); + else + id = scene->shader_manager->get_attribute_id(req.std); + + emit_attribute_mapping(attr_map, index, id, req, object->geometry); + index += ATTR_PRIM_TYPES; + } + + emit_attribute_map_terminator(attr_map, index, true, object->geometry->attr_map_offset); + } + } + + /* copy to device */ + /* Copy moved to device_update_attributes */ + dscene->attributes_map.tag_modified(); +} + +/* + * Copies the attribute data into the buffers and records + * the offsets + */ +void GeometryManager::update_attribute_element_offset(Geometry *geom, + device_vector &attr_float, + size_t &attr_float_offset, + device_vector &attr_float2, + size_t &attr_float2_offset, + device_vector &attr_float3, + size_t &attr_float3_offset, + device_vector &attr_float4, + size_t &attr_float4_offset, + device_vector &attr_uchar4, + size_t &attr_uchar4_offset, + Attribute *mattr, + AttributePrimitive prim, + TypeDesc &type, + AttributeDescriptor &desc) +{ + if (mattr) { + /* store element and type */ + desc.element = mattr->element; + desc.flags = mattr->flags; + type = mattr->type; + + /* store attribute data in arrays */ + size_t size = mattr->element_size(geom, prim); + + AttributeElement &element = desc.element; + int &offset = desc.offset; + + if (mattr->element == ATTR_ELEMENT_VOXEL) { + /* store slot in offset value */ + ImageHandle &handle = mattr->data_voxel(); + offset = handle.svm_slot(); + } + else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { + uchar4 *data = mattr->data_uchar4(); + offset = attr_uchar4_offset; + + assert(attr_uchar4.size() >= offset + size); + if (mattr->modified) { + for (size_t k = 0; k < size; k++) { + attr_uchar4[offset + k] = data[k]; + } + attr_uchar4.tag_modified(); + } + attr_uchar4_offset += size; + } + else if (mattr->type == TypeDesc::TypeFloat) { + float *data = mattr->data_float(); + offset = attr_float_offset; + + assert(attr_float.size() >= offset + size); + if (mattr->modified) { + for (size_t k = 0; k < size; k++) { + attr_float[offset + k] = data[k]; + } + attr_float.tag_modified(); + } + attr_float_offset += size; + } + else if (mattr->type == TypeFloat2) { + float2 *data = mattr->data_float2(); + offset = attr_float2_offset; + + assert(attr_float2.size() >= offset + size); + if (mattr->modified) { + for (size_t k = 0; k < size; k++) { + attr_float2[offset + k] = data[k]; + } + attr_float2.tag_modified(); + } + attr_float2_offset += size; + } + else if (mattr->type == TypeDesc::TypeMatrix) { + Transform *tfm = mattr->data_transform(); + offset = attr_float4_offset; + + assert(attr_float4.size() >= offset + size * 3); + if (mattr->modified) { + for (size_t k = 0; k < size * 3; k++) { + attr_float4[offset + k] = (&tfm->x)[k]; + } + attr_float4.tag_modified(); + } + attr_float4_offset += size * 3; + } + else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { + float4 *data = mattr->data_float4(); + offset = attr_float4_offset; + + assert(attr_float4.size() >= offset + size); + if (mattr->modified) { + for (size_t k = 0; k < size; k++) { + attr_float4[offset + k] = data[k]; + } + attr_float4.tag_modified(); + } + attr_float4_offset += size; + } + else { + float3 *data = mattr->data_float3(); + offset = attr_float3_offset; + + // Records where the motion vertices are in the attribute array + // so that they can be used later to reference the data when building + // the BVHs. + if (mattr->std == ATTR_STD_MOTION_VERTEX_POSITION) { + geom->motion_key_offset = offset; + } + + assert(attr_float3.size() >= offset + size); + if (mattr->modified) { + for (size_t k = 0; k < size; k++) { + attr_float3[offset + k] = data[k]; + } + attr_float3.tag_modified(); + } + attr_float3_offset += size; + } + + /* mesh vertex/curve index is global, not per object, so we sneak + * a correction for that in here */ + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + if (mesh->subdivision_type == Mesh::SUBDIVISION_CATMULL_CLARK && + desc.flags & ATTR_SUBDIVIDED) { + /* Indices for subdivided attributes are retrieved + * from patch table so no need for correction here. */ + } + else if (element == ATTR_ELEMENT_VERTEX) + offset -= mesh->vert_offset; + else if (element == ATTR_ELEMENT_VERTEX_MOTION) + offset -= mesh->vert_offset; + else if (element == ATTR_ELEMENT_FACE) { + if (prim == ATTR_PRIM_GEOMETRY) + offset -= mesh->prim_offset; + else + offset -= mesh->face_offset; + } + else if (element == ATTR_ELEMENT_CORNER || element == ATTR_ELEMENT_CORNER_BYTE) { + if (prim == ATTR_PRIM_GEOMETRY) + offset -= 3 * mesh->prim_offset; + else + offset -= mesh->corner_offset; + } + } + else if (geom->is_hair()) { + Hair *hair = static_cast(geom); + if (element == ATTR_ELEMENT_CURVE) + offset -= hair->prim_offset; + else if (element == ATTR_ELEMENT_CURVE_KEY) + offset -= hair->curve_key_offset; + else if (element == ATTR_ELEMENT_CURVE_KEY_MOTION) + offset -= hair->curve_key_offset; + } + else if (geom->is_pointcloud()) { + if (element == ATTR_ELEMENT_VERTEX) + offset -= geom->prim_offset; + else if (element == ATTR_ELEMENT_VERTEX_MOTION) + offset -= geom->prim_offset; + } + } + else { + /* attribute not found */ + desc.element = ATTR_ELEMENT_NONE; + desc.offset = 0; + } +} + +/* + * Copies the attribute buffer data to the devices + */ +void GeometryManager::device_update_attributes(Device *device, + DeviceScene *dscene, + const AttributeSizes *sizes, + Progress &progress) +{ + progress.set_status("Updating Mesh", "Copying Attributes to device"); + /* copy svm attributes to device */ + dscene->attributes_map.copy_to_device_if_modified(); + dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); + dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); + dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); + dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); + dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); + dscene->objects.copy_to_device_if_modified(); +} + +/* + * Packs the attribute buffers and records the sizes and offsets using + * the attribute sets + */ +bool GeometryManager::device_update_attributes_preprocess( + Device *device, + DeviceScene *dscene, + Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes, + Progress &progress) +{ + bool update_obj_offsets = false; + + progress.set_status("Updating Mesh", "Computing attributes"); + + // SHOULD NOT ALLOC ONLY ALLOC IF MORE SPACE IS NEEDED + dscene->attributes_float.alloc(sizes->attr_float_size); + dscene->attributes_float2.alloc(sizes->attr_float2_size); + dscene->attributes_float3.alloc(sizes->attr_float3_size); + dscene->attributes_float4.alloc(sizes->attr_float4_size); + dscene->attributes_uchar4.alloc(sizes->attr_uchar4_size); + + /* The order of those flags needs to match that of AttrKernelDataType. */ + const bool attributes_need_realloc[AttrKernelDataType::NUM] = { + dscene->attributes_float.need_realloc(), + dscene->attributes_float2.need_realloc(), + dscene->attributes_float3.need_realloc(), + dscene->attributes_float4.need_realloc(), + dscene->attributes_uchar4.need_realloc(), + }; + + size_t attr_float_offset = 0; + size_t attr_float2_offset = 0; + size_t attr_float3_offset = 0; + size_t attr_float4_offset = 0; + size_t attr_uchar4_offset = 0; + + /* Fill in attributes. */ + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + AttributeRequestSet &attributes = geom_attributes[i]; + + /* todo: we now store std and name attributes from requests even if + * they actually refer to the same mesh attributes, optimize */ + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = geom->attributes.find(req); + + if (attr) { + /* force a copy if we need to reallocate all the data */ + attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; + } + + update_attribute_element_offset(geom, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + attr, + ATTR_PRIM_GEOMETRY, + req.type, + req.desc); + + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + Attribute *subd_attr = mesh->subd_attributes.find(req); + + if (subd_attr) { + /* force a copy if we need to reallocate all the data */ + subd_attr->modified |= attributes_need_realloc[Attribute::kernel_type(*subd_attr)]; + } + + update_attribute_element_offset(mesh, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + subd_attr, + ATTR_PRIM_SUBD, + req.subd_type, + req.subd_desc); + } + + // if (progress.get_cancel()) + // return update_obj_offsets; + } + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + AttributeRequestSet &attributes = object_attributes[i]; + AttributeSet &values = object_attribute_values[i]; + + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = values.find(req); + + if (attr) { + attr->modified |= attributes_need_realloc[Attribute::kernel_type(*attr)]; + } + + update_attribute_element_offset(object->geometry, + dscene->attributes_float, + attr_float_offset, + dscene->attributes_float2, + attr_float2_offset, + dscene->attributes_float3, + attr_float3_offset, + dscene->attributes_float4, + attr_float4_offset, + dscene->attributes_uchar4, + attr_uchar4_offset, + attr, + ATTR_PRIM_GEOMETRY, + req.type, + req.desc); + + /* object attributes don't care about subdivision */ + req.subd_type = req.type; + req.subd_desc = req.desc; + } + } + + /* create attribute lookup maps */ + if (scene->shader_manager->use_osl()) + update_osl_globals(device, scene); + + update_svm_attributes(device, dscene, scene, geom_attributes, object_attributes); + + update_obj_offsets = scene->object_manager->device_update_geom_offsets(device, dscene, scene); + + return update_obj_offsets; +} + +/* + * Records the sizes of the attribute buffers + */ +static void update_attribute_element_size(Geometry *geom, + Attribute *mattr, + AttributePrimitive prim, + size_t *attr_float_size, + size_t *attr_float2_size, + size_t *attr_float3_size, + size_t *attr_float4_size, + size_t *attr_uchar4_size) +{ + if (mattr) { + size_t size = mattr->element_size(geom, prim); + + if (mattr->element == ATTR_ELEMENT_VOXEL) { + /* pass */ + } + else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { + *attr_uchar4_size += size; + } + else if (mattr->type == TypeDesc::TypeFloat) { + *attr_float_size += size; + } + else if (mattr->type == TypeFloat2) { + *attr_float2_size += size; + } + else if (mattr->type == TypeDesc::TypeMatrix) { + *attr_float4_size += size * 4; + } + else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { + *attr_float4_size += size; + } + else { + *attr_float3_size += size; + } + } +} + +/* + * Records all the attribute buffer sizes for all the attribute buffers for later use + */ +void GeometryManager::attrib_calc_sizes(Scene *scene, + AttributeSizes *p_sizes, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values) +{ + p_sizes->attr_float_size = 0; + p_sizes->attr_float2_size = 0; + p_sizes->attr_float3_size = 0; + p_sizes->attr_float4_size = 0; + p_sizes->attr_uchar4_size = 0; + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + AttributeRequestSet &attributes = geom_attributes[i]; + foreach (AttributeRequest &req, attributes.requests) { + Attribute *attr = geom->attributes.find(req); + + update_attribute_element_size(geom, + attr, + ATTR_PRIM_GEOMETRY, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + Attribute *subd_attr = mesh->subd_attributes.find(req); + + update_attribute_element_size(mesh, + subd_attr, + ATTR_PRIM_SUBD, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + } + } + } + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + + foreach (Attribute &attr, object_attribute_values[i].attributes) { + update_attribute_element_size(object->geometry, + &attr, + ATTR_PRIM_GEOMETRY, + &(p_sizes->attr_float_size), + &(p_sizes->attr_float2_size), + &(p_sizes->attr_float3_size), + &(p_sizes->attr_float4_size), + &(p_sizes->attr_uchar4_size)); + } + } +} + +/* + * Records the set of attributes used by the objects + */ +void GeometryManager::gather_attributes(Scene *scene, + vector &geom_attributes, + vector &object_attributes, + vector &object_attribute_values, + AttributeSizes *sizes) +{ + geom_attributes.clear(); + object_attributes.clear(); + object_attribute_values.clear(); + + /* gather per mesh requested attributes. as meshes may have multiple + * shaders assigned, this merges the requested attributes that have + * been set per shader by the shader manager */ + geom_attributes.resize(scene->geometry.size()); + + for (size_t i = 0; i < scene->geometry.size(); i++) { + Geometry *geom = scene->geometry[i]; + + geom->index = i; + scene->need_global_attributes(geom_attributes[i]); + + foreach (Node *node, geom->get_used_shaders()) { + Shader *shader = static_cast(node); + geom_attributes[i].add(shader->attributes); + } + + if (geom->is_hair() && static_cast(geom)->need_shadow_transparency()) { + geom_attributes[i].add(ATTR_STD_SHADOW_TRANSPARENCY); + } + } + + /* convert object attributes to use the same data structures as geometry ones */ + object_attributes.resize(scene->objects.size()); + object_attribute_values.reserve(scene->objects.size()); + + for (size_t i = 0; i < scene->objects.size(); i++) { + Object *object = scene->objects[i]; + Geometry *geom = object->geometry; + size_t geom_idx = geom->index; + + assert(geom_idx < scene->geometry.size() && scene->geometry[geom_idx] == geom); + + object_attribute_values.push_back(AttributeSet(geom, ATTR_PRIM_GEOMETRY)); + + AttributeRequestSet &geom_requests = geom_attributes[geom_idx]; + AttributeRequestSet &attributes = object_attributes[i]; + AttributeSet &values = object_attribute_values[i]; + + for (size_t j = 0; j < object->attributes.size(); j++) { + ParamValue ¶m = object->attributes[j]; + + /* add attributes that are requested and not already handled by the mesh */ + if (geom_requests.find(param.name()) && !geom->attributes.find(param.name())) { + attributes.add(param.name()); + + Attribute *attr = values.add(param.name(), param.type(), ATTR_ELEMENT_OBJECT); + assert(param.datasize() == attr->buffer.size()); + memcpy(attr->buffer.data(), param.data(), param.datasize()); + } + } + } + + /* Geometry attributes are stored in a single array per data type. Here determine the + * sizes of those buffers. + */ + attrib_calc_sizes(scene, sizes, geom_attributes, object_attributes, object_attribute_values); +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp new file mode 100644 index 00000000000..818f2630eef --- /dev/null +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -0,0 +1,325 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#include "bvh/bvh.h" +#include "bvh/bvh2.h" + +#include "device/device.h" + +#include "scene/attribute.h" +#include "scene/camera.h" +#include "scene/geometry.h" +#include "scene/hair.h" +#include "scene/light.h" +#include "scene/mesh.h" +#include "scene/object.h" +#include "scene/pointcloud.h" +#include "scene/scene.h" +#include "scene/shader.h" +#include "scene/shader_nodes.h" +#include "scene/stats.h" +#include "scene/volume.h" + +#include "subd/patch_table.h" +#include "subd/split.h" + +#include "kernel/osl/globals.h" + +#include "util/foreach.h" +#include "util/log.h" +#include "util/progress.h" +#include "util/task.h" + +CCL_NAMESPACE_BEGIN + +void GeometryManager::device_update_bvh(Device *device, + DeviceScene *dscene, + Scene *scene, + bool can_refit, + size_t n, + size_t total, + Progress &progress) +{ + BVH *bvh = scene->bvh; + BVH *sub_bvh = scene->bvh->get_device_bvh(device); + GeometryManager::device_update_sub_bvh( + device, dscene, bvh, sub_bvh, can_refit, n, total, &progress); +} + +void GeometryManager::device_update_bvh2(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + BVH *bvh = scene->bvh; + if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { + BVH2 *bvh2 = static_cast(bvh); + + /* When using BVH2, we always have to copy/update the data as its layout is dependent on + * the BVH's leaf nodes which may be different when the objects or vertices move. */ + + if (bvh2->pack.nodes.size()) { + dscene->bvh_nodes.assign_mem(bvh2->pack.nodes); + dscene->bvh_nodes.copy_to_device(); + } + if (bvh2->pack.leaf_nodes.size()) { + dscene->bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes); + dscene->bvh_leaf_nodes.copy_to_device(); + } + if (bvh2->pack.object_node.size()) { + dscene->object_node.assign_mem(bvh2->pack.object_node); + dscene->object_node.copy_to_device(); + } + if (bvh2->pack.prim_type.size()) { + dscene->prim_type.assign_mem(bvh2->pack.prim_type); + dscene->prim_type.copy_to_device(); + } + if (bvh2->pack.prim_visibility.size()) { + dscene->prim_visibility.assign_mem(bvh2->pack.prim_visibility); + dscene->prim_visibility.copy_to_device(); + } + if (bvh2->pack.prim_index.size()) { + dscene->prim_index.assign_mem(bvh2->pack.prim_index); + dscene->prim_index.copy_to_device(); + } + if (bvh2->pack.prim_object.size()) { + dscene->prim_object.assign_mem(bvh2->pack.prim_object); + dscene->prim_object.copy_to_device(); + } + if (bvh2->pack.prim_time.size()) { + dscene->prim_time.assign_mem(bvh2->pack.prim_time); + dscene->prim_time.copy_to_device(); + } + } +} + +void GeometryManager::device_update_bvh_postprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + BVH *bvh = scene->bvh; + + const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); + + //PackedBVH pack; + if (has_bvh2_layout) { + BVH2 *bvh2 = static_cast(scene->bvh); + //pack = std::move(static_cast(bvh)->pack); + dscene->data.bvh.root = bvh2->pack.root_index; + } + else { + //pack.root_index = -1; + dscene->data.bvh.root = -1; + } + + dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0); + dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions(); + dscene->data.device_bvh = 0; +} + +bool Geometry::create_new_bvh_if_needed(Object *object, + Device *device, + DeviceScene *dscene, + SceneParams *params) +{ + bool status = false; + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, + device->get_bvh_layout_mask()); + if (need_build_bvh(bvh_layout)) { + /* Ensure all visibility bits are set at the geometry level BVH. In + * the object level BVH is where actual visibility is tested. */ + object->set_is_shadow_catcher(true); + object->set_visibility(~0); + + object->set_geometry(this); + + vector geometry; + geometry.push_back(this); + vector objects; + objects.push_back(object); + + if (bvh && !need_update_rebuild) { + bvh->replace_geometry(geometry, objects); + } + else { + if (bvh != NULL) { + delete bvh; + } + const BVHLayout bvh_layout = BVHParams::best_bvh_layout(params->bvh_layout, + device->get_bvh_layout_mask()); + + BVHParams bparams; + bparams.use_spatial_split = params->use_bvh_spatial_split; + bparams.use_compact_structure = params->use_bvh_compact_structure; + bparams.bvh_layout = bvh_layout; + bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && + params->use_bvh_unaligned_nodes; + bparams.num_motion_triangle_steps = params->num_bvh_time_steps; + bparams.num_motion_curve_steps = params->num_bvh_time_steps; + bparams.num_motion_point_steps = params->num_bvh_time_steps; + bparams.bvh_type = params->bvh_type; + bparams.curve_subdivisions = params->curve_subdivisions(); + bvh = BVH::create(bparams, geometry, objects, device); + need_update_rebuild = true; + } + status = true; + } + + return status; +} + +void GeometryManager::device_update_sub_bvh(Device *device, + DeviceScene *dscene, + BVH *bvh, + BVH *sub_bvh, + bool can_refit, + size_t n, + size_t total, + Progress *progress) +{ + string msg = "Updating Geometry BVH"; + + // Is this a multi-bvh? + if (sub_bvh && can_refit) { + progress->set_status(msg, "Refitting BVH"); + // Don't redo the setup if this is not a sub-bvh + if (sub_bvh != bvh) { + sub_bvh->replace_geometry(bvh->geometry, bvh->objects); + // sub_bvh->geometry = bvh->geometry; + // sub_bvh->objects = bvh->objects; + } + } + else { + progress->set_status(msg, "Building BVH"); + // Don't redo the setup if this is not a sub-bvh + if (sub_bvh != bvh) { + // Yes, so setup the device specific sub_bvh in the multi-bvh. + BVHParams bparams = bvh->params; + // Set the layout to the correct one for the device + if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) + bparams.bvh_layout = BVH_LAYOUT_OPTIX; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) + bparams.bvh_layout = BVH_LAYOUT_METAL; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + bparams.bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : + BVH_LAYOUT_EMBREE; + else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + bparams.bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : + BVH_LAYOUT_EMBREE; + if (sub_bvh != NULL) { + delete sub_bvh; + } + VLOG_INFO << "Sub-BVH using layout " << bvh_layout_name(bparams.bvh_layout) << " from layout " << bvh_layout_name(bvh->params.bvh_layout); + /* BVH2 should not have a sub-bvh as only 1 is built on the CPU */ + assert(bparams.bvh_layout != BVH_LAYOUT_BVH2); + if(bparams.bvh_layout != BVH_LAYOUT_BVH2) { + sub_bvh = BVH::create(bparams, bvh->geometry, bvh->objects, device); + bvh->set_device_bvh(device, sub_bvh); + } + } + can_refit = false; + } + device->build_bvh(sub_bvh, dscene, *progress, can_refit); +} + +bool GeometryManager::device_update_bvh_preprocess(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + /* bvh build */ + + BVHParams bparams; + bparams.top_level = true; + bparams.bvh_layout = BVHParams::best_bvh_layout(scene->params.bvh_layout, + device->get_bvh_layout_mask()); + bparams.use_spatial_split = scene->params.use_bvh_spatial_split; + bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && + scene->params.use_bvh_unaligned_nodes; + bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; + bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; + bparams.num_motion_point_steps = scene->params.num_bvh_time_steps; + bparams.bvh_type = scene->params.bvh_type; + bparams.curve_subdivisions = scene->params.curve_subdivisions(); + + VLOG_INFO << "Using " << bvh_layout_name(bparams.bvh_layout) << " layout."; + + const bool can_refit = scene->bvh != nullptr && + (bparams.bvh_layout == BVHLayout::BVH_LAYOUT_OPTIX || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_METAL || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_OPTIX || + bparams.bvh_layout == BVHLayout::BVH_LAYOUT_MULTI_METAL); + + BVH *bvh = scene->bvh; + if (!scene->bvh) { + bvh = scene->bvh = BVH::create(bparams, scene->geometry, scene->objects, device); + } + /* Mark BVH as having not been built yet */ + bvh->built = false; + return can_refit; +} + +/* + * Creates a new BVH for the geometry if it is needed otherwise + * it determines if the BVH can be refitted. It also counts + * the number of BVH that need to be built. + */ +size_t GeometryManager::createObjectBVHs(Device *device, + DeviceScene *dscene, + Scene *scene, + const BVHLayout bvh_layout, + bool &need_update_scene_bvh) +{ + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (object BVHs preprocess)", time}); + } + }); + size_t num_bvh = 0; + + if (scene->geometry.size() > object_pool.size()) { + object_pool.resize(scene->geometry.size()); + } + + // Create BVH structures where needed + int id = 0; + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified() || geom->need_update_bvh_for_offset) { + need_update_scene_bvh = true; + Object *object = &object_pool[id]; + if(geom->create_new_bvh_if_needed(object, device, dscene, &scene->params)) { + num_bvh++; + } + } + id++; + } + + return num_bvh; +} + +/* + * Prepares scene BVH for building or refitting. Then builds or refits the scene + * BVH for all the devices. + */ +void GeometryManager::updateSceneBVHs(Device *device, + DeviceScene *dscene, + Scene *scene, + Progress &progress) +{ + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); + } + }); + + bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); + foreach (auto sub_dscene, scene->dscenes) { + Device *sub_device = sub_dscene->tri_verts.device; + device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); + } + device_update_bvh_postprocess(device, dscene, scene, progress); +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/scene/geometry_mesh.cpp b/intern/cycles/scene/geometry_mesh.cpp new file mode 100644 index 00000000000..5cdb369620f --- /dev/null +++ b/intern/cycles/scene/geometry_mesh.cpp @@ -0,0 +1,192 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#include "bvh/bvh.h" +#include "bvh/bvh2.h" + +#include "device/device.h" + +#include "scene/attribute.h" +#include "scene/camera.h" +#include "scene/geometry.h" +#include "scene/hair.h" +#include "scene/light.h" +#include "scene/mesh.h" +#include "scene/object.h" +#include "scene/pointcloud.h" +#include "scene/scene.h" +#include "scene/shader.h" +#include "scene/shader_nodes.h" +#include "scene/stats.h" +#include "scene/volume.h" + +#include "subd/patch_table.h" +#include "subd/split.h" + +#include "kernel/osl/globals.h" + +#include "util/foreach.h" +#include "util/log.h" +#include "util/progress.h" +#include "util/task.h" + +CCL_NAMESPACE_BEGIN + +/** + * This copies the data to the devices if they have been modified + */ +void GeometryManager::device_update_mesh(Device *device, + DeviceScene *dscene, + const GeometrySizes *p_sizes, + Progress &progress) +{ + progress.set_status("Updating Mesh", "Copying Mesh to device"); + if (p_sizes->tri_size != 0) { + dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); + dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); + dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); + dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); + } + + if (p_sizes->curve_segment_size != 0) { + dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); + dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); + dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); + } + + if (p_sizes->point_size != 0) { + dscene->points.copy_to_device(p_sizes->point_size, 0); + dscene->points_shader.copy_to_device(p_sizes->point_size, 0); + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + dscene->patches.copy_to_device(p_sizes->patch_size, 0); + } +} + +/** + * Packs the geometry data into the device scene. That is it fills out + * the geometry buffers + */ +void GeometryManager::device_update_mesh_preprocess( + Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *p_sizes, Progress &progress) +{ + /* Fill in all the arrays. */ + if (p_sizes->tri_size != 0) { + /* normals */ + progress.set_status("Updating Mesh", "Computing mesh"); + + packed_float3 *tri_verts = dscene->tri_verts.alloc(p_sizes->vert_size); + uint *tri_shader = dscene->tri_shader.alloc(p_sizes->tri_size); + packed_float3 *vnormal = dscene->tri_vnormal.alloc(p_sizes->vert_size); + packed_uint3 *tri_vindex = dscene->tri_vindex.alloc(p_sizes->tri_size); + uint *tri_patch = dscene->tri_patch.alloc(p_sizes->tri_size); + float2 *tri_patch_uv = dscene->tri_patch_uv.alloc(p_sizes->vert_size); + + const bool copy_all_data = dscene->tri_shader.need_realloc() || + dscene->tri_vindex.need_realloc() || + dscene->tri_vnormal.need_realloc() || + dscene->tri_patch.need_realloc() || + dscene->tri_patch_uv.need_realloc(); + + foreach (Geometry *geom, scene->geometry) { + if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { + Mesh *mesh = static_cast(geom); + + if (mesh->shader_is_modified() || mesh->smooth_is_modified() || + mesh->triangles_is_modified() || copy_all_data) { + mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); + } + + if (mesh->verts_is_modified() || copy_all_data) { + mesh->pack_normals(&vnormal[mesh->vert_offset]); + } + + if (mesh->verts_is_modified() || mesh->triangles_is_modified() || + mesh->vert_patch_uv_is_modified() || copy_all_data) { + mesh->pack_verts(&tri_verts[mesh->vert_offset], + &tri_vindex[mesh->prim_offset], + &tri_patch[mesh->prim_offset], + &tri_patch_uv[mesh->vert_offset]); + } + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->curve_segment_size != 0) { + progress.set_status("Updating Mesh", "Computing curves"); + + float4 *curve_keys = dscene->curve_keys.alloc(p_sizes->curve_key_size); + KernelCurve *curves = dscene->curves.alloc(p_sizes->curve_size); + KernelCurveSegment *curve_segments = dscene->curve_segments.alloc(p_sizes->curve_segment_size); + + const bool copy_all_data = dscene->curve_keys.need_realloc() || + dscene->curves.need_realloc() || + dscene->curve_segments.need_realloc(); + + foreach (Geometry *geom, scene->geometry) { + if (geom->is_hair()) { + Hair *hair = static_cast(geom); + + bool curve_keys_co_modified = hair->curve_radius_is_modified() || + hair->curve_keys_is_modified(); + bool curve_data_modified = hair->curve_shader_is_modified() || + hair->curve_first_key_is_modified(); + + if (!curve_keys_co_modified && !curve_data_modified && !copy_all_data) { + continue; + } + + hair->pack_curves(scene, + &curve_keys[hair->curve_key_offset], + &curves[hair->prim_offset], + &curve_segments[hair->curve_segment_offset]); + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->point_size != 0) { + progress.set_status("Updating Mesh", "Computing point clouds"); + + float4 *points = dscene->points.alloc(p_sizes->point_size); + uint *points_shader = dscene->points_shader.alloc(p_sizes->point_size); + + foreach (Geometry *geom, scene->geometry) { + if (geom->is_pointcloud()) { + PointCloud *pointcloud = static_cast(geom); + pointcloud->pack( + scene, &points[pointcloud->prim_offset], &points_shader[pointcloud->prim_offset]); + // if (progress.get_cancel()) + // return; + } + } + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + progress.set_status("Updating Mesh", "Computing patches"); + + uint *patch_data = dscene->patches.alloc(p_sizes->patch_size); + foreach (Geometry *geom, scene->geometry) { + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + mesh->pack_patches(&patch_data[mesh->patch_offset]); + + if (mesh->patch_table) { + mesh->patch_table->copy_adjusting_offsets(&patch_data[mesh->patch_table_offset], + mesh->patch_table_offset); + } + + // if (progress.get_cancel()) + // return; + } + } + } +} + +CCL_NAMESPACE_END -- 2.30.2 From 5409cc201177e0e0f7cfce0ac159a782c683bc79 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 6 Apr 2023 16:47:28 +0200 Subject: [PATCH 30/96] Refactor memory copy methods to remove duplication --- intern/cycles/device/cpu/device_impl.cpp | 39 ++++++-------- intern/cycles/device/cpu/device_impl.h | 3 +- intern/cycles/device/cuda/device_impl.cpp | 23 -------- intern/cycles/device/cuda/device_impl.h | 4 +- intern/cycles/device/device.cpp | 22 ++------ intern/cycles/device/device.h | 6 +-- intern/cycles/device/dummy/device.cpp | 2 +- intern/cycles/device/hip/device_impl.cpp | 23 -------- intern/cycles/device/hip/device_impl.h | 4 +- intern/cycles/device/memory.cpp | 9 +--- intern/cycles/device/memory.h | 29 +++------- intern/cycles/device/metal/device_impl.h | 8 +-- intern/cycles/device/metal/device_impl.mm | 39 +------------- intern/cycles/device/multi/device.cpp | 66 +---------------------- 14 files changed, 39 insertions(+), 238 deletions(-) diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index 9b7d1428ec2..451108f79d1 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -134,32 +134,27 @@ void CPUDevice::mem_alloc(device_memory &mem) } } -void CPUDevice::mem_copy_to(device_memory &mem) +void CPUDevice::mem_copy_to(device_memory &mem, size_t /* size */, size_t /* offset */) { - if (mem.type == MEM_GLOBAL) { - global_free(mem); - global_alloc(mem); - } - else if (mem.type == MEM_TEXTURE) { - tex_free((device_texture &)mem); - tex_alloc((device_texture &)mem); - } - else { - if (!mem.device_pointer) { - mem_alloc(mem); - } - - /* copy is no-op */ - } -} - -void CPUDevice::mem_copy_to(device_memory &mem, size_t, size_t offset) -{ - /* size (2n param) is not used as this does not actually copy anything + /* size (2n param) or offset are not used as this does not actually copy anything * as the original host memory is used as is. The device * memory is the same memory. */ - mem_copy_to(mem); + if (mem.type == MEM_GLOBAL) { + global_free(mem); + global_alloc(mem); + } + else if (mem.type == MEM_TEXTURE) { + tex_free((device_texture &)mem); + tex_alloc((device_texture &)mem); + } + else { + if (!mem.device_pointer) { + mem_alloc(mem); + } + + /* copy is no-op */ + } } void CPUDevice::mem_copy_from( diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index d6b9b83ce6f..e2efe536a2c 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -63,8 +63,7 @@ class CPUDevice : public Device { bool load_texture_info(); virtual void mem_alloc(device_memory &mem) override; - virtual void mem_copy_to(device_memory &mem) override; - virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + virtual void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; virtual void mem_copy_from( device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; virtual void mem_zero(device_memory &mem) override; diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index 83e9c0a13bd..e113c355b0e 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -584,29 +584,6 @@ void CUDADevice::mem_alloc(device_memory &mem) } } -void CUDADevice::mem_copy_to(device_memory &mem) -{ - if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { - global_free(mem); - global_alloc(mem); - } - else { - generic_copy_to(mem); - } - } - else if (mem.type == MEM_TEXTURE) { - tex_free((device_texture &)mem); - tex_alloc((device_texture &)mem); - } - else { - if (!mem.device_pointer) { - generic_alloc(mem); - } - generic_copy_to(mem); - } -} - void CUDADevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.type == MEM_GLOBAL) { diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index 864f8b29b4d..9202c3573e4 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -76,9 +76,7 @@ class CUDADevice : public GPUDevice { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem) override; - - void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 38a00418457..8c79eb5c65a 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -794,33 +794,19 @@ void GPUDevice::generic_free(device_memory &mem) } } -void GPUDevice::generic_copy_to(device_memory &mem) -{ - if (!mem.host_pointer || !mem.device_pointer) { - return; - } - - /* If use_mapped_host of mem is false, the current device only uses device memory allocated by - * backend device allocation regardless of mem.host_pointer and mem.shared_pointer, and should - * copy data from mem.host_pointer. */ - thread_scoped_lock lock(device_mem_map_mutex); - if (!device_mem_map[&mem].use_mapped_host || mem.host_pointer != mem.shared_pointer) { - copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size(), 0); - } -} - void GPUDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) -{ +{ if (!mem.host_pointer || !mem.device_pointer) { return; } - + /* If use_mapped_host of mem is false, the current device only uses device memory allocated by * cuMemAlloc regardless of mem.host_pointer and mem.shared_pointer, and should copy data from * mem.host_pointer. */ thread_scoped_lock lock(device_mem_map_mutex); if (!device_mem_map[&mem].use_mapped_host || mem.host_pointer != mem.shared_pointer) { - copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, mem.memory_size(), offset); + size = ((size == -1) ? mem.memory_size() : size); + copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, size, offset); } } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index adf8dd70b26..900dd714081 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -300,8 +300,7 @@ class Device { virtual void *host_mem_alloc(size_t size, int alignment); virtual void host_mem_free(void *p_mem); virtual void mem_alloc(device_memory &mem) = 0; - virtual void mem_copy_to(device_memory &mem) = 0; - virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) = 0; + virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset = 0) = 0; virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) = 0; virtual void mem_zero(device_memory &mem) = 0; virtual void mem_free(device_memory &mem) = 0; @@ -383,8 +382,7 @@ class GPUDevice : public Device { * support of device/host allocations. */ virtual GPUDevice::Mem *generic_alloc(device_memory &mem, size_t pitch_padding = 0); virtual void generic_free(device_memory &mem); - virtual void generic_copy_to(device_memory &mem); - void generic_copy_to(device_memory &mem, size_t size, size_t offset); + virtual void generic_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0); /* total - amount of device memory, free - amount of available device memory */ virtual void get_device_memory_info(size_t &total, size_t &free) = 0; diff --git a/intern/cycles/device/dummy/device.cpp b/intern/cycles/device/dummy/device.cpp index d81a9fcfa6a..c486aad764e 100644 --- a/intern/cycles/device/dummy/device.cpp +++ b/intern/cycles/device/dummy/device.cpp @@ -27,7 +27,7 @@ class DummyDevice : public Device { virtual void mem_alloc(device_memory &) override {} - virtual void mem_copy_to(device_memory &) override {} + // virtual void mem_copy_to(device_memory &) override {} virtual void mem_copy_to(device_memory &, size_t, size_t) override {} diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index 07386a846de..c68b798b749 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -531,29 +531,6 @@ void HIPDevice::mem_alloc(device_memory &mem) } } -void HIPDevice::mem_copy_to(device_memory &mem) -{ - if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { - global_free(mem); - global_alloc(mem); - } - else { - generic_copy_to(mem); - } - } - else if (mem.type == MEM_TEXTURE) { - tex_free((device_texture &)mem); - tex_alloc((device_texture &)mem); - } - else { - if (!mem.device_pointer) { - generic_alloc(mem); - } - generic_copy_to(mem); - } -} - void HIPDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.type == MEM_GLOBAL) { diff --git a/intern/cycles/device/hip/device_impl.h b/intern/cycles/device/hip/device_impl.h index 00418ab16da..6f9f2fb0356 100644 --- a/intern/cycles/device/hip/device_impl.h +++ b/intern/cycles/device/hip/device_impl.h @@ -67,9 +67,7 @@ class HIPDevice : public GPUDevice { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem) override; - - void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index b6ab6d35ae7..c93392c0c0e 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -82,17 +82,10 @@ void device_memory::device_free() } } -void device_memory::device_copy_to() -{ - if (host_pointer) { - device->mem_copy_to(*this); - } -} - void device_memory::device_copy_to(size_t size, size_t offset) { if (host_pointer) { - device->mem_copy_to(*this, size, offset); + device->mem_copy_to(*this, memory_elements_size(size), memory_elements_size(offset)); } } diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index daab1391ed7..f0397c35355 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -286,8 +286,7 @@ class device_memory { /* Device memory allocation and copying. */ void device_alloc(); void device_free(); - void device_copy_to(); - void device_copy_to(size_t size, size_t offset); + void device_copy_to(size_t size = -1, size_t offset = 0); void device_copy_from(size_t y, size_t w, size_t h, size_t elem); void device_zero(); @@ -430,7 +429,6 @@ template class device_vector : public device_memory { host_free(); if (new_size > data_size) { device_free(); - // host_pointer = host_alloc(sizeof(T) * new_size); modified = true; assert(device_pointer == 0); } @@ -584,21 +582,15 @@ template class device_vector : public device_memory { return data()[i]; } - void copy_to_device() + void copy_to_device(size_t size = -1, size_t offset = 0) { - if (data_size != 0) { - device_copy_to(); - } - } - - void copy_to_device(size_t size, size_t offset) - { - if (data_size != 0) { - assert(size <= data_size); + size = ((size == -1) ? data_size : size); + if (data_size != 0) { + assert((size + offset) <= data_size); device_copy_to(size, offset); } } - void copy_to_device_if_modified(size_t size, size_t offset) + void copy_to_device_if_modified(size_t size = -1, size_t offset = 0) { if (!modified) { return; @@ -607,15 +599,6 @@ template class device_vector : public device_memory { copy_to_device(size, offset); } - void copy_to_device_if_modified() - { - if (!modified) { - return; - } - - copy_to_device(); - } - void clear_modified() { modified = false; diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 821c4c41cd1..61e4de86ed8 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -147,17 +147,13 @@ class MetalDevice : public Device { MetalMem *generic_alloc(device_memory &mem); - void generic_copy_to(device_memory &mem); - - void generic_copy_to(device_memory &mem, size_t size, size_t offset); + void generic_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0); void generic_free(device_memory &mem); void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem) override; - - void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; void mem_copy_from(device_memory &mem) { diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index b2ea3b5c4e3..6e3deb324e3 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -766,30 +766,15 @@ size_t offset) std::lock_guard lock(metal_mem_map_mutex); if (!metal_mem_map.at(&mem)->use_UMA || mem.host_pointer != mem.shared_pointer) { + size = ((size == -1) ? mem.memory_size() : size); MetalMem &mmem = *metal_mem_map.at(&mem); - memcpy(mmem.hostPtr, mem.host_pointer, mem.memory_size()); + memcpy( reinterpret_cast(mmem.hostPtr) + offset, reinterpret_cast(mem.host_pointer) + offset, size); if (mmem.mtlBuffer.storageMode == MTLStorageModeManaged) { [mmem.mtlBuffer didModifyRange:NSMakeRange(offset, size)]; } } } -void MetalDevice::generic_copy_to(device_memory &mem) -{ - if (!mem.host_pointer || !mem.device_pointer) { - return; - } - - std::lock_guard lock(metal_mem_map_mutex); - if (!metal_mem_map.at(&mem)->use_UMA || mem.host_pointer != mem.shared_pointer) { - MetalMem &mmem = *metal_mem_map.at(&mem); - memcpy(mmem.hostPtr, mem.host_pointer, mem.memory_size()); - if (mmem.mtlBuffer.storageMode == MTLStorageModeManaged) { - [mmem.mtlBuffer didModifyRange:NSMakeRange(0, mem.memory_size())]; - } - } -} - void MetalDevice::generic_free(device_memory &mem) { if (mem.device_pointer) { @@ -870,26 +855,6 @@ void MetalDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) } } -void MetalDevice::mem_copy_to(device_memory &mem) -{ - if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { - global_free(mem); - global_alloc(mem); - } - } - else if (mem.type == MEM_TEXTURE) { - tex_free((device_texture &)mem); - tex_alloc((device_texture &)mem); - } - else { - if (!mem.device_pointer) { - generic_alloc(mem); - } - generic_copy_to(mem); - } -} - void MetalDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) { if (mem.host_pointer) { diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 09adfefff56..c741f565c55 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -307,37 +307,6 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov stats.mem_alloc(mem.device_size); } - void mem_copy_to(device_memory &mem) override - { - device_ptr existing_key = mem.device_pointer; - device_ptr key = (existing_key) ? existing_key : unique_key++; - size_t existing_size = mem.device_size; - - /* The tile buffers are allocated on each device (see below), so copy to all of them */ - foreach (const vector &island, peer_islands) { - SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); - mem.device = owner_sub->device; - mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; - mem.device_size = existing_size; - - owner_sub->device->mem_copy_to(mem); - owner_sub->ptr_map[key] = mem.device_pointer; - - if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) { - /* Need to create texture objects and update pointer in kernel globals on all devices */ - foreach (SubDevice *island_sub, island) { - if (island_sub != owner_sub) { - island_sub->device->mem_copy_to(mem); - } - } - } - } - - mem.device = this; - mem.device_pointer = key; - stats.mem_alloc(mem.device_size - existing_size); - } - void mem_copy_to(device_memory &mem, size_t size, size_t offset) override { device_ptr existing_key = mem.device_pointer; @@ -351,7 +320,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; mem.device_size = existing_size; - owner_sub->device->mem_copy_to(mem); + owner_sub->device->mem_copy_to(mem, size, offset); owner_sub->ptr_map[key] = mem.device_pointer; if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) { @@ -447,39 +416,6 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov } } - // void mem_free(device_memory &mem) override - // { - // device_ptr key = mem.device_pointer; - // size_t existing_size = mem.device_size; - - // /* Free memory that was allocated for all devices (see above) on each device */ - // foreach (const vector &island, peer_islands) { - // SubDevice *owner_sub = find_matching_mem_device(key, island.front()); - // mem.device = owner_sub->device; - // mem.device_pointer = owner_sub->ptr_map[key]; - // mem.device_size = existing_size; - - // owner_sub->device->mem_free(mem); - // owner_sub->ptr_map.erase(owner_sub->ptr_map.find(key)); - - // if (mem.type == MEM_TEXTURE) { - // /* Free texture objects on all devices */ - // foreach (SubDevice *island_sub, island) { - // if (island_sub != owner_sub) { - // island_sub->device->mem_free(mem); - // } - // } - // } - // } - - // if (mem.device_pointer) { - // mem.device = this; - // mem.device_pointer = 0; - // mem.device_size = 0; - // stats.mem_free(existing_size); - // } - // } - void const_copy_to(const char *name, void *host, size_t size) override { foreach (SubDevice *sub, devices) -- 2.30.2 From 9b3b180d232779df06abce21c9c691c6378ba01c Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 4 Apr 2023 16:23:47 +0200 Subject: [PATCH 31/96] FIX: Enable OneAPI build and fix compile issues Needed to add the memory copy methods the have offset and size. --- intern/cycles/device/oneapi/device_impl.cpp | 13 ++++++------- intern/cycles/device/oneapi/device_impl.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index 0aec8268bd5..65d7d4d6c33 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -154,17 +154,16 @@ void OneapiDevice::generic_alloc(device_memory &mem) stats.mem_alloc(memory_size); } -void OneapiDevice::generic_copy_to(device_memory &mem) +void OneapiDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) { if (!mem.device_pointer) { return; } - size_t memory_size = mem.memory_size(); /* Copy operation from host shouldn't be requested if there is no memory allocated on host. */ assert(mem.host_pointer); assert(device_queue_); - usm_memcpy(device_queue_, (void *)mem.device_pointer, (void *)mem.host_pointer, memory_size); + usm_memcpy(device_queue_, reinterpret_cast(mem.device_pointer) + offset, reinterpret_cast(mem.host_pointer) + offset, size); } /* TODO: Make sycl::queue part of OneapiQueue and avoid using pointers to sycl::queue. */ @@ -215,12 +214,12 @@ void OneapiDevice::mem_alloc(device_memory &mem) } } -void OneapiDevice::mem_copy_to(device_memory &mem) +void OneapiDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.name) { VLOG_DEBUG << "OneapiDevice::mem_copy_to: \"" << mem.name << "\", " - << string_human_readable_number(mem.memory_size()) << " bytes. (" - << string_human_readable_size(mem.memory_size()) << ")"; + << string_human_readable_number(size) << " bytes. (" + << string_human_readable_size(size) << ")"; } if (mem.type == MEM_GLOBAL) { @@ -235,7 +234,7 @@ void OneapiDevice::mem_copy_to(device_memory &mem) if (!mem.device_pointer) mem_alloc(mem); - generic_copy_to(mem); + generic_copy_to(mem, size, offset); } } diff --git a/intern/cycles/device/oneapi/device_impl.h b/intern/cycles/device/oneapi/device_impl.h index 197cf03d60d..9761a12cea5 100644 --- a/intern/cycles/device/oneapi/device_impl.h +++ b/intern/cycles/device/oneapi/device_impl.h @@ -50,7 +50,7 @@ class OneapiDevice : public Device { void generic_alloc(device_memory &mem); - void generic_copy_to(device_memory &mem); + void generic_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0); void generic_free(device_memory &mem); @@ -60,7 +60,7 @@ class OneapiDevice : public Device { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem) override; + void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; -- 2.30.2 From ac67371fa4793f983543ee2e8f319e21bcc02c06 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 10 Apr 2023 19:37:48 +0200 Subject: [PATCH 32/96] Makes sure the CPU is the last device just once at the end. Previously after every device was added the CPU device was swopped to the end of the list. Now the position it was added at is saved and it is swopped with the last device at the end. --- intern/cycles/device/multi/device.cpp | 81 +++++++++++++-------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index c741f565c55..491dfe3cf27 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -41,54 +41,49 @@ class MultiDevice : public Device { MultiDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler) : Device(info, stats, profiler), unique_key(1) { - foreach (const DeviceInfo &subinfo, info.multi_devices) { - /* Always add CPU devices at the back since GPU devices can change - * host memory pointers, which CPU uses as device pointer. */ - SubDevice *sub = new SubDevice; - if (subinfo.type == DEVICE_CPU) { + int cpu_device_idx = -1; + foreach (const DeviceInfo &subinfo, info.multi_devices) { + /* Always add CPU devices at the back since GPU devices can change + * host memory pointers, which CPU uses as device pointer. */ + SubDevice *sub = new SubDevice; + if (subinfo.type == DEVICE_CPU) { + assert(cpu_device_idx == -1); + cpu_device_idx = devices.size(); + } devices.emplace_back(sub); + sub->device = Device::create(subinfo, sub->stats, profiler); } - else { - devices.emplace_back(sub); - // find first CPU device and swop it with the new device - // to keep the CPU devices at the end of the vector. + + /* Swop the CPU device with the last device to ensure the CPU device is the last */ + { int last = devices.size() - 1; - int o = last; - while ((o > 0) && (devices[o - 1]->device->info.type == DEVICE_CPU)) { - o--; - }; - if (o != last) { - std::swap(devices[last], devices[o]); - } - sub = devices[o]; - } - - sub->device = Device::create(subinfo, sub->stats, profiler); - } - - /* Build a list of peer islands for the available render devices */ - foreach (SubDevice *sub, devices) { - /* First ensure that every device is in at least once peer island */ - if (sub->peer_island_index < 0) { - peer_islands.emplace_back(); - sub->peer_island_index = (int)peer_islands.size() - 1; - peer_islands[sub->peer_island_index].push_back(sub); - } - - if (!info.has_peer_memory) { - continue; - } - - /* Second check peer access between devices and fill up the islands accordingly */ - foreach (SubDevice *peer_sub, devices) { - if (peer_sub->peer_island_index < 0 && - peer_sub->device->info.type == sub->device->info.type && - peer_sub->device->check_peer_access(sub->device)) { - peer_sub->peer_island_index = sub->peer_island_index; - peer_islands[sub->peer_island_index].push_back(peer_sub); + if (cpu_device_idx != last) { + std::swap(devices[last], devices[cpu_device_idx]); + } + } + /* Build a list of peer islands for the available render devices */ + foreach (SubDevice *sub, devices) { + /* First ensure that every device is in at least once peer island */ + if (sub->peer_island_index < 0) { + peer_islands.emplace_back(); + sub->peer_island_index = (int)peer_islands.size() - 1; + peer_islands[sub->peer_island_index].push_back(sub); + } + + if (!info.has_peer_memory) { + continue; + } + + /* Second check peer access between devices and fill up the islands accordingly */ + foreach (SubDevice *peer_sub, devices) { + if (peer_sub->peer_island_index < 0 && + peer_sub->device->info.type == sub->device->info.type && + peer_sub->device->check_peer_access(sub->device)) { + peer_sub->peer_island_index = sub->peer_island_index; + peer_islands[sub->peer_island_index].push_back(peer_sub); + } } } - } } ~MultiDevice() -- 2.30.2 From 674721194e92883ea34665b149475a3cdfe87ac3 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 09:36:58 +0200 Subject: [PATCH 33/96] FIX: Adds case where no CPU is selected in MultiDevice Forgot to push the code which skips swopping if the is no CPU in the MultiDevice set. --- intern/cycles/device/multi/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 491dfe3cf27..a483ba1cd35 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -57,7 +57,7 @@ class MultiDevice : public Device { /* Swop the CPU device with the last device to ensure the CPU device is the last */ { int last = devices.size() - 1; - if (cpu_device_idx != last) { + if ((cpu_device_idx != -1) && (cpu_device_idx != last)) { std::swap(devices[last], devices[cpu_device_idx]); } } -- 2.30.2 From 3c81e479a66764625a4c56a0d30765c40f7ec817 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 09:38:26 +0200 Subject: [PATCH 34/96] Switch off using pinned memory on CUDA devices Pinned memory was used for all device_memory. However, due to that it may cause memory pressure this was removed and can be enabled by passing USE_DEVICE_PINNED_MEMORY. --- intern/cycles/device/cuda/device_impl.cpp | 4 +++- intern/cycles/device/cuda/device_impl.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index e113c355b0e..70558351316 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -547,11 +547,12 @@ void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, s { const CUDAContextScope scope(this); - cuda_assert(cuMemcpyHtoD((CUdeviceptr)device_pointer + offset, + cuda_assert(cuMemcpyHtoD(reinterpret_cast(device_pointer) + offset, reinterpret_cast(host_pointer) + offset, size)); } +#ifdef USE_DEVICE_PINNED_MEMORY void *CUDADevice::host_mem_alloc(size_t size, int aligment) { void *p_mem = NULL; CUDAContextScope scope(this); @@ -570,6 +571,7 @@ void CUDADevice::host_mem_free(void *p_mem) { CUDAContextScope scope(this); cuMemFreeHost(p_mem); } +#endif void CUDADevice::mem_alloc(device_memory &mem) { diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index 9202c3573e4..1577c991ab1 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -71,8 +71,11 @@ class CUDADevice : public GPUDevice { virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; + +#ifdef USE_DEVICE_PINNED_MEMORY void *host_mem_alloc(size_t size, int aligment) override; void host_mem_free(void *p_mem) override; +#endif void mem_alloc(device_memory &mem) override; -- 2.30.2 From e3068b23b7bc51e4497a10bf419e6600159eeadc Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 10:49:46 +0200 Subject: [PATCH 35/96] Remove only allocating memory if it needs to be enlarged. --- intern/cycles/device/cuda/device_impl.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index 70558351316..cc5c8379f69 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -589,13 +589,8 @@ void CUDADevice::mem_alloc(device_memory &mem) void CUDADevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { - global_free(mem); - global_alloc(mem); - } - else { - generic_copy_to(mem, size, offset); - } + global_free(mem); + global_alloc(mem); } else if (mem.type == MEM_TEXTURE) { tex_free((device_texture &)mem); -- 2.30.2 From bd08b280a4d47ccf674421128144ebbc53c20739 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 10:50:15 +0200 Subject: [PATCH 36/96] Replace include with forward declaration of DeviceScene. --- intern/cycles/device/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 900dd714081..b08244cf9b2 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -7,7 +7,6 @@ #include #include "bvh/params.h" -#include "scene/scene.h" #include "device/denoise.h" #include "device/memory.h" @@ -30,6 +29,7 @@ class Progress; class CPUKernels; class CPUKernelThreadGlobals; class Scene; +class DeviceScene; /* Device Types */ -- 2.30.2 From 0f1e29912cd3a4011e87edcce494dfe878dffc52 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 11:20:56 +0200 Subject: [PATCH 37/96] Remove unused constructor --- intern/cycles/device/memory.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index f0397c35355..a5716bcf9f5 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -376,24 +376,6 @@ template class device_vector : public device_memory { assert(data_elements > 0); } - device_vector(Device *device, - const char *name, - void *p_mem, - size_t width, - size_t height, - size_t depth, - MemoryType type) - : device_memory(device, name, type) - { - data_type = device_type_traits::data_type; - data_elements = device_type_traits::num_elements; - modified = true; - need_realloc_ = true; - assign_mem(p_mem, width, height, depth); - - assert(data_elements > 0); - } - virtual ~device_vector() { free(); @@ -446,7 +428,7 @@ template class device_vector : public device_memory { T *alloc(size_t width, size_t height = 0, size_t depth = 0) { size_t new_size = size(width, height, depth); - if (new_size > data_size) { + if (new_size != data_size) { device_free(); host_free(); host_pointer = host_alloc(sizeof(T) * new_size); -- 2.30.2 From 32c44f9f439df9dddc6bfa41eb85ad91a5fbb9d7 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 11:42:44 +0200 Subject: [PATCH 38/96] Remove only grow memory allocation. --- intern/cycles/device/metal/device_impl.mm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index 6e3deb324e3..f92f8dd1fe0 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -835,13 +835,8 @@ void MetalDevice::mem_alloc(device_memory &mem) void MetalDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { - global_free(mem); - global_alloc(mem); - } - else { - generic_copy_to(mem, size, offset); - } + global_free(mem); + global_alloc(mem); } else if (mem.type == MEM_TEXTURE) { tex_free((device_texture &)mem); -- 2.30.2 From 511d8789214a0405ffc946c00fbcd5f2ffd3257d Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 13:41:45 +0200 Subject: [PATCH 39/96] Use unique_ptr to handle the SubDevice and Device pointers --- intern/cycles/device/multi/device.cpp | 201 +++++++++++++------------- 1 file changed, 98 insertions(+), 103 deletions(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index a483ba1cd35..9c4537ddf90 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -26,74 +26,68 @@ class MultiDevice : public Device { public: struct SubDevice { Stats stats; - Device *device; + unique_ptr device; map ptr_map; int peer_island_index = -1; }; - // Switch from list to a vector to make the parallel_for easily map to the integer id. - // Also id now could be used to access the real device pointer more quickly. Also, since - // the vector reallocates the memory on resize the sub-devices are stored as pointers. - vector devices; + /* Switch from list to a vector to make the parallel_for easily map to the integer id. + Also id now could be used to access the real device pointer more quickly. Also, since + the vector reallocates the memory on resize the sub-devices are stored as pointers. */ + vector> devices; device_ptr unique_key; vector> peer_islands; MultiDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler) : Device(info, stats, profiler), unique_key(1) { - int cpu_device_idx = -1; - foreach (const DeviceInfo &subinfo, info.multi_devices) { - /* Always add CPU devices at the back since GPU devices can change - * host memory pointers, which CPU uses as device pointer. */ - SubDevice *sub = new SubDevice; - if (subinfo.type == DEVICE_CPU) { - assert(cpu_device_idx == -1); - cpu_device_idx = devices.size(); - } - devices.emplace_back(sub); - sub->device = Device::create(subinfo, sub->stats, profiler); + int cpu_device_idx = -1; + foreach (const DeviceInfo &subinfo, info.multi_devices) { + /* Always add CPU devices at the back since GPU devices can change + * host memory pointers, which CPU uses as device pointer. */ + unique_ptr sub = make_unique(); + if (subinfo.type == DEVICE_CPU) { + assert(cpu_device_idx == -1); + cpu_device_idx = devices.size(); + } + sub->device = std::unique_ptr(Device::create(subinfo, sub->stats, profiler)); + devices.emplace_back(std::move(sub)); + } + + /* Swop the CPU device with the last device to ensure the CPU device is the last */ + { + int last = devices.size() - 1; + if ((cpu_device_idx != -1) && (cpu_device_idx != last)) { + std::swap(devices[last], devices[cpu_device_idx]); + } + } + /* Build a list of peer islands for the available render devices */ + foreach (auto &sub, devices) { + /* First ensure that every device is in at least once peer island */ + if (sub->peer_island_index < 0) { + peer_islands.emplace_back(); + sub->peer_island_index = (int)peer_islands.size() - 1; + peer_islands[sub->peer_island_index].push_back(sub.get()); } - /* Swop the CPU device with the last device to ensure the CPU device is the last */ - { - int last = devices.size() - 1; - if ((cpu_device_idx != -1) && (cpu_device_idx != last)) { - std::swap(devices[last], devices[cpu_device_idx]); + if (!info.has_peer_memory) { + continue; + } + + /* Second check peer access between devices and fill up the islands accordingly */ + foreach (auto &peer_sub, devices) { + if (peer_sub->peer_island_index < 0 && + peer_sub->device->info.type == sub->device->info.type && + peer_sub->device->check_peer_access(sub->device.get())) { + peer_sub->peer_island_index = sub->peer_island_index; + peer_islands[sub->peer_island_index].push_back(peer_sub.get()); } } - /* Build a list of peer islands for the available render devices */ - foreach (SubDevice *sub, devices) { - /* First ensure that every device is in at least once peer island */ - if (sub->peer_island_index < 0) { - peer_islands.emplace_back(); - sub->peer_island_index = (int)peer_islands.size() - 1; - peer_islands[sub->peer_island_index].push_back(sub); - } - - if (!info.has_peer_memory) { - continue; - } - - /* Second check peer access between devices and fill up the islands accordingly */ - foreach (SubDevice *peer_sub, devices) { - if (peer_sub->peer_island_index < 0 && - peer_sub->device->info.type == sub->device->info.type && - peer_sub->device->check_peer_access(sub->device)) { - peer_sub->peer_island_index = sub->peer_island_index; - peer_islands[sub->peer_island_index].push_back(peer_sub); - } - } - } - } - - ~MultiDevice() - { - foreach (SubDevice *sub, devices) { - delete sub->device; - delete sub; } } + ~MultiDevice() {} + int get_num_devices() const override { return devices.size(); @@ -103,7 +97,7 @@ class MultiDevice : public Device { { error_msg.clear(); - foreach (SubDevice *sub, devices) + foreach (auto &sub, devices) error_msg += sub->device->error_message(); return error_msg; @@ -113,7 +107,7 @@ class MultiDevice : public Device { { BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL; BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE; - foreach (const SubDevice *sub_device, devices) { + foreach (const auto &sub_device, devices) { BVHLayoutMask device_bvh_layout_mask = sub_device->device->get_bvh_layout_mask(); bvh_layout_mask &= device_bvh_layout_mask; bvh_layout_mask_all |= device_bvh_layout_mask; @@ -144,7 +138,7 @@ class MultiDevice : public Device { bool load_kernels(const uint kernel_features) override { - foreach (SubDevice *sub, devices) + foreach (auto &sub, devices) if (!sub->device->load_kernels(kernel_features)) return false; @@ -153,14 +147,14 @@ class MultiDevice : public Device { bool load_osl_kernels() override { - foreach (SubDevice *sub, devices) + foreach (auto &sub, devices) if (!sub->device->load_osl_kernels()) return false; return true; } -void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override + void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override { /* Try to build and share a single acceleration structure, if possible */ if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2 || bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) { @@ -177,38 +171,39 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov bvh_multi->sub_bvhs.resize(devices.size()); /* Broadcast acceleration structure build to all render devices */ - parallel_for(size_t(0), devices.size(), [this, &bvh_multi, &dscene, refit, &progress](size_t id) { - // WL: Pointer translation is removed as it is not thread safe. Instead a new method is added - // to retrieve the real device pointer. - SubDevice *sub = devices[id]; + parallel_for( + size_t(0), devices.size(), [this, &bvh_multi, &dscene, refit, &progress](size_t id) { + /* Pointer translation is removed as it is not thread safe. Instead a new method is added + to retrieve the real device pointer. */ + auto &sub = devices[id]; - if (!bvh_multi->sub_bvhs[id]) { - BVHParams params = bvh_multi->params; - if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) - params.bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) - params.bvh_layout = BVH_LAYOUT_METAL; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - params.bvh_layout = sub->device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : - BVH_LAYOUT_EMBREE; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - params.bvh_layout = sub->device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : - BVH_LAYOUT_EMBREE; + if (!bvh_multi->sub_bvhs[id]) { + BVHParams params = bvh_multi->params; + if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) + params.bvh_layout = BVH_LAYOUT_OPTIX; + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) + params.bvh_layout = BVH_LAYOUT_METAL; + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + params.bvh_layout = sub->device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : + BVH_LAYOUT_EMBREE; + else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + params.bvh_layout = sub->device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : + BVH_LAYOUT_EMBREE; - /* Skip building a bottom level acceleration structure for non-instanced geometry on Embree - * (since they are put into the top level directly, see bvh_embree.cpp) */ - if (!params.top_level && params.bvh_layout == BVH_LAYOUT_EMBREE && - !bvh_multi->geometry[0]->is_instanced()) { - } - else { - bvh_multi->sub_bvhs[id] = BVH::create( - params, bvh_multi->geometry, bvh_multi->objects, sub->device); - } - } - if (bvh_multi->sub_bvhs[id]) { - sub->device->build_bvh(bvh_multi->sub_bvhs[id], dscene, progress, refit); - } - }); + /* Skip building a bottom level acceleration structure for non-instanced geometry on + * Embree (since they are put into the top level directly, see bvh_embree.cpp) */ + if (!params.top_level && params.bvh_layout == BVH_LAYOUT_EMBREE && + !bvh_multi->geometry[0]->is_instanced()) { + } + else { + bvh_multi->sub_bvhs[id] = BVH::create( + params, bvh_multi->geometry, bvh_multi->objects, sub->device.get()); + } + } + if (bvh_multi->sub_bvhs[id]) { + sub->device->build_bvh(bvh_multi->sub_bvhs[id], dscene, progress, refit); + } + }); } virtual void *get_cpu_osl_memory() override @@ -224,9 +219,9 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov bool is_resident(device_ptr key, Device *sub_device) override { - foreach (SubDevice *sub, devices) { - if (sub->device == sub_device) { - return find_matching_mem_device(key, sub)->device == sub_device; + foreach (auto &sub, devices) { + if (sub->device.get() == sub_device) { + return find_matching_mem_device(key, sub.get())->device.get() == sub_device; } } return false; @@ -268,9 +263,9 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov inline device_ptr find_matching_mem(device_ptr key, Device *dev) override { device_ptr ptr = 0; - foreach (SubDevice *sub, devices) { - if (sub->device == dev) { - return find_matching_mem_device(key, sub)->ptr_map[key]; + foreach (auto &sub, devices) { + if (sub->device.get() == dev) { + return find_matching_mem_device(key, sub.get())->ptr_map[key]; } } return ptr; @@ -289,7 +284,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov /* The remaining memory types can be distributed across devices */ foreach (const vector &island, peer_islands) { SubDevice *owner_sub = find_suitable_mem_device(key, island); - mem.device = owner_sub->device; + mem.device = owner_sub->device.get(); mem.device_pointer = 0; mem.device_size = 0; @@ -311,7 +306,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov /* The tile buffers are allocated on each device (see below), so copy to all of them */ foreach (const vector &island, peer_islands) { SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); - mem.device = owner_sub->device; + mem.device = owner_sub->device.get(); mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; mem.device_size = existing_size; @@ -338,12 +333,12 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov device_ptr key = mem.device_pointer; size_t i = 0, sub_h = h / devices.size(); - foreach (SubDevice *sub, devices) { + foreach (auto &sub, devices) { size_t sy = y + i * sub_h; size_t sh = (i == (size_t)devices.size() - 1) ? h - sub_h * i : sub_h; - SubDevice *owner_sub = find_matching_mem_device(key, sub); - mem.device = owner_sub->device; + SubDevice *owner_sub = find_matching_mem_device(key, sub.get()); + mem.device = owner_sub->device.get(); mem.device_pointer = owner_sub->ptr_map[key]; owner_sub->device->mem_copy_from(mem, sy, w, sh, elem); @@ -362,7 +357,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov foreach (const vector &island, peer_islands) { SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); - mem.device = owner_sub->device; + mem.device = owner_sub->device.get(); mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; mem.device_size = existing_size; @@ -385,7 +380,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov /* Free memory that was allocated for all devices (see above) on each device */ foreach (const vector &island, peer_islands) { SubDevice *owner_sub = find_matching_mem_device(key, island.front()); - mem.device = owner_sub->device; + mem.device = owner_sub->device.get(); mem.device_pointer = owner_sub->ptr_map[key]; mem.device_size = existing_size; owner_sub->device->mem_free(mem); @@ -413,7 +408,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov void const_copy_to(const char *name, void *host, size_t size) override { - foreach (SubDevice *sub, devices) + foreach (auto &sub, devices) sub->device->const_copy_to(name, host, size); } @@ -421,8 +416,8 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov { int i = 0; - for (const SubDevice *sub : devices) { - if (sub->device == sub_device) + for (const auto &sub : devices) { + if (sub->device.get() == sub_device) return i; i++; } @@ -432,7 +427,7 @@ void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) ov virtual void foreach_device(const function &callback) override { - foreach (SubDevice *sub, devices) { + foreach (auto &sub, devices) { sub->device->foreach_device(callback); } } -- 2.30.2 From 8731ee976110855c2f63d5bd3f95f7419888fa20 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 13:51:56 +0200 Subject: [PATCH 40/96] Change swop to swap. --- intern/cycles/device/multi/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 9c4537ddf90..85bf3d5cd8e 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -54,7 +54,7 @@ class MultiDevice : public Device { devices.emplace_back(std::move(sub)); } - /* Swop the CPU device with the last device to ensure the CPU device is the last */ + /* Swap the CPU device with the last device to ensure the CPU device is the last */ { int last = devices.size() - 1; if ((cpu_device_idx != -1) && (cpu_device_idx != last)) { -- 2.30.2 From 6e904ef6b2e59b543a6620280874101d040bf2bb Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 13:52:22 +0200 Subject: [PATCH 41/96] Rename progressErrorCheck check_cancel_update --- intern/cycles/scene/scene.cpp | 34 +++++++++++++++++----------------- intern/cycles/scene/scene.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index fe8ea30440c..feb98eec4b4 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN * checks the progress for if a cancel has been requested and also * the device to see if an error has occurred. */ -bool Scene::progressErrorCheck(Progress &progress, Device *device) { +bool Scene::check_cancel_update(Progress &progress, Device *device) { bool status = false; if (!background && progress.get_updates()) { status = progress.get_cancel(); @@ -299,7 +299,7 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Shaders"); shader_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } procedural_manager->update(this, progress); @@ -309,12 +309,12 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Background"); background->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Camera"); camera->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } geometry_manager->device_update_preprocess(device, this, progress); @@ -324,67 +324,67 @@ void Scene::device_update(Device *device_, Progress &progress) progress.set_status("Updating Objects"); object_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Particle Systems"); particle_system_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Meshes"); geometry_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Objects Flags"); object_manager->device_update_flags(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Primitive Offsets"); object_manager->device_update_prim_offsets(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Images"); image_manager->device_update(device, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Camera Volume"); camera->device_update_volume(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Lookup Tables"); lookup_tables->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Lights"); light_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Integrator"); integrator->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Film"); film->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Lookup Tables"); lookup_tables->device_update(device, &dscene, this); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } progress.set_status("Updating Baking"); bake_manager->device_update(device, &dscene, this, progress); - if(progressErrorCheck(progress, device)) { return; } + if(check_cancel_update(progress, device)) { return; } if (device->have_error() == false) { dscene.data.volume_stack_size = get_volume_stack_size(); diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 9f931d801e6..b1dfd82051a 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -343,7 +343,7 @@ class Scene : public NodeOwner { * checks the progress for if a cancel has been requested and also * the device to see if an error has occurred. */ - bool progressErrorCheck(Progress &progress, Device *device); + bool check_cancel_update(Progress &progress, Device *device); /* Check if some heavy data worth logging was updated. * Mainly used to suppress extra annoying logging. -- 2.30.2 From 06b43213b7f35006c75a81c11837f34521f29f0b Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 14:37:57 +0200 Subject: [PATCH 42/96] Don't use background to disable progress update. --- intern/cycles/scene/scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index feb98eec4b4..5a635a8c8f4 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -39,7 +39,7 @@ CCL_NAMESPACE_BEGIN */ bool Scene::check_cancel_update(Progress &progress, Device *device) { bool status = false; - if (!background && progress.get_updates()) { + if (progress.get_updates()) { status = progress.get_cancel(); } return status || ((device != NULL) && device->have_error()); -- 2.30.2 From 506106b3a8f7f322a7b60a8c0a011626725259bb Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 14:38:36 +0200 Subject: [PATCH 43/96] Remove custom spin lock and replace with that from utils/thread.h --- intern/cycles/util/progress.h | 209 +++++++++------------------------- 1 file changed, 51 insertions(+), 158 deletions(-) diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 563cd1e7eae..9dd3c13479c 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -4,10 +4,10 @@ #ifndef __UTIL_PROGRESS_H__ #define __UTIL_PROGRESS_H__ -//#define USE_SPINLOCK +#define USE_SPINLOCK #ifdef USE_SPINLOCK -#define MUTEX SpinLock -#define SCOPED_LOCK(mutex) ScopedSpinLock scopedspinlock(mutex) +#define MUTEX thread_spin_lock +#define SCOPED_LOCK(mutex) thread_scoped_spin_lock scopedspinlock(mutex); #else #define MUTEX thread_mutex #define SCOPED_LOCK(mutex) thread_scoped_lock scopedlock(mutex) @@ -28,49 +28,10 @@ CCL_NAMESPACE_BEGIN -class SpinLock { -public: - SpinLock() - { - update_status = true; - }; - - void lock() - { - // Busy wait until update status is true - bool can_update = true; - while (!update_status.compare_exchange_weak(can_update, false)) { - }; - }; - - void unlock() - { - update_status = true; - }; - -private: - std::atomic update_status; -}; - -class ScopedSpinLock { -public: - ScopedSpinLock(SpinLock &spinlock) : spinlock_(spinlock) - { - spinlock_.lock(); - }; - - ~ScopedSpinLock() - { - spinlock_.unlock(); - } -private: - SpinLock &spinlock_; -}; - class Progress { public: using callback_type = function; - + Progress() { pixel_samples = 0; @@ -93,8 +54,6 @@ class Progress { error_message = ""; cancel_cb = function_null; updates = true; - // update_call = true; - // update_status = true; } Progress(Progress &progress) @@ -105,14 +64,12 @@ class Progress { Progress &operator=(Progress &progress) { SCOPED_LOCK(progress_mutex); - //update_progress([this, &progress]() { - progress.get_status(status, substatus); + progress.get_status(status, substatus); + + pixel_samples = progress.pixel_samples; + total_pixel_samples = progress.total_pixel_samples; + current_tile_sample = progress.get_current_sample(); - pixel_samples = progress.pixel_samples; - total_pixel_samples = progress.total_pixel_samples; - current_tile_sample = progress.get_current_sample(); - //}); - return *this; } @@ -138,19 +95,18 @@ class Progress { updates = true; } - void set_updates(bool updates_) { + void set_updates(bool updates_) + { updates = updates_; - VLOG_INFO << "Set progress updates " << (updates_? "on" : "off"); + VLOG_INFO << "Set progress updates " << (updates_ ? "on" : "off"); } - + /* cancel */ void set_cancel(const string &cancel_message_) { SCOPED_LOCK(progress_mutex); - //update_progress([this, cancel_message_]() { cancel_message = cancel_message_; cancel = true; - //}); } bool get_cancel() const @@ -166,13 +122,9 @@ class Progress { return updates; } - string get_cancel_message() //const + string get_cancel_message() // const { SCOPED_LOCK(progress_mutex); - //string msg; - //update_progress([this, &msg]() { - //msg = cancel_message; - //}); return cancel_message; } @@ -185,13 +137,11 @@ class Progress { void set_error(const string &error_message_) { SCOPED_LOCK(progress_mutex); - //update_progress([this, error_message_]() { error_message = error_message_; error = true; /* If error happens we also stop rendering. */ cancel_message = error_message_; cancel = true; - //}); } bool get_error() const @@ -202,10 +152,6 @@ class Progress { string get_error_message() // const { SCOPED_LOCK(progress_mutex); - //string msg; - //update_progress([this, &msg]() { - //msg = error_message; - //}); return error_message; } @@ -214,26 +160,20 @@ class Progress { void set_start_time() { SCOPED_LOCK(progress_mutex); - //update_progress([this]() { start_time = time_dt(); end_time = 0.0; - //}); } void set_render_start_time() { SCOPED_LOCK(progress_mutex); - //update_progress([this]() { render_start_time = time_dt(); - //}); } void set_time_limit(double time_limit_) { SCOPED_LOCK(progress_mutex); - //update_progress([this, time_limit_]() { time_limit = time_limit_; - //}); } void add_skip_time(const scoped_timer &start_timer, bool only_render) @@ -246,16 +186,14 @@ class Progress { } } - void get_time(double &total_time_, double &render_time_) //const + void get_time(double &total_time_, double &render_time_) // const { SCOPED_LOCK(progress_mutex); - //update_progress([this, &total_time_, &render_time_](){ double et = end_time; double time = (et > 0) ? et : time_dt(); total_time_ = time - start_time; render_time_ = time - render_start_time; - //}); } void set_end_time() @@ -274,25 +212,21 @@ class Progress { void set_total_pixel_samples(uint64_t total_pixel_samples_) { SCOPED_LOCK(progress_mutex); - //update_progress([this, total_pixel_samples_](){ total_pixel_samples = total_pixel_samples_; - //}); } - double get_progress() //const + double get_progress() // const { SCOPED_LOCK(progress_mutex); double value = 0.0; - //update_progress([this, &value]() { - if (pixel_samples > 0) { - double progress_percent = (double)pixel_samples / (double)total_pixel_samples; - if (time_limit != 0.0) { - double time_since_render_start = time_dt() - render_start_time; - progress_percent = max(progress_percent, time_since_render_start / time_limit); - } - value = min(1.0, progress_percent); + if (pixel_samples > 0) { + double progress_percent = (double)pixel_samples / (double)total_pixel_samples; + if (time_limit != 0.0) { + double time_since_render_start = time_dt() - render_start_time; + progress_percent = max(progress_percent, time_since_render_start / time_limit); } - //}); + value = min(1.0, progress_percent); + } return value; } @@ -300,10 +234,8 @@ class Progress { void add_samples(uint64_t pixel_samples_, int tile_sample) { SCOPED_LOCK(progress_mutex); - //update_progress([this, pixel_samples_, tile_sample]() { - pixel_samples += pixel_samples_; - current_tile_sample = tile_sample; - //}); + pixel_samples += pixel_samples_; + current_tile_sample = tile_sample; } void add_samples_update(uint64_t pixel_samples_, int tile_sample) @@ -315,45 +247,31 @@ class Progress { void add_finished_tile(bool denoised) { SCOPED_LOCK(progress_mutex); - //update_progress([this, denoised]() { - if (denoised) { - denoised_tiles++; - } - else { - rendered_tiles++; - } - //}); + if (denoised) { + denoised_tiles++; + } + else { + rendered_tiles++; + } } - int get_current_sample() //const + int get_current_sample() // const { SCOPED_LOCK(progress_mutex); - //int sample; - //update_progress([this, &sample]() { /* Note that the value here always belongs to the last tile that updated, * so it's only useful if there is only one active tile. */ - //sample = current_tile_sample; - //}); return current_tile_sample; } - int get_rendered_tiles() //const + int get_rendered_tiles() // const { SCOPED_LOCK(progress_mutex); - //int tiles; - //update_progress([this, &tiles]() { - // tiles = rendered_tiles; - //}); return rendered_tiles; } - int get_denoised_tiles() //const + int get_denoised_tiles() // const { SCOPED_LOCK(progress_mutex); - //int denoised; - //update_progress([this, & denoised]() { - // denoised = denoised_tiles; - //}); return denoised_tiles; } @@ -361,12 +279,10 @@ class Progress { void set_status(const string &status_, const string &substatus_ = "") { - if(updates) { + if (updates) { SCOPED_LOCK(progress_mutex); - //update_progress([this, status_, substatus_]() { - status = status_; - substatus = substatus_; - //}); + status = status_; + substatus = substatus_; } set_update(); @@ -374,11 +290,9 @@ class Progress { void set_substatus(const string &substatus_) { - if(updates) { + if (updates) { SCOPED_LOCK(progress_mutex); - //update_progress([this, substatus_]() { - substatus = substatus_; - //}); + substatus = substatus_; } set_update(); @@ -386,12 +300,10 @@ class Progress { void set_sync_status(const string &status_, const string &substatus_ = "") { - if(updates) { + if (updates) { SCOPED_LOCK(progress_mutex); - //update_progress([this, status_, substatus_]() { sync_status = status_; sync_substatus = substatus_; - //}); } set_update(); @@ -399,29 +311,25 @@ class Progress { void set_sync_substatus(const string &substatus_) { - if(updates) { + if (updates) { SCOPED_LOCK(progress_mutex); - //update_progress([this, substatus_]() { sync_substatus = substatus_; - //}); } set_update(); } - void get_status(string &status_, string &substatus_) // const + void get_status(string &status_, string &substatus_) // const { SCOPED_LOCK(progress_mutex); - //update_progress([this, &status_, &substatus_]() { - if (sync_status != "") { - status_ = sync_status; - substatus_ = sync_substatus; - } - else { - status_ = status; - substatus_ = substatus; - } - //}); + if (sync_status != "") { + status_ = sync_status; + substatus_ = sync_substatus; + } + else { + status_ = status; + substatus_ = substatus; + } } /* callback */ @@ -430,11 +338,7 @@ class Progress { { if (updates && update_cb) { SCOPED_LOCK(update_mutex); - // Busy wait until update status is true - //bool can_update = true; - //while(!update_call.compare_exchange_weak(can_update, false)) {}; update_cb(); - //update_call = true; } } @@ -443,17 +347,6 @@ class Progress { update_cb = function; } - // void update_progress(callback_type cb) - // { - // // Busy wait until update status is true - // bool can_update = true; - // while(!update_status.compare_exchange_weak(can_update, false)) {}; - // if (cb) { - // cb(); - // } - // update_status = true; - // } - protected: mutable MUTEX progress_mutex; mutable MUTEX update_mutex; @@ -489,7 +382,7 @@ class Progress { volatile bool error; string error_message; - // Used to enable progress updates if true + /* Used to enable progress updates if true */ bool updates; }; -- 2.30.2 From cddd2bfdf06153d756bc7ed9b59a0b0191cce4eb Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 14:55:08 +0200 Subject: [PATCH 44/96] Replae upload and building times arrays with a vector struct Arrays of dougle values are replaced by a vector<> of a struct scene_times. --- intern/cycles/scene/geometry.cpp | 16 ++++++++-------- intern/cycles/scene/scene.cpp | 11 +---------- intern/cycles/scene/scene.h | 13 ++++++++----- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index b4e21b5f01d..05195b1d0b0 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -784,7 +784,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { // Save copy mesh to device duration for later logging - scene->mesh_times[idx] = time; + scene->times[idx].mesh = time; } }); device_update_mesh(sub_device, sub_dscene, &sizes, progress); @@ -793,7 +793,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - scene->attrib_times[idx] = time; + scene->times[idx].attrib = time; } }); device_update_attributes(sub_device, sub_dscene, &attrib_sizes, progress); @@ -803,7 +803,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - scene->object_bvh_times[idx] = time; + scene->times[idx].object_bvh = time; } }); size_t i = 0; @@ -821,7 +821,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, if(need_update_scene_bvh) { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { - scene->scene_bvh_times[idx] = time; + scene->times[idx].scene_bvh = time; } }); /* Build the scene BVH */ @@ -1008,10 +1008,10 @@ void GeometryManager::device_update(Device *device, double max_object_bvh_time = 0.0f; double max_scene_bvh_time = 0.0f; for (size_t i = 0; i < num_scenes; i++) { - max_mesh_time = max(max_mesh_time, scene->mesh_times[i]); - max_attrib_time = max(max_attrib_time, scene->attrib_times[i]); - max_object_bvh_time = max(max_object_bvh_time, scene->object_bvh_times[i]); - max_scene_bvh_time = max(max_scene_bvh_time, scene->scene_bvh_times[i]); + max_mesh_time = max(max_mesh_time, scene->times[i].mesh); + max_attrib_time = max(max_attrib_time, scene->times[i].attrib); + max_object_bvh_time = max(max_object_bvh_time, scene->times[i].object_bvh); + max_scene_bvh_time = max(max_scene_bvh_time, scene->times[i].scene_bvh); } scene->update_stats->geometry.times.add_entry( {"device_update (copy meshes to device)", max_mesh_time}); diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 5a635a8c8f4..0f424296de0 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -124,10 +124,7 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) /* Stats time logging allocate memory to store times for each device */ size_t device_count = this->dscenes.size(); - mesh_times = new double[device_count]; - attrib_times = new double[device_count]; - object_bvh_times = new double[device_count]; - scene_bvh_times = new double[device_count]; + this->times.resize(device_count); shader_manager = ShaderManager::create( device->info.has_osl ? params.shadingsystem : SHADINGSYSTEM_SVM, device); @@ -157,12 +154,6 @@ Scene::~Scene() foreach (DeviceScene *sub_scene, dscenes) { delete sub_scene; } - - /* free stats data */ - delete[] mesh_times; - delete[] attrib_times; - delete[] object_bvh_times; - delete[] scene_bvh_times; free_memory(true); } diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index b1dfd82051a..115d122fc7a 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -250,11 +250,14 @@ class Scene : public NodeOwner { std::vector dscenes; /* Stats time logging */ - double *mesh_times; - double *attrib_times; - double *object_bvh_times; - double *scene_bvh_times; - + struct SceneTimes { + double mesh; + double attrib; + double object_bvh; + double scene_bvh; + }; + vector times; + /* parameters */ SceneParams params; -- 2.30.2 From 66a6a7a0af2ad0fa46792a368a344f326f36d8fd Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 16:56:36 +0200 Subject: [PATCH 45/96] Clean up code 1. remove camelCase method names. 2. fix up white space changes. 3. remove some unnecessary changes. --- intern/cycles/device/cpu/device_impl.h | 2 +- intern/cycles/device/cuda/device.cpp | 1 - intern/cycles/device/cuda/device_impl.h | 3 +- intern/cycles/device/device.cpp | 6 +- intern/cycles/device/device.h | 5 +- intern/cycles/device/dummy/device.cpp | 2 - intern/cycles/device/hip/device_impl.h | 3 +- intern/cycles/device/memory.h | 2 + intern/cycles/device/metal/device_impl.h | 4 +- intern/cycles/device/oneapi/device_impl.cpp | 1 + intern/cycles/device/oneapi/device_impl.h | 2 +- intern/cycles/scene/geometry.cpp | 62 ++++++++++----------- intern/cycles/scene/geometry.h | 15 ++--- intern/cycles/scene/geometry_bvh.cpp | 4 +- 14 files changed, 56 insertions(+), 56 deletions(-) diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index e2efe536a2c..516810dc98a 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -63,7 +63,7 @@ class CPUDevice : public Device { bool load_texture_info(); virtual void mem_alloc(device_memory &mem) override; - virtual void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; + virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; virtual void mem_copy_from( device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; virtual void mem_zero(device_memory &mem) override; diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index 1b55bfac719..5a213c45b71 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -27,7 +27,6 @@ bool device_cuda_init() return result; initialized = true; - int cuew_result = cuewInit(CUEW_INIT_CUDA); if (cuew_result == CUEW_SUCCESS) { VLOG_INFO << "CUEW initialization succeeded"; diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index 1577c991ab1..4b3e2a7b045 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -68,7 +68,6 @@ class CUDADevice : public GPUDevice { virtual void free_device(void *device_pointer) override; virtual bool alloc_host(void *&shared_pointer, size_t size) override; virtual void free_host(void *shared_pointer) override; - virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; @@ -79,7 +78,7 @@ class CUDADevice : public GPUDevice { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 8c79eb5c65a..fc1ddf0dd0e 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -795,17 +795,17 @@ void GPUDevice::generic_free(device_memory &mem) } void GPUDevice::generic_copy_to(device_memory &mem, size_t size, size_t offset) -{ +{ if (!mem.host_pointer || !mem.device_pointer) { return; } - + /* If use_mapped_host of mem is false, the current device only uses device memory allocated by * cuMemAlloc regardless of mem.host_pointer and mem.shared_pointer, and should copy data from * mem.host_pointer. */ thread_scoped_lock lock(device_mem_map_mutex); if (!device_mem_map[&mem].use_mapped_host || mem.host_pointer != mem.shared_pointer) { - size = ((size == -1) ? mem.memory_size() : size); + size = ((size == -1) ? mem.memory_size() : size); copy_host_to_device((void *)mem.device_pointer, mem.host_pointer, size, offset); } } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b08244cf9b2..cc7537138dc 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -7,6 +7,7 @@ #include #include "bvh/params.h" + #include "device/denoise.h" #include "device/memory.h" @@ -300,7 +301,7 @@ class Device { virtual void *host_mem_alloc(size_t size, int alignment); virtual void host_mem_free(void *p_mem); virtual void mem_alloc(device_memory &mem) = 0; - virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset = 0) = 0; + virtual void mem_copy_to(device_memory &mem, size_t size, size_t offset) = 0; virtual void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) = 0; virtual void mem_zero(device_memory &mem) = 0; virtual void mem_free(device_memory &mem) = 0; @@ -383,7 +384,7 @@ class GPUDevice : public Device { virtual GPUDevice::Mem *generic_alloc(device_memory &mem, size_t pitch_padding = 0); virtual void generic_free(device_memory &mem); virtual void generic_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0); - + /* total - amount of device memory, free - amount of available device memory */ virtual void get_device_memory_info(size_t &total, size_t &free) = 0; diff --git a/intern/cycles/device/dummy/device.cpp b/intern/cycles/device/dummy/device.cpp index c486aad764e..895d4bd27c6 100644 --- a/intern/cycles/device/dummy/device.cpp +++ b/intern/cycles/device/dummy/device.cpp @@ -27,8 +27,6 @@ class DummyDevice : public Device { virtual void mem_alloc(device_memory &) override {} - // virtual void mem_copy_to(device_memory &) override {} - virtual void mem_copy_to(device_memory &, size_t, size_t) override {} virtual void mem_copy_from(device_memory &, size_t, size_t, size_t, size_t) override {} diff --git a/intern/cycles/device/hip/device_impl.h b/intern/cycles/device/hip/device_impl.h index 6f9f2fb0356..7331eb7f4dc 100644 --- a/intern/cycles/device/hip/device_impl.h +++ b/intern/cycles/device/hip/device_impl.h @@ -61,13 +61,12 @@ class HIPDevice : public GPUDevice { virtual void free_device(void *device_pointer) override; virtual bool alloc_host(void *&shared_pointer, size_t size) override; virtual void free_host(void *shared_pointer) override; - virtual void transform_host_pointer(void *&device_pointer, void *&shared_pointer) override; virtual void copy_host_to_device(void *device_pointer, void *host_pointer, size_t size, size_t offset) override; void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index a5716bcf9f5..aa573a4dc30 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -428,6 +428,7 @@ template class device_vector : public device_memory { T *alloc(size_t width, size_t height = 0, size_t depth = 0) { size_t new_size = size(width, height, depth); + if (new_size != data_size) { device_free(); host_free(); @@ -572,6 +573,7 @@ template class device_vector : public device_memory { device_copy_to(size, offset); } } + void copy_to_device_if_modified(size_t size = -1, size_t offset = 0) { if (!modified) { diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 61e4de86ed8..8f5ec8fbd62 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -153,8 +153,8 @@ class MetalDevice : public Device { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; - + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; + void mem_copy_from(device_memory &mem) { mem_copy_from(mem, -1, -1, -1, -1); diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index 65d7d4d6c33..76b85d7d9d9 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -163,6 +163,7 @@ void OneapiDevice::generic_copy_to(device_memory &mem, size_t size, size_t offse /* Copy operation from host shouldn't be requested if there is no memory allocated on host. */ assert(mem.host_pointer); assert(device_queue_); + size = ((size == -1) ? mem.memory_size() : size); usm_memcpy(device_queue_, reinterpret_cast(mem.device_pointer) + offset, reinterpret_cast(mem.host_pointer) + offset, size); } diff --git a/intern/cycles/device/oneapi/device_impl.h b/intern/cycles/device/oneapi/device_impl.h index 9761a12cea5..4162cdb8bc0 100644 --- a/intern/cycles/device/oneapi/device_impl.h +++ b/intern/cycles/device/oneapi/device_impl.h @@ -60,7 +60,7 @@ class OneapiDevice : public Device { void mem_alloc(device_memory &mem) override; - void mem_copy_to(device_memory &mem, size_t size = -1, size_t offset = 0) override; + void mem_copy_to(device_memory &mem, size_t size, size_t offset) override; void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override; diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 05195b1d0b0..c3d8aaa1a88 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -698,7 +698,7 @@ void GeometryManager::device_update_volume_images(Device *device, Scene *scene, * geometry that must be rebuilt. It also determines if any displacement * or shadow transparancy occurs in the scene. */ -void GeometryManager::preTessDispNormalAndVerticesSetup(Device *device, +void GeometryManager::pretess_disp_normal_and_vertices_setup(Device *device, Scene *scene, bool &true_displacement_used, bool &curve_shadow_transparency_used, @@ -760,16 +760,16 @@ void GeometryManager::preTessDispNormalAndVerticesSetup(Device *device, * Uploads the mesh data to the device and then builds or refits the BVH * using the uploaded data. */ -void GeometryManager::deviceDataXferAndBVHUpdate(int idx, - Scene *scene, - DeviceScene *dscene, - GeometrySizes &sizes, - AttributeSizes &attrib_sizes, - const BVHLayout bvh_layout, - size_t num_bvh, - bool can_refit, - bool need_update_scene_bvh, - Progress &progress) +void GeometryManager::device_data_xfer_and_bvh_update(int idx, + Scene *scene, + DeviceScene *dscene, + GeometrySizes &sizes, + AttributeSizes &attrib_sizes, + const BVHLayout bvh_layout, + size_t num_bvh, + bool can_refit, + bool need_update_scene_bvh, + Progress &progress) { auto sub_dscene = scene->dscenes[idx]; sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; @@ -834,7 +834,7 @@ void GeometryManager::deviceDataXferAndBVHUpdate(int idx, * Calculates the bounds for any modified geometry and * then updates the objects bounds from the geometry. */ -void GeometryManager::updateObjectBounds(Scene *scene) +void GeometryManager::update_object_bounds(Scene *scene) { Scene::MotionType need_motion = scene->need_motion(); bool motion_blur = need_motion == Scene::MOTION_BLUR; @@ -918,7 +918,7 @@ void GeometryManager::device_update(Device *device, bool curve_shadow_transparency_used = false; size_t total_tess_needed = 0; - preTessDispNormalAndVerticesSetup( + pretess_disp_normal_and_vertices_setup( device, scene, true_displacement_used, curve_shadow_transparency_used, total_tess_needed); tesselate(scene, total_tess_needed, progress); @@ -963,7 +963,7 @@ void GeometryManager::device_update(Device *device, } { - updateObjectBounds(scene); + update_object_bounds(scene); } /* Update the BVH even when there is no geometry so the kernel's BVH data is still valid, * especially when removing all of the objects during interactive renders. @@ -976,7 +976,7 @@ void GeometryManager::device_update(Device *device, device->get_bvh_layout_mask()); dscene->data.bvh.bvh_layout = bvh_layout; - size_t num_bvh = createObjectBVHs(device, dscene, scene, bvh_layout, need_update_scene_bvh); + size_t num_bvh = create_object_bvhs(device, dscene, scene, bvh_layout, need_update_scene_bvh); bool can_refit_scene_bvh = true; if(need_update_scene_bvh) { can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); @@ -984,20 +984,20 @@ void GeometryManager::device_update(Device *device, { size_t num_scenes = scene->dscenes.size(); VLOG_INFO << "Rendering using " << num_scenes << " devices"; - // Parallel upload the geometry data to the devices and - // calculate or refit the BVHs + /* Parallel upload the geometry data to the devices and + calculate or refit the BVHs */ parallel_for( size_t(0), num_scenes, [=, this, &sizes, &attrib_sizes, &progress](const size_t idx) { - deviceDataXferAndBVHUpdate(idx, - scene, - dscene, - sizes, - attrib_sizes, - bvh_layout, - num_bvh, - can_refit_scene_bvh, - need_update_scene_bvh, - progress); + device_data_xfer_and_bvh_update(idx, + scene, + dscene, + sizes, + attrib_sizes, + bvh_layout, + num_bvh, + can_refit_scene_bvh, + need_update_scene_bvh, + progress); }); if (need_update_scene_bvh) { device_update_bvh_postprocess(device, dscene, scene, progress); @@ -1024,8 +1024,8 @@ void GeometryManager::device_update(Device *device, } } - clearGeometryUpdateAndModifiedTags(scene); - clearShaderUpdateTags(scene); + clear_geometry_update_and_modified_tags(scene); + clear_shader_update_tags(scene); update_flags = UPDATE_NONE; device_scene_clear_modified(dscene); } @@ -1097,7 +1097,7 @@ void GeometryManager::collect_statistics(const Scene *scene, RenderStats *stats) /* * Clears all tags used to indicate the the shader needs to be updated. */ -void GeometryManager::clearShaderUpdateTags(Scene *scene) +void GeometryManager::clear_shader_update_tags(Scene *scene) { /* unset flags */ foreach (Shader *shader, scene->shaders) { @@ -1111,7 +1111,7 @@ void GeometryManager::clearShaderUpdateTags(Scene *scene) * Clears all tags used to indicate the the geometry needs to be updated * or has been modified. */ -void GeometryManager::clearGeometryUpdateAndModifiedTags(Scene *scene) +void GeometryManager::clear_geometry_update_and_modified_tags(Scene *scene) { // Clear update tags foreach (Geometry *geom, scene->geometry) { diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index e1893d1b8d0..a2a9deec4ed 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -217,6 +217,7 @@ struct GeometrySizes { size_t *motion_vert_offsets; }; +/* Attribute Sizes */ struct AttributeSizes { size_t attr_float_size; size_t attr_float2_size; @@ -280,15 +281,15 @@ class GeometryManager { /* Statistics */ void collect_statistics(const Scene *scene, RenderStats *stats); - size_t createObjectBVHs(Device *device, + size_t create_object_bvhs(Device *device, DeviceScene *dscene, Scene *scene, const BVHLayout bvh_layout, bool &need_update_scene_bvh); - void updateSceneBVHs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); - void clearShaderUpdateTags(Scene *scene); - void clearGeometryUpdateAndModifiedTags(Scene *scene); - void deviceDataXferAndBVHUpdate(int idx, + void update_scene_bvhs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); + void clear_shader_update_tags(Scene *scene); + void clear_geometry_update_and_modified_tags(Scene *scene); + void device_data_xfer_and_bvh_update(int idx, Scene *scene, DeviceScene *dscene, GeometrySizes &sizes, @@ -298,9 +299,9 @@ class GeometryManager { bool can_refit, bool need_update_scene_bvh, Progress &progress); - void updateObjectBounds(Scene *scene); + void update_object_bounds(Scene *scene); void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress); - void preTessDispNormalAndVerticesSetup(Device *device, + void pretess_disp_normal_and_vertices_setup(Device *device, Scene *scene, bool &true_displacement_used, bool &curve_shadow_transparency_used, diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 818f2630eef..44d546c03ec 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -265,7 +265,7 @@ bool GeometryManager::device_update_bvh_preprocess(Device *device, * it determines if the BVH can be refitted. It also counts * the number of BVH that need to be built. */ -size_t GeometryManager::createObjectBVHs(Device *device, +size_t GeometryManager::create_object_bvhs(Device *device, DeviceScene *dscene, Scene *scene, const BVHLayout bvh_layout, @@ -303,7 +303,7 @@ size_t GeometryManager::createObjectBVHs(Device *device, * Prepares scene BVH for building or refitting. Then builds or refits the scene * BVH for all the devices. */ -void GeometryManager::updateSceneBVHs(Device *device, +void GeometryManager::update_scene_bvhs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress) -- 2.30.2 From bb2e9cc75f45bd28f5a6ccb03107afd7f5c4bd73 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 11 Apr 2023 18:49:54 +0200 Subject: [PATCH 46/96] FIX: Size needs to be explicit as default params have been removed. --- intern/cycles/device/metal/queue.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/cycles/device/metal/queue.mm b/intern/cycles/device/metal/queue.mm index 800639691dc..41f53b79043 100644 --- a/intern/cycles/device/metal/queue.mm +++ b/intern/cycles/device/metal/queue.mm @@ -804,7 +804,8 @@ void MetalDeviceQueue::copy_to_device(device_memory &mem) size:mmem.size]; } else { - metal_device_->mem_copy_to(mem); + const size_t size = mem.memory_size(); + metal_device_->mem_copy_to(mem, size, 0); } } -- 2.30.2 From 5c9b27b374d4e72731c1774bab54ec3a02bfe508 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 13 Apr 2023 16:20:26 +0200 Subject: [PATCH 47/96] Switch to use Cycles CUDA error checking. --- intern/cycles/device/cuda/device_impl.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index cc5c8379f69..3c2ee6661b8 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -556,13 +556,7 @@ void CUDADevice::copy_host_to_device(void *device_pointer, void *host_pointer, s void *CUDADevice::host_mem_alloc(size_t size, int aligment) { void *p_mem = NULL; CUDAContextScope scope(this); - CUresult result = cuMemAllocHost(&p_mem, size); - if(result != CUDA_SUCCESS) { - char const * err_msg = NULL; - cuGetErrorString(result, &err_msg); - fprintf(stderr, "CUDA Runtime Error: %s\n", err_msg); - assert("unable to allocate memory."); - } + cuda_assert(cuMemAllocHost(&p_mem, size)); return p_mem; } -- 2.30.2 From b1fa18f6f814d6aab1f2ca8636727ef768ec75a7 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 13 Apr 2023 16:22:03 +0200 Subject: [PATCH 48/96] Restore const methods and clean up code. --- intern/cycles/util/progress.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 9dd3c13479c..19f82ea878c 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -122,7 +122,7 @@ class Progress { return updates; } - string get_cancel_message() // const + string get_cancel_message() const { SCOPED_LOCK(progress_mutex); return cancel_message; @@ -149,7 +149,7 @@ class Progress { return error; } - string get_error_message() // const + string get_error_message() const { SCOPED_LOCK(progress_mutex); return error_message; @@ -186,7 +186,7 @@ class Progress { } } - void get_time(double &total_time_, double &render_time_) // const + void get_time(double &total_time_, double &render_time_) const { SCOPED_LOCK(progress_mutex); double et = end_time; @@ -215,7 +215,7 @@ class Progress { total_pixel_samples = total_pixel_samples_; } - double get_progress() // const + double get_progress() const { SCOPED_LOCK(progress_mutex); double value = 0.0; @@ -255,7 +255,7 @@ class Progress { } } - int get_current_sample() // const + int get_current_sample() const { SCOPED_LOCK(progress_mutex); /* Note that the value here always belongs to the last tile that updated, @@ -263,13 +263,13 @@ class Progress { return current_tile_sample; } - int get_rendered_tiles() // const + int get_rendered_tiles() const { SCOPED_LOCK(progress_mutex); return rendered_tiles; } - int get_denoised_tiles() // const + int get_denoised_tiles() const { SCOPED_LOCK(progress_mutex); return denoised_tiles; @@ -319,7 +319,7 @@ class Progress { set_update(); } - void get_status(string &status_, string &substatus_) // const + void get_status(string &status_, string &substatus_) const { SCOPED_LOCK(progress_mutex); if (sync_status != "") { -- 2.30.2 From 4ba4f7bf65d655ca4671d57c1d8ec994167f38b1 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 13 Apr 2023 16:22:49 +0200 Subject: [PATCH 49/96] Remove commented out code --- intern/cycles/bvh/bvh2.h | 2 +- intern/cycles/scene/geometry_bvh.cpp | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index 83e7bda986a..fffe7637d45 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -33,7 +33,7 @@ struct BVHStackEntry { */ class BVH2 : public BVH { public: - /* The BVH2 needs to be build only once these + /* The BVH2 needs to be built only once these are used to ensure that it the case. */ thread_mutex build_mutex; thread_condition_variable build_cv; diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 44d546c03ec..963e1b6d229 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -102,14 +102,11 @@ void GeometryManager::device_update_bvh_postprocess(Device *device, const bool has_bvh2_layout = (bvh->params.bvh_layout == BVH_LAYOUT_BVH2); - //PackedBVH pack; if (has_bvh2_layout) { BVH2 *bvh2 = static_cast(scene->bvh); - //pack = std::move(static_cast(bvh)->pack); dscene->data.bvh.root = bvh2->pack.root_index; } else { - //pack.root_index = -1; dscene->data.bvh.root = -1; } @@ -186,8 +183,6 @@ void GeometryManager::device_update_sub_bvh(Device *device, // Don't redo the setup if this is not a sub-bvh if (sub_bvh != bvh) { sub_bvh->replace_geometry(bvh->geometry, bvh->objects); - // sub_bvh->geometry = bvh->geometry; - // sub_bvh->objects = bvh->objects; } } else { -- 2.30.2 From 63bb671388d44fd439ba099a3914e898588b2d81 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 13 Apr 2023 16:24:51 +0200 Subject: [PATCH 50/96] Restore cancel checks --- intern/cycles/scene/geometry_mesh.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/intern/cycles/scene/geometry_mesh.cpp b/intern/cycles/scene/geometry_mesh.cpp index 5cdb369620f..7d5884585ec 100644 --- a/intern/cycles/scene/geometry_mesh.cpp +++ b/intern/cycles/scene/geometry_mesh.cpp @@ -111,8 +111,8 @@ void GeometryManager::device_update_mesh_preprocess( &tri_patch[mesh->prim_offset], &tri_patch_uv[mesh->vert_offset]); } - // if (progress.get_cancel()) - // return; + if (progress.get_cancel()) + return; } } } @@ -145,8 +145,8 @@ void GeometryManager::device_update_mesh_preprocess( &curve_keys[hair->curve_key_offset], &curves[hair->prim_offset], &curve_segments[hair->curve_segment_offset]); - // if (progress.get_cancel()) - // return; + if (progress.get_cancel()) + return; } } } @@ -162,8 +162,8 @@ void GeometryManager::device_update_mesh_preprocess( PointCloud *pointcloud = static_cast(geom); pointcloud->pack( scene, &points[pointcloud->prim_offset], &points_shader[pointcloud->prim_offset]); - // if (progress.get_cancel()) - // return; + if (progress.get_cancel()) + return; } } } @@ -182,8 +182,8 @@ void GeometryManager::device_update_mesh_preprocess( mesh->patch_table_offset); } - // if (progress.get_cancel()) - // return; + if (progress.get_cancel()) + return; } } } -- 2.30.2 From 29396f62276ff41d00fb5c017075e8a32e389348 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 08:51:28 +0200 Subject: [PATCH 51/96] Remove unused data elements. --- intern/cycles/scene/geometry.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index a2a9deec4ed..ddd4c1da2c3 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -211,10 +211,6 @@ struct GeometrySizes { size_t patch_size; size_t face_size; size_t corner_size; - - size_t *num_geometries; - size_t *vert_offsets; - size_t *motion_vert_offsets; }; /* Attribute Sizes */ -- 2.30.2 From bbbf76c4dbefe06d7a8fc338c1ae519936d8f06a Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 10:55:18 +0200 Subject: [PATCH 52/96] GeometrySizes and AttributeSizes are stored in Scene Moved GeometrySizes and AttributeSizes to be stored in scene. This resulted in them being removed as parameters where a Scene was already passed in. --- intern/cycles/scene/geometry.cpp | 43 ++++++++------------ intern/cycles/scene/geometry.h | 44 ++++----------------- intern/cycles/scene/geometry_attributes.cpp | 21 +++++----- intern/cycles/scene/geometry_mesh.cpp | 3 +- intern/cycles/scene/scene.h | 27 +++++++++++++ 5 files changed, 63 insertions(+), 75 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index c3d8aaa1a88..bd9083983a2 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -763,8 +763,6 @@ void GeometryManager::pretess_disp_normal_and_vertices_setup(Device *device, void GeometryManager::device_data_xfer_and_bvh_update(int idx, Scene *scene, DeviceScene *dscene, - GeometrySizes &sizes, - AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, bool can_refit, @@ -777,7 +775,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, Device *sub_device = sub_dscene->tri_verts.device; // Assign the host_pointers to the sub_dscene so that they access // the correct data - device_update_host_pointers(sub_device, dscene, sub_dscene, &sizes); + device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes)); /* Upload geometry and attribute buffers to the device */ { @@ -787,7 +785,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].mesh = time; } }); - device_update_mesh(sub_device, sub_dscene, &sizes, progress); + device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress); } { @@ -796,7 +794,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].attrib = time; } }); - device_update_attributes(sub_device, sub_dscene, &attrib_sizes, progress); + device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress); } device_scene_clear_modified(sub_dscene); @@ -923,18 +921,16 @@ void GeometryManager::device_update(Device *device, tesselate(scene, total_tess_needed, progress); - GeometrySizes sizes; - geom_calc_offset(scene, &sizes); + geom_calc_offset(scene); // Gather the requests attributes for filling out the attribute and geometry buffers vector geom_attributes(scene->geometry.size()); vector object_attributes(scene->objects.size()); vector object_attribute_values; - AttributeSizes attrib_sizes; progress.set_status("Updating Mesh", "Computing attributes"); gather_attributes( - scene, geom_attributes, object_attributes, object_attribute_values, &attrib_sizes); + scene, geom_attributes, object_attributes, object_attribute_values); /* Device update. */ device_free(device, dscene, false); @@ -944,9 +940,8 @@ void GeometryManager::device_update(Device *device, geom_attributes, object_attributes, object_attribute_values, - &attrib_sizes, progress); - device_update_mesh_preprocess(device, dscene, scene, &sizes, progress); + device_update_mesh_preprocess(device, dscene, scene, progress); /* Update displacement and hair shadow transparency. */ if (curve_shadow_transparency_used || true_displacement_used) { @@ -954,8 +949,6 @@ void GeometryManager::device_update(Device *device, scene, device, dscene, - &sizes, - &attrib_sizes, geom_attributes, object_attributes, object_attribute_values, @@ -987,12 +980,10 @@ void GeometryManager::device_update(Device *device, /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ parallel_for( - size_t(0), num_scenes, [=, this, &sizes, &attrib_sizes, &progress](const size_t idx) { + size_t(0), num_scenes, [=, this, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, scene, dscene, - sizes, - attrib_sizes, bvh_layout, num_bvh, can_refit_scene_bvh, @@ -1177,7 +1168,7 @@ void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) void GeometryManager::device_update_host_pointers(Device *device, DeviceScene *dscene, DeviceScene *sub_dscene, - GeometrySizes *p_sizes) + const GeometrySizes *p_sizes) { if (p_sizes->tri_size != 0) { if (dscene->tri_verts.is_modified()) { @@ -1279,9 +1270,10 @@ void GeometryManager::device_update_host_pointers(Device *device, /* * Records all the geometry buffer sizes for later use */ -void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) +void GeometryManager::geom_calc_offset(Scene *scene) { // Zero sizes + GeometrySizes *p_sizes = &(scene->geom_sizes); p_sizes->vert_size = 0; p_sizes->tri_size = 0; @@ -1366,8 +1358,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( Scene *scene, Device *device, DeviceScene *dscene, - GeometrySizes *sizes, - AttributeSizes *attrib_sizes, vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, @@ -1400,9 +1390,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( {"device_update (displacement: copy meshes to device)", time}); } }); - device_update_host_pointers(sub_device, dscene, sub_dscene, sizes); - device_update_attributes(sub_device, sub_dscene, attrib_sizes, progress); - device_update_mesh(sub_device, sub_dscene, sizes, progress); + device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes)); + device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress); + device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress); } /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); @@ -1449,9 +1439,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( // Need to redo host side filling out the attribute and mesh buffers as these may have // changed. Hair adds a new attribute buffer and displace updates the mesh. - geom_calc_offset(scene, sizes); + geom_calc_offset(scene); gather_attributes( - scene, geom_attributes, object_attributes, object_attribute_values, attrib_sizes); + scene, geom_attributes, object_attributes, object_attribute_values); device_free(device, dscene, false); device_update_attributes_preprocess(device, dscene, @@ -1459,9 +1449,8 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( geom_attributes, object_attributes, object_attribute_values, - attrib_sizes, progress); - device_update_mesh_preprocess(device, dscene, scene, sizes, progress); + device_update_mesh_preprocess(device, dscene, scene, progress); } } diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index ddd4c1da2c3..38cd4011707 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -25,6 +25,8 @@ class Mesh; class Progress; class RenderStats; class Scene; +struct GeometrySizes; +struct AttributeSizes; class SceneParams; class Shader; class Volume; @@ -197,31 +199,6 @@ class Geometry : public Node { void tag_bvh_update(bool rebuild); }; -/* Geometry Sizes */ -struct GeometrySizes { - size_t vert_size; - size_t tri_size; - - size_t curve_size; - size_t curve_key_size; - size_t curve_segment_size; - - size_t point_size; - - size_t patch_size; - size_t face_size; - size_t corner_size; -}; - -/* Attribute Sizes */ -struct AttributeSizes { - size_t attr_float_size; - size_t attr_float2_size; - size_t attr_float3_size; - size_t attr_float4_size; - size_t attr_uchar4_size; -}; - /* Geometry Manager */ class GeometryManager { @@ -288,8 +265,6 @@ class GeometryManager { void device_data_xfer_and_bvh_update(int idx, Scene *scene, DeviceScene *dscene, - GeometrySizes &sizes, - AttributeSizes &attrib_sizes, const BVHLayout bvh_layout, size_t num_bvh, bool can_refit, @@ -324,9 +299,8 @@ class GeometryManager { vector &object_attributes); /* Compute verts/triangles/curves offsets in global arrays. */ - void geom_calc_offset(Scene *scene, GeometrySizes *sizes); + void geom_calc_offset(Scene *scene); void attrib_calc_sizes(Scene *scene, - AttributeSizes *p_sizes, vector &geom_attributes, vector &object_attributes, vector &object_attribute_values); @@ -334,21 +308,19 @@ class GeometryManager { void device_update_object(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_update_mesh_preprocess( - Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *sizes, Progress &progress); + Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_update_mesh(Device *device, DeviceScene *dscene, - /*Scene *scene,*/ const GeometrySizes *sizes, + const GeometrySizes *sizes, Progress &progress); void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_update_host_pointers(Device *device, DeviceScene *dscene, DeviceScene *sub_dscene, - GeometrySizes *p_sizes); + const GeometrySizes *p_sizes); bool displacement_and_curve_shadow_transparency(Scene *scene, Device *device, DeviceScene *dscene, - GeometrySizes *sizes, - AttributeSizes *attrib_sizes, vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, @@ -357,15 +329,13 @@ class GeometryManager { void gather_attributes(Scene *scene, vector &geom_attributes, vector &object_attributes, - vector &object_attribute_values, - AttributeSizes *sizes); + vector &object_attribute_values); bool device_update_attributes_preprocess(Device *device, DeviceScene *dscene, Scene *scene, vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, - AttributeSizes *sizes, Progress &progress); void device_update_attributes(Device *device, DeviceScene *dscene, diff --git a/intern/cycles/scene/geometry_attributes.cpp b/intern/cycles/scene/geometry_attributes.cpp index b10b4fd390c..68e95c4c158 100644 --- a/intern/cycles/scene/geometry_attributes.cpp +++ b/intern/cycles/scene/geometry_attributes.cpp @@ -405,7 +405,6 @@ bool GeometryManager::device_update_attributes_preprocess( vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, - AttributeSizes *sizes, Progress &progress) { bool update_obj_offsets = false; @@ -413,11 +412,14 @@ bool GeometryManager::device_update_attributes_preprocess( progress.set_status("Updating Mesh", "Computing attributes"); // SHOULD NOT ALLOC ONLY ALLOC IF MORE SPACE IS NEEDED - dscene->attributes_float.alloc(sizes->attr_float_size); - dscene->attributes_float2.alloc(sizes->attr_float2_size); - dscene->attributes_float3.alloc(sizes->attr_float3_size); - dscene->attributes_float4.alloc(sizes->attr_float4_size); - dscene->attributes_uchar4.alloc(sizes->attr_uchar4_size); + { + AttributeSizes *sizes = &(scene->attrib_sizes); + dscene->attributes_float.alloc(sizes->attr_float_size); + dscene->attributes_float2.alloc(sizes->attr_float2_size); + dscene->attributes_float3.alloc(sizes->attr_float3_size); + dscene->attributes_float4.alloc(sizes->attr_float4_size); + dscene->attributes_uchar4.alloc(sizes->attr_uchar4_size); + } /* The order of those flags needs to match that of AttrKernelDataType. */ const bool attributes_need_realloc[AttrKernelDataType::NUM] = { @@ -584,11 +586,11 @@ static void update_attribute_element_size(Geometry *geom, * Records all the attribute buffer sizes for all the attribute buffers for later use */ void GeometryManager::attrib_calc_sizes(Scene *scene, - AttributeSizes *p_sizes, vector &geom_attributes, vector &object_attributes, vector &object_attribute_values) { + AttributeSizes *p_sizes = &(scene->attrib_sizes); p_sizes->attr_float_size = 0; p_sizes->attr_float2_size = 0; p_sizes->attr_float3_size = 0; @@ -648,8 +650,7 @@ void GeometryManager::attrib_calc_sizes(Scene *scene, void GeometryManager::gather_attributes(Scene *scene, vector &geom_attributes, vector &object_attributes, - vector &object_attribute_values, - AttributeSizes *sizes) + vector &object_attribute_values) { geom_attributes.clear(); object_attributes.clear(); @@ -710,7 +711,7 @@ void GeometryManager::gather_attributes(Scene *scene, /* Geometry attributes are stored in a single array per data type. Here determine the * sizes of those buffers. */ - attrib_calc_sizes(scene, sizes, geom_attributes, object_attributes, object_attribute_values); + attrib_calc_sizes(scene, geom_attributes, object_attributes, object_attribute_values); } CCL_NAMESPACE_END diff --git a/intern/cycles/scene/geometry_mesh.cpp b/intern/cycles/scene/geometry_mesh.cpp index 7d5884585ec..5c1e864ed97 100644 --- a/intern/cycles/scene/geometry_mesh.cpp +++ b/intern/cycles/scene/geometry_mesh.cpp @@ -71,9 +71,10 @@ void GeometryManager::device_update_mesh(Device *device, * the geometry buffers */ void GeometryManager::device_update_mesh_preprocess( - Device *device, DeviceScene *dscene, Scene *scene, GeometrySizes *p_sizes, Progress &progress) + Device *device, DeviceScene *dscene, Scene *scene, Progress &progress) { /* Fill in all the arrays. */ + GeometrySizes *p_sizes = &(scene->geom_sizes); if (p_sizes->tri_size != 0) { /* normals */ progress.set_status("Updating Mesh", "Computing mesh"); diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 115d122fc7a..d2c4d51edc4 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -139,6 +139,31 @@ class DeviceScene { DeviceScene(Device *device); }; +/* Geometry Sizes */ +struct GeometrySizes { + size_t vert_size; + size_t tri_size; + + size_t curve_size; + size_t curve_key_size; + size_t curve_segment_size; + + size_t point_size; + + size_t patch_size; + size_t face_size; + size_t corner_size; +}; + +/* Attribute Sizes */ +struct AttributeSizes { + size_t attr_float_size; + size_t attr_float2_size; + size_t attr_float3_size; + size_t attr_float4_size; + size_t attr_uchar4_size; +}; + /* Scene Parameters */ class SceneParams { @@ -245,6 +270,8 @@ class Scene : public NodeOwner { /* device */ Device *device; DeviceScene dscene; + GeometrySizes geom_sizes; + AttributeSizes attrib_sizes; /* Stores a DeviceScene for each sub-device */ std::vector dscenes; -- 2.30.2 From b1dd204d421dc975c7e18d720e42b999f7b7c549 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 13:40:20 +0200 Subject: [PATCH 53/96] Moves DeviceScene related methods to the DeviceScene class Refactored the GeometryManager methods so that those relating to the DeviceScene are now methods in the DeviceScene. --- intern/cycles/kernel/osl/services.cpp | 4 + intern/cycles/scene/CMakeLists.txt | 2 + intern/cycles/scene/devicescene.cpp | 278 ++++++++++++++++++++ intern/cycles/scene/devicescene.h | 118 +++++++++ intern/cycles/scene/geometry.cpp | 189 +------------ intern/cycles/scene/geometry.h | 14 - intern/cycles/scene/geometry_attributes.cpp | 19 -- intern/cycles/scene/geometry_mesh.cpp | 34 --- intern/cycles/scene/scene.cpp | 54 +--- intern/cycles/scene/scene.h | 92 +------ 10 files changed, 415 insertions(+), 389 deletions(-) create mode 100644 intern/cycles/scene/devicescene.cpp create mode 100644 intern/cycles/scene/devicescene.h diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index 92708df3162..06357afc7b2 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -46,6 +46,10 @@ #include "kernel/util/color.h" +#ifdef WITH_OPTIX +#include "device/device.h" +#endif + CCL_NAMESPACE_BEGIN /* RenderServices implementation */ diff --git a/intern/cycles/scene/CMakeLists.txt b/intern/cycles/scene/CMakeLists.txt index e0be20a6f7f..b01dfbfe09c 100644 --- a/intern/cycles/scene/CMakeLists.txt +++ b/intern/cycles/scene/CMakeLists.txt @@ -15,6 +15,7 @@ set(SRC camera.cpp colorspace.cpp constant_fold.cpp + devicescene.cpp film.cpp geometry.cpp geometry_mesh.cpp @@ -58,6 +59,7 @@ set(SRC_HEADERS camera.h colorspace.h constant_fold.h + devicescene.h film.h geometry.h hair.h diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp new file mode 100644 index 00000000000..8883ed99c8f --- /dev/null +++ b/intern/cycles/scene/devicescene.cpp @@ -0,0 +1,278 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#include "scene/scene.h" +#include "scene/devicescene.h" + +CCL_NAMESPACE_BEGIN + +DeviceScene::DeviceScene(Device *device) + : bvh_nodes(device, "bvh_nodes", MEM_GLOBAL), + bvh_leaf_nodes(device, "bvh_leaf_nodes", MEM_GLOBAL), + object_node(device, "object_node", MEM_GLOBAL), + prim_type(device, "prim_type", MEM_GLOBAL), + prim_visibility(device, "prim_visibility", MEM_GLOBAL), + prim_index(device, "prim_index", MEM_GLOBAL), + prim_object(device, "prim_object", MEM_GLOBAL), + prim_time(device, "prim_time", MEM_GLOBAL), + tri_verts(device, "tri_verts", MEM_GLOBAL), + tri_shader(device, "tri_shader", MEM_GLOBAL), + tri_vnormal(device, "tri_vnormal", MEM_GLOBAL), + tri_vindex(device, "tri_vindex", MEM_GLOBAL), + tri_patch(device, "tri_patch", MEM_GLOBAL), + tri_patch_uv(device, "tri_patch_uv", MEM_GLOBAL), + curves(device, "curves", MEM_GLOBAL), + curve_keys(device, "curve_keys", MEM_GLOBAL), + curve_segments(device, "curve_segments", MEM_GLOBAL), + patches(device, "patches", MEM_GLOBAL), + points(device, "points", MEM_GLOBAL), + points_shader(device, "points_shader", MEM_GLOBAL), + objects(device, "objects", MEM_GLOBAL), + object_motion_pass(device, "object_motion_pass", MEM_GLOBAL), + object_motion(device, "object_motion", MEM_GLOBAL), + object_flag(device, "object_flag", MEM_GLOBAL), + object_volume_step(device, "object_volume_step", MEM_GLOBAL), + object_prim_offset(device, "object_prim_offset", MEM_GLOBAL), + camera_motion(device, "camera_motion", MEM_GLOBAL), + attributes_map(device, "attributes_map", MEM_GLOBAL), + attributes_float(device, "attributes_float", MEM_GLOBAL), + attributes_float2(device, "attributes_float2", MEM_GLOBAL), + attributes_float3(device, "attributes_float3", MEM_GLOBAL), + attributes_float4(device, "attributes_float4", MEM_GLOBAL), + attributes_uchar4(device, "attributes_uchar4", MEM_GLOBAL), + light_distribution(device, "light_distribution", MEM_GLOBAL), + lights(device, "lights", MEM_GLOBAL), + light_background_marginal_cdf(device, "light_background_marginal_cdf", MEM_GLOBAL), + light_background_conditional_cdf(device, "light_background_conditional_cdf", MEM_GLOBAL), + light_tree_nodes(device, "light_tree_nodes", MEM_GLOBAL), + light_tree_emitters(device, "light_tree_emitters", MEM_GLOBAL), + light_to_tree(device, "light_to_tree", MEM_GLOBAL), + object_lookup_offset(device, "object_lookup_offset", MEM_GLOBAL), + triangle_to_tree(device, "triangle_to_tree", MEM_GLOBAL), + particles(device, "particles", MEM_GLOBAL), + svm_nodes(device, "svm_nodes", MEM_GLOBAL), + shaders(device, "shaders", MEM_GLOBAL), + lookup_table(device, "lookup_table", MEM_GLOBAL), + sample_pattern_lut(device, "sample_pattern_lut", MEM_GLOBAL), + ies_lights(device, "ies", MEM_GLOBAL) +{ + memset((void *)&data, 0, sizeof(data)); +} + +void DeviceScene::device_free(bool force_free) +{ + bvh_nodes.free_if_need_realloc(force_free); + bvh_leaf_nodes.free_if_need_realloc(force_free); + object_node.free_if_need_realloc(force_free); + prim_type.free_if_need_realloc(force_free); + prim_visibility.free_if_need_realloc(force_free); + prim_index.free_if_need_realloc(force_free); + prim_object.free_if_need_realloc(force_free); + prim_time.free_if_need_realloc(force_free); + tri_verts.free_if_need_realloc(force_free); + tri_shader.free_if_need_realloc(force_free); + tri_vnormal.free_if_need_realloc(force_free); + tri_vindex.free_if_need_realloc(force_free); + tri_patch.free_if_need_realloc(force_free); + tri_patch_uv.free_if_need_realloc(force_free); + curves.free_if_need_realloc(force_free); + curve_keys.free_if_need_realloc(force_free); + curve_segments.free_if_need_realloc(force_free); + points.free_if_need_realloc(force_free); + points_shader.free_if_need_realloc(force_free); + patches.free_if_need_realloc(force_free); + attributes_map.free_if_need_realloc(force_free); + attributes_float.free_if_need_realloc(force_free); + attributes_float2.free_if_need_realloc(force_free); + attributes_float3.free_if_need_realloc(force_free); + attributes_float4.free_if_need_realloc(force_free); + attributes_uchar4.free_if_need_realloc(force_free); +} + +/* + * Clears the modified tags for all elements of the device scene + */ +void DeviceScene::device_scene_clear_modified() +{ + bvh_nodes.clear_modified(); + bvh_leaf_nodes.clear_modified(); + object_node.clear_modified(); + prim_type.clear_modified(); + prim_visibility.clear_modified(); + prim_index.clear_modified(); + prim_object.clear_modified(); + prim_time.clear_modified(); + tri_verts.clear_modified(); + tri_shader.clear_modified(); + tri_vindex.clear_modified(); + tri_patch.clear_modified(); + tri_vnormal.clear_modified(); + tri_patch_uv.clear_modified(); + curves.clear_modified(); + curve_keys.clear_modified(); + curve_segments.clear_modified(); + points.clear_modified(); + points_shader.clear_modified(); + patches.clear_modified(); + attributes_map.clear_modified(); + attributes_float.clear_modified(); + attributes_float2.clear_modified(); + attributes_float3.clear_modified(); + attributes_float4.clear_modified(); + attributes_uchar4.clear_modified(); + objects.clear_modified(); + attributes_map.clear_modified(); +} + +void DeviceScene::device_update_host_pointers(Device *device, + DeviceScene *dscene, + const GeometrySizes *p_sizes) +{ + if (p_sizes->tri_size != 0) { + if (dscene->tri_verts.is_modified()) { + tri_verts.assign_mem(dscene->tri_verts); + tri_verts.tag_modified(); + } + { + if (dscene->tri_shader.is_modified()) { + tri_shader.assign_mem(dscene->tri_shader); + tri_shader.tag_modified(); + } + } + { + if (dscene->tri_vnormal.is_modified()) { + tri_vnormal.assign_mem(dscene->tri_vnormal); + tri_vnormal.tag_modified(); + } + } + { + if (dscene->tri_vindex.is_modified()) { + tri_vindex.assign_mem(dscene->tri_vindex); + tri_vindex.tag_modified(); + } + } + { + if (dscene->tri_patch.is_modified()) { + tri_patch.assign_mem(dscene->tri_patch); + tri_patch.tag_modified(); + } + } + { + if (dscene->tri_patch_uv.is_modified()) { + tri_patch_uv.assign_mem(dscene->tri_patch_uv); + tri_patch_uv.tag_modified(); + } + } + } + + if (p_sizes->curve_segment_size != 0) { + if (dscene->curve_keys.is_modified()) { + curve_keys.assign_mem(dscene->curve_keys); + curve_keys.tag_modified(); + } + + if (dscene->curves.is_modified()) { + curves.assign_mem(dscene->curves); + curves.tag_modified(); + } + + if (dscene->curve_segments.is_modified()) { + curve_segments.assign_mem(dscene->curve_segments); + } + } + + if (p_sizes->point_size != 0) { + // TODO: Why does this not check the modified tag? + points.assign_mem(dscene->points); + // sub_dscene->points.tag_modified(); + + points_shader.assign_mem(dscene->points_shader); + // sub_dscene->points_shader.tag_modified(); + } + + if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + patches.assign_mem(dscene->patches); + } + + // Update the Attributes + if (dscene->attributes_map.is_modified()) { + attributes_map.assign_mem(dscene->attributes_map); + attributes_map.tag_modified(); + } + if (dscene->attributes_float.is_modified()) { + attributes_float.assign_mem(dscene->attributes_float); + attributes_float.tag_modified(); + } + if (dscene->attributes_float2.is_modified()) { + attributes_float2.assign_mem(dscene->attributes_float2); + attributes_float2.tag_modified(); + } + if (dscene->attributes_float3.is_modified()) { + attributes_float3.assign_mem(dscene->attributes_float3); + attributes_float3.tag_modified(); + } + if (dscene->attributes_float4.is_modified()) { + attributes_float4.assign_mem(dscene->attributes_float4); + attributes_float4.tag_modified(); + } + if (dscene->attributes_uchar4.is_modified()) { + attributes_uchar4.assign_mem(dscene->attributes_uchar4); + attributes_uchar4.tag_modified(); + } + if (dscene->objects.is_modified()) { + objects.assign_mem(dscene->objects); + objects.tag_modified(); + } +} + +/** + * This copies the data to the devices if they have been modified + */ +void DeviceScene::device_update_mesh(Device *device, + const GeometrySizes *p_sizes, + Progress &progress) +{ + progress.set_status("Updating Mesh", "Copying Mesh to device"); + if (p_sizes->tri_size != 0) { + tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); + tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); + tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); + tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); + tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); + tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); + } + + if (p_sizes->curve_segment_size != 0) { + curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); + curves.copy_to_device_if_modified(p_sizes->curve_size, 0); + curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); + } + + if (p_sizes->point_size != 0) { + points.copy_to_device(p_sizes->point_size, 0); + points_shader.copy_to_device(p_sizes->point_size, 0); + } + + if (p_sizes->patch_size != 0 && patches.need_realloc()) { + patches.copy_to_device(p_sizes->patch_size, 0); + } +} + +/* + * Copies the attribute buffer data to the devices + */ +void DeviceScene::device_update_attributes(Device *device, + const AttributeSizes *sizes, + Progress &progress) +{ + progress.set_status("Updating Mesh", "Copying Attributes to device"); + /* copy svm attributes to device */ + attributes_map.copy_to_device_if_modified(); + attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); + attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); + attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); + attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); + attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); + objects.copy_to_device_if_modified(); +} +CCL_NAMESPACE_END diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h new file mode 100644 index 00000000000..5aec52aeef5 --- /dev/null +++ b/intern/cycles/scene/devicescene.h @@ -0,0 +1,118 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2011-2022 Blender Foundation */ + +#ifndef __DEVICESCENE_H__ +#define __DEVICESCENE_H__ + +#include "device/memory.h" +#include "util/types.h" +#include "util/vector.h" +#include "util/progress.h" +#include "kernel/types.h" +CCL_NAMESPACE_BEGIN + + +struct GeometrySizes; +struct AttributeSizes; + +/* Scene Device Data */ + +class DeviceScene { + public: + /* BVH */ + device_vector bvh_nodes; + device_vector bvh_leaf_nodes; + device_vector object_node; + device_vector prim_type; + device_vector prim_visibility; + device_vector prim_index; + device_vector prim_object; + device_vector prim_time; + + /* mesh */ + device_vector tri_verts; + device_vector tri_shader; + device_vector tri_vnormal; + device_vector tri_vindex; + device_vector tri_patch; + device_vector tri_patch_uv; + + device_vector curves; + device_vector curve_keys; + device_vector curve_segments; + + device_vector patches; + + /* point-cloud */ + device_vector points; + device_vector points_shader; + + /* objects */ + device_vector objects; + device_vector object_motion_pass; + device_vector object_motion; + device_vector object_flag; + device_vector object_volume_step; + device_vector object_prim_offset; + + /* cameras */ + device_vector camera_motion; + + /* attributes */ + device_vector attributes_map; + device_vector attributes_float; + device_vector attributes_float2; + device_vector attributes_float3; + device_vector attributes_float4; + device_vector attributes_uchar4; + + /* lights */ + device_vector light_distribution; + device_vector lights; + device_vector light_background_marginal_cdf; + device_vector light_background_conditional_cdf; + + /* light tree */ + device_vector light_tree_nodes; + device_vector light_tree_emitters; + device_vector light_to_tree; + device_vector object_lookup_offset; + device_vector triangle_to_tree; + + /* particles */ + device_vector particles; + + /* shaders */ + device_vector svm_nodes; + device_vector shaders; + + /* lookup tables */ + device_vector lookup_table; + + /* integrator */ + device_vector sample_pattern_lut; + + /* IES lights */ + device_vector ies_lights; + + KernelData data; + + DeviceScene(Device *device); + + void device_free(bool force_free); + void device_scene_clear_modified(); + void device_update_host_pointers(Device *device, + DeviceScene *dscene, + const GeometrySizes *p_sizes); + void device_update_mesh(Device *device, + const GeometrySizes *p_sizes, + Progress &progress); + + void device_update_attributes(Device *device, + const AttributeSizes *sizes, + Progress &progress); +}; + +CCL_NAMESPACE_END + +#endif /* __DEVICESCENE_H__ */ diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index bd9083983a2..a81a8e559d9 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -775,7 +775,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, Device *sub_device = sub_dscene->tri_verts.device; // Assign the host_pointers to the sub_dscene so that they access // the correct data - device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes)); + sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); /* Upload geometry and attribute buffers to the device */ { @@ -785,7 +785,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].mesh = time; } }); - device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress); + sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } { @@ -794,10 +794,10 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].attrib = time; } }); - device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress); + sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); } - device_scene_clear_modified(sub_dscene); + sub_dscene->device_scene_clear_modified(); { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { @@ -1018,38 +1018,12 @@ void GeometryManager::device_update(Device *device, clear_geometry_update_and_modified_tags(scene); clear_shader_update_tags(scene); update_flags = UPDATE_NONE; - device_scene_clear_modified(dscene); + dscene->device_scene_clear_modified(); } void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free) { - dscene->bvh_nodes.free_if_need_realloc(force_free); - dscene->bvh_leaf_nodes.free_if_need_realloc(force_free); - dscene->object_node.free_if_need_realloc(force_free); - dscene->prim_type.free_if_need_realloc(force_free); - dscene->prim_visibility.free_if_need_realloc(force_free); - dscene->prim_index.free_if_need_realloc(force_free); - dscene->prim_object.free_if_need_realloc(force_free); - dscene->prim_time.free_if_need_realloc(force_free); - dscene->tri_verts.free_if_need_realloc(force_free); - dscene->tri_shader.free_if_need_realloc(force_free); - dscene->tri_vnormal.free_if_need_realloc(force_free); - dscene->tri_vindex.free_if_need_realloc(force_free); - dscene->tri_patch.free_if_need_realloc(force_free); - dscene->tri_patch_uv.free_if_need_realloc(force_free); - dscene->curves.free_if_need_realloc(force_free); - dscene->curve_keys.free_if_need_realloc(force_free); - dscene->curve_segments.free_if_need_realloc(force_free); - dscene->points.free_if_need_realloc(force_free); - dscene->points_shader.free_if_need_realloc(force_free); - dscene->patches.free_if_need_realloc(force_free); - dscene->attributes_map.free_if_need_realloc(force_free); - dscene->attributes_float.free_if_need_realloc(force_free); - dscene->attributes_float2.free_if_need_realloc(force_free); - dscene->attributes_float3.free_if_need_realloc(force_free); - dscene->attributes_float4.free_if_need_realloc(force_free); - dscene->attributes_uchar4.free_if_need_realloc(force_free); - + dscene->device_free(force_free); #ifdef WITH_OSL OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory(); @@ -1122,151 +1096,6 @@ void GeometryManager::clear_geometry_update_and_modified_tags(Scene *scene) } } -/* - * Clears the modified tags for all elements of the device scene - */ -void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) -{ - dscene->bvh_nodes.clear_modified(); - dscene->bvh_leaf_nodes.clear_modified(); - dscene->object_node.clear_modified(); - dscene->prim_type.clear_modified(); - dscene->prim_visibility.clear_modified(); - dscene->prim_index.clear_modified(); - dscene->prim_object.clear_modified(); - dscene->prim_time.clear_modified(); - dscene->tri_verts.clear_modified(); - dscene->tri_shader.clear_modified(); - dscene->tri_vindex.clear_modified(); - dscene->tri_patch.clear_modified(); - dscene->tri_vnormal.clear_modified(); - dscene->tri_patch_uv.clear_modified(); - dscene->curves.clear_modified(); - dscene->curve_keys.clear_modified(); - dscene->curve_segments.clear_modified(); - dscene->points.clear_modified(); - dscene->points_shader.clear_modified(); - dscene->patches.clear_modified(); - dscene->attributes_map.clear_modified(); - dscene->attributes_float.clear_modified(); - dscene->attributes_float2.clear_modified(); - dscene->attributes_float3.clear_modified(); - dscene->attributes_float4.clear_modified(); - dscene->attributes_uchar4.clear_modified(); - dscene->objects.clear_modified(); - dscene->attributes_map.clear_modified(); -} - - - - - -/* - * Assigns the host pointers to the sub-devicescenes so - * that they all have the same data sources - */ -void GeometryManager::device_update_host_pointers(Device *device, - DeviceScene *dscene, - DeviceScene *sub_dscene, - const GeometrySizes *p_sizes) -{ - if (p_sizes->tri_size != 0) { - if (dscene->tri_verts.is_modified()) { - sub_dscene->tri_verts.assign_mem(dscene->tri_verts); - sub_dscene->tri_verts.tag_modified(); - } - { - if (dscene->tri_shader.is_modified()) { - sub_dscene->tri_shader.assign_mem(dscene->tri_shader); - sub_dscene->tri_shader.tag_modified(); - } - } - { - if (dscene->tri_vnormal.is_modified()) { - sub_dscene->tri_vnormal.assign_mem(dscene->tri_vnormal); - sub_dscene->tri_vnormal.tag_modified(); - } - } - { - if (dscene->tri_vindex.is_modified()) { - sub_dscene->tri_vindex.assign_mem(dscene->tri_vindex); - sub_dscene->tri_vindex.tag_modified(); - } - } - { - if (dscene->tri_patch.is_modified()) { - sub_dscene->tri_patch.assign_mem(dscene->tri_patch); - sub_dscene->tri_patch.tag_modified(); - } - } - { - if (dscene->tri_patch_uv.is_modified()) { - sub_dscene->tri_patch_uv.assign_mem(dscene->tri_patch_uv); - sub_dscene->tri_patch_uv.tag_modified(); - } - } - } - - if (p_sizes->curve_segment_size != 0) { - if (dscene->curve_keys.is_modified()) { - sub_dscene->curve_keys.assign_mem(dscene->curve_keys); - sub_dscene->curve_keys.tag_modified(); - } - - if (dscene->curves.is_modified()) { - sub_dscene->curves.assign_mem(dscene->curves); - sub_dscene->curves.tag_modified(); - } - - if (dscene->curve_segments.is_modified()) { - sub_dscene->curve_segments.assign_mem(dscene->curve_segments); - } - } - - if (p_sizes->point_size != 0) { - // TODO: Why does this not check the modified tag? - sub_dscene->points.assign_mem(dscene->points); - // sub_dscene->points.tag_modified(); - - sub_dscene->points_shader.assign_mem(dscene->points_shader); - // sub_dscene->points_shader.tag_modified(); - } - - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - sub_dscene->patches.assign_mem(dscene->patches); - } - - // Update the Attributes - if (dscene->attributes_map.is_modified()) { - sub_dscene->attributes_map.assign_mem(dscene->attributes_map); - sub_dscene->attributes_map.tag_modified(); - } - if (dscene->attributes_float.is_modified()) { - sub_dscene->attributes_float.assign_mem(dscene->attributes_float); - sub_dscene->attributes_float.tag_modified(); - } - if (dscene->attributes_float2.is_modified()) { - sub_dscene->attributes_float2.assign_mem(dscene->attributes_float2); - sub_dscene->attributes_float2.tag_modified(); - } - if (dscene->attributes_float3.is_modified()) { - sub_dscene->attributes_float3.assign_mem(dscene->attributes_float3); - sub_dscene->attributes_float3.tag_modified(); - } - if (dscene->attributes_float4.is_modified()) { - sub_dscene->attributes_float4.assign_mem(dscene->attributes_float4); - sub_dscene->attributes_float4.tag_modified(); - } - if (dscene->attributes_uchar4.is_modified()) { - sub_dscene->attributes_uchar4.assign_mem(dscene->attributes_uchar4); - sub_dscene->attributes_uchar4.tag_modified(); - } - if (dscene->objects.is_modified()) { - sub_dscene->objects.assign_mem(dscene->objects); - sub_dscene->objects.tag_modified(); - } -} - /* * Records all the geometry buffer sizes for later use */ @@ -1390,9 +1219,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( {"device_update (displacement: copy meshes to device)", time}); } }); - device_update_host_pointers(sub_device, dscene, sub_dscene, &(scene->geom_sizes)); - device_update_attributes(sub_device, sub_dscene, &(scene->attrib_sizes), progress); - device_update_mesh(sub_device, sub_dscene, &(scene->geom_sizes), progress); + sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); + sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 38cd4011707..ba0ecd83c66 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -249,7 +249,6 @@ class GeometryManager { void tag_update(Scene *scene, uint32_t flag); bool need_update() const; - void device_scene_clear_modified(DeviceScene *dscene); /* Statistics */ void collect_statistics(const Scene *scene, RenderStats *stats); @@ -309,15 +308,7 @@ class GeometryManager { void device_update_mesh_preprocess( Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); - void device_update_mesh(Device *device, - DeviceScene *dscene, - const GeometrySizes *sizes, - Progress &progress); void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); - void device_update_host_pointers(Device *device, - DeviceScene *dscene, - DeviceScene *sub_dscene, - const GeometrySizes *p_sizes); bool displacement_and_curve_shadow_transparency(Scene *scene, Device *device, DeviceScene *dscene, @@ -337,11 +328,6 @@ class GeometryManager { vector &object_attributes, vector &object_attribute_values, Progress &progress); - void device_update_attributes(Device *device, - DeviceScene *dscene, - const AttributeSizes *sizes, - Progress &progress); - bool device_update_bvh_preprocess(Device *device, DeviceScene *dscene, Scene *scene, diff --git a/intern/cycles/scene/geometry_attributes.cpp b/intern/cycles/scene/geometry_attributes.cpp index 68e95c4c158..723f3f47803 100644 --- a/intern/cycles/scene/geometry_attributes.cpp +++ b/intern/cycles/scene/geometry_attributes.cpp @@ -375,25 +375,6 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom, } } -/* - * Copies the attribute buffer data to the devices - */ -void GeometryManager::device_update_attributes(Device *device, - DeviceScene *dscene, - const AttributeSizes *sizes, - Progress &progress) -{ - progress.set_status("Updating Mesh", "Copying Attributes to device"); - /* copy svm attributes to device */ - dscene->attributes_map.copy_to_device_if_modified(); - dscene->attributes_float.copy_to_device_if_modified(sizes->attr_float_size, 0); - dscene->attributes_float2.copy_to_device_if_modified(sizes->attr_float2_size, 0); - dscene->attributes_float3.copy_to_device_if_modified(sizes->attr_float3_size, 0); - dscene->attributes_float4.copy_to_device_if_modified(sizes->attr_float4_size, 0); - dscene->attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); - dscene->objects.copy_to_device_if_modified(); -} - /* * Packs the attribute buffers and records the sizes and offsets using * the attribute sets diff --git a/intern/cycles/scene/geometry_mesh.cpp b/intern/cycles/scene/geometry_mesh.cpp index 5c1e864ed97..034eae88db4 100644 --- a/intern/cycles/scene/geometry_mesh.cpp +++ b/intern/cycles/scene/geometry_mesh.cpp @@ -32,40 +32,6 @@ CCL_NAMESPACE_BEGIN -/** - * This copies the data to the devices if they have been modified - */ -void GeometryManager::device_update_mesh(Device *device, - DeviceScene *dscene, - const GeometrySizes *p_sizes, - Progress &progress) -{ - progress.set_status("Updating Mesh", "Copying Mesh to device"); - if (p_sizes->tri_size != 0) { - dscene->tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); - dscene->tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); - dscene->tri_vindex.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_patch.copy_to_device_if_modified(p_sizes->tri_size, 0); - dscene->tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); - } - - if (p_sizes->curve_segment_size != 0) { - dscene->curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); - dscene->curves.copy_to_device_if_modified(p_sizes->curve_size, 0); - dscene->curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); - } - - if (p_sizes->point_size != 0) { - dscene->points.copy_to_device(p_sizes->point_size, 0); - dscene->points_shader.copy_to_device(p_sizes->point_size, 0); - } - - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - dscene->patches.copy_to_device(p_sizes->patch_size, 0); - } -} - /** * Packs the geometry data into the device scene. That is it fills out * the geometry buffers diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 0f424296de0..6a38cf089a3 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -24,6 +24,7 @@ #include "scene/svm.h" #include "scene/tables.h" #include "scene/volume.h" +#include "scene/devicescene.h" #include "session/session.h" #include "util/foreach.h" @@ -45,58 +46,7 @@ bool Scene::check_cancel_update(Progress &progress, Device *device) { return status || ((device != NULL) && device->have_error()); } -DeviceScene::DeviceScene(Device *device) - : bvh_nodes(device, "bvh_nodes", MEM_GLOBAL), - bvh_leaf_nodes(device, "bvh_leaf_nodes", MEM_GLOBAL), - object_node(device, "object_node", MEM_GLOBAL), - prim_type(device, "prim_type", MEM_GLOBAL), - prim_visibility(device, "prim_visibility", MEM_GLOBAL), - prim_index(device, "prim_index", MEM_GLOBAL), - prim_object(device, "prim_object", MEM_GLOBAL), - prim_time(device, "prim_time", MEM_GLOBAL), - tri_verts(device, "tri_verts", MEM_GLOBAL), - tri_shader(device, "tri_shader", MEM_GLOBAL), - tri_vnormal(device, "tri_vnormal", MEM_GLOBAL), - tri_vindex(device, "tri_vindex", MEM_GLOBAL), - tri_patch(device, "tri_patch", MEM_GLOBAL), - tri_patch_uv(device, "tri_patch_uv", MEM_GLOBAL), - curves(device, "curves", MEM_GLOBAL), - curve_keys(device, "curve_keys", MEM_GLOBAL), - curve_segments(device, "curve_segments", MEM_GLOBAL), - patches(device, "patches", MEM_GLOBAL), - points(device, "points", MEM_GLOBAL), - points_shader(device, "points_shader", MEM_GLOBAL), - objects(device, "objects", MEM_GLOBAL), - object_motion_pass(device, "object_motion_pass", MEM_GLOBAL), - object_motion(device, "object_motion", MEM_GLOBAL), - object_flag(device, "object_flag", MEM_GLOBAL), - object_volume_step(device, "object_volume_step", MEM_GLOBAL), - object_prim_offset(device, "object_prim_offset", MEM_GLOBAL), - camera_motion(device, "camera_motion", MEM_GLOBAL), - attributes_map(device, "attributes_map", MEM_GLOBAL), - attributes_float(device, "attributes_float", MEM_GLOBAL), - attributes_float2(device, "attributes_float2", MEM_GLOBAL), - attributes_float3(device, "attributes_float3", MEM_GLOBAL), - attributes_float4(device, "attributes_float4", MEM_GLOBAL), - attributes_uchar4(device, "attributes_uchar4", MEM_GLOBAL), - light_distribution(device, "light_distribution", MEM_GLOBAL), - lights(device, "lights", MEM_GLOBAL), - light_background_marginal_cdf(device, "light_background_marginal_cdf", MEM_GLOBAL), - light_background_conditional_cdf(device, "light_background_conditional_cdf", MEM_GLOBAL), - light_tree_nodes(device, "light_tree_nodes", MEM_GLOBAL), - light_tree_emitters(device, "light_tree_emitters", MEM_GLOBAL), - light_to_tree(device, "light_to_tree", MEM_GLOBAL), - object_lookup_offset(device, "object_lookup_offset", MEM_GLOBAL), - triangle_to_tree(device, "triangle_to_tree", MEM_GLOBAL), - particles(device, "particles", MEM_GLOBAL), - svm_nodes(device, "svm_nodes", MEM_GLOBAL), - shaders(device, "shaders", MEM_GLOBAL), - lookup_table(device, "lookup_table", MEM_GLOBAL), - sample_pattern_lut(device, "sample_pattern_lut", MEM_GLOBAL), - ies_lights(device, "ies", MEM_GLOBAL) -{ - memset((void *)&data, 0, sizeof(data)); -} + Scene::Scene(const SceneParams ¶ms_, Device *device) : name("Scene"), diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index d2c4d51edc4..6524b219ccd 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -9,17 +9,13 @@ #include "scene/film.h" #include "scene/image.h" #include "scene/shader.h" - -#include "device/device.h" -#include "device/memory.h" +#include "scene/devicescene.h" #include "util/param.h" #include "util/string.h" #include "util/system.h" #include "util/texture.h" #include "util/thread.h" -#include "util/types.h" -#include "util/vector.h" CCL_NAMESPACE_BEGIN @@ -53,91 +49,7 @@ class BakeData; class RenderStats; class SceneUpdateStats; class Volume; - -/* Scene Device Data */ - -class DeviceScene { - public: - /* BVH */ - device_vector bvh_nodes; - device_vector bvh_leaf_nodes; - device_vector object_node; - device_vector prim_type; - device_vector prim_visibility; - device_vector prim_index; - device_vector prim_object; - device_vector prim_time; - - /* mesh */ - device_vector tri_verts; - device_vector tri_shader; - device_vector tri_vnormal; - device_vector tri_vindex; - device_vector tri_patch; - device_vector tri_patch_uv; - - device_vector curves; - device_vector curve_keys; - device_vector curve_segments; - - device_vector patches; - - /* point-cloud */ - device_vector points; - device_vector points_shader; - - /* objects */ - device_vector objects; - device_vector object_motion_pass; - device_vector object_motion; - device_vector object_flag; - device_vector object_volume_step; - device_vector object_prim_offset; - - /* cameras */ - device_vector camera_motion; - - /* attributes */ - device_vector attributes_map; - device_vector attributes_float; - device_vector attributes_float2; - device_vector attributes_float3; - device_vector attributes_float4; - device_vector attributes_uchar4; - - /* lights */ - device_vector light_distribution; - device_vector lights; - device_vector light_background_marginal_cdf; - device_vector light_background_conditional_cdf; - - /* light tree */ - device_vector light_tree_nodes; - device_vector light_tree_emitters; - device_vector light_to_tree; - device_vector object_lookup_offset; - device_vector triangle_to_tree; - - /* particles */ - device_vector particles; - - /* shaders */ - device_vector svm_nodes; - device_vector shaders; - - /* lookup tables */ - device_vector lookup_table; - - /* integrator */ - device_vector sample_pattern_lut; - - /* IES lights */ - device_vector ies_lights; - - KernelData data; - - DeviceScene(Device *device); -}; +class DeviceScene; /* Geometry Sizes */ struct GeometrySizes { -- 2.30.2 From f63c508b40e4519c586adea1c32e3354103e7e73 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 14:06:40 +0200 Subject: [PATCH 54/96] Move BVH2 device update to DeviceScene As the device_update_bvh2 method just involves transferring data to the device it was moved to DeviceScene. --- intern/cycles/scene/devicescene.cpp | 56 +++++++++++++++++++++++++--- intern/cycles/scene/devicescene.h | 23 +++++++----- intern/cycles/scene/geometry.cpp | 2 +- intern/cycles/scene/geometry.h | 31 ++++++++------- intern/cycles/scene/geometry_bvh.cpp | 47 ----------------------- 5 files changed, 80 insertions(+), 79 deletions(-) diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index 8883ed99c8f..ce9eb7e36f6 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: Apache-2.0 * Copyright 2011-2022 Blender Foundation */ -#include "scene/scene.h" #include "scene/devicescene.h" +#include "scene/scene.h" CCL_NAMESPACE_BEGIN @@ -229,8 +229,8 @@ void DeviceScene::device_update_host_pointers(Device *device, * This copies the data to the devices if they have been modified */ void DeviceScene::device_update_mesh(Device *device, - const GeometrySizes *p_sizes, - Progress &progress) + const GeometrySizes *p_sizes, + Progress &progress) { progress.set_status("Updating Mesh", "Copying Mesh to device"); if (p_sizes->tri_size != 0) { @@ -262,8 +262,8 @@ void DeviceScene::device_update_mesh(Device *device, * Copies the attribute buffer data to the devices */ void DeviceScene::device_update_attributes(Device *device, - const AttributeSizes *sizes, - Progress &progress) + const AttributeSizes *sizes, + Progress &progress) { progress.set_status("Updating Mesh", "Copying Attributes to device"); /* copy svm attributes to device */ @@ -275,4 +275,50 @@ void DeviceScene::device_update_attributes(Device *device, attributes_uchar4.copy_to_device_if_modified(sizes->attr_uchar4_size, 0); objects.copy_to_device_if_modified(); } + +void DeviceScene::device_update_bvh2(Device *device, + BVH *bvh, + Progress &progress) +{ + if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { + BVH2 *bvh2 = static_cast(bvh); + + /* When using BVH2, we always have to copy/update the data as its layout is dependent on + * the BVH's leaf nodes which may be different when the objects or vertices move. */ + + if (bvh2->pack.nodes.size()) { + bvh_nodes.assign_mem(bvh2->pack.nodes); + bvh_nodes.copy_to_device(); + } + if (bvh2->pack.leaf_nodes.size()) { + bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes); + bvh_leaf_nodes.copy_to_device(); + } + if (bvh2->pack.object_node.size()) { + object_node.assign_mem(bvh2->pack.object_node); + object_node.copy_to_device(); + } + if (bvh2->pack.prim_type.size()) { + prim_type.assign_mem(bvh2->pack.prim_type); + prim_type.copy_to_device(); + } + if (bvh2->pack.prim_visibility.size()) { + prim_visibility.assign_mem(bvh2->pack.prim_visibility); + prim_visibility.copy_to_device(); + } + if (bvh2->pack.prim_index.size()) { + prim_index.assign_mem(bvh2->pack.prim_index); + prim_index.copy_to_device(); + } + if (bvh2->pack.prim_object.size()) { + prim_object.assign_mem(bvh2->pack.prim_object); + prim_object.copy_to_device(); + } + if (bvh2->pack.prim_time.size()) { + prim_time.assign_mem(bvh2->pack.prim_time); + prim_time.copy_to_device(); + } + } +} + CCL_NAMESPACE_END diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h index 5aec52aeef5..22e2ec5628d 100644 --- a/intern/cycles/scene/devicescene.h +++ b/intern/cycles/scene/devicescene.h @@ -4,14 +4,20 @@ #ifndef __DEVICESCENE_H__ #define __DEVICESCENE_H__ +#include "bvh/bvh.h" +#include "bvh/bvh2.h" + #include "device/memory.h" + +#include "kernel/types.h" + +#include "util/progress.h" #include "util/types.h" #include "util/vector.h" -#include "util/progress.h" -#include "kernel/types.h" + CCL_NAMESPACE_BEGIN - +class BVH; struct GeometrySizes; struct AttributeSizes; @@ -104,13 +110,10 @@ class DeviceScene { void device_update_host_pointers(Device *device, DeviceScene *dscene, const GeometrySizes *p_sizes); - void device_update_mesh(Device *device, - const GeometrySizes *p_sizes, - Progress &progress); - - void device_update_attributes(Device *device, - const AttributeSizes *sizes, - Progress &progress); + void device_update_mesh(Device *device, const GeometrySizes *p_sizes, Progress &progress); + + void device_update_attributes(Device *device, const AttributeSizes *sizes, Progress &progress); + void device_update_bvh2(Device *device, BVH *bvh, Progress &progress); }; CCL_NAMESPACE_END diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index a81a8e559d9..62eb7d38303 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -824,7 +824,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, }); /* Build the scene BVH */ device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); - device_update_bvh2(sub_device, sub_dscene, scene, progress); + sub_dscene->device_update_bvh2(sub_device, scene->bvh, progress); } } diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index ba0ecd83c66..ed4761caefd 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -254,28 +254,28 @@ class GeometryManager { void collect_statistics(const Scene *scene, RenderStats *stats); size_t create_object_bvhs(Device *device, - DeviceScene *dscene, - Scene *scene, - const BVHLayout bvh_layout, - bool &need_update_scene_bvh); + DeviceScene *dscene, + Scene *scene, + const BVHLayout bvh_layout, + bool &need_update_scene_bvh); void update_scene_bvhs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void clear_shader_update_tags(Scene *scene); void clear_geometry_update_and_modified_tags(Scene *scene); void device_data_xfer_and_bvh_update(int idx, - Scene *scene, - DeviceScene *dscene, - const BVHLayout bvh_layout, - size_t num_bvh, - bool can_refit, - bool need_update_scene_bvh, - Progress &progress); + Scene *scene, + DeviceScene *dscene, + const BVHLayout bvh_layout, + size_t num_bvh, + bool can_refit, + bool need_update_scene_bvh, + Progress &progress); void update_object_bounds(Scene *scene); void tesselate(Scene *scene, size_t total_tess_needed, Progress &progress); void pretess_disp_normal_and_vertices_setup(Device *device, - Scene *scene, - bool &true_displacement_used, - bool &curve_shadow_transparency_used, - size_t &total_tess_needed); + Scene *scene, + bool &true_displacement_used, + bool &curve_shadow_transparency_used, + size_t &total_tess_needed); static void device_update_sub_bvh(Device *device, DeviceScene *dscene, BVH *bvh, @@ -308,7 +308,6 @@ class GeometryManager { void device_update_mesh_preprocess( Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); - void device_update_bvh2(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); bool displacement_and_curve_shadow_transparency(Scene *scene, Device *device, DeviceScene *dscene, diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 963e1b6d229..6763ff9e067 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -46,53 +46,6 @@ void GeometryManager::device_update_bvh(Device *device, device, dscene, bvh, sub_bvh, can_refit, n, total, &progress); } -void GeometryManager::device_update_bvh2(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - BVH *bvh = scene->bvh; - if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { - BVH2 *bvh2 = static_cast(bvh); - - /* When using BVH2, we always have to copy/update the data as its layout is dependent on - * the BVH's leaf nodes which may be different when the objects or vertices move. */ - - if (bvh2->pack.nodes.size()) { - dscene->bvh_nodes.assign_mem(bvh2->pack.nodes); - dscene->bvh_nodes.copy_to_device(); - } - if (bvh2->pack.leaf_nodes.size()) { - dscene->bvh_leaf_nodes.assign_mem(bvh2->pack.leaf_nodes); - dscene->bvh_leaf_nodes.copy_to_device(); - } - if (bvh2->pack.object_node.size()) { - dscene->object_node.assign_mem(bvh2->pack.object_node); - dscene->object_node.copy_to_device(); - } - if (bvh2->pack.prim_type.size()) { - dscene->prim_type.assign_mem(bvh2->pack.prim_type); - dscene->prim_type.copy_to_device(); - } - if (bvh2->pack.prim_visibility.size()) { - dscene->prim_visibility.assign_mem(bvh2->pack.prim_visibility); - dscene->prim_visibility.copy_to_device(); - } - if (bvh2->pack.prim_index.size()) { - dscene->prim_index.assign_mem(bvh2->pack.prim_index); - dscene->prim_index.copy_to_device(); - } - if (bvh2->pack.prim_object.size()) { - dscene->prim_object.assign_mem(bvh2->pack.prim_object); - dscene->prim_object.copy_to_device(); - } - if (bvh2->pack.prim_time.size()) { - dscene->prim_time.assign_mem(bvh2->pack.prim_time); - dscene->prim_time.copy_to_device(); - } - } -} - void GeometryManager::device_update_bvh_postprocess(Device *device, DeviceScene *dscene, Scene *scene, -- 2.30.2 From d7cd4a49517d02b63bda4fe2d440fb966906709a Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 14:52:07 +0200 Subject: [PATCH 55/96] FIX: Add device type definitions Moving DeviceScene from scene.h caused the device definitions to be no longer present in various files. This add them back in by including device.h in the required files. --- intern/cycles/device/metal/bvh.mm | 1 + intern/cycles/kernel/osl/services.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/intern/cycles/device/metal/bvh.mm b/intern/cycles/device/metal/bvh.mm index c692b762d86..47da7a54271 100644 --- a/intern/cycles/device/metal/bvh.mm +++ b/intern/cycles/device/metal/bvh.mm @@ -10,6 +10,7 @@ # include "util/progress.h" +# include "device/device.h" # include "device/metal/bvh.h" # include "device/metal/util.h" diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index 06357afc7b2..ea4356b6c0f 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -46,9 +46,7 @@ #include "kernel/util/color.h" -#ifdef WITH_OPTIX #include "device/device.h" -#endif CCL_NAMESPACE_BEGIN -- 2.30.2 From b407dba398d0e5f4ea838c2c2a94e5ccabe220b6 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 14 Apr 2023 15:52:09 +0200 Subject: [PATCH 56/96] FIX: Use new memory copy method that replaced the old one Forgot to add the file for the previous change to the memory copy methods, which resulted in the OneAPI build failing. --- intern/cycles/device/oneapi/queue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/oneapi/queue.cpp b/intern/cycles/device/oneapi/queue.cpp index 3d019661aa8..d6f254c5aad 100644 --- a/intern/cycles/device/oneapi/queue.cpp +++ b/intern/cycles/device/oneapi/queue.cpp @@ -122,7 +122,7 @@ void OneapiDeviceQueue::zero_to_device(device_memory &mem) void OneapiDeviceQueue::copy_to_device(device_memory &mem) { - oneapi_device_->mem_copy_to(mem); + oneapi_device_->mem_copy_to(mem, mem.memory_size(),0); } void OneapiDeviceQueue::copy_from_device(device_memory &mem) -- 2.30.2 From 7ffb958444b803016be43df4f4716734d71e77eb Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 17 Apr 2023 14:16:43 +0200 Subject: [PATCH 57/96] Remove only grow allocation for HIP devices --- intern/cycles/device/hip/device_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index c68b798b749..e8a0befadd4 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -534,7 +534,7 @@ void HIPDevice::mem_alloc(device_memory &mem) void HIPDevice::mem_copy_to(device_memory &mem, size_t size, size_t offset) { if (mem.type == MEM_GLOBAL) { - if ((mem.device_size < mem.memory_size()) || (!mem.device_pointer)) { + if ((mem.device_size != mem.memory_size()) || (!mem.device_pointer)) { global_free(mem); global_alloc(mem); } -- 2.30.2 From f89abb02c2df2a3b760a5fb2e3a22e1329cde52e Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 17 Apr 2023 16:43:12 +0200 Subject: [PATCH 58/96] Initialise built variable in class definition. --- intern/cycles/bvh/bvh.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h index 3b2b7ecdbb5..4cc00c1b9d2 100644 --- a/intern/cycles/bvh/bvh.h +++ b/intern/cycles/bvh/bvh.h @@ -65,7 +65,8 @@ class BVH { BVHParams params; vector geometry; vector objects; - bool built; + bool built = false; + static BVH *create(const BVHParams ¶ms, const vector &geometry, const vector &objects, -- 2.30.2 From 5f0678a81b5c062ed22d7663b289570e65cf3697 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 17 Apr 2023 16:46:13 +0200 Subject: [PATCH 59/96] Restore get_estimated_remaining_time methods constness --- intern/cycles/session/session.cpp | 2 +- intern/cycles/session/session.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp index 3ded6a6848b..42b15d0530c 100644 --- a/intern/cycles/session/session.cpp +++ b/intern/cycles/session/session.cpp @@ -629,7 +629,7 @@ void Session::set_display_driver(unique_ptr driver) path_trace_->set_display_driver(move(driver)); } -double Session::get_estimated_remaining_time() //const +double Session::get_estimated_remaining_time() const { const double completed = progress.get_progress(); if (completed == 0.0) { diff --git a/intern/cycles/session/session.h b/intern/cycles/session/session.h index 6ae9a45553f..d431c61a5fc 100644 --- a/intern/cycles/session/session.h +++ b/intern/cycles/session/session.h @@ -137,7 +137,7 @@ class Session { void set_output_driver(unique_ptr driver); void set_display_driver(unique_ptr driver); - double get_estimated_remaining_time(); // const; + double get_estimated_remaining_time() const; void device_free(); -- 2.30.2 From 5d0c87c1e4b60754f925aeb868be7cbc0465ea74 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 18 Apr 2023 09:04:05 +0200 Subject: [PATCH 60/96] Use info in device_memory to check to determine what data to upload --- intern/cycles/scene/devicescene.cpp | 80 +++++++++++++---------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index 1994f3fdd73..84918b4a8b1 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -129,44 +129,37 @@ void DeviceScene::device_update_host_pointers(Device *device, DeviceScene *dscene, const GeometrySizes *p_sizes) { - if (p_sizes->tri_size != 0) { - if (dscene->tri_verts.is_modified()) { - tri_verts.assign_mem(dscene->tri_verts); - tri_verts.tag_modified(); + if (dscene->tri_verts.size() > 0) { + tri_verts.assign_mem(dscene->tri_verts); + tri_verts.tag_modified(); + + if (dscene->tri_shader.is_modified()) { + tri_shader.assign_mem(dscene->tri_shader); + tri_shader.tag_modified(); } - { - if (dscene->tri_shader.is_modified()) { - tri_shader.assign_mem(dscene->tri_shader); - tri_shader.tag_modified(); - } + + if (dscene->tri_vnormal.is_modified()) { + tri_vnormal.assign_mem(dscene->tri_vnormal); + tri_vnormal.tag_modified(); } - { - if (dscene->tri_vnormal.is_modified()) { - tri_vnormal.assign_mem(dscene->tri_vnormal); - tri_vnormal.tag_modified(); - } + + if (dscene->tri_vindex.is_modified()) { + tri_vindex.assign_mem(dscene->tri_vindex); + tri_vindex.tag_modified(); } - { - if (dscene->tri_vindex.is_modified()) { - tri_vindex.assign_mem(dscene->tri_vindex); - tri_vindex.tag_modified(); - } + + if (dscene->tri_patch.is_modified()) { + tri_patch.assign_mem(dscene->tri_patch); + tri_patch.tag_modified(); } - { - if (dscene->tri_patch.is_modified()) { - tri_patch.assign_mem(dscene->tri_patch); - tri_patch.tag_modified(); - } - } - { - if (dscene->tri_patch_uv.is_modified()) { - tri_patch_uv.assign_mem(dscene->tri_patch_uv); - tri_patch_uv.tag_modified(); - } + + if (dscene->tri_patch_uv.is_modified()) { + tri_patch_uv.assign_mem(dscene->tri_patch_uv); + tri_patch_uv.tag_modified(); } } - if (p_sizes->curve_segment_size != 0) { + if (dscene->curve_segments.size() > 0) { if (dscene->curve_keys.is_modified()) { curve_keys.assign_mem(dscene->curve_keys); curve_keys.tag_modified(); @@ -179,20 +172,21 @@ void DeviceScene::device_update_host_pointers(Device *device, if (dscene->curve_segments.is_modified()) { curve_segments.assign_mem(dscene->curve_segments); + curve_segments.tag_modified(); } } - if (p_sizes->point_size != 0) { - // TODO: Why does this not check the modified tag? + if (dscene->points.size() > 0) { points.assign_mem(dscene->points); - // sub_dscene->points.tag_modified(); + points.tag_modified(); points_shader.assign_mem(dscene->points_shader); - // sub_dscene->points_shader.tag_modified(); + points_shader.tag_modified(); } - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { + if (dscene->patches.is_modified()) { patches.assign_mem(dscene->patches); + patches.tag_modified(); } // Update the Attributes @@ -234,7 +228,7 @@ void DeviceScene::device_update_mesh(Device *device, Progress &progress) { progress.set_status("Updating Mesh", "Copying Mesh to device"); - if (p_sizes->tri_size != 0) { + if (tri_verts.size() > 0) { tri_verts.copy_to_device_if_modified(p_sizes->vert_size, 0); tri_shader.copy_to_device_if_modified(p_sizes->tri_size, 0); tri_vnormal.copy_to_device_if_modified(p_sizes->vert_size, 0); @@ -243,20 +237,18 @@ void DeviceScene::device_update_mesh(Device *device, tri_patch_uv.copy_to_device_if_modified(p_sizes->vert_size, 0); } - if (p_sizes->curve_segment_size != 0) { + if (curve_segments.size() > 0) { curve_keys.copy_to_device_if_modified(p_sizes->curve_key_size, 0); curves.copy_to_device_if_modified(p_sizes->curve_size, 0); curve_segments.copy_to_device_if_modified(p_sizes->curve_segment_size, 0); } - if (p_sizes->point_size != 0) { - points.copy_to_device(p_sizes->point_size, 0); - points_shader.copy_to_device(p_sizes->point_size, 0); + if (points.size() > 0) { + points.copy_to_device_if_modified(p_sizes->point_size, 0); + points_shader.copy_to_device_if_modified(p_sizes->point_size, 0); } - if (p_sizes->patch_size != 0 && patches.need_realloc()) { - patches.copy_to_device(p_sizes->patch_size, 0); - } + patches.copy_to_device_if_modified(p_sizes->patch_size, 0); } /* -- 2.30.2 From 215f1267ca890d764cbcfa88c92650039267e2f3 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 19 Apr 2023 13:45:50 +0200 Subject: [PATCH 61/96] Allow BVH2 building to handle multiple sessions correctly --- intern/cycles/bvh/bvh2.h | 3 +++ intern/cycles/device/device.cpp | 10 ++++++---- intern/cycles/scene/geometry.cpp | 2 +- intern/cycles/scene/geometry.h | 1 + intern/cycles/scene/geometry_bvh.cpp | 9 +++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index fffe7637d45..3c5db6356a4 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -12,6 +12,8 @@ #include "util/vector.h" #include "util/thread.h" +#include + CCL_NAMESPACE_BEGIN #define BVH_NODE_SIZE 4 @@ -37,6 +39,7 @@ class BVH2 : public BVH { are used to ensure that it the case. */ thread_mutex build_mutex; thread_condition_variable build_cv; + std::atomic building{0}; void build(Progress &progress, Stats *stats); void refit(Progress &progress); diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 47442d5a406..f190484471b 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -51,22 +51,25 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r { assert(bvh->params.bvh_layout == BVH_LAYOUT_BVH2); BVH2 *const bvh2 = static_cast(bvh); - static std::atomic building{0}; /* Top level BVH2 build must wait on all other BVH2 builds to finish otherwise the top level BVH2 will not have all the correct data */ if(bvh2->params.top_level) { + /* + This is used to make sure all workers have reached this point. + device_init_update_bvh increments the counter. + */ + bvh2->building--; thread_scoped_lock build_wait_lock(bvh2->build_mutex); /* Wait for other BVH2 builds to complete before proceeding */ VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Waiting on other BVH2 builds."; - bvh2->build_cv.wait(build_wait_lock, [=]() { return (building == 0); }); + bvh2->build_cv.wait(build_wait_lock, [=]() { return (bvh2->building == 0); }); VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Done waiting on other BVH2 builds"; } thread_scoped_lock build_lock(bvh2->build_mutex, std::try_to_lock); if (build_lock) { /* Has the BVH already been built? */ if (!bvh->built) { - building++; /* Build the BVH */ VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Performing BVH2 build."; if (refit) { @@ -77,7 +80,6 @@ void Device::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool r } bvh->built = true; VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " Done building BVH2"; - building--; } else { VLOG_INFO << std::this_thread::get_id() << ":" << bvh2 << " BVH2 Already built"; diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 643c35a4921..485d424c02a 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -798,7 +798,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, } sub_dscene->device_scene_clear_modified(); - + device_init_update_bvh(scene); { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index ed4761caefd..e3256a0ee79 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -331,6 +331,7 @@ class GeometryManager { DeviceScene *dscene, Scene *scene, Progress &progress); + void device_init_update_bvh(Scene *scene); void device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 1825dc7e46e..5bfe426fb6e 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -32,6 +32,15 @@ CCL_NAMESPACE_BEGIN +void GeometryManager::device_init_update_bvh(Scene *scene) +{ + if (scene->bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { + /* To ensure that only 1 BVH2 scene is built a count of workers is used */ + BVH2 *const bvh2 = static_cast(scene->bvh); + bvh2->building++; + } +} + void GeometryManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, -- 2.30.2 From ce91384a2a696a0afb54c00821c294fd06da1d6c Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 19 Apr 2023 15:35:10 +0200 Subject: [PATCH 62/96] Rearrange methods to match the main_reorg PR --- intern/cycles/scene/CMakeLists.txt | 4 +- intern/cycles/scene/devicescene.cpp | 2 + intern/cycles/scene/devicescene.h | 6 +- intern/cycles/scene/geometry.cpp | 74 ----------- intern/cycles/scene/geometry_attributes.cpp | 132 ++++++++++++++------ intern/cycles/scene/geometry_bvh.cpp | 19 +++ 6 files changed, 117 insertions(+), 120 deletions(-) diff --git a/intern/cycles/scene/CMakeLists.txt b/intern/cycles/scene/CMakeLists.txt index b01dfbfe09c..3fc972da75e 100644 --- a/intern/cycles/scene/CMakeLists.txt +++ b/intern/cycles/scene/CMakeLists.txt @@ -18,9 +18,9 @@ set(SRC devicescene.cpp film.cpp geometry.cpp - geometry_mesh.cpp - geometry_bvh.cpp geometry_attributes.cpp + geometry_bvh.cpp + geometry_mesh.cpp hair.cpp image.cpp image_oiio.cpp diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index 84918b4a8b1..88c4dc72679 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: Apache-2.0 * Copyright 2011-2022 Blender Foundation */ +#include "bvh/bvh2.h" + #include "scene/devicescene.h" #include "scene/scene.h" diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h index 803a18266f0..acabcd8d07a 100644 --- a/intern/cycles/scene/devicescene.h +++ b/intern/cycles/scene/devicescene.h @@ -4,13 +4,9 @@ #ifndef __DEVICESCENE_H__ #define __DEVICESCENE_H__ -#include "bvh/bvh.h" -#include "bvh/bvh2.h" - +#include "device/device.h" #include "device/memory.h" -#include "kernel/types.h" - #include "util/progress.h" #include "util/types.h" #include "util/vector.h" diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 485d424c02a..2a51f2daebc 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -84,49 +84,6 @@ void Geometry::clear(bool preserve_shaders) tag_modified(); } -bool Geometry::need_attribute(Scene *scene, AttributeStandard std) -{ - if (std == ATTR_STD_NONE) - return false; - - if (scene->need_global_attribute(std)) - return true; - - foreach (Node *node, used_shaders) { - Shader *shader = static_cast(node); - if (shader->attributes.find(std)) - return true; - } - - return false; -} - -bool Geometry::need_attribute(Scene * /*scene*/, ustring name) -{ - if (name == ustring()) - return false; - - foreach (Node *node, used_shaders) { - Shader *shader = static_cast(node); - if (shader->attributes.find(name)) - return true; - } - - return false; -} - -AttributeRequestSet Geometry::needed_attributes() -{ - AttributeRequestSet result; - - foreach (Node *node, used_shaders) { - Shader *shader = static_cast(node); - result.add(shader->attributes); - } - - return result; -} - float Geometry::motion_time(int step) const { return (motion_steps > 1) ? 2.0f * step / (motion_steps - 1) - 1.0f : 0.0f; @@ -182,41 +139,11 @@ bool Geometry::has_true_displacement() const return false; } -void Geometry::compute_bvh(Device *device, - DeviceScene *dscene, - SceneParams *params, - Progress *progress, - size_t n, - size_t total) -{ - if (progress->get_cancel()) - return; - - const BVHLayout bvh_layout = BVHParams::best_bvh_layout( - params->bvh_layout, device->get_bvh_layout_mask(dscene->data.kernel_features)); - if (need_build_bvh(bvh_layout)) { - BVH *sub_bvh = bvh->get_device_bvh(device); - GeometryManager::device_update_sub_bvh( - device, dscene, bvh, sub_bvh, !need_update_rebuild, n, total, progress); - } -} - bool Geometry::has_motion_blur() const { return (use_motion_blur && attributes.find(ATTR_STD_MOTION_VERTEX_POSITION)); } -bool Geometry::has_voxel_attributes() const -{ - foreach (const Attribute &attr, attributes.attributes) { - if (attr.element == ATTR_ELEMENT_VOXEL) { - return true; - } - } - - return false; -} - void Geometry::tag_update(Scene *scene, bool rebuild) { if (rebuild) { @@ -280,7 +207,6 @@ void GeometryManager::update_osl_globals(Device *device, Scene *scene) #endif } - static void update_attribute_realloc_flags(uint32_t &device_update_flags, const AttributeSet &attributes) { diff --git a/intern/cycles/scene/geometry_attributes.cpp b/intern/cycles/scene/geometry_attributes.cpp index 723f3f47803..3691bfee198 100644 --- a/intern/cycles/scene/geometry_attributes.cpp +++ b/intern/cycles/scene/geometry_attributes.cpp @@ -32,6 +32,60 @@ CCL_NAMESPACE_BEGIN +bool Geometry::need_attribute(Scene *scene, AttributeStandard std) +{ + if (std == ATTR_STD_NONE) + return false; + + if (scene->need_global_attribute(std)) + return true; + + foreach (Node *node, used_shaders) { + Shader *shader = static_cast(node); + if (shader->attributes.find(std)) + return true; + } + + return false; +} + +bool Geometry::need_attribute(Scene * /*scene*/, ustring name) +{ + if (name == ustring()) + return false; + + foreach (Node *node, used_shaders) { + Shader *shader = static_cast(node); + if (shader->attributes.find(name)) + return true; + } + + return false; +} + +AttributeRequestSet Geometry::needed_attributes() +{ + AttributeRequestSet result; + + foreach (Node *node, used_shaders) { + Shader *shader = static_cast(node); + result.add(shader->attributes); + } + + return result; +} + +bool Geometry::has_voxel_attributes() const +{ + foreach (const Attribute &attr, attributes.attributes) { + if (attr.element == ATTR_ELEMENT_VOXEL) { + return true; + } + } + + return false; +} + /* Generate a normal attribute map entry from an attribute descriptor. */ static void emit_attribute_map_entry(AttributeMap *attr_map, size_t index, @@ -375,6 +429,45 @@ void GeometryManager::update_attribute_element_offset(Geometry *geom, } } +/* + * Records the sizes of the attribute buffers + */ +static void update_attribute_element_size(Geometry *geom, + Attribute *mattr, + AttributePrimitive prim, + size_t *attr_float_size, + size_t *attr_float2_size, + size_t *attr_float3_size, + size_t *attr_float4_size, + size_t *attr_uchar4_size) +{ + if (mattr) { + size_t size = mattr->element_size(geom, prim); + + if (mattr->element == ATTR_ELEMENT_VOXEL) { + /* pass */ + } + else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { + *attr_uchar4_size += size; + } + else if (mattr->type == TypeDesc::TypeFloat) { + *attr_float_size += size; + } + else if (mattr->type == TypeFloat2) { + *attr_float2_size += size; + } + else if (mattr->type == TypeDesc::TypeMatrix) { + *attr_float4_size += size * 4; + } + else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { + *attr_float4_size += size; + } + else { + *attr_float3_size += size; + } + } +} + /* * Packs the attribute buffers and records the sizes and offsets using * the attribute sets @@ -524,45 +617,6 @@ bool GeometryManager::device_update_attributes_preprocess( return update_obj_offsets; } -/* - * Records the sizes of the attribute buffers - */ -static void update_attribute_element_size(Geometry *geom, - Attribute *mattr, - AttributePrimitive prim, - size_t *attr_float_size, - size_t *attr_float2_size, - size_t *attr_float3_size, - size_t *attr_float4_size, - size_t *attr_uchar4_size) -{ - if (mattr) { - size_t size = mattr->element_size(geom, prim); - - if (mattr->element == ATTR_ELEMENT_VOXEL) { - /* pass */ - } - else if (mattr->element == ATTR_ELEMENT_CORNER_BYTE) { - *attr_uchar4_size += size; - } - else if (mattr->type == TypeDesc::TypeFloat) { - *attr_float_size += size; - } - else if (mattr->type == TypeFloat2) { - *attr_float2_size += size; - } - else if (mattr->type == TypeDesc::TypeMatrix) { - *attr_float4_size += size * 4; - } - else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) { - *attr_float4_size += size; - } - else { - *attr_float3_size += size; - } - } -} - /* * Records all the attribute buffer sizes for all the attribute buffers for later use */ diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 5bfe426fb6e..3f301bbeda1 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -32,6 +32,25 @@ CCL_NAMESPACE_BEGIN +void Geometry::compute_bvh(Device *device, + DeviceScene *dscene, + SceneParams *params, + Progress *progress, + size_t n, + size_t total) +{ + if (progress->get_cancel()) + return; + + const BVHLayout bvh_layout = BVHParams::best_bvh_layout( + params->bvh_layout, device->get_bvh_layout_mask(dscene->data.kernel_features)); + if (need_build_bvh(bvh_layout)) { + BVH *sub_bvh = bvh->get_device_bvh(device); + GeometryManager::device_update_sub_bvh( + device, dscene, bvh, sub_bvh, !need_update_rebuild, n, total, progress); + } +} + void GeometryManager::device_init_update_bvh(Scene *scene) { if (scene->bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { -- 2.30.2 From d96fd9b08feb0f607d72ccf9b62e36685b541649 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 21 Apr 2023 13:39:58 +0200 Subject: [PATCH 63/96] Handle the bvh root index correctly for the device specific DeviceScene Uses the unique_ptr to decallocate the BVH2 structure in the BVH postprocess and assignes the bvh root indices in the device specific areas also. --- intern/cycles/scene/devicescene.cpp | 3 ++- intern/cycles/scene/devicescene.h | 5 ++++- intern/cycles/scene/geometry.cpp | 2 -- intern/cycles/scene/geometry.h | 1 - intern/cycles/scene/geometry_bvh.cpp | 26 ++------------------------ 5 files changed, 8 insertions(+), 29 deletions(-) diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index da410408f82..e84196461ae 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -5,6 +5,7 @@ #include "scene/devicescene.h" #include "scene/scene.h" + #include "device/device.h" #include "device/memory.h" @@ -281,7 +282,7 @@ void DeviceScene::device_update_bvh2(Device *device, { if (bvh->params.bvh_layout == BVH_LAYOUT_BVH2) { BVH2 *bvh2 = static_cast(bvh); - + data.bvh.root = bvh2->pack.root_index; /* When using BVH2, we always have to copy/update the data as its layout is dependent on * the BVH's leaf nodes which may be different when the objects or vertices move. */ diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h index beb1daa0fba..382f87f775f 100644 --- a/intern/cycles/scene/devicescene.h +++ b/intern/cycles/scene/devicescene.h @@ -4,15 +4,18 @@ #ifndef __DEVICESCENE_H__ #define __DEVICESCENE_H__ -#include "device/device.h" #include "device/memory.h" #include "util/types.h" #include "util/vector.h" +#include "kernel/types.h" + CCL_NAMESPACE_BEGIN class BVH; +class Device; +class Progress; struct GeometrySizes; struct AttributeSizes; diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 2a51f2daebc..be576a933e0 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -779,8 +779,6 @@ void GeometryManager::update_object_bounds(Scene *scene) } } - - /* * Tesselates any modified object that requires it. */ diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index e3256a0ee79..0f20dfa7971 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -258,7 +258,6 @@ class GeometryManager { Scene *scene, const BVHLayout bvh_layout, bool &need_update_scene_bvh); - void update_scene_bvhs(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void clear_shader_update_tags(Scene *scene); void clear_geometry_update_and_modified_tags(Scene *scene); void device_data_xfer_and_bvh_update(int idx, diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 65a2340de09..7692b02d310 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -85,7 +85,8 @@ void GeometryManager::device_update_bvh_postprocess(Device *device, if (has_bvh2_layout) { BVH2 *bvh2 = static_cast(scene->bvh); - dscene->data.bvh.root = bvh2->pack.root_index; + PackedBVH pack = std::move(bvh2->pack); + dscene->data.bvh.root = pack.root_index; } else { dscene->data.bvh.root = -1; @@ -276,27 +277,4 @@ size_t GeometryManager::create_object_bvhs(Device *device, return num_bvh; } -/* - * Prepares scene BVH for building or refitting. Then builds or refits the scene - * BVH for all the devices. - */ -void GeometryManager::update_scene_bvhs(Device *device, - DeviceScene *dscene, - Scene *scene, - Progress &progress) -{ - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time}); - } - }); - - bool can_refit = device_update_bvh_preprocess(device, dscene, scene, progress); - foreach (auto sub_dscene, scene->dscenes) { - Device *sub_device = sub_dscene->tri_verts.device; - device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); - } - device_update_bvh_postprocess(device, dscene, scene, progress); -} - CCL_NAMESPACE_END -- 2.30.2 From 89f11dedda775f63288032bdcd1a2a217309bbbf Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 21 Apr 2023 15:37:05 +0200 Subject: [PATCH 64/96] Manage sub-BVHs life cycles using unique_ptr --- intern/cycles/bvh/multi.cpp | 15 +++++---------- intern/cycles/bvh/multi.h | 5 ++++- intern/cycles/device/multi/device.cpp | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/intern/cycles/bvh/multi.cpp b/intern/cycles/bvh/multi.cpp index 79c6ee94722..386ae266e3d 100644 --- a/intern/cycles/bvh/multi.cpp +++ b/intern/cycles/bvh/multi.cpp @@ -18,25 +18,20 @@ BVHMulti::BVHMulti(const BVHParams ¶ms_, sub_bvhs.resize(n); } -BVHMulti::~BVHMulti() -{ - foreach (BVH *bvh, sub_bvhs) { - delete bvh; - } -} +BVHMulti::~BVHMulti() { } BVH *BVHMulti::get_device_bvh(const Device *subdevice) { int id = device->device_number(subdevice); resize_sub_bvhs_if_needed(id); - return sub_bvhs[id]; + return sub_bvhs[id].get(); } void BVHMulti::set_device_bvh(const Device *subdevice, BVH *bvh) { int id = device->device_number(subdevice); resize_sub_bvhs_if_needed(id); - sub_bvhs[id] = bvh; + sub_bvhs[id] = unique_ptr(bvh); }; /** @@ -46,14 +41,14 @@ void BVHMulti::set_device_bvh(const Device *subdevice, BVH *bvh) void BVHMulti::resize_sub_bvhs_if_needed(int id) { if ((id != -1) && (id >= sub_bvhs.size())) { - sub_bvhs.resize(id + 1, NULL); + sub_bvhs.resize(id + 1); } } void BVHMulti::replace_geometry(const vector &geometry, const vector &objects) { - foreach (BVH *bvh, sub_bvhs) { + foreach (auto &bvh, sub_bvhs) { bvh->replace_geometry(geometry, objects); } } diff --git a/intern/cycles/bvh/multi.h b/intern/cycles/bvh/multi.h index 380247ced99..b9e04d35296 100644 --- a/intern/cycles/bvh/multi.h +++ b/intern/cycles/bvh/multi.h @@ -7,11 +7,14 @@ #include "bvh/bvh.h" #include "bvh/params.h" +#include "util/vector.h" +#include "util/unique_ptr.h" + CCL_NAMESPACE_BEGIN class BVHMulti : public BVH { public: - vector sub_bvhs; + vector> sub_bvhs; virtual BVH *get_device_bvh(const Device *device) override; virtual void set_device_bvh(const Device *sub_device, BVH *bvh) override; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index b56391d4ae2..c7d4e9283f2 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -197,12 +197,12 @@ class MultiDevice : public Device { !bvh_multi->geometry[0]->is_instanced()) { } else { - bvh_multi->sub_bvhs[id] = BVH::create( - params, bvh_multi->geometry, bvh_multi->objects, sub->device.get()); + bvh_multi->sub_bvhs[id] = std::unique_ptr(BVH::create( + params, bvh_multi->geometry, bvh_multi->objects, sub->device.get())); } } if (bvh_multi->sub_bvhs[id]) { - sub->device->build_bvh(bvh_multi->sub_bvhs[id], dscene, progress, refit); + sub->device->build_bvh(bvh_multi->sub_bvhs[id].get(), dscene, progress, refit); } }); } -- 2.30.2 From a126bf3b535d4e8fb8e202f63a18a8dbc4d6a4c9 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 21 Apr 2023 15:56:04 +0200 Subject: [PATCH 65/96] Revert progress related changes --- intern/cycles/blender/session.cpp | 1 - intern/cycles/scene/scene.cpp | 5 +- intern/cycles/util/progress.h | 116 +++++++++++++----------------- 3 files changed, 50 insertions(+), 72 deletions(-) diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index 3f7b0dc216a..6c865c2f9b0 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -125,7 +125,6 @@ void BlenderSession::create_session() session = new Session(session_params, scene_params); session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this)); session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this)); - session->progress.set_updates(!headless); session->set_pause(session_pause); /* create scene */ diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 0e4eda573eb..442b4452b82 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -40,9 +40,8 @@ CCL_NAMESPACE_BEGIN */ bool Scene::check_cancel_update(Progress &progress, Device *device) { bool status = false; - if (progress.get_updates()) { - status = progress.get_cancel(); - } + status = progress.get_cancel(); + return status || ((device != NULL) && device->have_error()); } diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h index 19f82ea878c..586979d2021 100644 --- a/intern/cycles/util/progress.h +++ b/intern/cycles/util/progress.h @@ -4,34 +4,21 @@ #ifndef __UTIL_PROGRESS_H__ #define __UTIL_PROGRESS_H__ -#define USE_SPINLOCK -#ifdef USE_SPINLOCK -#define MUTEX thread_spin_lock -#define SCOPED_LOCK(mutex) thread_scoped_spin_lock scopedspinlock(mutex); -#else -#define MUTEX thread_mutex -#define SCOPED_LOCK(mutex) thread_scoped_lock scopedlock(mutex) -#endif - /* Progress * * Simple class to communicate progress status messages, timing information, * update notifications from a job running in another thread. All methods * except for the constructor/destructor are thread safe. */ -#include #include "util/function.h" #include "util/string.h" #include "util/thread.h" #include "util/time.h" -#include "util/log.h" CCL_NAMESPACE_BEGIN class Progress { public: - using callback_type = function; - Progress() { pixel_samples = 0; @@ -53,7 +40,6 @@ class Progress { error = false; error_message = ""; cancel_cb = function_null; - updates = true; } Progress(Progress &progress) @@ -63,7 +49,8 @@ class Progress { Progress &operator=(Progress &progress) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress.progress_mutex); + progress.get_status(status, substatus); pixel_samples = progress.pixel_samples; @@ -92,19 +79,12 @@ class Progress { cancel_message = ""; error = false; error_message = ""; - updates = true; - } - - void set_updates(bool updates_) - { - updates = updates_; - VLOG_INFO << "Set progress updates " << (updates_ ? "on" : "off"); } /* cancel */ void set_cancel(const string &cancel_message_) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); cancel_message = cancel_message_; cancel = true; } @@ -117,14 +97,9 @@ class Progress { return cancel; } - bool get_updates() const + string get_cancel_message() const { - return updates; - } - - string get_cancel_message() const - { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); return cancel_message; } @@ -136,7 +111,7 @@ class Progress { /* error */ void set_error(const string &error_message_) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); error_message = error_message_; error = true; /* If error happens we also stop rendering. */ @@ -149,9 +124,9 @@ class Progress { return error; } - string get_error_message() const + string get_error_message() const { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); return error_message; } @@ -159,20 +134,23 @@ class Progress { void set_start_time() { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + start_time = time_dt(); end_time = 0.0; } void set_render_start_time() { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + render_start_time = time_dt(); } void set_time_limit(double time_limit_) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + time_limit = time_limit_; } @@ -186,11 +164,11 @@ class Progress { } } - void get_time(double &total_time_, double &render_time_) const + void get_time(double &total_time_, double &render_time_) const { - SCOPED_LOCK(progress_mutex); - double et = end_time; - double time = (et > 0) ? et : time_dt(); + thread_scoped_lock lock(progress_mutex); + + double time = (end_time > 0) ? end_time : time_dt(); total_time_ = time - start_time; render_time_ = time - render_start_time; @@ -203,6 +181,8 @@ class Progress { void reset_sample() { + thread_scoped_lock lock(progress_mutex); + pixel_samples = 0; current_tile_sample = 0; rendered_tiles = 0; @@ -211,29 +191,30 @@ class Progress { void set_total_pixel_samples(uint64_t total_pixel_samples_) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + total_pixel_samples = total_pixel_samples_; } - double get_progress() const + double get_progress() const { - SCOPED_LOCK(progress_mutex); - double value = 0.0; + thread_scoped_lock lock(progress_mutex); + if (pixel_samples > 0) { double progress_percent = (double)pixel_samples / (double)total_pixel_samples; if (time_limit != 0.0) { double time_since_render_start = time_dt() - render_start_time; progress_percent = max(progress_percent, time_since_render_start / time_limit); } - value = min(1.0, progress_percent); + return min(1.0, progress_percent); } - - return value; + return 0.0; } void add_samples(uint64_t pixel_samples_, int tile_sample) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + pixel_samples += pixel_samples_; current_tile_sample = tile_sample; } @@ -246,7 +227,8 @@ class Progress { void add_finished_tile(bool denoised) { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + if (denoised) { denoised_tiles++; } @@ -257,7 +239,7 @@ class Progress { int get_current_sample() const { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); /* Note that the value here always belongs to the last tile that updated, * so it's only useful if there is only one active tile. */ return current_tile_sample; @@ -265,13 +247,13 @@ class Progress { int get_rendered_tiles() const { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); return rendered_tiles; } int get_denoised_tiles() const { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); return denoised_tiles; } @@ -279,8 +261,8 @@ class Progress { void set_status(const string &status_, const string &substatus_ = "") { - if (updates) { - SCOPED_LOCK(progress_mutex); + { + thread_scoped_lock lock(progress_mutex); status = status_; substatus = substatus_; } @@ -290,8 +272,8 @@ class Progress { void set_substatus(const string &substatus_) { - if (updates) { - SCOPED_LOCK(progress_mutex); + { + thread_scoped_lock lock(progress_mutex); substatus = substatus_; } @@ -300,8 +282,8 @@ class Progress { void set_sync_status(const string &status_, const string &substatus_ = "") { - if (updates) { - SCOPED_LOCK(progress_mutex); + { + thread_scoped_lock lock(progress_mutex); sync_status = status_; sync_substatus = substatus_; } @@ -311,8 +293,8 @@ class Progress { void set_sync_substatus(const string &substatus_) { - if (updates) { - SCOPED_LOCK(progress_mutex); + { + thread_scoped_lock lock(progress_mutex); sync_substatus = substatus_; } @@ -321,7 +303,8 @@ class Progress { void get_status(string &status_, string &substatus_) const { - SCOPED_LOCK(progress_mutex); + thread_scoped_lock lock(progress_mutex); + if (sync_status != "") { status_ = sync_status; substatus_ = sync_substatus; @@ -336,8 +319,8 @@ class Progress { void set_update() { - if (updates && update_cb) { - SCOPED_LOCK(update_mutex); + if (update_cb) { + thread_scoped_lock lock(update_mutex); update_cb(); } } @@ -348,8 +331,8 @@ class Progress { } protected: - mutable MUTEX progress_mutex; - mutable MUTEX update_mutex; + mutable thread_mutex progress_mutex; + mutable thread_mutex update_mutex; function update_cb; function cancel_cb; @@ -381,9 +364,6 @@ class Progress { volatile bool error; string error_message; - - /* Used to enable progress updates if true */ - bool updates; }; CCL_NAMESPACE_END -- 2.30.2 From 0669acc5c51915124765577b94cceec35747819f Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 21 Apr 2023 17:29:22 +0200 Subject: [PATCH 66/96] Remove geometry_additions.cpp --- intern/cycles/scene/geometry_additions.cpp | 407 --------------------- 1 file changed, 407 deletions(-) delete mode 100644 intern/cycles/scene/geometry_additions.cpp diff --git a/intern/cycles/scene/geometry_additions.cpp b/intern/cycles/scene/geometry_additions.cpp deleted file mode 100644 index 13f331a4e51..00000000000 --- a/intern/cycles/scene/geometry_additions.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 - * Copyright 2011-2022 Blender Foundation */ - -#include "bvh/bvh.h" -#include "bvh/bvh2.h" - -#include "device/device.h" - -#include "scene/attribute.h" -#include "scene/camera.h" -#include "scene/geometry.h" -#include "scene/hair.h" -#include "scene/light.h" -#include "scene/mesh.h" -#include "scene/object.h" -#include "scene/pointcloud.h" -#include "scene/scene.h" -#include "scene/shader.h" -#include "scene/shader_nodes.h" -#include "scene/stats.h" -#include "scene/volume.h" - -#include "subd/patch_table.h" -#include "subd/split.h" - -#include "kernel/osl/globals.h" - -#include "util/foreach.h" -#include "util/log.h" -#include "util/progress.h" -#include "util/task.h" -CCL_NAMESPACE_BEGIN - -/* - * Clears all tags used to indicate the the shader needs to be updated. - */ -void GeometryManager::clearShaderUpdateTags(Scene *scene) -{ - /* unset flags */ - foreach (Shader *shader, scene->shaders) { - shader->need_update_uvs = false; - shader->need_update_attribute = false; - shader->need_update_displacement = false; - } -} - -/* - * Clears all tags used to indicate the the geometry needs to be updated - * or has been modified. - */ -void GeometryManager::clearGeometryUpdateAndModifiedTags(Scene *scene) -{ - // Clear update tags - foreach (Geometry *geom, scene->geometry) { - // Clear update indicators - if (geom->is_modified() || geom->need_update_bvh_for_offset) { - geom->need_update_rebuild = false; - geom->need_update_bvh_for_offset = false; - } - - // Clear modified tags - geom->clear_modified(); - geom->attributes.clear_modified(); - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - mesh->subd_attributes.clear_modified(); - } - } -} - -/* - * Clears the modified tags for all elements of the device scene - */ -void GeometryManager::device_scene_clear_modified(DeviceScene *dscene) -{ - dscene->bvh_nodes.clear_modified(); - dscene->bvh_leaf_nodes.clear_modified(); - dscene->object_node.clear_modified(); - dscene->prim_type.clear_modified(); - dscene->prim_visibility.clear_modified(); - dscene->prim_index.clear_modified(); - dscene->prim_object.clear_modified(); - dscene->prim_time.clear_modified(); - dscene->tri_verts.clear_modified(); - dscene->tri_shader.clear_modified(); - dscene->tri_vindex.clear_modified(); - dscene->tri_patch.clear_modified(); - dscene->tri_vnormal.clear_modified(); - dscene->tri_patch_uv.clear_modified(); - dscene->curves.clear_modified(); - dscene->curve_keys.clear_modified(); - dscene->curve_segments.clear_modified(); - dscene->points.clear_modified(); - dscene->points_shader.clear_modified(); - dscene->patches.clear_modified(); - dscene->attributes_map.clear_modified(); - dscene->attributes_float.clear_modified(); - dscene->attributes_float2.clear_modified(); - dscene->attributes_float3.clear_modified(); - dscene->attributes_float4.clear_modified(); - dscene->attributes_uchar4.clear_modified(); - dscene->objects.clear_modified(); - dscene->attributes_map.clear_modified(); -} - - - - - -/* - * Assigns the host pointers to the sub-devicescenes so - * that they all have the same data sources - */ -void GeometryManager::device_update_host_pointers(Device *device, - DeviceScene *dscene, - DeviceScene *sub_dscene, - GeometrySizes *p_sizes) -{ - if (p_sizes->tri_size != 0) { - if (dscene->tri_verts.is_modified()) { - sub_dscene->tri_verts.assign_mem(dscene->tri_verts); - sub_dscene->tri_verts.tag_modified(); - } - { - if (dscene->tri_shader.is_modified()) { - sub_dscene->tri_shader.assign_mem(dscene->tri_shader); - sub_dscene->tri_shader.tag_modified(); - } - } - { - if (dscene->tri_vnormal.is_modified()) { - sub_dscene->tri_vnormal.assign_mem(dscene->tri_vnormal); - sub_dscene->tri_vnormal.tag_modified(); - } - } - { - if (dscene->tri_vindex.is_modified()) { - sub_dscene->tri_vindex.assign_mem(dscene->tri_vindex); - sub_dscene->tri_vindex.tag_modified(); - } - } - { - if (dscene->tri_patch.is_modified()) { - sub_dscene->tri_patch.assign_mem(dscene->tri_patch); - sub_dscene->tri_patch.tag_modified(); - } - } - { - if (dscene->tri_patch_uv.is_modified()) { - sub_dscene->tri_patch_uv.assign_mem(dscene->tri_patch_uv); - sub_dscene->tri_patch_uv.tag_modified(); - } - } - } - - if (p_sizes->curve_segment_size != 0) { - if (dscene->curve_keys.is_modified()) { - sub_dscene->curve_keys.assign_mem(dscene->curve_keys); - sub_dscene->curve_keys.tag_modified(); - } - - if (dscene->curves.is_modified()) { - sub_dscene->curves.assign_mem(dscene->curves); - sub_dscene->curves.tag_modified(); - } - - if (dscene->curve_segments.is_modified()) { - sub_dscene->curve_segments.assign_mem(dscene->curve_segments); - } - } - - if (p_sizes->point_size != 0) { - // TODO: Why does this not check the modified tag? - sub_dscene->points.assign_mem(dscene->points); - // sub_dscene->points.tag_modified(); - - sub_dscene->points_shader.assign_mem(dscene->points_shader); - // sub_dscene->points_shader.tag_modified(); - } - - if (p_sizes->patch_size != 0 && dscene->patches.need_realloc()) { - sub_dscene->patches.assign_mem(dscene->patches); - } - - // Update the Attributes - if (dscene->attributes_map.is_modified()) { - sub_dscene->attributes_map.assign_mem(dscene->attributes_map); - sub_dscene->attributes_map.tag_modified(); - } - if (dscene->attributes_float.is_modified()) { - sub_dscene->attributes_float.assign_mem(dscene->attributes_float); - sub_dscene->attributes_float.tag_modified(); - } - if (dscene->attributes_float2.is_modified()) { - sub_dscene->attributes_float2.assign_mem(dscene->attributes_float2); - sub_dscene->attributes_float2.tag_modified(); - } - if (dscene->attributes_float3.is_modified()) { - sub_dscene->attributes_float3.assign_mem(dscene->attributes_float3); - sub_dscene->attributes_float3.tag_modified(); - } - if (dscene->attributes_float4.is_modified()) { - sub_dscene->attributes_float4.assign_mem(dscene->attributes_float4); - sub_dscene->attributes_float4.tag_modified(); - } - if (dscene->attributes_uchar4.is_modified()) { - sub_dscene->attributes_uchar4.assign_mem(dscene->attributes_uchar4); - sub_dscene->attributes_uchar4.tag_modified(); - } - if (dscene->objects.is_modified()) { - sub_dscene->objects.assign_mem(dscene->objects); - sub_dscene->objects.tag_modified(); - } -} - -/* - * Records all the geometry buffer sizes for later use - */ -void GeometryManager::geom_calc_offset(Scene *scene, GeometrySizes *p_sizes) -{ - // Zero sizes - p_sizes->vert_size = 0; - p_sizes->tri_size = 0; - - p_sizes->curve_size = 0; - p_sizes->curve_key_size = 0; - p_sizes->curve_segment_size = 0; - - p_sizes->point_size = 0; - - p_sizes->patch_size = 0; - p_sizes->face_size = 0; - p_sizes->corner_size = 0; - - // Write the buffer offsets to the geometries and increment the sizes - foreach (Geometry *geom, scene->geometry) { - bool prim_offset_changed = false; - if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { - Mesh *mesh = static_cast(geom); - - prim_offset_changed = (mesh->prim_offset != p_sizes->tri_size); - - mesh->vert_offset = p_sizes->vert_size; - mesh->prim_offset = p_sizes->tri_size; - - mesh->patch_offset = p_sizes->patch_size; - mesh->face_offset = p_sizes->face_size; - mesh->corner_offset = p_sizes->corner_size; - - p_sizes->vert_size += mesh->verts.size(); - // Store extra index set for motion blur - if(mesh->get_use_motion_blur()) { - p_sizes->tri_size += 2*mesh->num_triangles(); - } else { - p_sizes->tri_size += mesh->num_triangles(); - } - - if (mesh->get_num_subd_faces()) { - Mesh::SubdFace last = mesh->get_subd_face(mesh->get_num_subd_faces() - 1); - p_sizes->patch_size += (last.ptex_offset + last.num_ptex_faces()) * 8; - - /* patch tables are stored in same array so include them in patch_size */ - if (mesh->patch_table) { - mesh->patch_table_offset = p_sizes->patch_size; - p_sizes->patch_size += mesh->patch_table->total_size(); - } - } - - p_sizes->face_size += mesh->get_num_subd_faces(); - p_sizes->corner_size += mesh->subd_face_corners.size(); - } - else if (geom->is_hair()) { - Hair *hair = static_cast(geom); - - prim_offset_changed = (hair->curve_segment_offset != p_sizes->curve_segment_size); - hair->curve_key_offset = p_sizes->curve_key_size; - hair->curve_segment_offset = p_sizes->curve_segment_size; - hair->prim_offset = p_sizes->curve_size; - - p_sizes->curve_size += hair->num_curves(); - p_sizes->curve_key_size += hair->get_curve_keys().size(); - p_sizes->curve_segment_size += hair->num_segments(); - } - else if (geom->is_pointcloud()) { - PointCloud *pointcloud = static_cast(geom); - - prim_offset_changed = (pointcloud->prim_offset != p_sizes->point_size); - - pointcloud->prim_offset = p_sizes->point_size; - p_sizes->point_size += pointcloud->num_points(); - } - // Used to determine if the BVH needs to be recalculated - // as the buffer offsets have been altered. - geom->need_update_bvh_for_offset = prim_offset_changed; - } -} - - - - - -bool GeometryManager::displacement_and_curve_shadow_transparency( - Scene *scene, - Device *device, - DeviceScene *dscene, - GeometrySizes *sizes, - AttributeSizes *attrib_sizes, - vector &geom_attributes, - vector &object_attributes, - vector &object_attribute_values, - Progress &progress) -{ - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); - } - }); - /* Signal for shaders like displacement not to do ray tracing. */ - dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; - scene->object_manager->device_update_flags(device, dscene, scene, progress, false); - - bool displacement_done = false; - bool curve_shadow_transparency_done = false; - { - // Need to upload the attribute and mesh buffers for dispacement. - // Evaluate these on a single device (anyone will do, so use the first) - { - // Could break this out across all the devices as - // the results are read back to the host. For now, the computations - // are done on the first device. - DeviceScene *sub_dscene = scene->dscenes.front(); - Device *sub_device = sub_dscene->tri_verts.device; - { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: copy meshes to device)", time}); - } - }); - device_update_host_pointers(sub_device, dscene, sub_dscene, sizes); - device_update_attributes(sub_device, sub_dscene, attrib_sizes, progress); - device_update_mesh(sub_device, sub_dscene, sizes, progress); - } - /* Copy constant data needed by shader evaluation. */ - sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); - - foreach (Geometry *geom, scene->geometry) { - /* Update images needed for true displacement. */ - { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: load images)", time}); - } - }); - device_update_displacement_images(sub_device, scene, progress); - } - - if (geom->is_modified()) { - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - if (displace(sub_device, scene, mesh, progress)) { - displacement_done = true; - } - } - else if (geom->geometry_type == Geometry::HAIR) { - Hair *hair = static_cast(geom); - if (hair->update_shadow_transparency(sub_device, scene, progress)) { - curve_shadow_transparency_done = true; - } - } - } - } - } - - // Some host side code here as the mesh and attributes need to be - // recalculated after displacement and shadow transparency - /* Device re-update after displacement. */ - if (displacement_done || curve_shadow_transparency_done) { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: attributes)", time}); - } - }); - - // Need to redo host side filling out the attribute and mesh buffers as these may have - // changed. Hair adds a new attribute buffer and displace updates the mesh. - geom_calc_offset(scene, sizes); - gather_attributes( - scene, geom_attributes, object_attributes, object_attribute_values, attrib_sizes); - device_free(device, dscene, false); - device_update_attributes_preprocess(device, - dscene, - scene, - geom_attributes, - object_attributes, - object_attribute_values, - attrib_sizes, - progress); - device_update_mesh_preprocess(device, dscene, scene, sizes, progress); - } - } - - return scene->object_manager->need_flags_update; -} -CCL_NAMESPACE_END -- 2.30.2 From 4ca1060431c9a6fd3f088f2f2132b8ec4fb8dea8 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 25 Apr 2023 12:41:53 +0200 Subject: [PATCH 67/96] Rename DeviceScene method device_free to device_free_geometry --- intern/cycles/scene/devicescene.cpp | 2 +- intern/cycles/scene/devicescene.h | 2 +- intern/cycles/scene/geometry.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index e84196461ae..17eebf5575e 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -67,7 +67,7 @@ DeviceScene::DeviceScene(Device *device) memset((void *)&data, 0, sizeof(data)); } -void DeviceScene::device_free(bool force_free) +void DeviceScene::device_free_geometry(bool force_free) { bvh_nodes.free_if_need_realloc(force_free); bvh_leaf_nodes.free_if_need_realloc(force_free); diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h index 382f87f775f..d64ee9adff6 100644 --- a/intern/cycles/scene/devicescene.h +++ b/intern/cycles/scene/devicescene.h @@ -104,7 +104,7 @@ class DeviceScene { DeviceScene(Device *device); - void device_free(bool force_free); + void device_free_geometry(bool force_free); void device_scene_clear_modified(); void device_update_host_pointers(Device *device, DeviceScene *dscene, diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index be576a933e0..af7a8cc53ba 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -948,7 +948,7 @@ void GeometryManager::device_update(Device *device, void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free) { - dscene->device_free(force_free); + dscene->device_free_geometry(force_free); #ifdef WITH_OSL OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory(); -- 2.30.2 From d949741a33072caf01cb11bd0c0b961863c498aa Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 26 Apr 2023 09:50:00 +0200 Subject: [PATCH 68/96] FIX: Clear the device buffers after hair transparency calculations --- intern/cycles/scene/geometry.cpp | 25 ++++++++++++++----------- intern/cycles/scene/geometry.h | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index af7a8cc53ba..5bfd48f491c 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -877,6 +877,7 @@ void GeometryManager::device_update(Device *device, geom_attributes, object_attributes, object_attribute_values, + true_displacement_used, progress); } @@ -1115,6 +1116,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, + bool true_displacement_used, Progress &progress) { scoped_callback_timer timer([scene](double time) { @@ -1129,12 +1131,12 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( bool displacement_done = false; bool curve_shadow_transparency_done = false; { - // Need to upload the attribute and mesh buffers for dispacement. - // Evaluate these on a single device (anyone will do, so use the first) + /* Need to upload the attribute and mesh buffers for dispacement. + Evaluate these on a single device (anyone will do, so use the first) */ { - // Could break this out across all the devices as - // the results are read back to the host. For now, the computations - // are done on the first device. + /* Could break this out across all the devices as + the results are read back to the host. For now, the computations + are done on the first device. */ DeviceScene *sub_dscene = scene->dscenes.front(); Device *sub_device = sub_dscene->tri_verts.device; { @@ -1149,11 +1151,11 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } /* Copy constant data needed by shader evaluation. */ - sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); + sub_device->const_copy_to("data", &sub_dscene->data, sizeof(sub_dscene->data)); foreach (Geometry *geom, scene->geometry) { /* Update images needed for true displacement. */ - { + if(true_displacement_used){ scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( @@ -1178,10 +1180,11 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( } } } + sub_dscene->device_free_geometry(false); } - // Some host side code here as the mesh and attributes need to be - // recalculated after displacement and shadow transparency + /* Some host side code here as the mesh and attributes need to be + recalculated after displacement and shadow transparency */ /* Device re-update after displacement. */ if (displacement_done || curve_shadow_transparency_done) { scoped_callback_timer timer([scene](double time) { @@ -1191,8 +1194,8 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( } }); - // Need to redo host side filling out the attribute and mesh buffers as these may have - // changed. Hair adds a new attribute buffer and displace updates the mesh. + /* Need to redo host side filling out the attribute and mesh buffers as these may have + changed. Hair adds a new attribute buffer and displace updates the mesh. */ geom_calc_offset(scene); gather_attributes( scene, geom_attributes, object_attributes, object_attribute_values); diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 0f20dfa7971..66d7957f4f7 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -313,6 +313,7 @@ class GeometryManager { vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, + bool true_displacement_used, Progress &progress); void gather_attributes(Scene *scene, -- 2.30.2 From 1560ec66c940560553b58f7b36fbc0fd7417fac5 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 26 Apr 2023 10:02:39 +0200 Subject: [PATCH 69/96] FIX: Create CUDA context earlier and remove lock Some CUDA commands were used before the context was setup. Also since the BVHs are build in order there is not need for the lock to prevent 2 being build at tehe same time to save memory. --- intern/cycles/device/optix/device_impl.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index 8398726cd03..cda2ddc205c 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -949,11 +949,6 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, * from running out of memory (since both original and compacted acceleration structure memory * may be allocated at the same time for the duration of this function). The builds would * otherwise happen on the same CUDA stream anyway. */ - static thread_mutex mutex; - thread_scoped_lock lock(mutex); - - const CUDAContextScope scope(this); - const bool use_fast_trace_bvh = (bvh->params.bvh_type == BVH_TYPE_STATIC); /* Compute memory usage. */ @@ -1063,6 +1058,7 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, void OptiXDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { + const CUDAContextScope scope(this); const bool use_fast_trace_bvh = (bvh->params.bvh_type == BVH_TYPE_STATIC); free_bvh_memory_delayed(); -- 2.30.2 From 8ba98b81382d370d6df034436423abc456855658 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 26 Apr 2023 12:22:50 +0200 Subject: [PATCH 70/96] Move displacement image upload out of geometry loop --- intern/cycles/scene/geometry.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 5bfd48f491c..6d02afcf1d7 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -1150,21 +1150,21 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } - /* Copy constant data needed by shader evaluation. */ - sub_device->const_copy_to("data", &sub_dscene->data, sizeof(sub_dscene->data)); + /* Copy constant data needed by shader evaluation. */ + sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); + + /* Update images needed for true displacement. */ + if (true_displacement_used) { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry( + {"device_update (displacement: load images)", time}); + } + }); + device_update_displacement_images(sub_device, scene, progress); + } foreach (Geometry *geom, scene->geometry) { - /* Update images needed for true displacement. */ - if(true_displacement_used){ - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: load images)", time}); - } - }); - device_update_displacement_images(sub_device, scene, progress); - } - if (geom->is_modified()) { if (geom->is_mesh()) { Mesh *mesh = static_cast(geom); @@ -1197,8 +1197,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( /* Need to redo host side filling out the attribute and mesh buffers as these may have changed. Hair adds a new attribute buffer and displace updates the mesh. */ geom_calc_offset(scene); - gather_attributes( - scene, geom_attributes, object_attributes, object_attribute_values); + gather_attributes(scene, geom_attributes, object_attributes, object_attribute_values); device_free(device, dscene, false); device_update_attributes_preprocess(device, dscene, -- 2.30.2 From 0af6a3efbe5211c81cece6a9008437ec8c5066c8 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 26 Apr 2023 16:15:17 +0200 Subject: [PATCH 71/96] FIX:Add correct parameters to the OneAPI build_bvh method --- intern/cycles/device/oneapi/device_impl.cpp | 4 ++-- intern/cycles/device/oneapi/device_impl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index 7c76013bb3c..1b391a5b98b 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -135,7 +135,7 @@ BVHLayoutMask OneapiDevice::get_bvh_layout_mask(uint requested_features) const } # ifdef WITH_EMBREE_GPU -void OneapiDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) +void OneapiDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { if (embree_device && bvh->params.bvh_layout == BVH_LAYOUT_EMBREE) { BVHEmbree *const bvh_embree = static_cast(bvh); @@ -150,7 +150,7 @@ void OneapiDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) } } else { - Device::build_bvh(bvh, progress, refit); + Device::build_bvh(bvh, dscene, progress, refit); } } # endif diff --git a/intern/cycles/device/oneapi/device_impl.h b/intern/cycles/device/oneapi/device_impl.h index 0dab3ef6961..d9a638ea541 100644 --- a/intern/cycles/device/oneapi/device_impl.h +++ b/intern/cycles/device/oneapi/device_impl.h @@ -45,7 +45,7 @@ class OneapiDevice : public Device { virtual ~OneapiDevice(); # ifdef WITH_EMBREE_GPU - void build_bvh(BVH *bvh, Progress &progress, bool refit) override; + void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override; # endif bool check_peer_access(Device *peer_device) override; -- 2.30.2 From 58cddaeefed6c16babca73d83976832426a82c0f Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 27 Apr 2023 10:57:04 +0200 Subject: [PATCH 72/96] FIX: Upload textures to all devices For the displacement and shadow texture generation the textures were originally only uploaded to 1 device. However, this resulted in some textures that were needed across all devices not being uploaded. This fixes that by uploading them to all devices. --- intern/cycles/scene/geometry.cpp | 11 +++++++---- intern/cycles/scene/geometry.h | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 3f31834d834..0cf66889fcc 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -879,7 +879,6 @@ void GeometryManager::device_update(Device *device, geom_attributes, object_attributes, object_attribute_values, - true_displacement_used, progress); } @@ -1118,7 +1117,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, - bool true_displacement_used, Progress &progress) { scoped_callback_timer timer([scene](double time) { @@ -1156,14 +1154,19 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); /* Update images needed for true displacement. */ - if (true_displacement_used) { + { scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( {"device_update (displacement: load images)", time}); } }); - device_update_displacement_images(sub_device, scene, progress); + /* Upload the textures to all devices as this includes bump maps + which are used when rendering and only uploaded here. Also + you can't iterate over all devices as this routine sets some + state which stops some images getting uploaded. + */ + device_update_displacement_images(device, scene, progress); } foreach (Geometry *geom, scene->geometry) { diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 66d7957f4f7..0f20dfa7971 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -313,7 +313,6 @@ class GeometryManager { vector &geom_attributes, vector &object_attributes, vector &object_attribute_values, - bool true_displacement_used, Progress &progress); void gather_attributes(Scene *scene, -- 2.30.2 From a916e340339ceaedb0bc2c7a95bb538bc0910bd5 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 27 Apr 2023 11:14:53 +0200 Subject: [PATCH 73/96] Move scene DeviceScene to use unique_ptr To reduce the amount of code and manage the life cycles of the DeviceScenes they are now stored as unique_ptrs --- intern/cycles/scene/geometry.cpp | 4 ++-- intern/cycles/scene/scene.cpp | 8 ++------ intern/cycles/scene/scene.h | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 0cf66889fcc..77a21ded48d 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -697,7 +697,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, bool need_update_scene_bvh, Progress &progress) { - auto sub_dscene = scene->dscenes[idx]; + auto sub_dscene = scene->dscenes[idx].get(); sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; // Get the device to use for this DeviceScene from one of the buffers Device *sub_device = sub_dscene->tri_verts.device; @@ -1137,7 +1137,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( /* Could break this out across all the devices as the results are read back to the host. For now, the computations are done on the first device. */ - DeviceScene *sub_dscene = scene->dscenes.front(); + DeviceScene *sub_dscene = scene->dscenes.front().get(); Device *sub_device = sub_dscene->tri_verts.device; { scoped_callback_timer timer([scene](double time) { diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 9d70f4a6da2..000d6161711 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -63,9 +63,9 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) { /* Create a DeviceScene for each device */ device->foreach_device([this](Device *sub_device) { - auto sub_dscene = new DeviceScene(sub_device); - this->dscenes.push_back(sub_dscene); + auto sub_dscene = make_unique(sub_device); memset((void *)&sub_dscene->data, 0, sizeof(sub_dscene->data)); + this->dscenes.push_back(std::move(sub_dscene)); }); memset((void *)&dscene.data, 0, sizeof(dscene.data)); @@ -98,10 +98,6 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) Scene::~Scene() { - foreach (DeviceScene *sub_scene, dscenes) { - delete sub_scene; - } - free_memory(true); } diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 5a14a3f0b18..1d284cc134c 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -186,7 +186,7 @@ class Scene : public NodeOwner { AttributeSizes attrib_sizes; /* Stores a DeviceScene for each sub-device */ - std::vector dscenes; + std::vector> dscenes; /* Stats time logging */ struct SceneTimes { -- 2.30.2 From e5250ab494c81538ec48a57f655eb14c37d33ff7 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 28 Apr 2023 10:23:44 +0200 Subject: [PATCH 74/96] FIX: Remove this from lambda capture for parallel_for --- intern/cycles/scene/geometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 77a21ded48d..0c5afe181f7 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -907,7 +907,7 @@ void GeometryManager::device_update(Device *device, /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ parallel_for( - size_t(0), num_scenes, [=, this, &progress](const size_t idx) { + size_t(0), num_scenes, [=, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, scene, dscene, -- 2.30.2 From df62806c94071ef587f48330caa898933f620527 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 28 Apr 2023 10:31:38 +0200 Subject: [PATCH 75/96] Use task pool for object BVH build also fixes stats recording Re-instates the task pool used to build the BVHs for the objects. Also the displacement timing was being reported twice and this is fixed. --- intern/cycles/scene/geometry.cpp | 61 ++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 0c5afe181f7..b8a99ec87a0 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -733,16 +733,23 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].object_bvh = time; } }); + TaskPool pool; + size_t i = 0; /* Build the Object BVHs */ foreach (Geometry *geom, scene->geometry) { if (geom->is_modified() || geom->need_update_bvh_for_offset) { - geom->compute_bvh(sub_device, sub_dscene, &scene->params, &progress, i, num_bvh); + pool.push(function_bind( + &Geometry::compute_bvh, geom, sub_device, sub_dscene, &scene->params, &progress, i, num_bvh)); + //geom->compute_bvh(sub_device, sub_dscene, &scene->params, &progress, i, num_bvh); if (geom->need_build_bvh(bvh_layout)) { i++; } } } + TaskPool::Summary summary; + pool.wait_work(&summary); + VLOG_WORK << "Objects BVH build pool statistics:\n" << summary.full_report(); } if(need_update_scene_bvh) { @@ -1119,11 +1126,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( vector &object_attribute_values, Progress &progress) { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); - } - }); /* Signal for shaders like displacement not to do ray tracing. */ dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; scene->object_manager->device_update_flags(device, dscene, scene, progress, false); @@ -1139,6 +1141,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( are done on the first device. */ DeviceScene *sub_dscene = scene->dscenes.front().get(); Device *sub_device = sub_dscene->tri_verts.device; + + sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); + { scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { @@ -1146,8 +1151,14 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( {"device_update (displacement: copy meshes to device)", time}); } }); - sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + } + { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"displacement: copy attributes to device", time}); + } + }); sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } /* Copy constant data needed by shader evaluation. */ @@ -1168,22 +1179,28 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( */ device_update_displacement_images(device, scene, progress); } - - foreach (Geometry *geom, scene->geometry) { - if (geom->is_modified()) { - if (geom->is_mesh()) { - Mesh *mesh = static_cast(geom); - if (displace(sub_device, scene, mesh, progress)) { - displacement_done = true; + { + scoped_callback_timer timer([scene](double time) { + if (scene->update_stats) { + scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time}); + } + }); + foreach (Geometry *geom, scene->geometry) { + if (geom->is_modified()) { + if (geom->is_mesh()) { + Mesh *mesh = static_cast(geom); + if (displace(sub_device, scene, mesh, progress)) { + displacement_done = true; + } + } + else if (geom->geometry_type == Geometry::HAIR) { + Hair *hair = static_cast(geom); + if (hair->update_shadow_transparency(sub_device, scene, progress)) { + curve_shadow_transparency_done = true; + } } } - else if (geom->geometry_type == Geometry::HAIR) { - Hair *hair = static_cast(geom); - if (hair->update_shadow_transparency(sub_device, scene, progress)) { - curve_shadow_transparency_done = true; - } - } - } + } } sub_dscene->device_free_geometry(false); } @@ -1195,7 +1212,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( scoped_callback_timer timer([scene](double time) { if (scene->update_stats) { scene->update_stats->geometry.times.add_entry( - {"device_update (displacement: attributes)", time}); + {"device_update (displacement: preprocess attributes & mesh)", time}); } }); -- 2.30.2 From 429f953d6c34f745794f51d4adbfd373b4ff0f1b Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 28 Apr 2023 15:28:57 +0200 Subject: [PATCH 76/96] Move CUDA context into a smaller scope --- intern/cycles/device/optix/device_impl.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index cda2ddc205c..b0209f16af8 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -1017,15 +1017,13 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, use_fast_trace_bvh ? 1 : 0)); bvh->traversable_handle = static_cast(out_handle); - /* Wait for all operations to finish. */ - cuda_assert(cuStreamSynchronize(NULL)); - /* Compact acceleration structure to save memory (do not do this in viewport for faster builds). */ if (use_fast_trace_bvh) { + const CUDAContextScope scope(this); uint64_t compacted_size = sizes.outputSizeInBytes; cuda_assert(cuMemcpyDtoH(&compacted_size, compacted_size_prop.result, sizeof(compacted_size))); - + /* Temporary memory is no longer needed, so free it now to make space. */ temp_mem.free(); @@ -1058,7 +1056,6 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, void OptiXDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) { - const CUDAContextScope scope(this); const bool use_fast_trace_bvh = (bvh->params.bvh_type == BVH_TYPE_STATIC); free_bvh_memory_delayed(); -- 2.30.2 From d756933965acd028cfa48a4f32a93488ccc556a1 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 2 May 2023 16:22:31 +0200 Subject: [PATCH 77/96] Create upload_changed to upload all changed buffers --- intern/cycles/device/cpu/device_impl.h | 1 + intern/cycles/device/device.cpp | 18 ++++ intern/cycles/device/device.h | 15 +++- intern/cycles/device/dummy/device.cpp | 1 + intern/cycles/device/memory.cpp | 2 +- intern/cycles/device/memory.h | 4 +- intern/cycles/device/metal/device_impl.h | 2 + intern/cycles/device/multi/device.cpp | 103 +++++++++++++++++++---- intern/cycles/scene/geometry.cpp | 6 +- 9 files changed, 128 insertions(+), 24 deletions(-) diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index 10de36cd3bb..8c629b77885 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -88,6 +88,7 @@ class CPUDevice : public Device { vector &kernel_thread_globals) override; virtual void *get_cpu_osl_memory() override; + virtual void upload_changed() override {} ; protected: virtual bool load_kernels(uint /*kernel_features*/) override; }; diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index cbfe5981396..f2631d78276 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -645,6 +645,24 @@ void GPUDevice::move_textures_to_host(size_t size, bool for_texture) load_texture_info(); } +void Device::register_buffer(device_memory *mem) +{ + VLOG_INFO << "Register buffer " << mem->name; + /* Insert into set of buffers. */ + thread_scoped_lock lock(device_buffer_mutex); + device_buffers.insert(mem); +} + +void Device::upload_changed() { + for (const auto& buffer : device_buffers) { + VLOG_INFO << "Checking " << buffer->name; + if(buffer->modified) { + VLOG_INFO << "Uploading to " << buffer->name; + this->mem_copy_to(*buffer, buffer->device_size, 0); + } + } +} + GPUDevice::Mem *GPUDevice::generic_alloc(device_memory &mem, size_t pitch_padding) { void *device_pointer = 0; diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 0b781426d18..8823a326e85 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -21,6 +21,7 @@ #include "util/types.h" #include "util/unique_ptr.h" #include "util/vector.h" +#include "util/set.h" CCL_NAMESPACE_BEGIN @@ -120,8 +121,9 @@ class DeviceInfo { class Device { friend class device_sub_ptr; - - protected: + thread_mutex device_buffer_mutex; + set device_buffers; +protected: Device(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_) : info(info_), stats(stats_), profiler(profiler_) { @@ -293,6 +295,12 @@ class Device { static void free_memory(); + /* + * Upload to the device any buffers that have changed + */ + virtual void upload_changed(); + + virtual void register_buffer(device_memory *); protected: /* Memory allocation, only accessed through device_memory. */ friend class MultiDevice; @@ -317,7 +325,7 @@ class Device { static vector hip_devices; static vector metal_devices; static vector oneapi_devices; - static uint devices_initialized_mask; + static uint devices_initialized_mask; }; /* Device, which is GPU, with some common functionality for GPU back-ends. */ @@ -348,7 +356,6 @@ class GPUDevice : public Device { /* Returns true if the texture info was copied to the device (meaning, some more * re-initialization might be needed). */ virtual bool load_texture_info(); - protected: /* Memory allocation, only accessed through device_memory. */ friend class device_memory; diff --git a/intern/cycles/device/dummy/device.cpp b/intern/cycles/device/dummy/device.cpp index badd7d06c2b..8e682c12c3c 100644 --- a/intern/cycles/device/dummy/device.cpp +++ b/intern/cycles/device/dummy/device.cpp @@ -36,6 +36,7 @@ class DummyDevice : public Device { virtual void mem_free(device_memory &) override {} virtual void const_copy_to(const char *, void *, size_t) override {} + virtual void upload_changed() override {} }; Device *device_dummy_create(const DeviceInfo &info, Stats &stats, Profiler &profiler) diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index c93392c0c0e..d4649613011 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -45,7 +45,7 @@ void *device_memory::host_alloc(size_t size) } void *ptr = device->host_mem_alloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES); - + device->register_buffer(this); if (ptr) { util_guarded_mem_alloc(size); } diff --git a/intern/cycles/device/memory.h b/intern/cycles/device/memory.h index aa573a4dc30..914ebedd47c 100644 --- a/intern/cycles/device/memory.h +++ b/intern/cycles/device/memory.h @@ -246,7 +246,8 @@ class device_memory { void *shared_pointer; /* reference counter for shared_pointer */ int shared_counter; - + bool modified; + virtual ~device_memory(); void swap_device(Device *new_device, size_t new_device_size, device_ptr new_device_ptr); @@ -296,7 +297,6 @@ class device_memory { size_t original_device_size; Device *original_device; bool need_realloc_; - bool modified; bool shared_mem; }; diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 38823678b53..982a76d93fe 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -180,6 +180,8 @@ class MetalDevice : public Device { void tex_free(device_texture &mem); void flush_delayed_free_list(); + + void upload_changed() {}; }; CCL_NAMESPACE_END diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 5ed51afe5b1..d169c50b292 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -31,6 +31,45 @@ class MultiDevice : public Device { int peer_island_index = -1; }; + class device_memory_clone : public device_texture { + public: + device_memory_clone(const device_memory &mem, Device *sub_device, device_ptr sub_device_pointer) + : device_texture(sub_device, mem.name, 0, IMAGE_DATA_TYPE_FLOAT,INTERPOLATION_NONE,EXTENSION_REPEAT) //mem.type) + { + data_type = mem.data_type; + data_elements = mem.data_elements; + data_size = mem.data_size; + device_size = mem.device_size; + data_width = mem.data_width; + data_height = mem.data_height; + data_depth = mem.data_depth; + type = mem.type; + name = mem.name; + + /* Pointers. */ + device = sub_device; + device_pointer = sub_device_pointer; + + host_pointer = mem.host_pointer; + shared_pointer = mem.shared_pointer; + /* reference counter for shared_pointer */ + shared_counter = mem.shared_counter; + modified = mem.modified; + + if(type == MEM_TEXTURE) { + const device_texture *p_tex = static_cast(&mem); + memcpy(&info, &(p_tex->info), sizeof(TextureInfo)); + slot = p_tex->slot; + } + } + + ~device_memory_clone() { + // Don't free anything + host_pointer = 0; + device_pointer = 0; + } + }; + /* Switch from list to a vector to make the parallel_for easily map to the integer id. Also id now could be used to access the real device pointer more quickly. Also, since the vector reallocates the memory on resize the sub-devices are stored as pointers. */ @@ -317,26 +356,25 @@ class MultiDevice : public Device { /* The tile buffers are allocated on each device (see below), so copy to all of them */ foreach (const vector &island, peer_islands) { + //parallel_for_each (peer_islands.begin(), peer_islands.end(), [&](const vector &island) { SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); - mem.device = owner_sub->device.get(); - mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; - mem.device_size = existing_size; - owner_sub->device->mem_copy_to(mem, size, offset); - owner_sub->ptr_map[key] = mem.device_pointer; + Device *sub_device = owner_sub->device.get(); + device_ptr sub_device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; + device_memory_clone sub_mem(mem, sub_device, sub_device_pointer); + owner_sub->device->mem_copy_to(sub_mem, size, offset); + owner_sub->ptr_map[key] = sub_mem.device_pointer; if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) { - /* Need to create texture objects and update pointer in kernel globals on all devices */ - foreach (SubDevice *island_sub, island) { - if (island_sub != owner_sub) { - island_sub->device->mem_copy_to(mem, size, offset); - } - } - } - } + /* Need to create texture objects and update pointer in kernel globals on all devices */ + foreach (SubDevice *island_sub, island) { + if (island_sub != owner_sub) { + island_sub->device->mem_copy_to(mem, size, offset); + } + } + } + }//); - mem.device = this; - mem.device_pointer = key; stats.mem_alloc(mem.device_size - existing_size); } @@ -443,6 +481,41 @@ class MultiDevice : public Device { sub->device->foreach_device(callback); } } + + virtual void upload_changed() override + { + //foreach (const vector &island, peer_islands) { + parallel_for_each (peer_islands.begin(), peer_islands.end(), [&](const vector &island) { + for (const device_memory *buffer: device_buffers) { + VLOG_INFO << "Checking " << buffer->name << " on " << this; + if (buffer->modified) { + device_ptr existing_key = buffer->device_pointer; + device_ptr key = (existing_key) ? existing_key : unique_key++; + size_t existing_size = buffer->device_size; + + SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); + Device *sub_device = owner_sub->device.get(); + device_ptr sub_device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; + device_memory_clone sub_mem(*buffer, sub_device, sub_device_pointer); + + VLOG_INFO << "Uploading to " << buffer->name; + owner_sub->device->mem_copy_to(sub_mem, existing_size, 0); + owner_sub->ptr_map[key] = sub_mem.device_pointer; + + if (sub_mem.type == MEM_GLOBAL || sub_mem.type == MEM_TEXTURE) { + /* Need to create texture objects and update pointer in kernel globals on all devices */ + foreach (SubDevice *island_sub, island) { + if (island_sub != owner_sub) { + island_sub->device->mem_copy_to(sub_mem, existing_size, 0); + } + } + } + stats.mem_alloc(sub_mem.device_size - existing_size); + } + } + } + ); + } }; Device *device_multi_create(const DeviceInfo &info, Stats &stats, Profiler &profiler) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index b8a99ec87a0..8c6c8b7cc51 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -713,7 +713,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].mesh = time; } }); - sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); + //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } { @@ -722,7 +722,7 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].attrib = time; } }); - sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); } sub_dscene->device_scene_clear_modified(); @@ -909,10 +909,12 @@ void GeometryManager::device_update(Device *device, can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); } { + //device->upload_changed(); size_t num_scenes = scene->dscenes.size(); VLOG_INFO << "Rendering using " << num_scenes << " devices"; /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ + device->upload_changed(); parallel_for( size_t(0), num_scenes, [=, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, -- 2.30.2 From 6f458619a4a58108f36888adcd7653cb5cc7e308 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 3 May 2023 14:56:10 +0200 Subject: [PATCH 78/96] Change upload_changed to take a vector of buffers to upload --- .clang-format | 2 +- intern/clog/CLG_log.h | 9 +- intern/clog/clog.c | 3 +- intern/cycles/app/cycles_standalone.cpp | 3 +- intern/cycles/app/oiio_output_driver.cpp | 3 +- intern/cycles/app/opengl/window.cpp | 3 +- intern/cycles/blender/camera.cpp | 3 +- intern/cycles/blender/curves.cpp | 51 +- intern/cycles/blender/device.cpp | 3 +- intern/cycles/blender/display_driver.cpp | 12 +- intern/cycles/blender/geometry.cpp | 9 +- intern/cycles/blender/light.cpp | 3 +- intern/cycles/blender/mesh.cpp | 15 +- intern/cycles/blender/object.cpp | 15 +- intern/cycles/blender/pointcloud.cpp | 6 +- intern/cycles/blender/python.cpp | 9 +- intern/cycles/blender/session.cpp | 16 +- intern/cycles/blender/shader.cpp | 18 +- intern/cycles/blender/sync.cpp | 15 +- intern/cycles/blender/util.h | 14 +- intern/cycles/blender/volume.cpp | 18 +- intern/cycles/bvh/build.cpp | 6 +- intern/cycles/bvh/bvh2.cpp | 3 +- intern/cycles/device/cpu/device_impl.cpp | 3 +- intern/cycles/device/cpu/device_impl.h | 2 +- intern/cycles/device/cuda/device.cpp | 6 +- intern/cycles/device/cuda/device_impl.cpp | 6 +- intern/cycles/device/device.cpp | 21 +- intern/cycles/device/device.h | 8 +- intern/cycles/device/dummy/device.cpp | 2 +- intern/cycles/device/hip/device.cpp | 6 +- intern/cycles/device/hip/device_impl.cpp | 3 +- intern/cycles/device/hiprt/device_impl.cpp | 3 +- intern/cycles/device/memory.cpp | 2 +- intern/cycles/device/metal/device_impl.mm | 8 +- intern/cycles/device/metal/kernel.mm | 9 +- intern/cycles/device/metal/queue.mm | 3 +- intern/cycles/device/metal/util.mm | 6 +- intern/cycles/device/multi/device.cpp | 13 +- intern/cycles/device/oneapi/device_impl.cpp | 12 +- intern/cycles/device/optix/device_impl.cpp | 70 ++- intern/cycles/device/optix/queue.cpp | 3 +- intern/cycles/hydra/curves.cpp | 6 +- intern/cycles/hydra/display_driver.cpp | 3 +- intern/cycles/hydra/instancer.cpp | 6 +- intern/cycles/hydra/light.cpp | 3 +- intern/cycles/hydra/material.cpp | 15 +- intern/cycles/hydra/mesh.cpp | 18 +- intern/cycles/hydra/output_driver.cpp | 3 +- intern/cycles/hydra/pointcloud.cpp | 6 +- intern/cycles/hydra/render_delegate.cpp | 9 +- intern/cycles/hydra/render_pass.cpp | 4 +- intern/cycles/hydra/volume.cpp | 10 +- intern/cycles/integrator/denoiser.cpp | 4 +- intern/cycles/integrator/denoiser_oidn.cpp | 6 +- intern/cycles/integrator/pass_accessor.cpp | 3 +- intern/cycles/integrator/path_trace.cpp | 6 +- .../cycles/integrator/path_trace_display.cpp | 3 +- .../cycles/integrator/path_trace_work_cpu.cpp | 3 +- .../cycles/integrator/path_trace_work_gpu.cpp | 18 +- intern/cycles/integrator/render_scheduler.cpp | 3 +- intern/cycles/kernel/bvh/local.h | 6 +- intern/cycles/kernel/bvh/traversal.h | 6 +- .../kernel/closure/bsdf_ashikhmin_shirley.h | 3 +- .../cycles/kernel/closure/bsdf_microfacet.h | 3 +- .../closure/bsdf_microfacet_multi_impl.h | 3 +- intern/cycles/kernel/device/cpu/bvh.h | 12 +- intern/cycles/kernel/device/cpu/kernel.cpp | 3 +- intern/cycles/kernel/device/gpu/image.h | 6 +- .../kernel/device/gpu/parallel_sorted_index.h | 6 +- intern/cycles/kernel/device/hiprt/common.h | 3 +- intern/cycles/kernel/device/oneapi/image.h | 3 +- intern/cycles/kernel/device/oneapi/kernel.cpp | 9 +- intern/cycles/kernel/device/optix/bvh.h | 3 +- intern/cycles/kernel/film/data_passes.h | 3 +- intern/cycles/kernel/film/light_passes.h | 3 +- intern/cycles/kernel/film/read.h | 4 +- intern/cycles/kernel/geom/attribute.h | 3 +- intern/cycles/kernel/geom/primitive.h | 3 +- intern/cycles/kernel/geom/shader_data.h | 3 +- intern/cycles/kernel/geom/subd_triangle.h | 12 +- intern/cycles/kernel/geom/triangle.h | 3 +- intern/cycles/kernel/integrator/guiding.h | 9 +- .../kernel/integrator/intersect_shadow.h | 3 +- .../integrator/intersect_volume_stack.h | 3 +- .../cycles/kernel/integrator/shade_surface.h | 6 +- .../cycles/kernel/integrator/shade_volume.h | 9 +- .../cycles/kernel/integrator/surface_shader.h | 15 +- intern/cycles/kernel/light/area.h | 6 +- intern/cycles/kernel/light/light.h | 9 +- intern/cycles/kernel/light/tree.h | 23 +- intern/cycles/kernel/light/triangle.h | 4 +- intern/cycles/kernel/osl/closures_setup.h | 12 +- intern/cycles/kernel/osl/services.cpp | 18 +- intern/cycles/kernel/osl/services_gpu.h | 40 +- .../kernel/osl/shaders/node_normal_map.osl | 3 +- intern/cycles/kernel/svm/closure.h | 28 +- intern/cycles/kernel/svm/displace.h | 9 +- intern/cycles/kernel/svm/math.h | 3 +- intern/cycles/kernel/svm/sky.h | 3 +- intern/cycles/kernel/svm/vector_transform.h | 6 +- intern/cycles/scene/alembic.cpp | 18 +- intern/cycles/scene/alembic_read.cpp | 6 +- intern/cycles/scene/attribute.cpp | 6 +- intern/cycles/scene/colorspace.cpp | 9 +- intern/cycles/scene/constant_fold.cpp | 3 +- intern/cycles/scene/film.cpp | 9 +- intern/cycles/scene/geometry.cpp | 34 +- intern/cycles/scene/geometry_mesh.cpp | 6 +- intern/cycles/scene/image.cpp | 3 +- intern/cycles/scene/integrator.cpp | 6 +- intern/cycles/scene/light.cpp | 6 +- intern/cycles/scene/light_tree.cpp | 3 +- intern/cycles/scene/mesh_displace.cpp | 3 +- intern/cycles/scene/object.cpp | 10 +- intern/cycles/scene/pass.cpp | 3 +- intern/cycles/scene/scene.cpp | 3 +- intern/cycles/scene/shader.cpp | 6 +- intern/cycles/scene/shader_nodes.cpp | 12 +- intern/cycles/scene/svm.cpp | 6 +- intern/cycles/scene/volume.cpp | 3 +- intern/cycles/session/buffers.cpp | 12 +- intern/cycles/session/merge.cpp | 12 +- intern/cycles/session/session.cpp | 3 +- intern/cycles/session/tile.cpp | 9 +- intern/cycles/subd/patch_table.cpp | 4 +- intern/cycles/subd/split.cpp | 3 +- intern/cycles/util/math_matrix.h | 3 +- intern/cycles/util/md5.cpp | 3 +- intern/cycles/util/path.cpp | 9 +- intern/cycles/util/transform.h | 3 +- intern/dualcon/intern/octree.cpp | 6 +- intern/ffmpeg/ffmpeg_compat.h | 3 +- intern/ghost/intern/GHOST_ContextCGL.mm | 7 +- intern/ghost/intern/GHOST_ContextEGL.cc | 9 +- intern/ghost/intern/GHOST_ContextGLX.cc | 3 +- intern/ghost/intern/GHOST_ContextVK.cc | 6 +- .../ghost/intern/GHOST_DisplayManagerWin32.cc | 3 +- .../ghost/intern/GHOST_DisplayManagerX11.cc | 9 +- intern/ghost/intern/GHOST_DropTargetWin32.cc | 3 +- intern/ghost/intern/GHOST_DropTargetX11.cc | 3 +- intern/ghost/intern/GHOST_ImeWin32.cc | 3 +- intern/ghost/intern/GHOST_SystemCocoa.mm | 10 +- intern/ghost/intern/GHOST_SystemWayland.cc | 24 +- intern/ghost/intern/GHOST_SystemWin32.cc | 6 +- intern/ghost/intern/GHOST_SystemX11.cc | 19 +- intern/ghost/intern/GHOST_TrackpadWin32.cc | 9 +- intern/ghost/intern/GHOST_WindowCocoa.mm | 6 +- intern/ghost/intern/GHOST_WindowViewCocoa.hh | 3 +- intern/ghost/intern/GHOST_WindowWayland.cc | 15 +- intern/ghost/intern/GHOST_WindowWin32.cc | 6 +- intern/ghost/intern/GHOST_WindowX11.cc | 4 +- intern/ghost/intern/GHOST_Wintab.cc | 3 +- intern/ghost/intern/GHOST_XrContext.cc | 9 +- .../ghost/intern/GHOST_XrControllerModel.cc | 11 +- .../ghost/intern/GHOST_XrGraphicsBinding.cc | 18 +- intern/ghost/intern/GHOST_XrSession.cc | 3 +- intern/locale/boost_locale_wrapper.cpp | 4 +- intern/mantaflow/intern/MANTA_main.cpp | 2 +- intern/mikktspace/mikktspace.hh | 3 +- intern/opencolorio/ocio_capi.h | 38 +- intern/opencolorio/ocio_impl.cc | 6 +- intern/opencolorio/ocio_impl_glsl.cc | 12 +- intern/opensubdiv/internal/base/util.cc | 3 +- .../internal/evaluator/evaluator_impl.cc | 6 +- .../evaluator/gl_compute_evaluator.cc | 6 +- .../topology/mesh_topology_compare.cc | 3 +- intern/rigidbody/rb_convex_hull_api.cpp | 9 +- .../asset_system/intern/asset_catalog.cc | 4 +- .../asset_system/intern/asset_catalog_path.cc | 3 +- .../asset_system/intern/asset_library.cc | 5 +- .../tests/asset_library_service_test.cc | 3 +- source/blender/blenfont/BLF_api.h | 65 ++- source/blender/blenfont/intern/blf.c | 62 ++- source/blender/blenfont/intern/blf_dir.c | 106 ---- source/blender/blenfont/intern/blf_font.c | 43 +- source/blender/blenfont/intern/blf_glyph.c | 9 +- source/blender/blenfont/intern/blf_internal.h | 16 +- .../blenfont/intern/blf_internal_types.h | 13 +- source/blender/blenfont/intern/blf_thumbs.c | 10 +- source/blender/blenkernel/BKE_armature.h | 3 +- source/blender/blenkernel/BKE_asset.h | 3 +- .../blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/BKE_collection.h | 6 +- source/blender/blenkernel/BKE_curves_utils.hh | 6 +- source/blender/blenkernel/BKE_fcurve.h | 4 + source/blender/blenkernel/BKE_idprop.h | 19 +- source/blender/blenkernel/BKE_image.h | 18 +- source/blender/blenkernel/BKE_image_format.h | 9 +- source/blender/blenkernel/BKE_layer.h | 3 +- source/blender/blenkernel/BKE_node.h | 6 +- source/blender/blenkernel/BKE_packedFile.h | 2 +- source/blender/blenkernel/BKE_particle.h | 4 +- source/blender/blenkernel/BKE_pbvh_pixels.hh | 3 +- source/blender/blenkernel/BKE_studiolight.h | 6 +- source/blender/blenkernel/BKE_writeavi.h | 4 +- source/blender/blenkernel/BKE_writeffmpeg.h | 2 +- source/blender/blenkernel/intern/CCGSubSurf.c | 15 +- .../blenkernel/intern/CCGSubSurf_legacy.c | 4 +- .../blender/blenkernel/intern/DerivedMesh.cc | 9 +- source/blender/blenkernel/intern/action.c | 3 +- source/blender/blenkernel/intern/anim_data.c | 9 +- source/blender/blenkernel/intern/anim_sys.c | 33 +- source/blender/blenkernel/intern/appdir.c | 69 +-- source/blender/blenkernel/intern/armature.c | 15 +- .../blenkernel/intern/armature_update.c | 3 +- source/blender/blenkernel/intern/attribute.cc | 19 +- .../blenkernel/intern/attribute_access.cc | 9 +- .../intern/attribute_access_intern.hh | 16 +- source/blender/blenkernel/intern/blender.c | 4 +- source/blender/blenkernel/intern/blendfile.cc | 10 +- .../blenkernel/intern/blendfile_link_append.c | 54 +- source/blender/blenkernel/intern/boids.c | 36 +- source/blender/blenkernel/intern/bpath.c | 6 +- source/blender/blenkernel/intern/brush.cc | 6 +- source/blender/blenkernel/intern/cachefile.c | 5 +- source/blender/blenkernel/intern/camera.c | 9 +- source/blender/blenkernel/intern/cloth.cc | 37 +- source/blender/blenkernel/intern/collection.c | 34 +- source/blender/blenkernel/intern/collision.cc | 10 +- source/blender/blenkernel/intern/colorband.c | 9 +- source/blender/blenkernel/intern/constraint.c | 15 +- source/blender/blenkernel/intern/context.cc | 6 +- .../blender/blenkernel/intern/crazyspace.cc | 9 +- .../blender/blenkernel/intern/cryptomatte.cc | 6 +- source/blender/blenkernel/intern/curve.cc | 6 +- .../intern/curve_to_mesh_convert.cc | 9 +- .../blenkernel/intern/curves_geometry.cc | 6 +- .../blender/blenkernel/intern/customdata.cc | 28 +- .../blenkernel/intern/data_transfer.cc | 75 ++- source/blender/blenkernel/intern/deform.cc | 6 +- source/blender/blenkernel/intern/displist.cc | 12 +- .../blender/blenkernel/intern/dynamicpaint.cc | 85 +-- source/blender/blenkernel/intern/editmesh.cc | 7 +- .../blenkernel/intern/editmesh_tangent.cc | 3 +- source/blender/blenkernel/intern/effect.c | 6 +- source/blender/blenkernel/intern/fcurve.c | 52 +- .../blender/blenkernel/intern/fcurve_driver.c | 9 +- source/blender/blenkernel/intern/fluid.cc | 67 ++- source/blender/blenkernel/intern/fmodifier.c | 9 +- source/blender/blenkernel/intern/freestyle.c | 6 +- .../blenkernel/intern/geometry_fields.cc | 34 +- .../blenkernel/intern/gpencil_curve_legacy.c | 6 +- .../blenkernel/intern/gpencil_geom_legacy.cc | 18 +- .../blenkernel/intern/gpencil_legacy.c | 43 +- .../intern/gpencil_modifier_legacy.c | 6 +- source/blender/blenkernel/intern/icons.cc | 3 +- source/blender/blenkernel/intern/idprop.c | 49 +- .../blenkernel/intern/idprop_create.cc | 2 +- source/blender/blenkernel/intern/idtype.c | 3 +- source/blender/blenkernel/intern/image.cc | 191 ++++--- .../blender/blenkernel/intern/image_format.cc | 78 +-- source/blender/blenkernel/intern/image_gen.c | 6 +- source/blender/blenkernel/intern/image_gpu.cc | 12 +- .../intern/image_partial_update_test.cc | 3 +- .../blender/blenkernel/intern/image_save.cc | 28 +- .../blender/blenkernel/intern/image_test.cc | 3 +- source/blender/blenkernel/intern/ipo.c | 12 +- source/blender/blenkernel/intern/key.cc | 24 +- source/blender/blenkernel/intern/layer.cc | 42 +- source/blender/blenkernel/intern/lib_id.c | 21 +- .../blender/blenkernel/intern/lib_id_delete.c | 3 +- .../blender/blenkernel/intern/lib_override.cc | 508 ++++++++++++------ .../intern/lib_override_proxy_conversion.c | 5 +- source/blender/blenkernel/intern/lib_query.c | 15 +- source/blender/blenkernel/intern/lib_remap.c | 12 +- source/blender/blenkernel/intern/library.c | 4 +- .../blender/blenkernel/intern/lightprobe.cc | 6 +- source/blender/blenkernel/intern/linestyle.cc | 16 +- source/blender/blenkernel/intern/main.c | 3 +- .../blender/blenkernel/intern/main_namemap.cc | 12 +- source/blender/blenkernel/intern/mask.c | 45 +- .../blender/blenkernel/intern/mask_evaluate.c | 15 +- .../blenkernel/intern/mask_rasterize.c | 21 +- source/blender/blenkernel/intern/material.cc | 13 +- source/blender/blenkernel/intern/mball.cc | 23 +- .../blenkernel/intern/mball_tessellate.cc | 13 +- source/blender/blenkernel/intern/mesh.cc | 12 +- .../blenkernel/intern/mesh_evaluate.cc | 3 +- .../blenkernel/intern/mesh_legacy_convert.cc | 151 +++--- .../blender/blenkernel/intern/mesh_mapping.cc | 14 +- .../intern/mesh_merge_customdata.cc | 3 +- .../blender/blenkernel/intern/mesh_mirror.cc | 10 +- .../blender/blenkernel/intern/mesh_normals.cc | 17 +- .../blender/blenkernel/intern/mesh_remap.cc | 50 +- .../blenkernel/intern/mesh_remesh_voxel.cc | 3 +- .../blender/blenkernel/intern/mesh_tangent.cc | 9 +- .../blenkernel/intern/mesh_tessellate.cc | 3 +- .../blenkernel/intern/mesh_validate.cc | 28 +- source/blender/blenkernel/intern/modifier.cc | 11 +- source/blender/blenkernel/intern/movieclip.c | 15 +- source/blender/blenkernel/intern/multires.cc | 3 +- .../blenkernel/intern/multires_reshape.cc | 6 +- .../intern/multires_reshape_smooth.cc | 6 +- .../intern/multires_reshape_subdivide.cc | 4 +- .../intern/multires_reshape_util.cc | 3 +- .../blenkernel/intern/multires_unsubdivide.cc | 7 +- .../blenkernel/intern/multires_versioning.cc | 10 +- source/blender/blenkernel/intern/nla.c | 15 +- source/blender/blenkernel/intern/node.cc | 145 +++-- .../blender/blenkernel/intern/node_runtime.cc | 3 +- .../intern/node_tree_anonymous_attributes.cc | 12 +- .../intern/node_tree_field_inferencing.cc | 10 +- .../blenkernel/intern/node_tree_update.cc | 12 +- source/blender/blenkernel/intern/object.cc | 36 +- .../blender/blenkernel/intern/object_deform.c | 3 +- .../blender/blenkernel/intern/object_dupli.cc | 30 +- .../blenkernel/intern/object_facemap.c | 4 +- .../blenkernel/intern/object_update.cc | 9 +- source/blender/blenkernel/intern/ocean.c | 65 +-- source/blender/blenkernel/intern/packedFile.c | 102 ++-- source/blender/blenkernel/intern/paint.cc | 13 +- .../blenkernel/intern/paint_toolslots.c | 4 +- source/blender/blenkernel/intern/particle.cc | 55 +- .../blenkernel/intern/particle_distribute.c | 3 +- .../blenkernel/intern/particle_system.c | 62 ++- source/blender/blenkernel/intern/pbvh.cc | 18 +- .../blender/blenkernel/intern/pbvh_bmesh.cc | 30 +- .../blenkernel/intern/pbvh_pixels_copy.cc | 3 +- .../blenkernel/intern/pbvh_uv_islands.cc | 10 +- source/blender/blenkernel/intern/pointcache.c | 41 +- source/blender/blenkernel/intern/rigidbody.c | 28 +- source/blender/blenkernel/intern/scene.cc | 18 +- source/blender/blenkernel/intern/screen.c | 3 +- .../blender/blenkernel/intern/shrinkwrap.cc | 16 +- source/blender/blenkernel/intern/softbody.c | 56 +- source/blender/blenkernel/intern/sound.c | 3 +- .../blender/blenkernel/intern/studiolight.c | 45 +- .../blender/blenkernel/intern/subdiv_ccg.cc | 3 +- .../blenkernel/intern/subdiv_deform.cc | 3 +- .../blenkernel/intern/subdiv_foreach.cc | 32 +- .../blender/blenkernel/intern/subdiv_mesh.cc | 12 +- .../blender/blenkernel/intern/subsurf_ccg.cc | 33 +- source/blender/blenkernel/intern/text.c | 12 +- source/blender/blenkernel/intern/texture.cc | 3 +- source/blender/blenkernel/intern/tracking.cc | 7 +- .../blenkernel/intern/tracking_auto.cc | 6 +- .../intern/tracking_plane_tracker.cc | 3 +- .../intern/tracking_region_tracker.cc | 3 +- .../blenkernel/intern/tracking_stabilize.cc | 12 +- .../blenkernel/intern/tracking_util.cc | 14 +- .../blender/blenkernel/intern/undo_system.cc | 3 +- source/blender/blenkernel/intern/unit.c | 9 +- source/blender/blenkernel/intern/vfont.c | 78 +-- .../blenkernel/intern/vfontdata_freetype.c | 6 +- source/blender/blenkernel/intern/volume.cc | 4 +- source/blender/blenkernel/intern/workspace.cc | 23 +- source/blender/blenkernel/intern/writeavi.c | 31 +- .../blender/blenkernel/intern/writeffmpeg.c | 48 +- .../blenlib/BLI_atomic_disjoint_set.hh | 3 +- source/blender/blenlib/BLI_fileops.h | 13 +- source/blender/blenlib/BLI_linklist_stack.h | 3 +- source/blender/blenlib/BLI_path_util.h | 93 ++-- source/blender/blenlib/BLI_string.h | 101 ++-- source/blender/blenlib/BLI_string_utils.h | 21 +- source/blender/blenlib/BLI_virtual_array.hh | 6 +- source/blender/blenlib/intern/BLI_filelist.c | 3 +- source/blender/blenlib/intern/BLI_kdopbvh.c | 49 +- source/blender/blenlib/intern/BLI_mempool.c | 3 +- source/blender/blenlib/intern/BLI_mmap.c | 6 +- source/blender/blenlib/intern/array_store.c | 9 +- source/blender/blenlib/intern/array_utils.c | 6 +- source/blender/blenlib/intern/boxpack_2d.c | 3 +- source/blender/blenlib/intern/delaunay_2d.cc | 30 +- source/blender/blenlib/intern/dynlib.c | 3 +- .../blender/blenlib/intern/expr_pylike_eval.c | 6 +- source/blender/blenlib/intern/fileops.c | 47 +- .../blender/blenlib/intern/filereader_zstd.c | 3 +- .../blenlib/intern/implicit_sharing.cc | 3 +- source/blender/blenlib/intern/kdtree_impl.h | 22 +- source/blender/blenlib/intern/listbase.cc | 7 +- source/blender/blenlib/intern/math_boolean.cc | 9 +- source/blender/blenlib/intern/math_geom.c | 18 +- source/blender/blenlib/intern/math_matrix.c | 3 +- source/blender/blenlib/intern/math_rotation.c | 9 +- source/blender/blenlib/intern/math_vec.cc | 3 +- source/blender/blenlib/intern/mesh_boolean.cc | 6 +- source/blender/blenlib/intern/path_util.c | 115 ++-- source/blender/blenlib/intern/polyfill_2d.c | 12 +- source/blender/blenlib/intern/scanfill.c | 10 +- .../blender/blenlib/intern/scanfill_utils.c | 12 +- source/blender/blenlib/intern/smallhash.c | 9 +- source/blender/blenlib/intern/storage.c | 17 +- source/blender/blenlib/intern/string.c | 13 + source/blender/blenlib/intern/string_utf8.c | 12 +- source/blender/blenlib/intern/string_utils.c | 35 +- source/blender/blenlib/intern/system_win32.c | 6 +- source/blender/blenlib/intern/voronoi_2d.c | 6 +- source/blender/blenlib/intern/winstuff.c | 2 +- source/blender/blenlib/intern/winstuff_dir.c | 3 +- .../blenlib/tests/BLI_delaunay_2d_test.cc | 3 +- .../tests/BLI_linklist_lockfree_test.cc | 6 +- .../blenlib/tests/BLI_mesh_intersect_test.cc | 6 +- .../blenlib/tests/BLI_path_util_test.cc | 36 +- .../blenlib/tests/BLI_polyfill_2d_test.cc | 3 +- source/blender/blenlib/tests/BLI_task_test.cc | 3 +- .../performance/BLI_task_performance_test.cc | 3 +- .../blenloader/intern/blend_validate.cc | 3 +- .../blenloader/intern/readblenentry.cc | 6 +- source/blender/blenloader/intern/readfile.cc | 30 +- source/blender/blenloader/intern/undofile.cc | 12 +- .../blenloader/intern/versioning_250.c | 6 +- .../blenloader/intern/versioning_260.c | 26 +- .../blenloader/intern/versioning_270.c | 17 +- .../blenloader/intern/versioning_280.c | 71 ++- .../blenloader/intern/versioning_290.cc | 18 +- .../blenloader/intern/versioning_300.cc | 103 ++-- .../blenloader/intern/versioning_common.cc | 3 +- .../blenloader/intern/versioning_cycles.c | 21 +- .../blenloader/intern/versioning_legacy.c | 8 +- source/blender/blenloader/intern/writefile.cc | 19 +- source/blender/bmesh/intern/bmesh_core.c | 6 +- source/blender/bmesh/intern/bmesh_edgeloop.c | 3 +- source/blender/bmesh/intern/bmesh_interp.c | 3 +- .../blender/bmesh/intern/bmesh_iterators.cc | 6 +- source/blender/bmesh/intern/bmesh_marking.c | 13 +- source/blender/bmesh/intern/bmesh_mesh.cc | 7 +- .../bmesh/intern/bmesh_mesh_convert.cc | 12 +- .../bmesh/intern/bmesh_mesh_normals.cc | 25 +- .../bmesh/intern/bmesh_mesh_tessellate.c | 3 +- .../bmesh/intern/bmesh_mesh_validate.c | 12 +- source/blender/bmesh/intern/bmesh_mods.c | 6 +- source/blender/bmesh/intern/bmesh_operators.c | 12 +- source/blender/bmesh/intern/bmesh_polygon.c | 3 +- .../bmesh/intern/bmesh_polygon_edgenet.c | 31 +- source/blender/bmesh/intern/bmesh_query.c | 12 +- .../blender/bmesh/intern/bmesh_walkers_impl.c | 12 +- source/blender/bmesh/operators/bmo_beautify.c | 3 +- .../bmesh/operators/bmo_bisect_plane.c | 3 +- source/blender/bmesh/operators/bmo_connect.c | 9 +- .../bmesh/operators/bmo_connect_nonplanar.c | 3 +- source/blender/bmesh/operators/bmo_dissolve.c | 10 +- source/blender/bmesh/operators/bmo_edgenet.c | 15 +- source/blender/bmesh/operators/bmo_extrude.c | 9 +- .../blender/bmesh/operators/bmo_fill_grid.c | 7 +- source/blender/bmesh/operators/bmo_hull.c | 3 +- source/blender/bmesh/operators/bmo_inset.c | 12 +- .../bmesh/operators/bmo_join_triangles.c | 15 +- .../bmesh/operators/bmo_offset_edgeloops.c | 3 +- .../bmesh/operators/bmo_smooth_laplacian.c | 6 +- .../blender/bmesh/operators/bmo_subdivide.c | 6 +- .../bmesh/operators/bmo_subdivide_edgering.c | 18 +- source/blender/bmesh/operators/bmo_utils.c | 10 +- source/blender/bmesh/tools/bmesh_beautify.c | 3 +- source/blender/bmesh/tools/bmesh_bevel.c | 43 +- .../blender/bmesh/tools/bmesh_bisect_plane.c | 3 +- source/blender/bmesh/tools/bmesh_boolean.cc | 6 +- .../bmesh/tools/bmesh_decimate_collapse.c | 33 +- .../bmesh/tools/bmesh_decimate_dissolve.c | 18 +- .../bmesh/tools/bmesh_decimate_unsubdivide.c | 3 +- source/blender/bmesh/tools/bmesh_edgenet.c | 3 +- source/blender/bmesh/tools/bmesh_edgesplit.c | 3 +- source/blender/bmesh/tools/bmesh_intersect.c | 38 +- .../bmesh/tools/bmesh_intersect_edges.c | 7 +- .../blender/bmesh/tools/bmesh_path_region.c | 3 +- .../bmesh/tools/bmesh_path_region_uv.c | 6 +- .../blender/bmesh/tools/bmesh_region_match.c | 15 +- .../compositor/intern/COM_ConstantFolder.cc | 3 +- source/blender/compositor/intern/COM_Debug.cc | 6 +- .../compositor/intern/COM_ExecutionGroup.cc | 10 +- .../compositor/intern/COM_MemoryBuffer.cc | 3 +- .../compositor/intern/COM_MemoryBuffer.h | 3 +- .../compositor/intern/COM_NodeGraph.cc | 12 +- .../compositor/intern/COM_NodeOperation.cc | 5 +- .../intern/COM_NodeOperationBuilder.cc | 11 +- .../compositor/intern/COM_WorkScheduler.cc | 3 +- .../nodes/COM_ConvertColorSpaceNode.cc | 3 +- .../compositor/nodes/COM_CryptomatteNode.cc | 3 +- .../blender/compositor/nodes/COM_MaskNode.cc | 11 +- .../compositor/nodes/COM_Stabilize2dNode.cc | 2 +- .../operations/COM_AntiAliasOperation.cc | 12 +- .../operations/COM_BokehImageOperation.cc | 6 +- .../operations/COM_ColorMatteOperation.cc | 6 +- .../COM_ConvertColorSpaceOperation.cc | 3 +- .../COM_ConvertDepthToRadiusOperation.cc | 4 +- .../operations/COM_DespeckleOperation.cc | 6 +- .../operations/COM_DisplaceSimpleOperation.cc | 3 +- .../operations/COM_DoubleEdgeMaskOperation.cc | 348 ++++++------ .../COM_FastGaussianBlurOperation.cc | 6 +- .../operations/COM_MaskOperation.cc | 4 +- .../COM_OutputFileMultiViewOperation.cc | 48 +- .../COM_OutputFileMultiViewOperation.h | 11 +- .../operations/COM_OutputFileOperation.cc | 22 +- .../operations/COM_PlaneCornerPinOperation.cc | 3 +- .../COM_PlaneDistortCommonOperation.cc | 9 +- .../COM_ProjectorLensDistortionOperation.cc | 6 +- .../operations/COM_RenderLayersProg.cc | 3 +- .../operations/COM_SMAAOperation.cc | 6 +- .../operations/COM_TextureOperation.cc | 3 +- .../COM_VariableSizeBokehBlurOperation.cc | 9 +- .../operations/COM_VectorBlurOperation.cc | 3 +- .../realtime_compositor/CMakeLists.txt | 2 + .../realtime_compositor/COM_context.hh | 3 + .../COM_static_cache_manager.hh | 4 +- .../cached_resources/COM_cached_mask.hh | 86 +++ .../cached_resources/COM_cached_texture.hh | 5 +- .../cached_resources/intern/cached_mask.cc | 199 +++++++ .../cached_resources/intern/cached_texture.cc | 2 +- .../intern/compile_state.cc | 3 +- .../realtime_compositor/intern/context.cc | 5 + .../realtime_compositor/intern/scheduler.cc | 4 +- .../intern/static_cache_manager.cc | 1 + source/blender/datatoc/datatoc_icon.c | 4 +- .../intern/builder/deg_builder_nodes.cc | 13 +- .../intern/builder/deg_builder_nodes_rig.cc | 10 +- .../intern/builder/deg_builder_relations.cc | 47 +- .../builder/deg_builder_relations_impl.h | 7 +- .../builder/deg_builder_relations_rig.cc | 6 +- .../intern/builder/deg_builder_rna.cc | 9 +- .../depsgraph/intern/depsgraph_physics.cc | 6 +- .../intern/depsgraph_query_foreach.cc | 3 +- .../depsgraph/intern/depsgraph_query_iter.cc | 3 +- .../blender/depsgraph/intern/eval/deg_eval.cc | 3 +- .../intern/eval/deg_eval_copy_on_write.cc | 6 +- .../depsgraph/intern/eval/deg_eval_flush.cc | 7 +- .../eval/deg_eval_runtime_backup_animation.cc | 6 +- .../intern/node/deg_node_component.cc | 3 +- .../blender/draw/engines/basic/basic_engine.c | 3 +- .../draw/engines/eevee/eevee_cryptomatte.c | 3 +- .../draw/engines/eevee/eevee_depth_of_field.c | 6 +- .../draw/engines/eevee/eevee_effects.c | 6 +- .../blender/draw/engines/eevee/eevee_engine.c | 12 +- .../draw/engines/eevee/eevee_lightcache.c | 27 +- .../draw/engines/eevee/eevee_lightprobes.c | 16 +- .../draw/engines/eevee/eevee_lookdev.c | 9 +- .../draw/engines/eevee/eevee_motion_blur.c | 21 +- .../draw/engines/eevee/eevee_occlusion.c | 7 +- .../blender/draw/engines/eevee/eevee_render.c | 3 +- .../draw/engines/eevee/eevee_renderpasses.c | 9 +- .../draw/engines/eevee/eevee_shaders_extra.cc | 3 +- .../draw/engines/eevee/eevee_shadows.c | 3 +- .../engines/eevee/eevee_temporal_sampling.c | 12 +- .../draw/engines/eevee/eevee_volumes.c | 7 +- .../eevee/shaders/closure_eval_lib.glsl | 4 +- .../eevee/shaders/effect_dof_gather_frag.glsl | 3 +- .../engines/eevee/shaders/effect_dof_lib.glsl | 3 +- .../shaders/volumetric_scatter_frag.glsl | 3 +- .../engines/eevee_next/eevee_cryptomatte.cc | 6 +- .../eevee_next/eevee_depth_of_field.cc | 3 +- .../draw/engines/eevee_next/eevee_instance.cc | 3 +- .../draw/engines/eevee_next/eevee_material.cc | 3 +- .../draw/engines/eevee_next/eevee_shader.cc | 3 +- .../draw/engines/eevee_next/eevee_shadow.cc | 9 +- .../eevee_depth_of_field_accumulator_lib.glsl | 3 +- .../eevee_depth_of_field_stabilize_comp.glsl | 3 +- .../shaders/eevee_shadow_debug_frag.glsl | 4 +- .../draw/engines/external/external_engine.c | 3 +- .../engines/gpencil/gpencil_cache_utils.c | 6 +- .../draw/engines/gpencil/gpencil_engine.c | 10 +- .../draw/engines/gpencil/gpencil_shader_fx.c | 3 +- .../draw/engines/image/image_drawing_mode.hh | 7 +- .../draw/engines/overlay/overlay_armature.cc | 31 +- .../engines/overlay/overlay_background.cc | 3 +- .../draw/engines/overlay/overlay_edit_uv.cc | 3 +- .../draw/engines/overlay/overlay_extra.cc | 9 +- .../draw/engines/overlay/overlay_gpencil.cc | 9 +- .../draw/engines/overlay/overlay_grid.cc | 3 +- .../draw/engines/overlay/overlay_image.cc | 3 +- .../engines/overlay/overlay_sculpt_curves.cc | 4 +- .../draw/engines/overlay/overlay_wireframe.cc | 3 +- .../overlay_edit_curve_point_vert.glsl | 3 +- .../overlay/shaders/overlay_grid_frag.glsl | 3 +- .../overlay_outline_prepass_gpencil_frag.glsl | 3 +- .../draw/engines/select/select_engine.c | 3 +- .../engines/workbench/workbench_effect_dof.c | 6 +- .../draw/engines/workbench/workbench_engine.c | 3 +- .../draw/engines/workbench/workbench_shadow.c | 6 +- .../draw/engines/workbench/workbench_state.cc | 3 +- .../draw/engines/workbench/workbench_volume.c | 3 +- source/blender/draw/intern/DRW_gpu_wrapper.hh | 3 +- source/blender/draw/intern/draw_attributes.cc | 6 +- .../draw/intern/draw_cache_extract_mesh.cc | 3 +- .../draw_cache_extract_mesh_render_data.cc | 7 +- .../draw/intern/draw_cache_impl_curve.cc | 9 +- .../draw/intern/draw_cache_impl_lattice.c | 3 +- .../draw/intern/draw_cache_impl_mesh.cc | 9 +- .../draw/intern/draw_cache_impl_particles.c | 18 +- .../draw/intern/draw_cache_impl_pointcloud.cc | 4 +- .../intern/draw_cache_impl_subdivision.cc | 16 +- .../draw/intern/draw_color_management.cc | 6 +- source/blender/draw/intern/draw_common.c | 6 +- source/blender/draw/intern/draw_curves.cc | 3 +- source/blender/draw/intern/draw_fluid.c | 3 +- source/blender/draw/intern/draw_hair.cc | 3 +- .../blender/draw/intern/draw_instance_data.c | 3 +- source/blender/draw/intern/draw_manager.c | 19 +- source/blender/draw/intern/draw_manager.cc | 3 +- .../blender/draw/intern/draw_manager_exec.c | 6 +- .../blender/draw/intern/draw_manager_shader.c | 3 +- .../blender/draw/intern/draw_manager_text.cc | 15 +- source/blender/draw/intern/draw_pbvh.cc | 4 +- .../blender/draw/intern/draw_texture_pool.cc | 3 +- source/blender/draw/intern/draw_view.c | 3 +- source/blender/draw/intern/draw_volume.cc | 3 +- .../extract_mesh_ibo_lines_paint_mask.cc | 6 +- .../extract_mesh_vbo_edit_data.cc | 3 +- .../mesh_extractors/extract_mesh_vbo_lnor.cc | 8 +- .../extract_mesh_vbo_mesh_analysis.cc | 6 +- .../extract_mesh_vbo_pos_nor.cc | 6 +- .../intern/shaders/common_gpencil_lib.glsl | 3 +- .../editors/animation/anim_channels_defines.c | 30 +- .../editors/animation/anim_channels_edit.c | 6 +- source/blender/editors/animation/anim_deps.c | 10 +- source/blender/editors/animation/anim_draw.c | 3 +- .../blender/editors/animation/anim_filter.c | 35 +- .../editors/animation/anim_ipo_utils.c | 9 +- .../blender/editors/animation/anim_markers.c | 9 +- .../editors/animation/anim_motion_paths.c | 3 +- source/blender/editors/animation/anim_ops.c | 4 +- source/blender/editors/animation/drivers.c | 15 +- .../blender/editors/animation/fmodifier_ui.c | 5 +- .../editors/animation/keyframes_edit.c | 3 +- .../editors/animation/keyframes_general.c | 40 +- source/blender/editors/animation/keyframing.c | 17 +- .../blender/editors/armature/armature_add.c | 45 +- .../blender/editors/armature/armature_edit.c | 12 +- .../editors/armature/armature_select.c | 24 +- .../editors/armature/armature_skinning.c | 3 +- .../blender/editors/armature/armature_utils.c | 4 +- .../blender/editors/armature/meshlaplacian.cc | 6 +- source/blender/editors/armature/pose_lib_2.c | 6 +- source/blender/editors/armature/pose_select.c | 14 +- source/blender/editors/armature/pose_slide.c | 6 +- .../editors/asset/intern/asset_indexer.cc | 6 +- .../blender/editors/asset/intern/asset_ops.cc | 26 +- source/blender/editors/curve/editcurve.c | 49 +- source/blender/editors/curve/editcurve_add.c | 3 +- .../blender/editors/curve/editcurve_paint.c | 16 +- source/blender/editors/curve/editcurve_pen.c | 15 +- source/blender/editors/curve/editfont.c | 10 +- .../editors/curves/intern/curves_ops.cc | 3 +- .../editors/curves/intern/curves_selection.cc | 9 +- .../editors/geometry/geometry_attributes.cc | 6 +- .../gizmo_types/button2d_gizmo.c | 3 +- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 12 +- .../gizmo_library/gizmo_types/move3d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/snap3d_gizmo.c | 3 +- .../editors/gpencil_legacy/annotate_draw.c | 3 +- .../editors/gpencil_legacy/annotate_paint.c | 38 +- .../editors/gpencil_legacy/drawgpencil.c | 6 +- .../editors/gpencil_legacy/gpencil_convert.c | 9 +- .../editors/gpencil_legacy/gpencil_data.c | 9 +- .../editors/gpencil_legacy/gpencil_edit.c | 11 +- .../gpencil_legacy/gpencil_edit_curve.c | 3 +- .../editors/gpencil_legacy/gpencil_fill.c | 31 +- .../gpencil_legacy/gpencil_interpolate.c | 11 +- .../editors/gpencil_legacy/gpencil_paint.c | 81 +-- .../gpencil_legacy/gpencil_primitive.c | 24 +- .../gpencil_legacy/gpencil_sculpt_paint.c | 20 +- .../editors/gpencil_legacy/gpencil_select.c | 9 +- .../gpencil_legacy/gpencil_trace_ops.c | 4 +- .../editors/gpencil_legacy/gpencil_utils.c | 43 +- .../editors/gpencil_legacy/gpencil_uv.c | 3 +- .../gpencil_legacy/gpencil_vertex_ops.c | 6 +- .../gpencil_legacy/gpencil_vertex_paint.c | 7 +- .../gpencil_legacy/gpencil_weight_paint.c | 7 +- source/blender/editors/include/UI_view2d.h | 15 - .../blender/editors/interface/CMakeLists.txt | 1 + .../interface/eyedroppers/eyedropper_color.cc | 6 +- .../eyedroppers/eyedropper_datablock.cc | 6 +- .../interface/eyedroppers/eyedropper_depth.cc | 15 +- .../eyedroppers/eyedropper_driver.cc | 3 +- source/blender/editors/interface/interface.cc | 85 +-- .../editors/interface/interface_align.cc | 3 +- .../editors/interface/interface_anim.cc | 3 +- .../interface/interface_context_menu.cc | 10 +- .../editors/interface/interface_draw.cc | 6 +- .../editors/interface/interface_handlers.cc | 195 ++++--- .../editors/interface/interface_icons.cc | 3 +- .../editors/interface/interface_layout.cc | 42 +- .../editors/interface/interface_ops.cc | 65 ++- .../editors/interface/interface_panel.cc | 9 +- .../editors/interface/interface_query.cc | 12 +- .../interface_region_color_picker.cc | 3 +- .../editors/interface/interface_region_hud.cc | 3 +- .../interface/interface_region_menu_popup.cc | 4 +- .../interface/interface_region_search.cc | 9 +- .../interface/interface_region_tooltip.cc | 15 +- .../interface_template_asset_view.cc | 4 +- .../interface/interface_template_list.cc | 9 +- .../interface_template_search_menu.cc | 10 +- .../interface_template_search_operator.cc | 7 +- .../editors/interface/interface_templates.cc | 68 ++- .../editors/interface/interface_utils.cc | 14 +- .../editors/interface/interface_widgets.cc | 28 +- source/blender/editors/interface/resources.cc | 4 +- source/blender/editors/interface/view2d.cc | 41 +- .../editors/interface/view2d_edge_pan.cc | 6 +- .../interface/view2d_gizmo_navigate.cc | 3 +- .../editors/interface/view2d_intern.hh | 35 ++ .../blender/editors/interface/view2d_ops.cc | 35 +- .../editors/interface/views/grid_view.cc | 3 +- .../editors/interface/views/interface_view.cc | 3 +- .../editors/interface/views/tree_view.cc | 6 +- source/blender/editors/io/io_alembic.c | 4 +- source/blender/editors/io/io_collada.c | 2 +- source/blender/editors/io/io_gpencil_import.c | 3 +- source/blender/editors/io/io_stl_ops.c | 3 +- .../editors/lattice/editlattice_select.c | 3 +- source/blender/editors/mask/mask_add.c | 25 +- source/blender/editors/mask/mask_draw.c | 6 +- source/blender/editors/mask/mask_editaction.c | 24 +- source/blender/editors/mask/mask_ops.c | 21 +- source/blender/editors/mask/mask_query.c | 24 +- source/blender/editors/mask/mask_select.c | 21 +- source/blender/editors/mask/mask_shapekey.c | 18 +- source/blender/editors/mesh/editface.cc | 11 +- source/blender/editors/mesh/editmesh_add.c | 27 +- .../blender/editors/mesh/editmesh_add_gizmo.c | 3 +- source/blender/editors/mesh/editmesh_bevel.c | 9 +- source/blender/editors/mesh/editmesh_bisect.c | 3 +- .../blender/editors/mesh/editmesh_extrude.c | 6 +- .../editors/mesh/editmesh_extrude_screw.c | 3 +- .../editors/mesh/editmesh_extrude_spin.c | 3 +- source/blender/editors/mesh/editmesh_inset.c | 6 +- .../blender/editors/mesh/editmesh_intersect.c | 6 +- source/blender/editors/mesh/editmesh_knife.c | 100 ++-- .../blender/editors/mesh/editmesh_loopcut.c | 3 +- .../editors/mesh/editmesh_mask_extract.cc | 6 +- source/blender/editors/mesh/editmesh_path.c | 18 +- .../blender/editors/mesh/editmesh_polybuild.c | 9 +- .../mesh/editmesh_preselect_edgering.c | 3 +- .../editors/mesh/editmesh_preselect_elem.c | 3 +- source/blender/editors/mesh/editmesh_rip.c | 3 +- .../blender/editors/mesh/editmesh_select.cc | 59 +- .../editors/mesh/editmesh_select_similar.c | 12 +- source/blender/editors/mesh/editmesh_tools.cc | 142 +++-- source/blender/editors/mesh/editmesh_undo.cc | 5 +- source/blender/editors/mesh/editmesh_utils.c | 12 +- source/blender/editors/mesh/mesh_data.cc | 6 +- source/blender/editors/mesh/mesh_mirror.cc | 3 +- source/blender/editors/mesh/meshtools.cc | 6 +- source/blender/editors/object/object_add.cc | 79 ++- .../blender/editors/object/object_bake_api.cc | 58 +- .../editors/object/object_collection.c | 3 +- .../editors/object/object_constraint.c | 18 +- .../editors/object/object_data_transfer.c | 3 +- .../editors/object/object_data_transform.cc | 9 +- source/blender/editors/object/object_edit.cc | 21 +- source/blender/editors/object/object_hook.c | 3 +- source/blender/editors/object/object_modes.cc | 3 +- .../blender/editors/object/object_modifier.cc | 33 +- .../blender/editors/object/object_relations.c | 41 +- .../blender/editors/object/object_remesh.cc | 6 +- source/blender/editors/object/object_select.c | 3 +- .../editors/object/object_transform.cc | 21 +- .../blender/editors/object/object_vgroup.cc | 21 +- source/blender/editors/object/object_volume.c | 2 +- .../editors/physics/dynamicpaint_ops.c | 4 +- .../blender/editors/physics/particle_edit.c | 24 +- .../blender/editors/physics/particle_object.c | 13 +- .../blender/editors/physics/physics_fluid.c | 3 +- .../editors/physics/physics_pointcache.c | 3 +- .../editors/physics/rigidbody_constraint.c | 3 +- .../editors/physics/rigidbody_object.c | 3 +- .../blender/editors/render/render_internal.cc | 27 +- .../blender/editors/render/render_opengl.cc | 39 +- .../blender/editors/render/render_preview.cc | 20 +- .../blender/editors/render/render_shading.cc | 5 +- .../blender/editors/render/render_update.cc | 12 +- source/blender/editors/render/render_view.cc | 6 +- source/blender/editors/scene/scene_edit.c | 4 +- source/blender/editors/screen/area.cc | 41 +- source/blender/editors/screen/screen_edit.c | 18 +- .../blender/editors/screen/screen_geometry.c | 3 +- source/blender/editors/screen/screen_ops.c | 51 +- .../blender/editors/screen/screen_user_menu.c | 10 +- source/blender/editors/screen/screendump.c | 3 +- .../blender/editors/screen/workspace_edit.c | 6 +- .../editors/screen/workspace_listen.cc | 3 +- .../editors/sculpt_paint/curves_sculpt_add.cc | 3 +- .../sculpt_paint/curves_sculpt_brush.cc | 3 +- .../sculpt_paint/curves_sculpt_grow_shrink.cc | 3 +- .../sculpt_paint/curves_sculpt_slide.cc | 3 +- .../editors/sculpt_paint/paint_canvas.cc | 3 +- .../editors/sculpt_paint/paint_cursor.cc | 24 +- .../editors/sculpt_paint/paint_image_2d.c | 15 +- .../editors/sculpt_paint/paint_image_proj.cc | 96 ++-- .../blender/editors/sculpt_paint/paint_ops.cc | 9 +- .../editors/sculpt_paint/paint_stroke.cc | 30 +- .../editors/sculpt_paint/paint_utils.c | 3 +- .../editors/sculpt_paint/paint_vertex.cc | 43 +- .../sculpt_paint/paint_vertex_color_ops.cc | 16 +- .../editors/sculpt_paint/paint_vertex_proj.c | 3 +- .../sculpt_paint/paint_vertex_weight_ops.cc | 26 +- source/blender/editors/sculpt_paint/sculpt.cc | 106 ++-- .../sculpt_paint/sculpt_automasking.cc | 21 +- .../editors/sculpt_paint/sculpt_boundary.cc | 36 +- .../sculpt_paint/sculpt_brush_types.cc | 15 +- .../editors/sculpt_paint/sculpt_cloth.cc | 9 +- .../editors/sculpt_paint/sculpt_detail.cc | 12 +- .../editors/sculpt_paint/sculpt_expand.cc | 12 +- .../editors/sculpt_paint/sculpt_face_set.cc | 4 +- .../sculpt_paint/sculpt_filter_mesh.cc | 19 +- .../editors/sculpt_paint/sculpt_geodesic.cc | 3 +- .../editors/sculpt_paint/sculpt_intern.hh | 6 +- .../sculpt_paint/sculpt_mask_expand.cc | 6 +- .../editors/sculpt_paint/sculpt_ops.cc | 4 +- .../editors/sculpt_paint/sculpt_pose.cc | 24 +- .../editors/sculpt_paint/sculpt_undo.cc | 10 +- .../editors/space_action/action_draw.cc | 15 +- .../editors/space_action/action_edit.cc | 12 +- .../editors/space_action/action_select.cc | 12 +- .../editors/space_action/space_action.cc | 3 +- .../editors/space_buttons/buttons_context.c | 15 +- .../editors/space_buttons/space_buttons.c | 3 +- .../editors/space_clip/clip_dopesheet_draw.cc | 3 +- .../blender/editors/space_clip/clip_draw.cc | 15 +- .../blender/editors/space_clip/clip_editor.cc | 6 +- .../editors/space_clip/clip_graph_ops.cc | 3 +- .../blender/editors/space_clip/space_clip.cc | 2 +- .../editors/space_clip/tracking_ops.cc | 18 +- .../editors/space_clip/tracking_ops_plane.cc | 3 +- .../editors/space_clip/tracking_ops_solve.cc | 3 +- .../editors/space_clip/tracking_select.cc | 9 +- .../space_file/asset_catalog_tree_view.cc | 3 +- .../blender/editors/space_file/file_draw.cc | 22 +- source/blender/editors/space_file/file_ops.c | 111 ++-- source/blender/editors/space_file/filelist.cc | 85 +-- source/blender/editors/space_file/filelist.h | 4 + source/blender/editors/space_file/filesel.cc | 44 +- source/blender/editors/space_file/fsmenu.c | 35 +- .../blender/editors/space_file/space_file.c | 31 +- .../editors/space_graph/graph_buttons.c | 6 +- .../blender/editors/space_graph/graph_draw.c | 28 +- .../editors/space_graph/graph_select.c | 8 +- .../editors/space_graph/graph_slider_ops.c | 8 +- .../blender/editors/space_graph/space_graph.c | 3 +- .../editors/space_image/image_buttons.c | 13 +- .../blender/editors/space_image/image_edit.c | 3 +- .../blender/editors/space_image/image_ops.c | 21 +- .../editors/space_image/image_sequence.c | 6 +- .../blender/editors/space_image/image_undo.cc | 26 +- source/blender/editors/space_info/info_ops.c | 6 +- .../blender/editors/space_info/info_stats.cc | 3 +- source/blender/editors/space_nla/nla_draw.c | 9 +- source/blender/editors/space_nla/nla_edit.c | 15 +- .../blender/editors/space_node/clipboard.cc | 4 +- source/blender/editors/space_node/drawnode.cc | 12 +- source/blender/editors/space_node/node_add.cc | 3 +- .../blender/editors/space_node/node_draw.cc | 34 +- .../blender/editors/space_node/node_edit.cc | 19 +- .../blender/editors/space_node/node_group.cc | 15 +- .../editors/space_node/node_relationships.cc | 28 +- .../blender/editors/space_node/node_select.cc | 21 +- .../editors/space_node/node_templates.cc | 20 +- .../blender/editors/space_node/space_node.cc | 3 +- .../space_outliner/outliner_collections.cc | 17 +- .../space_outliner/outliner_dragdrop.cc | 15 +- .../editors/space_outliner/outliner_draw.cc | 51 +- .../editors/space_outliner/outliner_edit.cc | 30 +- .../editors/space_outliner/outliner_select.cc | 18 +- .../editors/space_outliner/outliner_sync.cc | 6 +- .../editors/space_outliner/outliner_tools.cc | 47 +- .../editors/space_outliner/outliner_tree.cc | 34 +- .../editors/space_outliner/outliner_utils.cc | 6 +- .../editors/space_outliner/space_outliner.cc | 3 +- ...ee_display_override_library_hierarchies.cc | 9 +- .../tree/tree_display_view_layer.cc | 3 +- .../tree/tree_element_overrides.cc | 24 +- .../editors/space_sequencer/sequencer_add.c | 29 +- .../space_sequencer/sequencer_drag_drop.c | 6 +- .../editors/space_sequencer/sequencer_draw.c | 47 +- .../editors/space_sequencer/sequencer_edit.c | 29 +- .../sequencer_gizmo_retime_type.cc | 9 +- .../space_sequencer/sequencer_select.c | 33 +- .../space_sequencer/sequencer_thumbnails.c | 12 +- .../editors/space_sequencer/space_sequencer.c | 10 +- .../space_spreadsheet/space_spreadsheet.cc | 3 +- .../spreadsheet_data_source_geometry.cc | 9 +- .../spreadsheet_row_filter_ui.cc | 6 +- .../blender/editors/space_text/space_text.c | 3 +- .../editors/space_text/text_autocomplete.c | 12 +- source/blender/editors/space_text/text_draw.c | 13 +- .../editors/space_text/text_format_lua.c | 3 +- .../editors/space_text/text_format_osl.c | 3 +- .../editors/space_text/text_format_pov.c | 3 +- .../editors/space_text/text_format_pov_ini.c | 3 +- .../editors/space_text/text_format_py.c | 6 +- source/blender/editors/space_text/text_ops.c | 18 +- .../editors/space_userpref/userpref_ops.c | 2 +- .../editors/space_view3d/space_view3d.cc | 14 +- .../editors/space_view3d/view3d_buttons.c | 13 +- .../editors/space_view3d/view3d_cursor_snap.c | 6 +- .../editors/space_view3d/view3d_draw.cc | 15 +- .../editors/space_view3d/view3d_edit.c | 9 +- .../space_view3d/view3d_gizmo_camera.c | 3 +- .../space_view3d/view3d_gizmo_navigate.c | 6 +- .../view3d_gizmo_preselect_type.cc | 9 +- .../space_view3d/view3d_gizmo_ruler.cc | 17 +- .../editors/space_view3d/view3d_iterators.cc | 56 +- .../editors/space_view3d/view3d_navigate.cc | 18 +- .../space_view3d/view3d_navigate_fly.c | 6 +- .../space_view3d/view3d_navigate_smoothview.c | 3 +- .../space_view3d/view3d_navigate_walk.c | 15 +- .../space_view3d/view3d_navigate_zoom.c | 3 +- .../view3d_navigate_zoom_border.c | 7 +- .../editors/space_view3d/view3d_placement.c | 28 +- .../editors/space_view3d/view3d_project.c | 13 +- .../editors/space_view3d/view3d_select.cc | 71 ++- .../editors/space_view3d/view3d_snap.c | 6 +- .../editors/space_view3d/view3d_utils.c | 33 +- .../editors/space_view3d/view3d_view.c | 6 +- source/blender/editors/transform/transform.c | 121 +++-- .../editors/transform/transform_constraints.c | 6 +- .../editors/transform/transform_convert.c | 33 +- .../transform/transform_convert_action.c | 15 +- .../transform/transform_convert_armature.c | 26 +- .../transform/transform_convert_graph.c | 9 +- .../transform/transform_convert_mesh.c | 41 +- .../transform/transform_convert_mesh_edge.c | 3 +- .../editors/transform/transform_convert_nla.c | 12 +- .../transform/transform_convert_node.cc | 3 +- .../transform/transform_convert_object.c | 19 +- .../transform/transform_convert_sequencer.c | 3 +- .../transform/transform_convert_tracking.c | 3 +- .../transform_convert_tracking_curves.c | 3 +- .../editors/transform/transform_generics.c | 50 +- .../editors/transform/transform_gizmo_3d.cc | 22 +- .../transform/transform_gizmo_3d_cage.cc | 3 +- .../transform/transform_gizmo_extrude_3d.c | 6 +- .../editors/transform/transform_input.c | 4 +- .../editors/transform/transform_mode.c | 6 +- .../transform_mode_curveshrinkfatten.c | 3 +- .../transform/transform_mode_edge_slide.c | 6 +- .../editors/transform/transform_mode_rotate.c | 3 +- .../transform/transform_mode_translate.c | 3 +- .../transform/transform_orientations.c | 11 +- .../editors/transform/transform_snap.cc | 51 +- .../transform/transform_snap_object.cc | 122 +++-- source/blender/editors/undo/ed_undo.cc | 12 +- source/blender/editors/util/ed_util.cc | 8 +- source/blender/editors/util/ed_util_ops.cc | 5 +- source/blender/editors/util/numinput.c | 3 +- .../editors/uvedit/uvedit_clipboard.cc | 3 +- .../uvedit/uvedit_clipboard_graph_iso.cc | 6 +- source/blender/editors/uvedit/uvedit_path.c | 24 +- source/blender/editors/uvedit/uvedit_rip.c | 15 +- source/blender/editors/uvedit/uvedit_select.c | 54 +- .../editors/uvedit/uvedit_smart_stitch.c | 38 +- .../editors/uvedit/uvedit_unwrap_ops.cc | 9 +- .../blender_interface/BlenderFileLoader.cpp | 9 +- .../BlenderStrokeRenderer.cpp | 6 +- .../blender_interface/FRS_freestyle.cpp | 32 +- .../freestyle/intern/geometry/GeomUtils.cpp | 3 +- .../freestyle/intern/geometry/Grid.cpp | 6 +- .../freestyle/intern/geometry/GridHelpers.h | 6 +- .../freestyle/intern/geometry/Polygon.h | 7 +- .../freestyle/intern/geometry/SweepLine.h | 9 +- .../intern/python/BPy_BinaryPredicate0D.cpp | 11 +- .../intern/python/BPy_BinaryPredicate1D.cpp | 11 +- .../intern/python/BPy_ContextFunctions.cpp | 10 +- .../freestyle/intern/python/BPy_Freestyle.cpp | 6 +- .../intern/python/BPy_FrsMaterial.cpp | 3 +- .../freestyle/intern/python/BPy_Id.cpp | 3 +- .../intern/python/BPy_IntegrationType.cpp | 3 +- .../intern/python/BPy_Interface0D.cpp | 4 +- .../freestyle/intern/python/BPy_Operators.cpp | 47 +- .../intern/python/BPy_StrokeAttribute.cpp | 9 +- .../intern/python/BPy_UnaryPredicate0D.cpp | 3 +- .../intern/python/BPy_UnaryPredicate1D.cpp | 4 +- .../freestyle/intern/python/BPy_ViewShape.cpp | 3 +- .../BPy_ViewMapGradientNormBP1D.cpp | 3 +- .../python/Interface0D/BPy_CurvePoint.cpp | 6 +- .../intern/python/Interface0D/BPy_SVertex.cpp | 3 +- .../CurvePoint/BPy_StrokeVertex.cpp | 13 +- .../intern/python/Interface1D/BPy_FEdge.cpp | 11 +- .../python/Interface1D/BPy_FrsCurve.cpp | 3 +- .../intern/python/Interface1D/BPy_Stroke.cpp | 7 +- .../python/Interface1D/Curve/BPy_Chain.cpp | 9 +- .../Interface1D/FEdge/BPy_FEdgeSharp.cpp | 11 +- .../Interface1D/FEdge/BPy_FEdgeSmooth.cpp | 15 +- .../python/Iterator/BPy_AdjacencyIterator.cpp | 6 +- .../Iterator/BPy_ChainPredicateIterator.cpp | 6 +- .../Iterator/BPy_ChainSilhouetteIterator.cpp | 6 +- .../python/Iterator/BPy_ChainingIterator.cpp | 9 +- .../Iterator/BPy_CurvePointIterator.cpp | 6 +- .../Iterator/BPy_Interface0DIterator.cpp | 9 +- .../python/Iterator/BPy_SVertexIterator.cpp | 6 +- .../Iterator/BPy_StrokeVertexIterator.cpp | 6 +- .../python/Iterator/BPy_ViewEdgeIterator.cpp | 6 +- .../Iterator/BPy_orientedViewEdgeIterator.cpp | 3 +- .../StrokeShader/BPy_CalligraphicShader.cpp | 3 +- .../BPy_IncreasingColorShader.cpp | 3 +- .../StrokeShader/BPy_SmoothingShader.cpp | 3 +- .../StrokeShader/BPy_SpatialNoiseShader.cpp | 3 +- .../BPy_UnaryFunction0DDouble.cpp | 3 +- .../BPy_UnaryFunction0DEdgeNature.cpp | 3 +- .../BPy_UnaryFunction0DFloat.cpp | 3 +- .../UnaryFunction0D/BPy_UnaryFunction0DId.cpp | 3 +- .../BPy_UnaryFunction0DMaterial.cpp | 3 +- .../BPy_UnaryFunction0DUnsigned.cpp | 3 +- .../BPy_UnaryFunction0DVec2f.cpp | 3 +- .../BPy_UnaryFunction0DVec3f.cpp | 3 +- .../BPy_UnaryFunction0DVectorViewShape.cpp | 3 +- .../BPy_UnaryFunction0DViewShape.cpp | 3 +- .../UnaryFunction1D_double/BPy_DensityF1D.cpp | 3 +- .../BPy_GetCompleteViewMapDensityF1D.cpp | 3 +- .../BPy_GetDirectionalViewMapDensityF1D.cpp | 3 +- .../BPy_GetSteerableViewMapDensityF1D.cpp | 3 +- .../BPy_GetViewMapGradientNormF1D.cpp | 3 +- .../BPy_LocalAverageDepthF1D.cpp | 3 +- .../freestyle/intern/scene_graph/LineRep.h | 4 +- .../intern/stroke/AdvancedFunctions0D.cpp | 6 +- .../intern/stroke/BasicStrokeShaders.cpp | 27 +- .../freestyle/intern/stroke/Canvas.cpp | 20 +- .../blender/freestyle/intern/stroke/Curve.cpp | 15 +- .../freestyle/intern/stroke/Operators.cpp | 29 +- .../freestyle/intern/stroke/Stroke.cpp | 16 +- .../freestyle/intern/stroke/StrokeIO.cpp | 3 +- .../freestyle/intern/stroke/StrokeLayer.cpp | 9 +- .../freestyle/intern/stroke/StrokeRep.cpp | 20 +- .../freestyle/intern/stroke/StyleModule.h | 3 +- .../freestyle/intern/system/StringUtils.cpp | 3 +- .../freestyle/intern/view_map/BoxGrid.cpp | 4 +- .../freestyle/intern/view_map/BoxGrid.h | 3 +- .../intern/view_map/FEdgeXDetector.cpp | 23 +- .../freestyle/intern/view_map/Silhouette.cpp | 9 +- .../freestyle/intern/view_map/Silhouette.h | 16 +- .../intern/view_map/SphericalGrid.cpp | 4 +- .../freestyle/intern/view_map/SphericalGrid.h | 3 +- .../intern/view_map/SteerableViewMap.cpp | 12 +- .../intern/view_map/ViewEdgeXBuilder.cpp | 11 +- .../freestyle/intern/view_map/ViewMap.cpp | 43 +- .../freestyle/intern/view_map/ViewMap.h | 9 +- .../intern/view_map/ViewMapBuilder.cpp | 46 +- .../intern/winged_edge/Curvature.cpp | 3 +- .../freestyle/intern/winged_edge/Curvature.h | 3 +- .../freestyle/intern/winged_edge/WEdge.cpp | 6 +- .../freestyle/intern/winged_edge/WEdge.h | 15 +- .../freestyle/intern/winged_edge/WXEdge.cpp | 6 +- .../freestyle/intern/winged_edge/WXEdge.h | 27 +- .../intern/winged_edge/WingedEdgeBuilder.cpp | 3 +- .../functions/FN_multi_function_builder.hh | 12 +- .../intern/lazy_function_graph_executor.cc | 6 +- .../functions/intern/multi_function.cc | 3 +- .../intern/multi_function_procedure.cc | 6 +- .../geometry/intern/add_curves_on_mesh.cc | 14 +- .../blender/geometry/intern/fillet_curves.cc | 6 +- .../geometry/intern/mesh_merge_by_distance.cc | 14 +- .../geometry/intern/mesh_split_edges.cc | 9 +- .../geometry/intern/resample_curves.cc | 3 +- .../geometry/intern/subdivide_curves.cc | 25 +- source/blender/geometry/intern/trim_curves.cc | 12 +- source/blender/geometry/intern/uv_pack.cc | 40 +- .../geometry/intern/uv_parametrizer.cc | 4 +- .../intern/MOD_gpencil_legacy_array.c | 6 +- .../intern/MOD_gpencil_legacy_build.c | 4 +- .../intern/MOD_gpencil_legacy_color.c | 7 +- .../intern/MOD_gpencil_legacy_dash.c | 3 +- .../intern/MOD_gpencil_legacy_envelope.c | 6 +- .../intern/MOD_gpencil_legacy_hook.c | 6 +- .../intern/MOD_gpencil_legacy_lattice.c | 6 +- .../intern/MOD_gpencil_legacy_length.c | 3 +- .../intern/MOD_gpencil_legacy_lineart.c | 3 +- .../intern/MOD_gpencil_legacy_mirror.c | 3 +- .../intern/MOD_gpencil_legacy_multiply.c | 3 +- .../intern/MOD_gpencil_legacy_noise.c | 3 +- .../intern/MOD_gpencil_legacy_offset.c | 3 +- .../intern/MOD_gpencil_legacy_opacity.c | 3 +- .../intern/MOD_gpencil_legacy_outline.c | 3 +- .../intern/MOD_gpencil_legacy_shrinkwrap.c | 6 +- .../intern/MOD_gpencil_legacy_simplify.c | 3 +- .../intern/MOD_gpencil_legacy_smooth.c | 3 +- .../intern/MOD_gpencil_legacy_subdiv.c | 3 +- .../intern/MOD_gpencil_legacy_texture.c | 3 +- .../intern/MOD_gpencil_legacy_thick.c | 3 +- .../intern/MOD_gpencil_legacy_tint.c | 3 +- .../intern/MOD_gpencil_legacy_weight_angle.c | 3 +- .../MOD_gpencil_legacy_weight_proximity.c | 3 +- .../intern/lineart/MOD_lineart.h | 13 +- .../intern/lineart/lineart_chain.c | 37 +- .../intern/lineart/lineart_cpu.cc | 135 +++-- .../intern/lineart/lineart_shadow.c | 29 +- source/blender/gpu/GPU_texture.h | 2 +- source/blender/gpu/intern/gpu_codegen.cc | 6 +- source/blender/gpu/intern/gpu_framebuffer.cc | 3 +- source/blender/gpu/intern/gpu_immediate.cc | 3 +- source/blender/gpu/intern/gpu_node_graph.cc | 15 +- source/blender/gpu/intern/gpu_select_pick.c | 4 +- .../blender/gpu/intern/gpu_shader_builtin.cc | 3 +- .../gpu/intern/gpu_shader_create_info.cc | 6 +- .../gpu/intern/gpu_shader_dependency.cc | 3 +- source/blender/gpu/intern/gpu_shader_log.cc | 9 +- source/blender/gpu/intern/gpu_texture.cc | 4 +- .../blender/gpu/intern/gpu_texture_private.hh | 7 +- .../blender/gpu/intern/gpu_uniform_buffer.cc | 3 +- source/blender/gpu/intern/gpu_viewport.c | 3 +- source/blender/gpu/metal/mtl_batch.mm | 3 +- .../blender/gpu/metal/mtl_command_buffer.mm | 37 +- source/blender/gpu/metal/mtl_context.mm | 24 +- source/blender/gpu/metal/mtl_framebuffer.mm | 33 +- source/blender/gpu/metal/mtl_immediate.mm | 3 +- source/blender/gpu/metal/mtl_memory.mm | 9 +- .../gpu/metal/mtl_pso_descriptor_state.hh | 6 +- source/blender/gpu/metal/mtl_shader.hh | 21 +- source/blender/gpu/metal/mtl_shader.mm | 13 +- .../blender/gpu/metal/mtl_shader_generator.hh | 3 +- .../blender/gpu/metal/mtl_shader_generator.mm | 25 +- source/blender/gpu/metal/mtl_state.mm | 3 +- source/blender/gpu/metal/mtl_texture.hh | 3 +- source/blender/gpu/metal/mtl_texture.mm | 30 +- source/blender/gpu/opengl/gl_backend.cc | 61 ++- source/blender/gpu/opengl/gl_debug.cc | 12 +- source/blender/gpu/opengl/gl_framebuffer.cc | 4 +- source/blender/gpu/opengl/gl_immediate.cc | 3 +- source/blender/gpu/opengl/gl_shader.cc | 6 +- source/blender/gpu/opengl/gl_shader_log.cc | 6 +- source/blender/gpu/opengl/gl_state.cc | 6 +- source/blender/gpu/opengl/gl_texture.cc | 8 +- source/blender/gpu/opengl/gl_texture.hh | 2 +- .../shaders/common/gpu_shader_smaa_lib.glsl | 12 +- .../shaders/gpu_shader_2D_nodelink_vert.glsl | 3 +- ...ader_image_overlays_stereo_merge_frag.glsl | 4 +- .../gpu_shader_keyframe_shape_vert.glsl | 3 +- source/blender/gpu/tests/index_buffer_test.cc | 3 +- source/blender/gpu/tests/texture_test.cc | 8 +- .../blender/gpu/vulkan/vk_command_buffer.cc | 2 +- .../blender/gpu/vulkan/vk_command_buffer.hh | 1 + source/blender/gpu/vulkan/vk_common.cc | 6 +- .../blender/gpu/vulkan/vk_data_conversion.cc | 149 +++-- source/blender/gpu/vulkan/vk_framebuffer.cc | 3 +- source/blender/gpu/vulkan/vk_pipeline.cc | 3 +- .../blender/gpu/vulkan/vk_push_constants.hh | 3 +- source/blender/gpu/vulkan/vk_shader.cc | 6 +- source/blender/gpu/vulkan/vk_texture.cc | 2 +- source/blender/gpu/vulkan/vk_texture.hh | 2 +- .../blender/ikplugin/intern/itasc_plugin.cpp | 33 +- source/blender/imbuf/CMakeLists.txt | 54 +- source/blender/imbuf/IMB_colormanagement.h | 2 +- source/blender/imbuf/IMB_imbuf.h | 15 +- source/blender/imbuf/IMB_imbuf_types.h | 6 +- source/blender/imbuf/intern/IMB_anim.h | 6 +- .../imbuf/intern/IMB_colormanagement_intern.h | 11 +- source/blender/imbuf/intern/IMB_indexer.h | 8 +- .../intern/{allocimbuf.c => allocimbuf.cc} | 126 ++--- .../intern/{anim_movie.c => anim_movie.cc} | 243 +++++---- .../imbuf/intern/cineon/CMakeLists.txt | 10 +- .../cineon/{cineon_dpx.c => cineon_dpx.cc} | 28 +- .../cineon/{cineonlib.c => cineonlib.cc} | 54 +- .../intern/cineon/{dpxlib.c => dpxlib.cc} | 55 +- .../{logImageCore.c => logImageCore.cc} | 123 ++--- .../cineon/{logmemfile.c => logmemfile.cc} | 10 +- .../{colormanagement.c => colormanagement.cc} | 506 +++++++++-------- ...ment_inline.c => colormanagement_inline.h} | 0 .../imbuf/intern/dds/DirectDrawSurface.cpp | 21 +- .../imbuf/intern/{divers.c => divers.cc} | 114 ++-- source/blender/imbuf/intern/filetype.c | 240 --------- source/blender/imbuf/intern/filetype.cc | 240 +++++++++ .../imbuf/intern/{filter.c => filter.cc} | 36 +- .../{imageprocess.c => imageprocess.cc} | 95 ++-- .../imbuf/intern/{indexer.c => indexer.cc} | 283 +++++----- .../blender/imbuf/intern/{iris.c => iris.cc} | 76 +-- source/blender/imbuf/intern/{jp2.c => jp2.cc} | 137 +++-- .../blender/imbuf/intern/{jpeg.c => jpeg.cc} | 57 +- .../imbuf/intern/{metadata.c => metadata.cc} | 24 +- .../imbuf/intern/{module.c => module.cc} | 0 .../imbuf/intern/oiio/openimageio_support.cc | 8 +- .../imbuf/intern/openexr/openexr_api.cpp | 8 +- .../intern/{readimage.c => readimage.cc} | 36 +- .../imbuf/intern/{rectop.c => rectop.cc} | 99 ++-- .../imbuf/intern/{rotate.c => rotate.cc} | 14 +- .../imbuf/intern/{scaling.c => scaling.cc} | 289 +++++----- .../intern/{stereoimbuf.c => stereoimbuf.cc} | 110 ++-- .../imbuf/intern/{thumbs.c => thumbs.cc} | 92 ++-- .../{thumbs_blend.c => thumbs_blend.cc} | 11 +- .../intern/{thumbs_font.c => thumbs_font.cc} | 2 +- source/blender/imbuf/intern/transform.cc | 27 +- .../blender/imbuf/intern/{util.c => util.cc} | 35 +- .../imbuf/intern/{util_gpu.c => util_gpu.cc} | 57 +- .../blender/imbuf/intern/{webp.c => webp.cc} | 55 +- .../intern/{writeimage.c => writeimage.cc} | 6 +- .../io/alembic/exporter/abc_writer_mesh.cc | 3 +- .../io/alembic/intern/abc_reader_camera.cc | 3 +- .../io/alembic/intern/abc_reader_mesh.cc | 14 +- source/blender/io/avi/AVI_avi.h | 14 +- source/blender/io/avi/intern/avi.c | 36 +- .../io/collada/AnimationClipExporter.cpp | 4 +- .../blender/io/collada/AnimationImporter.cpp | 9 +- .../blender/io/collada/ArmatureImporter.cpp | 5 +- .../blender/io/collada/DocumentExporter.cpp | 4 +- .../blender/io/collada/DocumentImporter.cpp | 5 +- source/blender/io/collada/ErrorHandler.cpp | 12 +- source/blender/io/collada/ImageExporter.cpp | 5 +- source/blender/io/collada/MeshImporter.cpp | 3 +- source/blender/io/collada/collada_utils.cpp | 8 +- source/blender/io/common/intern/path_util.cc | 2 +- .../gpencil/intern/gpencil_io_export_pdf.cc | 3 +- .../blender/io/usd/intern/usd_asset_utils.cc | 4 +- .../blender/io/usd/intern/usd_capi_export.cc | 12 +- .../io/usd/intern/usd_reader_material.cc | 21 +- .../blender/io/usd/intern/usd_reader_mesh.cc | 30 +- .../blender/io/usd/intern/usd_reader_stage.cc | 11 +- .../io/usd/intern/usd_writer_material.cc | 28 +- .../blender/io/usd/intern/usd_writer_mesh.cc | 6 +- .../io/usd/intern/usd_writer_volume.cc | 19 +- .../exporter/obj_export_file_writer.cc | 12 +- .../io/wavefront_obj/exporter/obj_exporter.cc | 4 +- .../importer/obj_import_file_reader.cc | 32 +- .../wavefront_obj/importer/obj_import_mesh.cc | 6 +- .../wavefront_obj/tests/obj_exporter_tests.cc | 2 +- source/blender/makesdna/DNA_ID.h | 44 +- source/blender/makesdna/DNA_mask_types.h | 2 + source/blender/makesdna/DNA_node_types.h | 30 +- source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesdna/intern/dna_genfile.c | 3 +- source/blender/makesdna/intern/makesdna.c | 3 +- source/blender/makesrna/RNA_access.h | 9 +- source/blender/makesrna/intern/makesrna.c | 17 +- source/blender/makesrna/intern/rna_ID.c | 38 +- source/blender/makesrna/intern/rna_access.cc | 49 +- .../intern/rna_access_compare_override.c | 111 ++-- .../blender/makesrna/intern/rna_animation.c | 11 +- source/blender/makesrna/intern/rna_brush.c | 3 +- source/blender/makesrna/intern/rna_camera.c | 2 +- .../blender/makesrna/intern/rna_collection.c | 4 +- source/blender/makesrna/intern/rna_color.c | 3 +- source/blender/makesrna/intern/rna_define.c | 3 +- source/blender/makesrna/intern/rna_fcurve.c | 12 +- source/blender/makesrna/intern/rna_fluid.c | 3 +- .../intern/rna_gpencil_legacy_modifier.c | 3 +- .../blender/makesrna/intern/rna_image_api.c | 3 +- source/blender/makesrna/intern/rna_mesh.c | 2 +- source/blender/makesrna/intern/rna_modifier.c | 8 +- source/blender/makesrna/intern/rna_nodetree.c | 19 +- source/blender/makesrna/intern/rna_object.c | 12 +- .../blender/makesrna/intern/rna_object_api.c | 9 +- .../makesrna/intern/rna_object_force.c | 11 +- source/blender/makesrna/intern/rna_particle.c | 3 +- source/blender/makesrna/intern/rna_path.cc | 8 +- source/blender/makesrna/intern/rna_pose.c | 2 +- source/blender/makesrna/intern/rna_rna.c | 182 +++---- source/blender/makesrna/intern/rna_scene.c | 10 +- .../blender/makesrna/intern/rna_scene_api.c | 9 +- .../blender/makesrna/intern/rna_sequencer.c | 18 +- .../makesrna/intern/rna_sequencer_api.c | 4 +- source/blender/makesrna/intern/rna_space.c | 15 +- source/blender/makesrna/intern/rna_tracking.c | 3 +- source/blender/makesrna/intern/rna_ui_api.c | 3 +- source/blender/makesrna/intern/rna_userdef.c | 15 +- .../blender/modifiers/intern/MOD_armature.c | 3 +- source/blender/modifiers/intern/MOD_array.cc | 21 +- source/blender/modifiers/intern/MOD_build.cc | 3 +- source/blender/modifiers/intern/MOD_cast.c | 3 +- source/blender/modifiers/intern/MOD_cloth.c | 3 +- .../modifiers/intern/MOD_correctivesmooth.cc | 9 +- .../modifiers/intern/MOD_datatransfer.cc | 6 +- .../blender/modifiers/intern/MOD_displace.cc | 16 +- .../modifiers/intern/MOD_dynamicpaint.c | 6 +- .../blender/modifiers/intern/MOD_edgesplit.c | 3 +- .../blender/modifiers/intern/MOD_explode.cc | 6 +- source/blender/modifiers/intern/MOD_hook.c | 3 +- .../modifiers/intern/MOD_laplaciansmooth.cc | 18 +- source/blender/modifiers/intern/MOD_mask.cc | 3 +- .../modifiers/intern/MOD_meshcache_mdd.c | 9 +- .../modifiers/intern/MOD_meshcache_pc2.c | 9 +- .../modifiers/intern/MOD_meshsequencecache.cc | 3 +- source/blender/modifiers/intern/MOD_nodes.cc | 30 +- .../modifiers/intern/MOD_normal_edit.cc | 9 +- .../modifiers/intern/MOD_particleinstance.cc | 7 +- .../modifiers/intern/MOD_particlesystem.cc | 3 +- source/blender/modifiers/intern/MOD_screw.cc | 3 +- .../blender/modifiers/intern/MOD_shrinkwrap.c | 7 +- .../modifiers/intern/MOD_simpledeform.c | 3 +- source/blender/modifiers/intern/MOD_skin.cc | 12 +- .../blender/modifiers/intern/MOD_solidify.cc | 3 +- .../modifiers/intern/MOD_solidify_extrude.cc | 12 +- .../intern/MOD_solidify_nonmanifold.cc | 24 +- source/blender/modifiers/intern/MOD_surface.c | 3 +- .../modifiers/intern/MOD_surfacedeform.cc | 15 +- .../modifiers/intern/MOD_triangulate.cc | 3 +- .../blender/modifiers/intern/MOD_ui_common.c | 13 +- .../modifiers/intern/MOD_volume_to_mesh.cc | 3 +- source/blender/modifiers/intern/MOD_warp.c | 6 +- source/blender/modifiers/intern/MOD_wave.cc | 3 +- .../modifiers/intern/MOD_weighted_normal.cc | 33 +- .../modifiers/intern/MOD_weightvg_util.c | 19 +- .../modifiers/intern/MOD_weightvgproximity.cc | 2 +- source/blender/nodes/NOD_math_functions.hh | 4 +- .../nodes/composite/node_composite_tree.cc | 3 +- .../nodes/node_composite_cryptomatte.cc | 9 +- .../composite/nodes/node_composite_curves.cc | 3 +- .../nodes/node_composite_displace.cc | 3 +- .../composite/nodes/node_composite_image.cc | 3 +- .../composite/nodes/node_composite_mask.cc | 82 ++- .../nodes/node_composite_output_file.cc | 3 +- .../composite/nodes/node_composite_scale.cc | 2 +- .../nodes/node_composite_stabilize2d.cc | 71 ++- .../composite/nodes/node_composite_texture.cc | 2 +- .../nodes/node_composite_trackpos.cc | 3 +- .../function/nodes/node_fn_boolean_math.cc | 6 +- .../nodes/function/nodes/node_fn_compare.cc | 9 +- .../nodes/geometry/node_geometry_tree.cc | 3 +- .../nodes/node_geo_accumulate_field.cc | 7 +- .../nodes/node_geo_attribute_domain_size.cc | 10 +- .../nodes/node_geo_attribute_statistic.cc | 3 +- .../geometry/nodes/node_geo_blur_attribute.cc | 3 +- .../node_geo_curve_handle_type_selection.cc | 3 +- .../node_geo_curve_primitive_quadrilateral.cc | 3 +- .../nodes/node_geo_curve_primitive_star.cc | 3 +- .../nodes/node_geo_curve_spline_type.cc | 3 +- .../geometry/nodes/node_geo_curve_trim.cc | 3 +- .../geometry/nodes/node_geo_dual_mesh.cc | 18 +- .../nodes/node_geo_duplicate_elements.cc | 20 +- .../nodes/node_geo_edge_paths_to_selection.cc | 6 +- .../geometry/nodes/node_geo_extrude_mesh.cc | 3 +- .../nodes/node_geo_input_curve_handles.cc | 3 +- .../node_geo_input_mesh_edge_vertices.cc | 3 +- .../node_geo_input_shortest_edge_paths.cc | 6 +- .../nodes/node_geo_instance_on_points.cc | 3 +- .../nodes/node_geo_instances_to_points.cc | 4 +- .../nodes/node_geo_interpolate_curves.cc | 7 +- .../nodes/node_geo_material_selection.cc | 3 +- .../nodes/node_geo_mesh_primitive_line.cc | 3 +- ...geo_mesh_topology_offset_corner_in_face.cc | 3 +- .../nodes/node_geo_points_to_volume.cc | 3 +- .../nodes/geometry/nodes/node_geo_raycast.cc | 3 +- .../nodes/node_geo_remove_attribute.cc | 3 +- .../geometry/nodes/node_geo_sample_nearest.cc | 12 +- .../nodes/geometry/nodes/node_geo_set_id.cc | 3 +- .../geometry/nodes/node_geo_set_position.cc | 3 +- .../nodes/node_geo_store_named_attribute.cc | 3 +- .../nodes/node_geo_string_to_curves.cc | 7 +- .../nodes/node_geo_transform_geometry.cc | 3 +- .../geometry/nodes/node_geo_volume_cube.cc | 4 +- .../geometry/nodes/node_geo_volume_to_mesh.cc | 6 +- .../intern/geometry_nodes_lazy_function.cc | 52 +- .../nodes/intern/geometry_nodes_log.cc | 10 +- source/blender/nodes/intern/node_common.cc | 3 +- source/blender/nodes/intern/node_exec.cc | 3 +- .../nodes/intern/node_geometry_exec.cc | 4 +- .../blender/nodes/shader/node_shader_tree.cc | 15 +- .../nodes/shader/nodes/node_shader_curves.cc | 3 +- .../shader/nodes/node_shader_map_range.cc | 6 +- .../nodes/shader/nodes/node_shader_math.cc | 3 +- .../nodes/node_shader_tex_environment.cc | 3 +- .../shader/nodes/node_shader_tex_image.cc | 3 +- .../shader/nodes/node_shader_tex_musgrave.cc | 3 +- .../nodes/shader/nodes/node_shader_tex_sky.cc | 3 +- .../shader/nodes/node_shader_tex_voronoi.cc | 3 +- .../shader/nodes/node_shader_vector_math.cc | 9 +- .../nodes/node_shader_vector_transform.cc | 6 +- .../nodes/texture/node_texture_tree.cc | 8 +- .../texture/nodes/node_texture_bricks.cc | 3 +- source/blender/python/bmesh/bmesh_py_api.c | 6 +- .../blender/python/bmesh/bmesh_py_ops_call.c | 36 +- source/blender/python/bmesh/bmesh_py_types.c | 44 +- source/blender/python/bmesh/bmesh_py_types.h | 8 +- .../python/bmesh/bmesh_py_types_customdata.c | 4 +- source/blender/python/bmesh/bmesh_py_utils.c | 52 +- source/blender/python/generic/bgl.c | 3 +- source/blender/python/generic/blf_py_api.c | 7 +- source/blender/python/generic/idprop_py_api.c | 6 +- .../blender/python/generic/idprop_py_ui_api.c | 27 +- source/blender/python/generic/imbuf_py_api.c | 26 +- source/blender/python/generic/py_capi_rna.c | 6 +- source/blender/python/generic/py_capi_utils.c | 10 +- source/blender/python/gpu/gpu_py_batch.c | 13 +- source/blender/python/gpu/gpu_py_buffer.c | 6 +- source/blender/python/gpu/gpu_py_element.c | 3 +- .../blender/python/gpu/gpu_py_framebuffer.c | 9 +- source/blender/python/gpu/gpu_py_matrix.c | 6 +- source/blender/python/gpu/gpu_py_offscreen.c | 6 +- source/blender/python/gpu/gpu_py_shader.c | 16 +- .../python/gpu/gpu_py_shader_create_info.cc | 12 +- source/blender/python/gpu/gpu_py_texture.c | 13 +- .../blender/python/gpu/gpu_py_vertex_buffer.c | 3 +- .../blender/python/gpu/gpu_py_vertex_format.c | 3 +- source/blender/python/intern/bpy.c | 12 +- source/blender/python/intern/bpy_app.c | 3 +- .../blender/python/intern/bpy_app_handlers.c | 3 +- source/blender/python/intern/bpy_app_icons.c | 3 +- .../python/intern/bpy_app_translations.c | 15 +- source/blender/python/intern/bpy_driver.c | 9 +- source/blender/python/intern/bpy_gizmo_wrap.c | 6 +- source/blender/python/intern/bpy_interface.c | 6 +- .../blender/python/intern/bpy_library_load.c | 9 +- .../blender/python/intern/bpy_library_write.c | 3 +- source/blender/python/intern/bpy_msgbus.c | 6 +- source/blender/python/intern/bpy_operator.c | 9 +- source/blender/python/intern/bpy_props.c | 69 ++- source/blender/python/intern/bpy_rna.c | 61 ++- source/blender/python/intern/bpy_rna_anim.c | 21 +- source/blender/python/intern/bpy_rna_array.c | 12 +- .../blender/python/intern/bpy_rna_callback.c | 12 +- .../blender/python/intern/bpy_rna_context.c | 3 +- source/blender/python/intern/bpy_rna_driver.c | 3 +- source/blender/python/intern/bpy_rna_gizmo.c | 18 +- .../python/intern/bpy_rna_id_collection.c | 9 +- source/blender/python/intern/bpy_rna_text.c | 6 +- source/blender/python/intern/bpy_traceback.c | 9 +- .../blender/python/intern/bpy_utils_units.c | 6 +- source/blender/python/mathutils/mathutils.c | 6 +- .../python/mathutils/mathutils_Color.c | 6 +- .../python/mathutils/mathutils_Euler.c | 9 +- .../python/mathutils/mathutils_Matrix.c | 32 +- .../python/mathutils/mathutils_Quaternion.c | 26 +- .../python/mathutils/mathutils_Vector.c | 41 +- .../python/mathutils/mathutils_bvhtree.cc | 16 +- .../python/mathutils/mathutils_geometry.c | 111 ++-- .../python/mathutils/mathutils_interpolate.c | 3 +- .../python/mathutils/mathutils_kdtree.c | 3 +- .../python/mathutils/mathutils_noise.c | 85 +-- source/blender/render/CMakeLists.txt | 2 +- source/blender/render/intern/bake.cc | 3 +- source/blender/render/intern/engine.cc | 2 +- source/blender/render/intern/initrender.cc | 2 +- source/blender/render/intern/pipeline.cc | 98 ++-- source/blender/render/intern/pipeline.h | 24 - source/blender/render/intern/pipeline.hh | 16 + source/blender/render/intern/render_result.cc | 12 +- source/blender/render/intern/render_result.h | 3 +- source/blender/render/intern/texture_image.c | 6 +- .../render/intern/texture_pointdensity.c | 7 +- source/blender/sequencer/intern/disk_cache.c | 26 +- source/blender/sequencer/intern/effects.c | 6 +- source/blender/sequencer/intern/image_cache.c | 12 +- source/blender/sequencer/intern/iterator.c | 7 +- source/blender/sequencer/intern/prefetch.c | 16 +- source/blender/sequencer/intern/proxy.c | 69 +-- source/blender/sequencer/intern/render.c | 50 +- source/blender/sequencer/intern/sequencer.c | 3 +- source/blender/sequencer/intern/strip_add.c | 17 +- .../sequencer/intern/strip_relations.c | 16 +- .../sequencer/intern/strip_retiming.cc | 2 +- .../sequencer/intern/strip_transform.c | 18 +- source/blender/sequencer/intern/utils.c | 29 +- .../intern/ConstrainedConjugateGradient.h | 7 +- .../simulation/intern/SIM_mass_spring.cpp | 15 +- .../simulation/intern/implicit_blender.c | 8 +- .../windowmanager/gizmo/intern/wm_gizmo.c | 3 +- .../gizmo/intern/wm_gizmo_group.c | 19 +- .../windowmanager/gizmo/intern/wm_gizmo_map.c | 23 +- .../blender/windowmanager/intern/wm_cursors.c | 3 +- .../windowmanager/intern/wm_dragdrop.cc | 4 +- source/blender/windowmanager/intern/wm_draw.c | 6 +- .../windowmanager/intern/wm_event_query.c | 3 +- .../windowmanager/intern/wm_event_system.cc | 72 ++- .../blender/windowmanager/intern/wm_files.cc | 42 +- .../windowmanager/intern/wm_files_link.c | 6 +- .../windowmanager/intern/wm_init_exit.cc | 3 +- .../blender/windowmanager/intern/wm_keymap.c | 6 +- .../windowmanager/intern/wm_keymap_utils.c | 6 +- .../windowmanager/intern/wm_operator_type.c | 4 +- .../windowmanager/intern/wm_operators.c | 41 +- .../intern/wm_platform_support.c | 3 +- .../windowmanager/intern/wm_playanim.c | 38 +- .../windowmanager/intern/wm_splash_screen.c | 3 +- .../blender/windowmanager/intern/wm_stereo.c | 3 +- .../windowmanager/intern/wm_toolsystem.c | 3 +- .../blender/windowmanager/intern/wm_window.c | 3 +- .../message_bus/intern/wm_message_bus.c | 7 +- .../message_bus/intern/wm_message_bus_rna.c | 16 +- .../windowmanager/xr/intern/wm_xr_action.c | 3 +- .../windowmanager/xr/intern/wm_xr_draw.c | 6 +- .../windowmanager/xr/intern/wm_xr_operators.c | 4 +- .../windowmanager/xr/intern/wm_xr_session.c | 61 ++- source/creator/blender_launcher_win32.c | 3 +- source/creator/creator_args.c | 19 +- source/creator/creator_signals.c | 27 +- tests/python/bl_usd_export_test.py | 70 +++ 1462 files changed, 14409 insertions(+), 9268 deletions(-) create mode 100644 source/blender/compositor/realtime_compositor/cached_resources/COM_cached_mask.hh create mode 100644 source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc create mode 100644 source/blender/editors/interface/view2d_intern.hh rename source/blender/imbuf/intern/{allocimbuf.c => allocimbuf.cc} (80%) rename source/blender/imbuf/intern/{anim_movie.c => anim_movie.cc} (88%) rename source/blender/imbuf/intern/cineon/{cineon_dpx.c => cineon_dpx.cc} (89%) rename source/blender/imbuf/intern/cineon/{cineonlib.c => cineonlib.cc} (94%) rename source/blender/imbuf/intern/cineon/{dpxlib.c => dpxlib.cc} (95%) rename source/blender/imbuf/intern/cineon/{logImageCore.c => logImageCore.cc} (93%) rename source/blender/imbuf/intern/cineon/{logmemfile.c => logmemfile.cc} (86%) rename source/blender/imbuf/intern/{colormanagement.c => colormanagement.cc} (91%) rename source/blender/imbuf/intern/{colormanagement_inline.c => colormanagement_inline.h} (100%) rename source/blender/imbuf/intern/{divers.c => divers.cc} (88%) delete mode 100644 source/blender/imbuf/intern/filetype.c create mode 100644 source/blender/imbuf/intern/filetype.cc rename source/blender/imbuf/intern/{filter.c => filter.cc} (95%) rename source/blender/imbuf/intern/{imageprocess.c => imageprocess.cc} (83%) rename source/blender/imbuf/intern/{indexer.c => indexer.cc} (84%) rename source/blender/imbuf/intern/{iris.c => iris.cc} (91%) rename source/blender/imbuf/intern/{jp2.c => jp2.cc} (91%) rename source/blender/imbuf/intern/{jpeg.c => jpeg.cc} (93%) rename source/blender/imbuf/intern/{metadata.c => metadata.cc} (80%) rename source/blender/imbuf/intern/{module.c => module.cc} (100%) rename source/blender/imbuf/intern/{readimage.c => readimage.cc} (89%) rename source/blender/imbuf/intern/{rectop.c => rectop.cc} (92%) rename source/blender/imbuf/intern/{rotate.c => rotate.cc} (85%) rename source/blender/imbuf/intern/{scaling.c => scaling.cc} (86%) rename source/blender/imbuf/intern/{stereoimbuf.c => stereoimbuf.cc} (94%) rename source/blender/imbuf/intern/{thumbs.c => thumbs.cc} (90%) rename source/blender/imbuf/intern/{thumbs_blend.c => thumbs_blend.cc} (89%) rename source/blender/imbuf/intern/{thumbs_font.c => thumbs_font.cc} (98%) rename source/blender/imbuf/intern/{util.c => util.cc} (92%) rename source/blender/imbuf/intern/{util_gpu.c => util_gpu.cc} (93%) rename source/blender/imbuf/intern/{webp.c => webp.cc} (82%) rename source/blender/imbuf/intern/{writeimage.c => writeimage.cc} (90%) delete mode 100644 source/blender/render/intern/pipeline.h create mode 100644 source/blender/render/intern/pipeline.hh diff --git a/.clang-format b/.clang-format index 71ce9e68e44..17196f7ddab 100644 --- a/.clang-format +++ b/.clang-format @@ -62,7 +62,7 @@ ContinuationIndentWidth: 4 BreakBeforeBraces: Custom BraceWrapping: { AfterClass: 'false', - AfterControlStatement: 'false', + AfterControlStatement: 'MultiLine', AfterEnum : 'false', AfterFunction : 'true', AfterNamespace : 'false', diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h index c01c361d175..185cd9df38b 100644 --- a/intern/clog/CLG_log.h +++ b/intern/clog/CLG_log.h @@ -156,7 +156,8 @@ int CLG_color_support_get(CLG_LogRef *clg_ref); { \ CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \ - (severity >= CLG_SEVERITY_WARN)) { \ + (severity >= CLG_SEVERITY_WARN)) \ + { \ CLG_logf(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, __VA_ARGS__); \ } \ } \ @@ -166,7 +167,8 @@ int CLG_color_support_get(CLG_LogRef *clg_ref); { \ CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \ - (severity >= CLG_SEVERITY_WARN)) { \ + (severity >= CLG_SEVERITY_WARN)) \ + { \ CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, str); \ } \ } \ @@ -176,7 +178,8 @@ int CLG_color_support_get(CLG_LogRef *clg_ref); { \ CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \ if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \ - (severity >= CLG_SEVERITY_WARN)) { \ + (severity >= CLG_SEVERITY_WARN)) \ + { \ const char *_str = str; \ CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, _str); \ MEM_freeN((void *)_str); \ diff --git a/intern/clog/clog.c b/intern/clog/clog.c index 7e9a36c2b14..fb87a169043 100644 --- a/intern/clog/clog.c +++ b/intern/clog/clog.c @@ -316,7 +316,8 @@ static bool clg_ctx_filter_check(CLogContext *ctx, const char *identifier) } else if ((len >= 2) && (STREQLEN(".*", &flt->match[len - 2], 2))) { if (((identifier_len == len - 2) && STREQLEN(identifier, flt->match, len - 2)) || - ((identifier_len >= len - 1) && STREQLEN(identifier, flt->match, len - 1))) { + ((identifier_len >= len - 1) && STREQLEN(identifier, flt->match, len - 1))) + { return (bool)i; } } diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 8b40adc8d92..8e1ba65458f 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -511,7 +511,8 @@ static void options_parse(int argc, const char **argv) exit(EXIT_FAILURE); } else if (options.scene_params.shadingsystem == SHADINGSYSTEM_OSL && - options.session_params.device.type != DEVICE_CPU) { + options.session_params.device.type != DEVICE_CPU) + { fprintf(stderr, "OSL shading system only works with CPU device\n"); exit(EXIT_FAILURE); } diff --git a/intern/cycles/app/oiio_output_driver.cpp b/intern/cycles/app/oiio_output_driver.cpp index 9bd164fb953..928313f3855 100644 --- a/intern/cycles/app/oiio_output_driver.cpp +++ b/intern/cycles/app/oiio_output_driver.cpp @@ -59,7 +59,8 @@ void OIIOOutputDriver::write_render_tile(const Tile &tile) /* Apply gamma correction for (some) non-linear file formats. * TODO: use OpenColorIO view transform if available. */ if (ColorSpaceManager::detect_known_colorspace( - u_colorspace_auto, "", image_output->format_name(), true) == u_colorspace_srgb) { + u_colorspace_auto, "", image_output->format_name(), true) == u_colorspace_srgb) + { const float g = 1.0f / 2.2f; ImageBufAlgo::pow(image_buffer, image_buffer, {g, g, g, 1.0f}); } diff --git a/intern/cycles/app/opengl/window.cpp b/intern/cycles/app/opengl/window.cpp index f3352decd08..9166d7140c0 100644 --- a/intern/cycles/app/opengl/window.cpp +++ b/intern/cycles/app/opengl/window.cpp @@ -314,7 +314,8 @@ void window_main_loop(const char *title, } else if (event.type == SDL_WINDOWEVENT) { if (event.window.event == SDL_WINDOWEVENT_RESIZED || - event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { + event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) + { window_reshape(event.window.data1, event.window.data2); } } diff --git a/intern/cycles/blender/camera.cpp b/intern/cycles/blender/camera.cpp index d7def9fdb7c..0cdf395e12c 100644 --- a/intern/cycles/blender/camera.cpp +++ b/intern/cycles/blender/camera.cpp @@ -432,7 +432,8 @@ static void blender_camera_sync(Camera *cam, /* panorama sensor */ if (bcam->type == CAMERA_PANORAMA && (bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID || - bcam->panorama_type == PANORAMA_FISHEYE_LENS_POLYNOMIAL)) { + bcam->panorama_type == PANORAMA_FISHEYE_LENS_POLYNOMIAL)) + { float fit_xratio = (float)bcam->render_width * bcam->pixelaspect.x; float fit_yratio = (float)bcam->render_height * bcam->pixelaspect.y; bool horizontal_fit; diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index 411eb16cd9d..b9a76a4960a 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -55,13 +55,15 @@ static bool ObtainCacheParticleData( for (BL::Modifier &b_mod : b_ob->modifiers) { if ((b_mod.type() == b_mod.type_PARTICLE_SYSTEM) && - (background ? b_mod.show_render() : b_mod.show_viewport())) { + (background ? b_mod.show_render() : b_mod.show_viewport())) + { BL::ParticleSystemModifier psmd((const PointerRNA)b_mod.ptr); BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr); BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr); if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && - (b_part.type() == BL::ParticleSettings::type_HAIR)) { + (b_part.type() == BL::ParticleSettings::type_HAIR)) + { int shader = clamp(b_part.material() - 1, 0, hair->get_used_shaders().size() - 1); int display_step = background ? b_part.render_step() : b_part.display_step(); int totparts = b_psys.particles.length(); @@ -150,13 +152,15 @@ static bool ObtainCacheParticleUV(Hair *hair, for (BL::Modifier &b_mod : b_ob->modifiers) { if ((b_mod.type() == b_mod.type_PARTICLE_SYSTEM) && - (background ? b_mod.show_render() : b_mod.show_viewport())) { + (background ? b_mod.show_render() : b_mod.show_viewport())) + { BL::ParticleSystemModifier psmd((const PointerRNA)b_mod.ptr); BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr); BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr); if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && - (b_part.type() == BL::ParticleSettings::type_HAIR)) { + (b_part.type() == BL::ParticleSettings::type_HAIR)) + { int totparts = b_psys.particles.length(); int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * @@ -212,13 +216,15 @@ static bool ObtainCacheParticleVcol(Hair *hair, for (BL::Modifier &b_mod : b_ob->modifiers) { if ((b_mod.type() == b_mod.type_PARTICLE_SYSTEM) && - (background ? b_mod.show_render() : b_mod.show_viewport())) { + (background ? b_mod.show_render() : b_mod.show_viewport())) + { BL::ParticleSystemModifier psmd((const PointerRNA)b_mod.ptr); BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr); BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr); if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && - (b_part.type() == BL::ParticleSettings::type_HAIR)) { + (b_part.type() == BL::ParticleSettings::type_HAIR)) + { int totparts = b_psys.particles.length(); int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * @@ -283,7 +289,8 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa for (int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { for (int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; - curve++) { + curve++) + { num_keys += CData->curve_keynum[curve]; num_curves++; } @@ -298,12 +305,14 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa for (int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { for (int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; - curve++) { + curve++) + { size_t num_curve_keys = 0; for (int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; - curvekey++) { + curvekey++) + { const float3 ickey_loc = CData->curvekey_co[curvekey]; const float curve_time = CData->curvekey_time[curvekey]; const float curve_length = CData->curve_length[curve]; @@ -311,7 +320,8 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa float radius = shaperadius( CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], time); if (CData->psys_closetip[sys] && - (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)) { + (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)) + { radius = 0.0f; } hair->add_curve_key(ickey_loc, radius); @@ -433,7 +443,8 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int for (int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { for (int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; - curve++) { + curve++) + { /* Curve lengths may not match! Curves can be clipped. */ int curve_key_end = (num_curves + 1 < (int)hair->get_curve_first_key().size() ? hair->get_curve_first_key()[num_curves + 1] : @@ -444,7 +455,8 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int if (!is_num_keys_different) { for (int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; - curvekey++) { + curvekey++) + { if (i < hair->get_curve_keys().size()) { mP[i] = CurveSegmentMotionCV(CData, sys, curve, curvekey); if (!have_motion) { @@ -489,13 +501,15 @@ bool BlenderSync::object_has_particle_hair(BL::Object b_ob) /* Test if the object has a particle modifier with hair. */ for (BL::Modifier &b_mod : b_ob.modifiers) { if ((b_mod.type() == b_mod.type_PARTICLE_SYSTEM) && - (preview ? b_mod.show_viewport() : b_mod.show_render())) { + (preview ? b_mod.show_viewport() : b_mod.show_render())) + { BL::ParticleSystemModifier psmd((const PointerRNA)b_mod.ptr); BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr); BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr); if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && - (b_part.type() == BL::ParticleSettings::type_HAIR)) { + (b_part.type() == BL::ParticleSettings::type_HAIR)) + { return true; } } @@ -677,7 +691,8 @@ static void fill_generic_attribute(const int num_curves, static void attr_create_motion(Hair *hair, BL::Attribute &b_attribute, const float motion_scale) { if (!(b_attribute.domain() == BL::Attribute::domain_POINT) && - (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) { + (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) + { return; } @@ -748,7 +763,8 @@ static void attr_create_generic(Scene *scene, /* Weak, use first float2 attribute as standard UV. */ if (need_uv && !have_uv && b_data_type == BL::Attribute::data_type_FLOAT2 && - b_domain == BL::Attribute::domain_CURVE) { + b_domain == BL::Attribute::domain_CURVE) + { attr_create_uv(attributes, num_curves, num_keys, b_attribute, name); have_uv = true; continue; @@ -1100,7 +1116,8 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H for (const SocketType &socket : new_hair.type->inputs) { /* Those sockets are updated in sync_object, so do not modify them. */ if (socket.name == "use_motion_blur" || socket.name == "motion_steps" || - socket.name == "used_shaders") { + socket.name == "used_shaders") + { continue; } hair->set_value(socket, new_hair, socket); diff --git a/intern/cycles/blender/device.cpp b/intern/cycles/blender/device.cpp index 4e1f77eb9cb..3059035f320 100644 --- a/intern/cycles/blender/device.cpp +++ b/intern/cycles/blender/device.cpp @@ -115,7 +115,8 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences, bool accumulated_use_hardware_raytracing = false; foreach ( DeviceInfo &info, - (device.multi_devices.size() != 0 ? device.multi_devices : vector({device}))) { + (device.multi_devices.size() != 0 ? device.multi_devices : vector({device}))) + { if (info.type == DEVICE_METAL && !get_boolean(cpreferences, "use_metalrt")) { info.use_hardware_raytracing = false; } diff --git a/intern/cycles/blender/display_driver.cpp b/intern/cycles/blender/display_driver.cpp index 2dbbefe43c5..918f52cbd29 100644 --- a/intern/cycles/blender/display_driver.cpp +++ b/intern/cycles/blender/display_driver.cpp @@ -312,7 +312,8 @@ class DisplayGPUPixelBuffer { /* Try to re-use the existing PBO if it has usable size. */ if (gpu_pixel_buffer) { if (new_width != width || new_height != height || - GPU_pixel_buffer_size(gpu_pixel_buffer) < required_size) { + GPU_pixel_buffer_size(gpu_pixel_buffer) < required_size) + { gpu_resources_destroy(); } } @@ -513,7 +514,8 @@ bool BlenderDisplayDriver::update_begin(const Params ¶ms, const int buffer_height = params.size.y; if (!current_tile_buffer_object.gpu_resources_ensure(buffer_width, buffer_height) || - !current_tile.texture.gpu_resources_ensure(texture_width, texture_height)) { + !current_tile.texture.gpu_resources_ensure(texture_width, texture_height)) + { tiles_->current_tile.gpu_resources_destroy(); gpu_context_disable(); return false; @@ -563,7 +565,8 @@ void BlenderDisplayDriver::update_end() * renders while Blender is drawing. As a workaround update texture during draw, under assumption * that there is no graphics interop on macOS and viewport render has a single tile. */ if (!background_ && - GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY)) { + GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY)) + { tiles_->current_tile.need_update_texture_pixels = true; } else { @@ -708,7 +711,8 @@ static void draw_tile(const float2 &zoom, GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0); } else if (zoomed_width - draw_tile.params.size.x > 0.5f || - zoomed_height - draw_tile.params.size.y > 0.5f) { + zoomed_height - draw_tile.params.size.y > 0.5f) + { GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0); } else { diff --git a/intern/cycles/blender/geometry.cpp b/intern/cycles/blender/geometry.cpp index fc03ca6e489..5a064a5cea7 100644 --- a/intern/cycles/blender/geometry.cpp +++ b/intern/cycles/blender/geometry.cpp @@ -28,7 +28,8 @@ static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_parti if (b_ob_info.object_data.is_a(&RNA_Volume) || (b_ob_info.object_data == b_ob_info.real_object.data() && - object_fluid_gas_domain_find(b_ob_info.real_object))) { + object_fluid_gas_domain_find(b_ob_info.real_object))) + { return Geometry::VOLUME; } @@ -192,7 +193,8 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph, Geometry *geom = object->get_geometry(); if (geometry_motion_synced.find(geom) != geometry_motion_synced.end() || - geometry_motion_attribute_synced.find(geom) != geometry_motion_attribute_synced.end()) { + geometry_motion_attribute_synced.find(geom) != geometry_motion_attribute_synced.end()) + { return; } @@ -218,7 +220,8 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph, sync_hair_motion(b_depsgraph, b_ob_info, hair, motion_step); } else if (b_ob_info.object_data.is_a(&RNA_Volume) || - object_fluid_gas_domain_find(b_ob_info.real_object)) { + object_fluid_gas_domain_find(b_ob_info.real_object)) + { /* No volume motion blur support yet. */ } else if (b_ob_info.object_data.is_a(&RNA_PointCloud)) { diff --git a/intern/cycles/blender/light.cpp b/intern/cycles/blender/light.cpp index 49545047d9e..19cde43115d 100644 --- a/intern/cycles/blender/light.cpp +++ b/intern/cycles/blender/light.cpp @@ -169,7 +169,8 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal) ObjectKey key(b_world, 0, b_world, false); if (light_map.add_or_update(&light, b_world, b_world, key) || world_recalc || - b_world.ptr.data != world_map) { + b_world.ptr.data != world_map) + { light->set_light_type(LIGHT_BACKGROUND); if (sampling_method == SAMPLING_MANUAL) { light->set_map_resolution(get_int(cworld, "sample_map_resolution")); diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index 636ba94eaa8..b0302cbfeca 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -337,7 +337,8 @@ static void fill_generic_attribute(BL::Mesh &b_mesh, static void attr_create_motion(Mesh *mesh, BL::Attribute &b_attribute, const float motion_scale) { if (!(b_attribute.domain() == BL::Attribute::domain_POINT) && - (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) { + (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) + { return; } @@ -384,7 +385,8 @@ static void attr_create_generic(Scene *scene, } if (!(mesh->need_attribute(scene, name) || - (is_render_color && mesh->need_attribute(scene, ATTR_STD_VERTEX_COLOR)))) { + (is_render_color && mesh->need_attribute(scene, ATTR_STD_VERTEX_COLOR)))) + { continue; } if (attributes.find(name)) { @@ -741,13 +743,15 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b const float3 &vert_co = mesh->get_verts()[vert_index]; bool found = false; for (int other_sorted_vert_index = sorted_vert_index + 1; other_sorted_vert_index < num_verts; - ++other_sorted_vert_index) { + ++other_sorted_vert_index) + { const int other_vert_index = sorted_vert_indeices[other_sorted_vert_index]; const float3 &other_vert_co = mesh->get_verts()[other_vert_index]; /* We are too far away now, we wouldn't have duplicate. */ if ((other_vert_co.x + other_vert_co.y + other_vert_co.z) - (vert_co.x + vert_co.y + vert_co.z) > - 3 * FLT_EPSILON) { + 3 * FLT_EPSILON) + { break; } /* Found duplicate. */ @@ -1325,7 +1329,8 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, M for (const SocketType &socket : new_mesh.type->inputs) { /* Those sockets are updated in sync_object, so do not modify them. */ if (socket.name == "use_motion_blur" || socket.name == "motion_steps" || - socket.name == "used_shaders") { + socket.name == "used_shaders") + { continue; } mesh->set_value(socket, new_mesh, socket); diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index 5af1e18a597..815a8b37846 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -63,7 +63,8 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info) BL::Object::type_enum type = b_ob_info.iter_object.type(); if (type == BL::Object::type_VOLUME || type == BL::Object::type_CURVES || - type == BL::Object::type_POINTCLOUD) { + type == BL::Object::type_POINTCLOUD) + { /* Will be exported attached to mesh. */ return true; } @@ -325,7 +326,8 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph, * transform comparison should not be needed, but duplis don't work perfect * in the depsgraph and may not signal changes, so this is a workaround */ if (object->is_modified() || object_updated || - (object->get_geometry() && object->get_geometry()->is_modified())) { + (object->get_geometry() && object->get_geometry()->is_modified())) + { object->name = b_ob.name().c_str(); object->set_pass_id(b_ob.pass_index()); const BL::Array object_color = b_ob.color(); @@ -408,7 +410,8 @@ bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance BlenderAttributeType type = blender_attribute_name_split_type(name, &real_name); if (type == BL::ShaderNodeAttribute::attribute_type_OBJECT || - type == BL::ShaderNodeAttribute::attribute_type_INSTANCER) { + type == BL::ShaderNodeAttribute::attribute_type_INSTANCER) + { bool use_instancer = (type == BL::ShaderNodeAttribute::attribute_type_INSTANCER); float4 value = lookup_instance_property(b_instance, real_name, use_instancer); @@ -556,7 +559,8 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, for (b_depsgraph.object_instances.begin(b_instance_iter); b_instance_iter != b_depsgraph.object_instances.end() && !cancel; - ++b_instance_iter) { + ++b_instance_iter) + { BL::DepsgraphObjectInstance b_instance = *b_instance_iter; BL::Object b_ob = b_instance.object(); @@ -667,7 +671,8 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render, float frame_center_delta = 0.0f; if (scene->need_motion() != Scene::MOTION_PASS && - scene->camera->get_motion_position() != MOTION_POSITION_CENTER) { + scene->camera->get_motion_position() != MOTION_POSITION_CENTER) + { float shuttertime = scene->camera->get_shuttertime(); if (scene->camera->get_motion_position() == MOTION_POSITION_END) { frame_center_delta = -shuttertime * 0.5f; diff --git a/intern/cycles/blender/pointcloud.cpp b/intern/cycles/blender/pointcloud.cpp index 32caebc0358..36c313642df 100644 --- a/intern/cycles/blender/pointcloud.cpp +++ b/intern/cycles/blender/pointcloud.cpp @@ -21,7 +21,8 @@ static void attr_create_motion(PointCloud *pointcloud, const float motion_scale) { if (!(b_attribute.domain() == BL::Attribute::domain_POINT) && - (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) { + (b_attribute.data_type() == BL::Attribute::data_type_FLOAT_VECTOR)) + { return; } @@ -313,7 +314,8 @@ void BlenderSync::sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info for (const SocketType &socket : new_pointcloud.type->inputs) { /* Those sockets are updated in sync_object, so do not modify them. */ if (socket.name == "use_motion_blur" || socket.name == "motion_steps" || - socket.name == "used_shaders") { + socket.name == "used_shaders") + { continue; } pointcloud->set_value(socket, new_pointcloud, socket); diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp index 1afd1e9bd1c..8ca984078bb 100644 --- a/intern/cycles/blender/python.cpp +++ b/intern/cycles/blender/python.cpp @@ -163,7 +163,8 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) &pyregion, &pyv3d, &pyrv3d, - &preview_osl)) { + &preview_osl)) + { return NULL; } @@ -522,7 +523,8 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args) } else if (param->type.vecsemantics == TypeDesc::POINT || param->type.vecsemantics == TypeDesc::VECTOR || - param->type.vecsemantics == TypeDesc::NORMAL) { + param->type.vecsemantics == TypeDesc::NORMAL) + { socket_type = "NodeSocketVector"; data_type = BL::NodeSocket::type_VECTOR; @@ -738,7 +740,8 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key &pyscene, &pyviewlayer, &pyinput, - &pyoutput)) { + &pyoutput)) + { return NULL; } diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index 6c865c2f9b0..417c0b54d00 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -202,7 +202,8 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg b_scene, background, use_developer_ui); if (scene->params.modified(scene_params) || session->params.modified(session_params) || - !this->b_render.use_persistent_data()) { + !this->b_render.use_persistent_data()) + { /* if scene or session parameters changed, it's easier to simply re-create * them rather than trying to distinguish which settings need to be updated */ @@ -376,8 +377,8 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_) } int view_index = 0; - for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); - ++b_view_iter, ++view_index) { + for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) + { b_rview_name = b_view_iter->name(); buffer_params.layer = b_view_layer.name(); @@ -562,7 +563,8 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type_str, const int /* Light component passes. */ else if (strcmp(bake_type, "DIFFUSE") == 0) { if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) && - bake_filter & BL::BakeSettings::pass_filter_INDIRECT) { + bake_filter & BL::BakeSettings::pass_filter_INDIRECT) + { type = PASS_DIFFUSE; use_direct_light = true; use_indirect_light = true; @@ -583,7 +585,8 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type_str, const int } else if (strcmp(bake_type, "GLOSSY") == 0) { if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) && - bake_filter & BL::BakeSettings::pass_filter_INDIRECT) { + bake_filter & BL::BakeSettings::pass_filter_INDIRECT) + { type = PASS_GLOSSY; use_direct_light = true; use_indirect_light = true; @@ -604,7 +607,8 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type_str, const int } else if (strcmp(bake_type, "TRANSMISSION") == 0) { if ((bake_filter & BL::BakeSettings::pass_filter_DIRECT) && - bake_filter & BL::BakeSettings::pass_filter_INDIRECT) { + bake_filter & BL::BakeSettings::pass_filter_INDIRECT) + { type = PASS_TRANSMISSION; use_direct_light = true; use_indirect_light = true; diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp index 813d7a95964..ecf4384aee7 100644 --- a/intern/cycles/blender/shader.cpp +++ b/intern/cycles/blender/shader.cpp @@ -1246,7 +1246,8 @@ static void add_nodes(Scene *scene, } } else if (b_node.is_a(&RNA_ShaderNodeGroup) || b_node.is_a(&RNA_NodeCustomGroup) || - b_node.is_a(&RNA_ShaderNodeCustomGroup)) { + b_node.is_a(&RNA_ShaderNodeCustomGroup)) + { BL::ShaderNodeTree b_group_ntree(PointerRNA_NULL); if (b_node.is_a(&RNA_ShaderNodeGroup)) @@ -1382,7 +1383,8 @@ static void add_nodes(Scene *scene, /* Ignore invalid links to avoid unwanted cycles created in graph. * Also ignore links with unavailable sockets. */ if (!(b_link.is_valid() && b_link.from_socket().enabled() && b_link.to_socket().enabled()) || - b_link.is_muted()) { + b_link.is_muted()) + { continue; } /* get blender link data */ @@ -1531,7 +1533,8 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all) /* test if we need to sync */ if (shader_map.add_or_update(&shader, b_mat) || update_all || - scene_attr_needs_recalc(shader, b_depsgraph)) { + scene_attr_needs_recalc(shader, b_depsgraph)) + { ShaderGraph *graph = new ShaderGraph(); shader->name = b_mat.name().c_str(); @@ -1614,12 +1617,14 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, if (world_recalc || update_all || b_world.ptr.data != world_map || viewport_parameters.shader_modified(new_viewport_parameters) || - scene_attr_needs_recalc(shader, b_depsgraph)) { + scene_attr_needs_recalc(shader, b_depsgraph)) + { ShaderGraph *graph = new ShaderGraph(); /* create nodes */ if (new_viewport_parameters.use_scene_world && b_world && b_world.use_nodes() && - b_world.node_tree()) { + b_world.node_tree()) + { BL::ShaderNodeTree b_ntree(b_world.node_tree()); add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree); @@ -1781,7 +1786,8 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all) /* test if we need to sync */ if (shader_map.add_or_update(&shader, b_light) || update_all || - scene_attr_needs_recalc(shader, b_depsgraph)) { + scene_attr_needs_recalc(shader, b_depsgraph)) + { ShaderGraph *graph = new ShaderGraph(); /* create nodes */ diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index 9ae886f8c9f..40979dfda0b 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -169,7 +169,8 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } if (updated_geometry || - (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { + (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) + { BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); geometry_map.set_recalc(key); @@ -277,7 +278,8 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, geometry_synced.clear(); /* use for objects and motion sync */ if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE || - scene->camera->get_motion_position() == MOTION_POSITION_CENTER) { + scene->camera->get_motion_position() == MOTION_POSITION_CENTER) + { sync_objects(b_depsgraph, b_v3d); } sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state); @@ -445,7 +447,8 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background) /* No denoising support for vertex color baking, vertices packed into image * buffer have no relation to neighbors. */ if (scene->bake_manager->get_baking() && - b_scene.render().bake().target() != BL::BakeSettings::target_IMAGE_TEXTURES) { + b_scene.render().bake().target() != BL::BakeSettings::target_IMAGE_TEXTURES) + { denoise_params.use = false; } @@ -709,7 +712,8 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v BL::ViewLayer::lightgroups_iterator b_lightgroup_iter; for (b_view_layer.lightgroups.begin(b_lightgroup_iter); b_lightgroup_iter != b_view_layer.lightgroups.end(); - ++b_lightgroup_iter) { + ++b_lightgroup_iter) + { BL::Lightgroup b_lightgroup(*b_lightgroup_iter); string name = string_printf("Combined_%s", b_lightgroup.name().c_str()); @@ -732,7 +736,8 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v } if (pass_type == PASS_MOTION && - (b_view_layer.use_motion_blur() && b_scene.render().use_motion_blur())) { + (b_view_layer.use_motion_blur() && b_scene.render().use_motion_blur())) + { continue; } diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h index 7394fa5ba51..c216ef1639c 100644 --- a/intern/cycles/blender/util.h +++ b/intern/cycles/blender/util.h @@ -21,8 +21,12 @@ extern "C" { void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra); -void BKE_image_user_file_path_ex( - void *bmain, void *iuser, void *ima, char *path, bool resolve_udim, bool resolve_multiview); +void BKE_image_user_file_path_ex(void *bmain, + void *iuser, + void *ima, + char *filepath, + bool resolve_udim, + bool resolve_multiview); unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile); float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile); } @@ -588,7 +592,8 @@ static inline BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b BL::FluidModifier b_mmd(b_mod); if (b_mmd.fluid_type() == BL::FluidModifier::fluid_type_DOMAIN && - b_mmd.domain_settings().domain_type() == BL::FluidDomainSettings::domain_type_GAS) { + b_mmd.domain_settings().domain_type() == BL::FluidDomainSettings::domain_type_GAS) + { return b_mmd.domain_settings(); } } @@ -637,7 +642,8 @@ static inline Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob, bool enabled = preview ? mod.show_viewport() : mod.show_render(); if (enabled && mod.type() == BL::Modifier::type_SUBSURF && - RNA_boolean_get(&cobj, "use_adaptive_subdivision")) { + RNA_boolean_get(&cobj, "use_adaptive_subdivision")) + { BL::SubsurfModifier subsurf(mod); if (subsurf.subdivision_type() == BL::SubsurfModifier::subdivision_type_CATMULL_CLARK) { diff --git a/intern/cycles/blender/volume.cpp b/intern/cycles/blender/volume.cpp index 61b2f9ee276..864ddd28c10 100644 --- a/intern/cycles/blender/volume.cpp +++ b/intern/cycles/blender/volume.cpp @@ -35,7 +35,8 @@ class BlenderSmokeLoader : public ImageLoader { } if (attribute == ATTR_STD_VOLUME_DENSITY || attribute == ATTR_STD_VOLUME_FLAME || - attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) { + attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) + { metadata.type = IMAGE_DATA_TYPE_FLOAT; metadata.channels = 1; } @@ -315,24 +316,29 @@ static void sync_volume_object(BL::BlendData &b_data, std = ATTR_STD_VOLUME_TEMPERATURE; } else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) || - name == b_volume.velocity_grid()) { + name == b_volume.velocity_grid()) + { std = ATTR_STD_VOLUME_VELOCITY; } else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY_X) || - name == b_volume.velocity_x_grid()) { + name == b_volume.velocity_x_grid()) + { std = ATTR_STD_VOLUME_VELOCITY_X; } else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY_Y) || - name == b_volume.velocity_y_grid()) { + name == b_volume.velocity_y_grid()) + { std = ATTR_STD_VOLUME_VELOCITY_Y; } else if (name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY_Z) || - name == b_volume.velocity_z_grid()) { + name == b_volume.velocity_z_grid()) + { std = ATTR_STD_VOLUME_VELOCITY_Z; } if ((std != ATTR_STD_NONE && volume->need_attribute(scene, std)) || - volume->need_attribute(scene, name)) { + volume->need_attribute(scene, name)) + { Attribute *attr = (std != ATTR_STD_NONE) ? volume->attributes.add(std) : volume->attributes.add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL); diff --git a/intern/cycles/bvh/build.cpp b/intern/cycles/bvh/build.cpp index dd3b7954e11..e4aaf19abef 100644 --- a/intern/cycles/bvh/build.cpp +++ b/intern/cycles/bvh/build.cpp @@ -689,7 +689,8 @@ BVHNode *BVHBuild::build_node(const BVHObjectBinning &range, int level) if (!(range.size() > 0 && params.top_level && level == 0)) { /* Make leaf node when threshold reached or SAH tells us. */ if ((params.small_enough_for_leaf(size, level)) || - (range_within_max_leaf_size(range, references) && leafSAH < splitSAH)) { + (range_within_max_leaf_size(range, references) && leafSAH < splitSAH)) + { return create_leaf_node(range, references); } } @@ -708,7 +709,8 @@ BVHNode *BVHBuild::build_node(const BVHObjectBinning &range, int level) unalignedLeafSAH = params.sah_primitive_cost * unaligned_range.leafSAH; if (!(range.size() > 0 && params.top_level && level == 0)) { if (unalignedLeafSAH < unalignedSplitSAH && unalignedSplitSAH < splitSAH && - range_within_max_leaf_size(range, references)) { + range_within_max_leaf_size(range, references)) + { return create_leaf_node(range, references); } } diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index a6d3d3557eb..bbda58f5f9b 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -516,7 +516,8 @@ void BVH2::pack_instances(size_t nodes_size, size_t leaf_nodes_size) pack.object_node.resize(objects.size()); if (params.num_motion_curve_steps > 0 || params.num_motion_triangle_steps > 0 || - params.num_motion_point_steps > 0) { + params.num_motion_point_steps > 0) + { pack.prim_time.resize(prim_index_size); } diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index 514a15d9295..e2712ae45d7 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -269,7 +269,8 @@ void CPUDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, boo #ifdef WITH_EMBREE if (bvh->params.bvh_layout == BVH_LAYOUT_EMBREE || bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE || - bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) { + bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + { BVHEmbree *const bvh_embree = static_cast(bvh); if (refit) { bvh_embree->refit(progress); diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index 8c629b77885..b16c3c62349 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -88,7 +88,7 @@ class CPUDevice : public Device { vector &kernel_thread_globals) override; virtual void *get_cpu_osl_memory() override; - virtual void upload_changed() override {} ; + virtual void upload_changed(vector ) override {} ; protected: virtual bool load_kernels(uint /*kernel_features*/) override; }; diff --git a/intern/cycles/device/cuda/device.cpp b/intern/cycles/device/cuda/device.cpp index 5a213c45b71..b49ee1f8205 100644 --- a/intern/cycles/device/cuda/device.cpp +++ b/intern/cycles/device/cuda/device.cpp @@ -75,10 +75,12 @@ Device *device_cuda_create(const DeviceInfo &info, Stats &stats, Profiler &profi static CUresult device_cuda_safe_init() { # ifdef _WIN32 - __try { + __try + { return cuInit(0); } - __except (EXCEPTION_EXECUTE_HANDLER) { + __except (EXCEPTION_EXECUTE_HANDLER) + { /* Ignore crashes inside the CUDA driver and hope we can * survive even with corrupted CUDA installs. */ fprintf(stderr, "Cycles CUDA: driver crashed, continuing without CUDA.\n"); diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index bfdae9d1356..552e40b6909 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -333,7 +333,8 @@ string CUDADevice::compile_kernel(const string &common_cflags, return string(); } else if (!(nvcc_cuda_version == 101 || nvcc_cuda_version == 102 || nvcc_cuda_version == 111 || - nvcc_cuda_version == 112 || nvcc_cuda_version == 113 || nvcc_cuda_version == 114)) { + nvcc_cuda_version == 112 || nvcc_cuda_version == 113 || nvcc_cuda_version == 114)) + { printf( "CUDA version %d.%d detected, build may succeed but only " "CUDA 10.1 to 11.4 are officially supported.\n", @@ -864,7 +865,8 @@ void CUDADevice::tex_alloc(device_texture &mem) if (mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FLOAT && mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FLOAT3 && mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FPN && - mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FP16) { + mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FP16) + { CUDA_RESOURCE_DESC resDesc; memset(&resDesc, 0, sizeof(resDesc)); diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index f2631d78276..248a95f413f 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -645,16 +645,16 @@ void GPUDevice::move_textures_to_host(size_t size, bool for_texture) load_texture_info(); } -void Device::register_buffer(device_memory *mem) -{ - VLOG_INFO << "Register buffer " << mem->name; - /* Insert into set of buffers. */ - thread_scoped_lock lock(device_buffer_mutex); - device_buffers.insert(mem); -} +// void Device::register_buffer(device_memory *mem) +// { +// VLOG_INFO << "Register buffer " << mem->name; +// /* Insert into set of buffers. */ +// thread_scoped_lock lock(device_buffer_mutex); +// device_buffers.insert(mem); +// } -void Device::upload_changed() { - for (const auto& buffer : device_buffers) { +void Device::upload_changed(vector buffers) { + for (const auto& buffer : buffers) { VLOG_INFO << "Checking " << buffer->name; if(buffer->modified) { VLOG_INFO << "Uploading to " << buffer->name; @@ -761,7 +761,8 @@ GPUDevice::Mem *GPUDevice::generic_alloc(device_memory &mem, size_t pitch_paddin * since other devices might be using the memory. */ if (!move_texture_to_host && pitch_padding == 0 && mem.host_pointer && - mem.host_pointer != shared_pointer) { + mem.host_pointer != shared_pointer) + { memcpy(shared_pointer, mem.host_pointer, size); /* A Call to device_memory::host_free() should be preceded by diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 8823a326e85..f15b0d812bf 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -121,8 +121,8 @@ class DeviceInfo { class Device { friend class device_sub_ptr; - thread_mutex device_buffer_mutex; - set device_buffers; + //thread_mutex device_buffer_mutex; + //set device_buffers; protected: Device(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_) : info(info_), stats(stats_), profiler(profiler_) @@ -298,9 +298,9 @@ protected: /* * Upload to the device any buffers that have changed */ - virtual void upload_changed(); + virtual void upload_changed(vector buffers); - virtual void register_buffer(device_memory *); + //virtual void register_buffer(device_memory *); protected: /* Memory allocation, only accessed through device_memory. */ friend class MultiDevice; diff --git a/intern/cycles/device/dummy/device.cpp b/intern/cycles/device/dummy/device.cpp index 8e682c12c3c..b3192ca8897 100644 --- a/intern/cycles/device/dummy/device.cpp +++ b/intern/cycles/device/dummy/device.cpp @@ -36,7 +36,7 @@ class DummyDevice : public Device { virtual void mem_free(device_memory &) override {} virtual void const_copy_to(const char *, void *, size_t) override {} - virtual void upload_changed() override {} + virtual void upload_changed(vector) override {} }; Device *device_dummy_create(const DeviceInfo &info, Stats &stats, Profiler &profiler) diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp index b982dd39ed3..7a4b6db88d6 100644 --- a/intern/cycles/device/hip/device.cpp +++ b/intern/cycles/device/hip/device.cpp @@ -91,10 +91,12 @@ Device *device_hip_create(const DeviceInfo &info, Stats &stats, Profiler &profil static hipError_t device_hip_safe_init() { # ifdef _WIN32 - __try { + __try + { return hipInit(0); } - __except (EXCEPTION_EXECUTE_HANDLER) { + __except (EXCEPTION_EXECUTE_HANDLER) + { /* Ignore crashes inside the HIP driver and hope we can * survive even with corrupted HIP installs. */ fprintf(stderr, "Cycles HIP: driver crashed, continuing without HIP.\n"); diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index d64931ea7e0..f366902e8bd 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -822,7 +822,8 @@ void HIPDevice::tex_alloc(device_texture &mem) if (mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FLOAT && mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FLOAT3 && mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FPN && - mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FP16) { + mem.info.data_type != IMAGE_DATA_TYPE_NANOVDB_FP16) + { /* Bindless textures. */ hipResourceDesc resDesc; memset(&resDesc, 0, sizeof(resDesc)); diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp index beb255deba4..5d5c2d6b2a2 100644 --- a/intern/cycles/device/hiprt/device_impl.cpp +++ b/intern/cycles/device/hiprt/device_impl.cpp @@ -387,7 +387,8 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_triangle_blas(BVHHIPRT *bvh, Mesh * geom_input.geomType = Triangle; if (mesh->has_motion_blur() && - !(bvh->params.num_motion_triangle_steps == 0 || bvh->params.use_spatial_split)) { + !(bvh->params.num_motion_triangle_steps == 0 || bvh->params.use_spatial_split)) + { const Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); const size_t num_triangles = mesh->num_triangles(); diff --git a/intern/cycles/device/memory.cpp b/intern/cycles/device/memory.cpp index d4649613011..c93392c0c0e 100644 --- a/intern/cycles/device/memory.cpp +++ b/intern/cycles/device/memory.cpp @@ -45,7 +45,7 @@ void *device_memory::host_alloc(size_t size) } void *ptr = device->host_mem_alloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES); - device->register_buffer(this); + if (ptr) { util_guarded_mem_alloc(size); } diff --git a/intern/cycles/device/metal/device_impl.mm b/intern/cycles/device/metal/device_impl.mm index 0b71692c3e2..f1f5b063f3e 100644 --- a/intern/cycles/device/metal/device_impl.mm +++ b/intern/cycles/device/metal/device_impl.mm @@ -1034,8 +1034,7 @@ void MetalDevice::const_copy_to(const char *name, void *host, size_t size) offsetof(KernelParamsMetal, integrator_state), host, size, pointer_block_size); } # define KERNEL_DATA_ARRAY(data_type, tex_name) \ - else if (strcmp(name, #tex_name) == 0) \ - { \ + else if (strcmp(name, #tex_name) == 0) { \ update_launch_pointers(offsetof(KernelParamsMetal, tex_name), host, size, size); \ } # include "kernel/data_arrays.h" @@ -1098,9 +1097,8 @@ void MetalDevice::tex_alloc(device_texture &mem) } MTLStorageMode storage_mode = MTLStorageModeManaged; if (@available(macos 10.15, *)) { - if ([mtlDevice hasUnifiedMemory] && - device_vendor != - METAL_GPU_INTEL) { /* Intel GPUs don't support MTLStorageModeShared for MTLTextures */ + /* Intel GPUs don't support MTLStorageModeShared for MTLTextures. */ + if ([mtlDevice hasUnifiedMemory] && device_vendor != METAL_GPU_INTEL) { storage_mode = MTLStorageModeShared; } } diff --git a/intern/cycles/device/metal/kernel.mm b/intern/cycles/device/metal/kernel.mm index ea0fb6ef3f4..0e3ec43e38d 100644 --- a/intern/cycles/device/metal/kernel.mm +++ b/intern/cycles/device/metal/kernel.mm @@ -263,7 +263,8 @@ bool ShaderCache::should_load_kernel(DeviceKernel device_kernel, if (pso_type != PSO_GENERIC) { /* Only specialize kernels where it can make an impact. */ if (device_kernel < DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST || - device_kernel > DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) { + device_kernel > DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) + { return false; } @@ -400,7 +401,8 @@ bool MetalKernelPipeline::should_use_binary_archive() const if ((device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND && device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) || (device_kernel >= DEVICE_KERNEL_SHADER_EVAL_DISPLACE && - device_kernel <= DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY)) { + device_kernel <= DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY)) + { /* Archive all shade kernels - they take a long time to compile. */ return true; } @@ -704,7 +706,8 @@ void MetalKernelPipeline::compile() if (creating_new_archive && ShaderCache::running) { NSError *error; if (![archive addComputePipelineFunctionsWithDescriptor:computePipelineStateDescriptor - error:&error]) { + error:&error]) + { NSString *errStr = [error localizedDescription]; metal_printf("Failed to add PSO to archive:\n%s\n", errStr ? [errStr UTF8String] : "nil"); diff --git a/intern/cycles/device/metal/queue.mm b/intern/cycles/device/metal/queue.mm index 41f53b79043..0ee710bfe0f 100644 --- a/intern/cycles/device/metal/queue.mm +++ b/intern/cycles/device/metal/queue.mm @@ -893,7 +893,8 @@ id MetalDeviceQueue::get_compute_encoder(DeviceKernel if (mtlComputeEncoder_) { if (mtlComputeEncoder_.dispatchType == concurrent ? MTLDispatchTypeConcurrent : - MTLDispatchTypeSerial) { + MTLDispatchTypeSerial) + { /* declare usage of MTLBuffers etc */ prepare_resources(kernel); diff --git a/intern/cycles/device/metal/util.mm b/intern/cycles/device/metal/util.mm index df4e146f759..f559d298cff 100644 --- a/intern/cycles/device/metal/util.mm +++ b/intern/cycles/device/metal/util.mm @@ -35,7 +35,8 @@ int MetalInfo::get_apple_gpu_core_count(id device) io_service_t gpu_service = IOServiceGetMatchingService( kIOMainPortDefault, IORegistryEntryIDMatching(device.registryID)); if (CFNumberRef numberRef = (CFNumberRef)IORegistryEntryCreateCFProperty( - gpu_service, CFSTR("gpu-core-count"), 0, 0)) { + gpu_service, CFSTR("gpu-core-count"), 0, 0)) + { if (CFGetTypeID(numberRef) == CFNumberGetTypeID()) { CFNumberGetValue(numberRef, kCFNumberSInt32Type, &core_count); } @@ -170,7 +171,8 @@ id MetalBufferPool::get_buffer(id device, /* Check if buffer matches size and storage mode and is old enough to reuse */ if (bufferEntry.buffer.length == length && storageMode == bufferEntry.buffer.storageMode && - cpuCacheMode == bufferEntry.buffer.cpuCacheMode) { + cpuCacheMode == bufferEntry.buffer.cpuCacheMode) + { buffer = bufferEntry.buffer; buffer_free_list.erase(entry); bufferEntry.command_buffer = command_buffer; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index d169c50b292..27f0c908b2d 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -117,7 +117,8 @@ class MultiDevice : public Device { foreach (auto &peer_sub, devices) { if (peer_sub->peer_island_index < 0 && peer_sub->device->info.type == sub->device->info.type && - peer_sub->device->check_peer_access(sub->device.get())) { + peer_sub->device->check_peer_access(sub->device.get())) + { peer_sub->peer_island_index = sub->peer_island_index; peer_islands[sub->peer_island_index].push_back(peer_sub.get()); } @@ -288,7 +289,8 @@ class MultiDevice : public Device { if (owner_sub->ptr_map.find(key) == owner_sub->ptr_map.end()) { foreach (SubDevice *island_sub, peer_islands[sub->peer_island_index]) { if (island_sub != owner_sub && - island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) { + island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) + { owner_sub = island_sub; } } @@ -304,7 +306,8 @@ class MultiDevice : public Device { SubDevice *owner_sub = island.front(); foreach (SubDevice *island_sub, island) { if (key ? (island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) : - (island_sub->device->stats.mem_used < owner_sub->device->stats.mem_used)) { + (island_sub->device->stats.mem_used < owner_sub->device->stats.mem_used)) + { owner_sub = island_sub; } } @@ -482,11 +485,11 @@ class MultiDevice : public Device { } } - virtual void upload_changed() override + virtual void upload_changed(vector buffers) override { //foreach (const vector &island, peer_islands) { parallel_for_each (peer_islands.begin(), peer_islands.end(), [&](const vector &island) { - for (const device_memory *buffer: device_buffers) { + for (const device_memory *buffer: buffers) { VLOG_INFO << "Checking " << buffer->name << " on " << this; if (buffer->modified) { device_ptr existing_key = buffer->device_pointer; diff --git a/intern/cycles/device/oneapi/device_impl.cpp b/intern/cycles/device/oneapi/device_impl.cpp index 1b391a5b98b..e8919346c5b 100644 --- a/intern/cycles/device/oneapi/device_impl.cpp +++ b/intern/cycles/device/oneapi/device_impl.cpp @@ -696,8 +696,7 @@ void OneapiDevice::set_global_memory(SyclQueue *queue_, /* This macro will change global ptr of KernelGlobals via name matching. */ # define KERNEL_DATA_ARRAY(type, name) \ - else if (#name == matched_name) \ - { \ + else if (#name == matched_name) { \ globals->__##name = (type *)memory_device_pointer; \ return; \ } @@ -709,8 +708,7 @@ void OneapiDevice::set_global_memory(SyclQueue *queue_, } KERNEL_DATA_ARRAY(KernelData, data) # include "kernel/data_arrays.h" - else - { + else { std::cerr << "Can't found global/constant memory with name \"" << matched_name << "\"!" << std::endl; assert(false); @@ -823,7 +821,8 @@ std::vector OneapiDevice::available_devices() int driver_build_version = parse_driver_build_version(device); if ((driver_build_version > 100000 && driver_build_version < lowest_supported_driver_version_win) || - driver_build_version < lowest_supported_driver_version_neo) { + driver_build_version < lowest_supported_driver_version_neo) + { filter_out = true; } } @@ -965,7 +964,8 @@ int OneapiDevice::get_max_num_threads_per_multiprocessor() { const sycl::device &device = reinterpret_cast(device_queue_)->get_device(); if (device.has(sycl::aspect::ext_intel_gpu_eu_simd_width) && - device.has(sycl::aspect::ext_intel_gpu_hw_threads_per_eu)) { + device.has(sycl::aspect::ext_intel_gpu_hw_threads_per_eu)) + { return device.get_info() * device.get_info(); } diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index b0209f16af8..8fbc92dbc33 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -357,7 +357,23 @@ bool OptiXDevice::load_kernels(const uint kernel_features) return false; } -# if OPTIX_ABI_VERSION >= 55 +# if OPTIX_ABI_VERSION >= 84 + OptixTask task = nullptr; + OptixResult result = optixModuleCreateWithTasks(context, + &module_options, + &pipeline_options, + ptx_data.data(), + ptx_data.size(), + nullptr, + nullptr, + &optix_module, + &task); + if (result == OPTIX_SUCCESS) { + TaskPool pool; + execute_optix_task(pool, task, result); + pool.wait_work(); + } +# elif OPTIX_ABI_VERSION >= 55 OptixTask task = nullptr; OptixResult result = optixModuleCreateFromPTXWithTasks(context, &module_options, @@ -560,7 +576,11 @@ bool OptiXDevice::load_kernels(const uint kernel_features) memset(sbt_data.host_pointer, 0, sizeof(SbtRecord) * NUM_PROGRAM_GROUPS); for (int i = 0; i < NUM_PROGRAM_GROUPS; ++i) { optix_assert(optixSbtRecordPackHeader(groups[i], &sbt_data[i])); +# if OPTIX_ABI_VERSION >= 84 + optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i], nullptr)); +# else optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i])); +# endif } sbt_data.copy_to_device(); /* Upload SBT to device. */ @@ -582,7 +602,9 @@ bool OptiXDevice::load_kernels(const uint kernel_features) OptixPipelineLinkOptions link_options = {}; link_options.maxTraceDepth = 1; +# if OPTIX_ABI_VERSION < 84 link_options.debugLevel = module_options.debugLevel; +# endif if (use_osl) { /* Re-create OSL pipeline in case kernels are reloaded after it has been created before. */ @@ -698,7 +720,8 @@ bool OptiXDevice::load_osl_kernels() vector osl_kernels; for (ShaderType type = SHADER_TYPE_SURFACE; type <= SHADER_TYPE_BUMP; - type = static_cast(type + 1)) { + type = static_cast(type + 1)) + { const vector &groups = (type == SHADER_TYPE_SURFACE ? osl_globals.surface_state : type == SHADER_TYPE_VOLUME ? @@ -773,6 +796,16 @@ bool OptiXDevice::load_osl_kernels() return false; } +# if OPTIX_ABI_VERSION >= 84 + const OptixResult result = optixModuleCreate(context, + &module_options, + &pipeline_options, + ptx_data.data(), + ptx_data.size(), + nullptr, + 0, + &osl_modules.back()); +# else const OptixResult result = optixModuleCreateFromPTX(context, &module_options, &pipeline_options, @@ -781,6 +814,7 @@ bool OptiXDevice::load_osl_kernels() nullptr, 0, &osl_modules.back()); +# endif if (result != OPTIX_SUCCESS) { set_error(string_printf("Failed to load OptiX OSL services kernel from '%s' (%s)", ptx_filename.c_str(), @@ -805,7 +839,21 @@ bool OptiXDevice::load_osl_kernels() continue; } -# if OPTIX_ABI_VERSION >= 55 +# if OPTIX_ABI_VERSION >= 84 + OptixTask task = nullptr; + results[i] = optixModuleCreateWithTasks(context, + &module_options, + &pipeline_options, + osl_kernels[i].ptx.data(), + osl_kernels[i].ptx.size(), + nullptr, + nullptr, + &osl_modules[i], + &task); + if (results[i] == OPTIX_SUCCESS) { + execute_optix_task(pool, task, results[i]); + } +# elif OPTIX_ABI_VERSION >= 55 OptixTask task = nullptr; results[i] = optixModuleCreateFromPTXWithTasks(context, &module_options, @@ -866,12 +914,20 @@ bool OptiXDevice::load_osl_kernels() sbt_data.alloc(NUM_PROGRAM_GROUPS + osl_groups.size()); for (int i = 0; i < NUM_PROGRAM_GROUPS; ++i) { optix_assert(optixSbtRecordPackHeader(groups[i], &sbt_data[i])); +# if OPTIX_ABI_VERSION >= 84 + optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i], nullptr)); +# else optix_assert(optixProgramGroupGetStackSize(groups[i], &stack_size[i])); +# endif } for (size_t i = 0; i < osl_groups.size(); ++i) { if (osl_groups[i] != NULL) { optix_assert(optixSbtRecordPackHeader(osl_groups[i], &sbt_data[NUM_PROGRAM_GROUPS + i])); +# if OPTIX_ABI_VERSION >= 84 + optix_assert(optixProgramGroupGetStackSize(osl_groups[i], &osl_stack_size[i], nullptr)); +# else optix_assert(optixProgramGroupGetStackSize(osl_groups[i], &osl_stack_size[i])); +# endif } else { /* Default to "__direct_callable__dummy_services", so that OSL evaluation for empty @@ -883,7 +939,9 @@ bool OptiXDevice::load_osl_kernels() OptixPipelineLinkOptions link_options = {}; link_options.maxTraceDepth = 0; +# if OPTIX_ABI_VERSION < 84 link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE; +# endif { vector pipeline_groups; @@ -958,7 +1016,8 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, if (use_fast_trace_bvh || /* The build flags have to match the ones used to query the built-in curve intersection * program (see optixBuiltinISModuleGet above) */ - build_input.type == OPTIX_BUILD_INPUT_TYPE_CURVES) { + build_input.type == OPTIX_BUILD_INPUT_TYPE_CURVES) + { VLOG_INFO << "Using fast to trace OptiX BVH"; options.buildFlags = OPTIX_BUILD_FLAG_PREFER_FAST_TRACE | OPTIX_BUILD_FLAG_ALLOW_COMPACTION; } @@ -1456,7 +1515,8 @@ void OptiXDevice::build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, b } if (ob->get_geometry()->geometry_type == Geometry::HAIR && - static_cast(ob->get_geometry())->curve_shape == CURVE_THICK) { + static_cast(ob->get_geometry())->curve_shape == CURVE_THICK) + { if (pipeline_options.usesMotionBlur && ob->get_geometry()->has_motion_blur()) { /* Select between motion blur and non-motion blur built-in intersection module. */ instance.sbtOffset = PG_HITD_MOTION - PG_HITD; diff --git a/intern/cycles/device/optix/queue.cpp b/intern/cycles/device/optix/queue.cpp index b45bb72c22b..4bafa3f9f34 100644 --- a/intern/cycles/device/optix/queue.cpp +++ b/intern/cycles/device/optix/queue.cpp @@ -80,7 +80,8 @@ bool OptiXDeviceQueue::enqueue(DeviceKernel kernel, } if (kernel == DEVICE_KERNEL_SHADER_EVAL_DISPLACE || kernel == DEVICE_KERNEL_SHADER_EVAL_BACKGROUND || - kernel == DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY) { + kernel == DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY) + { cuda_device_assert(cuda_device_, cuMemcpyHtoDAsync(launch_params_ptr + offsetof(KernelParamsOptiX, offset), args.values[2], // &d_offset diff --git a/intern/cycles/hydra/curves.cpp b/intern/cycles/hydra/curves.cpp index 771ec42c725..edb43200845 100644 --- a/intern/cycles/hydra/curves.cpp +++ b/intern/cycles/hydra/curves.cpp @@ -72,7 +72,8 @@ void HdCyclesCurves::PopulatePoints(HdSceneDelegate *sceneDelegate) VtValue value; for (const HdExtComputationPrimvarDescriptor &desc : - sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) { + sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) + { if (desc.name == HdTokens->points) { auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate); const auto valueStoreIt = valueStore.find(desc.name); @@ -179,7 +180,8 @@ void HdCyclesCurves::PopulatePrimvars(HdSceneDelegate *sceneDelegate) // Skip attributes that are not needed if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) || - _geom->need_attribute(scene, name)) { + _geom->need_attribute(scene, name)) + { ApplyPrimvars(_geom->attributes, name, value, interpolation.second, std); } } diff --git a/intern/cycles/hydra/display_driver.cpp b/intern/cycles/hydra/display_driver.cpp index 484d6ce06ba..7fc6fdfdbec 100644 --- a/intern/cycles/hydra/display_driver.cpp +++ b/intern/cycles/hydra/display_driver.cpp @@ -226,7 +226,8 @@ void HdCyclesDisplayDriver::draw(const Params ¶ms) const auto renderBuffer = static_cast( _renderParam->GetDisplayAovBinding().renderBuffer); if (!renderBuffer || // Ensure this render buffer matches the texture dimensions - (renderBuffer->GetWidth() != params.size.x || renderBuffer->GetHeight() != params.size.y)) { + (renderBuffer->GetWidth() != params.size.x || renderBuffer->GetHeight() != params.size.y)) + { return; } diff --git a/intern/cycles/hydra/instancer.cpp b/intern/cycles/hydra/instancer.cpp index 6b25a298a95..7b1c8d1926f 100644 --- a/intern/cycles/hydra/instancer.cpp +++ b/intern/cycles/hydra/instancer.cpp @@ -48,7 +48,8 @@ void HdCyclesInstancer::SyncPrimvars() sceneDelegate->GetRenderIndex().GetChangeTracker().GetInstancerDirtyBits(GetId()); for (const HdPrimvarDescriptor &desc : - sceneDelegate->GetPrimvarDescriptors(GetId(), HdInterpolationInstance)) { + sceneDelegate->GetPrimvarDescriptors(GetId(), HdInterpolationInstance)) + { if (!HdChangeTracker::IsPrimvarDirty(dirtyBits, GetId(), desc.name)) { continue; } @@ -119,7 +120,8 @@ VtMatrix4dArray HdCyclesInstancer::ComputeInstanceTransforms(const SdfPath &prot VtMatrix4dArray resultTransforms; if (const auto instancer = static_cast( - GetDelegate()->GetRenderIndex().GetInstancer(GetParentId()))) { + GetDelegate()->GetRenderIndex().GetInstancer(GetParentId()))) + { for (const GfMatrix4d &parentTransform : instancer->ComputeInstanceTransforms(GetId())) { for (const GfMatrix4d &localTransform : transforms) { resultTransforms.push_back(parentTransform * localTransform); diff --git a/intern/cycles/hydra/light.cpp b/intern/cycles/hydra/light.cpp index 86a0962a6b4..a512baf3797 100644 --- a/intern/cycles/hydra/light.cpp +++ b/intern/cycles/hydra/light.cpp @@ -168,7 +168,8 @@ void HdCyclesLight::Sync(HdSceneDelegate *sceneDelegate, } // Need to update shader graph when transform changes in case transform was baked into it else if (_light->tfm_is_modified() && (_lightType == HdPrimTypeTokens->domeLight || - _light->get_shader()->has_surface_spatial_varying)) { + _light->get_shader()->has_surface_spatial_varying)) + { PopulateShaderGraph(sceneDelegate); } diff --git a/intern/cycles/hydra/material.cpp b/intern/cycles/hydra/material.cpp index 92d7d675c11..88ca601c364 100644 --- a/intern/cycles/hydra/material.cpp +++ b/intern/cycles/hydra/material.cpp @@ -71,7 +71,8 @@ class UsdToCyclesMapping { } // TODO: Is there a better mapping than 'color'? if (name == CyclesMaterialTokens->r || name == CyclesMaterialTokens->g || - name == CyclesMaterialTokens->b) { + name == CyclesMaterialTokens->b) + { return "color"; } @@ -168,7 +169,8 @@ class UsdToCycles { usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float2 || usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float3 || usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_float4 || - usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_int) { + usdNodeType == CyclesMaterialTokens->UsdPrimvarReader_int) + { return &UsdPrimvarReader; } @@ -492,7 +494,8 @@ void HdCyclesMaterial::PopulateShaderGraph(const HdMaterialNetwork2 &networkMap) const char *inputName = nullptr; const char *outputName = nullptr; if (terminalName == HdMaterialTerminalTokens->surface || - terminalName == CyclesMaterialTokens->cyclesSurface) { + terminalName == CyclesMaterialTokens->cyclesSurface) + { inputName = "Surface"; // Find default output name based on the node if none is provided if (node->type->name == "add_closure" || node->type->name == "mix_closure") { @@ -506,11 +509,13 @@ void HdCyclesMaterial::PopulateShaderGraph(const HdMaterialNetwork2 &networkMap) } } else if (terminalName == HdMaterialTerminalTokens->displacement || - terminalName == CyclesMaterialTokens->cyclesDisplacement) { + terminalName == CyclesMaterialTokens->cyclesDisplacement) + { inputName = outputName = "Displacement"; } else if (terminalName == HdMaterialTerminalTokens->volume || - terminalName == CyclesMaterialTokens->cyclesVolume) { + terminalName == CyclesMaterialTokens->cyclesVolume) + { inputName = outputName = "Volume"; } diff --git a/intern/cycles/hydra/mesh.cpp b/intern/cycles/hydra/mesh.cpp index aef0d16dcc6..8d888d34885 100644 --- a/intern/cycles/hydra/mesh.cpp +++ b/intern/cycles/hydra/mesh.cpp @@ -53,7 +53,8 @@ VtValue ComputeTriangulatedFaceVaryingPrimvar(VtValue value, HdMeshUtil &meshUtil) { if (meshUtil.ComputeTriangulatedFaceVaryingPrimvar( - HdGetValueData(value), value.GetArraySize(), valueType, &value)) { + HdGetValueData(value), value.GetArraySize(), valueType, &value)) + { return value; } @@ -113,7 +114,8 @@ HdDirtyBits HdCyclesMesh::_PropagateDirtyBits(HdDirtyBits bits) const } if (bits & (HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyDisplayStyle | - HdChangeTracker::DirtySubdivTags)) { + HdChangeTracker::DirtySubdivTags)) + { // Do full topology update when display style or subdivision changes bits |= HdChangeTracker::DirtyTopology | HdChangeTracker::DirtyDisplayStyle | HdChangeTracker::DirtySubdivTags; @@ -159,7 +161,8 @@ void HdCyclesMesh::PopulatePoints(HdSceneDelegate *sceneDelegate) VtValue value; for (const HdExtComputationPrimvarDescriptor &desc : - sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) { + sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) + { if (desc.name == HdTokens->points) { auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate); const auto valueStoreIt = valueStore.find(desc.name); @@ -208,7 +211,8 @@ void HdCyclesMesh::PopulateNormals(HdSceneDelegate *sceneDelegate) for (int i = 0; i < HdInterpolationCount && interpolation == HdInterpolationCount; ++i) { for (const HdExtComputationPrimvarDescriptor &desc : sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), - static_cast(i))) { + static_cast(i))) + { if (desc.name == HdTokens->normals) { auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate); const auto valueStoreIt = valueStore.find(desc.name); @@ -270,7 +274,8 @@ void HdCyclesMesh::PopulateNormals(HdSceneDelegate *sceneDelegate) TF_VERIFY(normals.size() == static_cast(_topology.GetNumFaceVaryings())); if (!_util.ComputeTriangulatedFaceVaryingPrimvar( - normals.data(), normals.size(), HdTypeFloatVec3, &value)) { + normals.data(), normals.size(), HdTypeFloatVec3, &value)) + { return; } @@ -340,7 +345,8 @@ void HdCyclesMesh::PopulatePrimvars(HdSceneDelegate *sceneDelegate) // Skip attributes that are not needed if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) || - _geom->need_attribute(scene, name)) { + _geom->need_attribute(scene, name)) + { const HdType valueType = HdGetValueTupleType(value).type; if (!subdivision) { diff --git a/intern/cycles/hydra/output_driver.cpp b/intern/cycles/hydra/output_driver.cpp index 3bef8a011b9..163f813b72e 100644 --- a/intern/cycles/hydra/output_driver.cpp +++ b/intern/cycles/hydra/output_driver.cpp @@ -44,7 +44,8 @@ bool HdCyclesOutputDriver::update_render_tile(const Tile &tile) // Avoid extra copy by mapping render buffer directly when dimensions/format match the tile if (tile.offset.x == 0 && tile.offset.y == 0 && tile.size.x == renderBuffer->GetWidth() && tile.size.y == renderBuffer->GetHeight() && - (format >= HdFormatFloat32 && format <= HdFormatFloat32Vec4)) { + (format >= HdFormatFloat32 && format <= HdFormatFloat32Vec4)) + { float *const data = static_cast(renderBuffer->Map()); TF_VERIFY(tile.get_pass_pixels(aovBinding.aovName.GetString(), channels, data)); renderBuffer->Unmap(); diff --git a/intern/cycles/hydra/pointcloud.cpp b/intern/cycles/hydra/pointcloud.cpp index 2d274f190a2..ba964e2744d 100644 --- a/intern/cycles/hydra/pointcloud.cpp +++ b/intern/cycles/hydra/pointcloud.cpp @@ -74,7 +74,8 @@ void HdCyclesPoints::PopulatePoints(HdSceneDelegate *sceneDelegate) VtValue value; for (const HdExtComputationPrimvarDescriptor &desc : - sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) { + sceneDelegate->GetExtComputationPrimvarDescriptors(GetId(), HdInterpolationVertex)) + { if (desc.name == HdTokens->points) { auto valueStore = HdExtComputationUtils::GetComputedPrimvarValues({desc}, sceneDelegate); const auto valueStoreIt = valueStore.find(desc.name); @@ -187,7 +188,8 @@ void HdCyclesPoints::PopulatePrimvars(HdSceneDelegate *sceneDelegate) // Skip attributes that are not needed if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) || - _geom->need_attribute(scene, name)) { + _geom->need_attribute(scene, name)) + { ApplyPrimvars(_geom->attributes, name, value, interpolation.second, std); } } diff --git a/intern/cycles/hydra/render_delegate.cpp b/intern/cycles/hydra/render_delegate.cpp index 28c23e4f21b..6b22ac36e00 100644 --- a/intern/cycles/hydra/render_delegate.cpp +++ b/intern/cycles/hydra/render_delegate.cpp @@ -123,7 +123,8 @@ HdCyclesDelegate::HdCyclesDelegate(const HdRenderSettingsMap &settingsMap, for (const auto &setting : settingsMap) { // Skip over the settings known to be used for initialization only if (setting.first == HdCyclesRenderSettingsTokens->device || - setting.first == HdCyclesRenderSettingsTokens->threads) { + setting.first == HdCyclesRenderSettingsTokens->threads) + { continue; } @@ -284,7 +285,8 @@ HdSprim *HdCyclesDelegate::CreateSprim(const TfToken &typeId, const SdfPath &spr } if (typeId == HdPrimTypeTokens->diskLight || typeId == HdPrimTypeTokens->distantLight || typeId == HdPrimTypeTokens->domeLight || typeId == HdPrimTypeTokens->rectLight || - typeId == HdPrimTypeTokens->sphereLight) { + typeId == HdPrimTypeTokens->sphereLight) + { return new HdCyclesLight(sprimId, typeId); } if (typeId == HdPrimTypeTokens->extComputation) { @@ -400,7 +402,8 @@ HdAovDescriptor HdCyclesDelegate::GetDefaultAovDescriptor(const TfToken &name) c return HdAovDescriptor(HdFormatFloat32Vec3, false, VtValue(GfVec3f(0.0f))); } if (name == HdAovTokens->primId || name == HdAovTokens->instanceId || - name == HdAovTokens->elementId) { + name == HdAovTokens->elementId) + { return HdAovDescriptor(HdFormatInt32, false, VtValue(-1)); } diff --git a/intern/cycles/hydra/render_pass.cpp b/intern/cycles/hydra/render_pass.cpp index be787382158..e7d6712410f 100644 --- a/intern/cycles/hydra/render_pass.cpp +++ b/intern/cycles/hydra/render_pass.cpp @@ -90,8 +90,8 @@ void HdCyclesRenderPass::_Execute(const HdRenderPassStateSharedPtr &renderPassSt const HdRenderPassAovBindingVector &aovBindings = renderPassState->GetAovBindings(); if (_renderParam->GetAovBindings() != aovBindings || // Need to resync passes when denoising is enabled or disabled to update the pass mode - (settingsVersion != _lastSettingsVersion && - scene->integrator->use_denoise_is_modified())) { + (settingsVersion != _lastSettingsVersion && scene->integrator->use_denoise_is_modified())) + { _renderParam->SyncAovBindings(aovBindings); if (renderDelegate->IsDisplaySupported()) { diff --git a/intern/cycles/hydra/volume.cpp b/intern/cycles/hydra/volume.cpp index f2bac15d3b5..fe19195dd0a 100644 --- a/intern/cycles/hydra/volume.cpp +++ b/intern/cycles/hydra/volume.cpp @@ -44,10 +44,11 @@ void HdCyclesVolume::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyB Scene *const scene = (Scene *)_geom->get_owner(); if (dirtyBits & HdChangeTracker::DirtyVolumeField) { - for (const HdVolumeFieldDescriptor &field : - sceneDelegate->GetVolumeFieldDescriptors(GetId())) { + for (const HdVolumeFieldDescriptor &field : sceneDelegate->GetVolumeFieldDescriptors(GetId())) + { if (const auto openvdbAsset = static_cast( - sceneDelegate->GetRenderIndex().GetBprim(_tokens->openvdbAsset, field.fieldId))) { + sceneDelegate->GetRenderIndex().GetBprim(_tokens->openvdbAsset, field.fieldId))) + { const ustring name(field.fieldName.GetString()); AttributeStandard std = ATTR_STD_NONE; @@ -72,7 +73,8 @@ void HdCyclesVolume::Populate(HdSceneDelegate *sceneDelegate, HdDirtyBits dirtyB // Skip attributes that are not needed if ((std != ATTR_STD_NONE && _geom->need_attribute(scene, std)) || - _geom->need_attribute(scene, name)) { + _geom->need_attribute(scene, name)) + { Attribute *const attr = (std != ATTR_STD_NONE) ? _geom->attributes.add(std) : _geom->attributes.add( diff --git a/intern/cycles/integrator/denoiser.cpp b/intern/cycles/integrator/denoiser.cpp index ee0fd04f509..17f0d8b869b 100644 --- a/intern/cycles/integrator/denoiser.cpp +++ b/intern/cycles/integrator/denoiser.cpp @@ -109,8 +109,8 @@ static Device *find_best_device(Device *device, DenoiserType type) } else { /* Prefer a device that can use graphics interop for faster display update. */ - if (sub_device->should_use_graphics_interop() && - !best_device->should_use_graphics_interop()) { + if (sub_device->should_use_graphics_interop() && !best_device->should_use_graphics_interop()) + { best_device = sub_device; } diff --git a/intern/cycles/integrator/denoiser_oidn.cpp b/intern/cycles/integrator/denoiser_oidn.cpp index 04e659a15e2..f7c94203eb1 100644 --- a/intern/cycles/integrator/denoiser_oidn.cpp +++ b/intern/cycles/integrator/denoiser_oidn.cpp @@ -164,7 +164,8 @@ class OIDNDenoiseContext { oidn_filter.set("hdr", true); oidn_filter.set("srgb", false); if (denoise_params_.prefilter == DENOISER_PREFILTER_NONE || - denoise_params_.prefilter == DENOISER_PREFILTER_ACCURATE) { + denoise_params_.prefilter == DENOISER_PREFILTER_ACCURATE) + { oidn_filter.set("cleanAux", true); } oidn_filter.commit(); @@ -189,7 +190,8 @@ class OIDNDenoiseContext { void filter_guiding_pass_if_needed(oidn::DeviceRef &oidn_device, OIDNPass &oidn_pass) { if (denoise_params_.prefilter != DENOISER_PREFILTER_ACCURATE || !oidn_pass || - oidn_pass.is_filtered) { + oidn_pass.is_filtered) + { return; } diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp index ab056e953c2..bce07232862 100644 --- a/intern/cycles/integrator/pass_accessor.cpp +++ b/intern/cycles/integrator/pass_accessor.cpp @@ -180,7 +180,8 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers, } else if ((pass_info.divide_type != PASS_NONE || pass_info.direct_type != PASS_NONE || pass_info.indirect_type != PASS_NONE) && - mode != PassMode::DENOISED) { + mode != PassMode::DENOISED) + { /* RGB lighting passes that need to divide out color and/or sum direct and indirect. * These can also optionally write alpha like the combined pass. */ get_pass_light_path(render_buffers, buffer_params, destination); diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp index 4812ff2614d..cbfab137833 100644 --- a/intern/cycles/integrator/path_trace.cpp +++ b/intern/cycles/integrator/path_trace.cpp @@ -348,7 +348,8 @@ void PathTrace::update_work_buffer_params_if_needed(const RenderWork &render_wor } if (render_state_.need_reset_params || - render_state_.resolution_divider != render_work.resolution_divider) { + render_state_.resolution_divider != render_work.resolution_divider) + { update_effective_work_buffer_params(render_work); } @@ -565,7 +566,8 @@ void PathTrace::denoise(const RenderWork &render_work) if (denoiser_->denoise_buffer(render_state_.effective_big_tile_params, buffer_to_denoise, get_num_samples_in_buffer(), - allow_inplace_modification)) { + allow_inplace_modification)) + { render_state_.has_denoised_result = true; } diff --git a/intern/cycles/integrator/path_trace_display.cpp b/intern/cycles/integrator/path_trace_display.cpp index 0bd68c80aae..d77906fef75 100644 --- a/intern/cycles/integrator/path_trace_display.cpp +++ b/intern/cycles/integrator/path_trace_display.cpp @@ -117,7 +117,8 @@ void PathTraceDisplay::copy_pixels_to_texture( const int texture_height = texture_state_.size.y; if (texture_x == 0 && texture_y == 0 && pixels_width == texture_width && - pixels_height == texture_height) { + pixels_height == texture_height) + { const size_t size_in_bytes = sizeof(half4) * texture_width * texture_height; memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes); } diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp index 6aaa31a1a65..0864740a86d 100644 --- a/intern/cycles/integrator/path_trace_work_cpu.cpp +++ b/intern/cycles/integrator/path_trace_work_cpu.cpp @@ -232,7 +232,8 @@ int PathTraceWorkCPU::adaptive_sampling_converge_filter_count_active(float thres uint num_row_pixels_active = 0; for (int x = 0; x < width; ++x) { if (!kernels_.adaptive_sampling_convergence_check( - kernel_globals, render_buffer, full_x + x, y, threshold, reset, offset, stride)) { + kernel_globals, render_buffer, full_x + x, y, threshold, reset, offset, stride)) + { ++num_row_pixels_active; row_converged = false; } diff --git a/intern/cycles/integrator/path_trace_work_gpu.cpp b/intern/cycles/integrator/path_trace_work_gpu.cpp index 9bba6ed5570..325cd30df10 100644 --- a/intern/cycles/integrator/path_trace_work_gpu.cpp +++ b/intern/cycles/integrator/path_trace_work_gpu.cpp @@ -22,7 +22,8 @@ static size_t estimate_single_state_size(const uint kernel_features) { size_t state_size = 0; -#define KERNEL_STRUCT_BEGIN(name) for (int array_index = 0;; array_index++) { +#define KERNEL_STRUCT_BEGIN(name) \ + for (int array_index = 0;; array_index++) { #define KERNEL_STRUCT_MEMBER(parent_struct, type, name, feature) \ state_size += (kernel_features & (feature)) ? sizeof(type) : 0; #define KERNEL_STRUCT_ARRAY_MEMBER(parent_struct, type, name, feature) \ @@ -96,7 +97,8 @@ void PathTraceWorkGPU::alloc_integrator_soa() const int requested_volume_stack_size = device_scene_->data.volume_stack_size; const uint kernel_features = device_scene_->data.kernel_features; if ((integrator_state_soa_kernel_features_ & kernel_features) == kernel_features && - integrator_state_soa_volume_stack_size_ >= requested_volume_stack_size) { + integrator_state_soa_volume_stack_size_ >= requested_volume_stack_size) + { return; } integrator_state_soa_kernel_features_ = kernel_features; @@ -121,7 +123,8 @@ void PathTraceWorkGPU::alloc_integrator_soa() * write the pointers into a struct that resides in constant memory. * * TODO: store float3 in separate XYZ arrays. */ -#define KERNEL_STRUCT_BEGIN(name) for (int array_index = 0;; array_index++) { +#define KERNEL_STRUCT_BEGIN(name) \ + for (int array_index = 0;; array_index++) { #define KERNEL_STRUCT_MEMBER(parent_struct, type, name, feature) \ if ((kernel_features & (feature)) && (integrator_state_gpu_.parent_struct.name == nullptr)) { \ device_only_memory *array = new device_only_memory(device_, \ @@ -132,7 +135,8 @@ void PathTraceWorkGPU::alloc_integrator_soa() } #define KERNEL_STRUCT_ARRAY_MEMBER(parent_struct, type, name, feature) \ if ((kernel_features & (feature)) && \ - (integrator_state_gpu_.parent_struct[array_index].name == nullptr)) { \ + (integrator_state_gpu_.parent_struct[array_index].name == nullptr)) \ + { \ device_only_memory *array = new device_only_memory(device_, \ "integrator_state_" #name); \ array->alloc_to_device(max_num_paths_); \ @@ -611,7 +615,8 @@ void PathTraceWorkGPU::compact_main_paths(const int num_active_paths) const int min_compact_paths = 32; if (max_active_main_path_index_ == num_active_paths || - max_active_main_path_index_ < min_compact_paths) { + max_active_main_path_index_ < min_compact_paths) + { return; } @@ -647,7 +652,8 @@ void PathTraceWorkGPU::compact_shadow_paths() const float shadow_compact_ratio = 0.5f; const int min_compact_paths = 32; if (integrator_next_shadow_path_index_.data()[0] < num_active_paths * shadow_compact_ratio || - integrator_next_shadow_path_index_.data()[0] < min_compact_paths) { + integrator_next_shadow_path_index_.data()[0] < min_compact_paths) + { return; } diff --git a/intern/cycles/integrator/render_scheduler.cpp b/intern/cycles/integrator/render_scheduler.cpp index 8568fe93a52..f54f78413b3 100644 --- a/intern/cycles/integrator/render_scheduler.cpp +++ b/intern/cycles/integrator/render_scheduler.cpp @@ -465,7 +465,8 @@ void RenderScheduler::report_work_begin(const RenderWork &render_work) * because it might be wrongly 0. Check for whether path tracing is actually happening as it is * expected to happen in the first work. */ if (render_work.resolution_divider == pixel_size_ && render_work.path_trace.num_samples != 0 && - render_work.path_trace.start_sample == get_start_sample()) { + render_work.path_trace.start_sample == get_start_sample()) + { state_.start_render_time = time_dt(); } } diff --git a/intern/cycles/kernel/bvh/local.h b/intern/cycles/kernel/bvh/local.h index add61adc126..e5c28b4a27e 100644 --- a/intern/cycles/kernel/bvh/local.h +++ b/intern/cycles/kernel/bvh/local.h @@ -159,7 +159,8 @@ ccl_device_inline tmin, isect_t, lcg_state, - max_hits)) { + max_hits)) + { return true; } } @@ -196,7 +197,8 @@ ccl_device_inline tmin, isect_t, lcg_state, - max_hits)) { + max_hits)) + { return true; } } diff --git a/intern/cycles/kernel/bvh/traversal.h b/intern/cycles/kernel/bvh/traversal.h index f3744aca5c0..bc52f46b433 100644 --- a/intern/cycles/kernel/bvh/traversal.h +++ b/intern/cycles/kernel/bvh/traversal.h @@ -140,7 +140,8 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals kg, visibility, prim_object, prim, - prim_addr)) { + prim_addr)) + { /* shadow ray early termination */ if (visibility & PATH_RAY_SHADOW_OPAQUE) return true; @@ -159,7 +160,8 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals kg, visibility, prim_object, prim, - prim_addr)) { + prim_addr)) + { /* shadow ray early termination */ if (visibility & PATH_RAY_SHADOW_OPAQUE) return true; diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h index 32f6ae17d1c..f55ebefd987 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h @@ -55,7 +55,8 @@ ccl_device_forceinline Spectrum bsdf_ashikhmin_shirley_eval(ccl_private const Sh float out = 0.0f; if ((cosNgO < 0.0f) || fmaxf(bsdf->alpha_x, bsdf->alpha_y) <= 1e-4f || - !(NdotI > 0.0f && NdotO > 0.0f)) { + !(NdotI > 0.0f && NdotO > 0.0f)) + { *pdf = 0.0f; return zero_spectrum(); } diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index 6bf463f9301..89fec29d43b 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -399,7 +399,8 @@ ccl_device Spectrum bsdf_microfacet_eval(ccl_private const ShaderClosure *sc, * - Purely refractive closures can't have reflection. */ if ((cos_NI <= 0) || (alpha_x * alpha_y <= 1e-7f) || ((cos_NgO < 0.0f) != is_refraction) || - (is_refraction && !m_refractive) || (!is_refraction && m_refractive && !m_glass)) { + (is_refraction && !m_refractive) || (!is_refraction && m_refractive && !m_glass)) + { *pdf = 0.0f; return zero_spectrum(); } diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h index 8b595ebfa3b..af1a821b361 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h @@ -38,7 +38,8 @@ ccl_device_forceinline Spectrum MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi, } else #endif - if (wo.z < wi.z) { + if (wo.z < wi.z) + { swapped = true; float3 tmp = wo; wo = wi; diff --git a/intern/cycles/kernel/device/cpu/bvh.h b/intern/cycles/kernel/device/cpu/bvh.h index 0870e7da2fb..bdf2a13db39 100644 --- a/intern/cycles/kernel/device/cpu/bvh.h +++ b/intern/cycles/kernel/device/cpu/bvh.h @@ -284,7 +284,8 @@ ccl_device_forceinline void kernel_embree_filter_intersection_func_impl( const Ray *cray = ctx->ray; if (kernel_embree_is_self_intersection( - kg, hit, cray, reinterpret_cast(args->geometryUserPtr))) { + kg, hit, cray, reinterpret_cast(args->geometryUserPtr))) + { *args->valid = 0; } } @@ -577,7 +578,8 @@ ccl_device void kernel_embree_filter_func_backface_cull(const RTCFilterFunctionN /* Always ignore back-facing intersections. */ if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z), - make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) { + make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) + { *args->valid = 0; return; } @@ -587,7 +589,8 @@ ccl_device void kernel_embree_filter_func_backface_cull(const RTCFilterFunctionN const Ray *cray = ctx->ray; if (kernel_embree_is_self_intersection( - kg, hit, cray, reinterpret_cast(args->geometryUserPtr))) { + kg, hit, cray, reinterpret_cast(args->geometryUserPtr))) + { *args->valid = 0; } } @@ -600,7 +603,8 @@ ccl_device void kernel_embree_filter_occluded_func_backface_cull( /* Always ignore back-facing intersections. */ if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z), - make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) { + make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) + { *args->valid = 0; return; } diff --git a/intern/cycles/kernel/device/cpu/kernel.cpp b/intern/cycles/kernel/device/cpu/kernel.cpp index 558431961ab..191da05337a 100644 --- a/intern/cycles/kernel/device/cpu/kernel.cpp +++ b/intern/cycles/kernel/device/cpu/kernel.cpp @@ -72,8 +72,7 @@ void kernel_global_memory_copy(KernelGlobalsCPU *kg, const char *name, void *mem } #define KERNEL_DATA_ARRAY(type, tname) \ - else if (strcmp(name, #tname) == 0) \ - { \ + else if (strcmp(name, #tname) == 0) { \ kg->tname.data = (type *)mem; \ kg->tname.width = size; \ } diff --git a/intern/cycles/kernel/device/gpu/image.h b/intern/cycles/kernel/device/gpu/image.h index 60bf1890072..8f2f4ccfef1 100644 --- a/intern/cycles/kernel/device/gpu/image.h +++ b/intern/cycles/kernel/device/gpu/image.h @@ -193,7 +193,8 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo /* float4, byte4, ushort4 and half4 */ const int texture_type = info.data_type; if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 || - texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) { + texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) + { if (info.interpolation == INTERPOLATION_CUBIC || info.interpolation == INTERPOLATION_SMART) { return kernel_tex_image_interp_bicubic(info, x, y); } @@ -256,7 +257,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, } #endif if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 || - texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) { + texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) + { if (interpolation == INTERPOLATION_CUBIC || interpolation == INTERPOLATION_SMART) { return kernel_tex_image_interp_tricubic(info, x, y, z); } diff --git a/intern/cycles/kernel/device/gpu/parallel_sorted_index.h b/intern/cycles/kernel/device/gpu/parallel_sorted_index.h index f5053587853..665a9ca8065 100644 --- a/intern/cycles/kernel/device/gpu/parallel_sorted_index.h +++ b/intern/cycles/kernel/device/gpu/parallel_sorted_index.h @@ -53,7 +53,8 @@ ccl_device_inline void gpu_parallel_sort_bucket_pass(const uint num_states, const uint partition_end = min(num_states, partition_start + partition_size); for (int state_index = partition_start + uint(local_id); state_index < partition_end; - state_index += uint(local_size)) { + state_index += uint(local_size)) + { ushort kernel_index = d_queued_kernel[state_index]; if (kernel_index == queued_kernel) { uint key = d_shader_sort_key[state_index] % max_shaders; @@ -115,7 +116,8 @@ ccl_device_inline void gpu_parallel_sort_write_pass(const uint num_states, ccl_global int *key_offsets = partition_key_offsets + (uint(grid_id) * max_shaders); for (int state_index = partition_start + uint(local_id); state_index < partition_end; - state_index += uint(local_size)) { + state_index += uint(local_size)) + { ushort kernel_index = d_queued_kernel[state_index]; if (kernel_index == queued_kernel) { uint key = d_shader_sort_key[state_index] % max_shaders; diff --git a/intern/cycles/kernel/device/hiprt/common.h b/intern/cycles/kernel/device/hiprt/common.h index 1017857d8f9..44e9846d42a 100644 --- a/intern/cycles/kernel/device/hiprt/common.h +++ b/intern/cycles/kernel/device/hiprt/common.h @@ -442,7 +442,8 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray, # else if (num_hits >= max_hits || - !(intersection_get_shader_flags(NULL, prim, type) & SD_HAS_TRANSPARENT_SHADOW)) { + !(intersection_get_shader_flags(NULL, prim, type) & SD_HAS_TRANSPARENT_SHADOW)) + { return false; } diff --git a/intern/cycles/kernel/device/oneapi/image.h b/intern/cycles/kernel/device/oneapi/image.h index bdb81bb8645..970b394024d 100644 --- a/intern/cycles/kernel/device/oneapi/image.h +++ b/intern/cycles/kernel/device/oneapi/image.h @@ -330,7 +330,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals, int id, float3 P, in if (info.data_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT || info.data_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT3 || info.data_type == IMAGE_DATA_TYPE_NANOVDB_FPN || - info.data_type == IMAGE_DATA_TYPE_NANOVDB_FP16) { + info.data_type == IMAGE_DATA_TYPE_NANOVDB_FP16) + { return make_float4( TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); } diff --git a/intern/cycles/kernel/device/oneapi/kernel.cpp b/intern/cycles/kernel/device/oneapi/kernel.cpp index e4e0f01add1..f57a2ee9255 100644 --- a/intern/cycles/kernel/device/oneapi/kernel.cpp +++ b/intern/cycles/kernel/device/oneapi/kernel.cpp @@ -217,7 +217,8 @@ bool oneapi_load_kernels(SyclQueue *queue_, const std::string &kernel_name = kernel_id.get_name(); if (!oneapi_kernel_is_required_for_features(kernel_name, kernel_features) || - !oneapi_kernel_is_using_embree(kernel_name)) { + !oneapi_kernel_is_using_embree(kernel_name)) + { continue; } @@ -259,7 +260,8 @@ bool oneapi_load_kernels(SyclQueue *queue_, /* In case HWRT is on, compilation of kernels using Embree is already handled in previous * block. */ if (!oneapi_kernel_is_required_for_features(kernel_name, kernel_features) || - (use_hardware_raytracing && oneapi_kernel_is_using_embree(kernel_name))) { + (use_hardware_raytracing && oneapi_kernel_is_using_embree(kernel_name))) + { continue; } @@ -323,7 +325,8 @@ bool oneapi_enqueue_kernel(KernelContext *kernel_context, device_kernel == DEVICE_KERNEL_INTEGRATOR_TERMINATED_PATHS_ARRAY || device_kernel == DEVICE_KERNEL_INTEGRATOR_TERMINATED_SHADOW_PATHS_ARRAY || device_kernel == DEVICE_KERNEL_INTEGRATOR_COMPACT_PATHS_ARRAY || - device_kernel == DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_PATHS_ARRAY) { + device_kernel == DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_PATHS_ARRAY) + { int num_states = *((int *)(args[0])); /* Round up to the next work-group. */ size_t groups_count = (num_states + local_size - 1) / local_size; diff --git a/intern/cycles/kernel/device/optix/bvh.h b/intern/cycles/kernel/device/optix/bvh.h index b3062e49931..a1c0acafd88 100644 --- a/intern/cycles/kernel/device/optix/bvh.h +++ b/intern/cycles/kernel/device/optix/bvh.h @@ -195,7 +195,8 @@ extern "C" __global__ void __anyhit__kernel_optix_shadow_all_hit() /* If no transparent shadows, all light is blocked and we can stop immediately. */ if (num_hits >= max_hits || - !(intersection_get_shader_flags(NULL, prim, type) & SD_HAS_TRANSPARENT_SHADOW)) { + !(intersection_get_shader_flags(NULL, prim, type) & SD_HAS_TRANSPARENT_SHADOW)) + { optixSetPayload_5(true); return optixTerminateRay(); } diff --git a/intern/cycles/kernel/film/data_passes.h b/intern/cycles/kernel/film/data_passes.h index 0ed5828ff30..d0035b107a4 100644 --- a/intern/cycles/kernel/film/data_passes.h +++ b/intern/cycles/kernel/film/data_passes.h @@ -68,7 +68,8 @@ ccl_device_inline void film_write_data_passes(KernelGlobals kg, } if (!(sd->flag & SD_TRANSPARENT) || kernel_data.film.pass_alpha_threshold == 0.0f || - average(surface_shader_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) { + average(surface_shader_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) + { if (flag & PASSMASK(NORMAL)) { const float3 normal = surface_shader_average_normal(kg, sd); film_write_pass_float3(buffer + kernel_data.film.pass_normal, normal); diff --git a/intern/cycles/kernel/film/light_passes.h b/intern/cycles/kernel/film/light_passes.h index 4cfd1aef43a..98b46997806 100644 --- a/intern/cycles/kernel/film/light_passes.h +++ b/intern/cycles/kernel/film/light_passes.h @@ -366,7 +366,8 @@ ccl_device_inline void film_write_emission_or_background_pass( const bool is_shadowcatcher = (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) != 0; if (!is_shadowcatcher && lightgroup != LIGHTGROUP_NONE && - kernel_data.film.pass_lightgroup != PASS_UNUSED) { + kernel_data.film.pass_lightgroup != PASS_UNUSED) + { film_write_pass_spectrum(buffer + kernel_data.film.pass_lightgroup + 3 * lightgroup, contribution); } diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h index 108f992e29d..ccea547b231 100644 --- a/intern/cycles/kernel/film/read.h +++ b/intern/cycles/kernel/film/read.h @@ -538,8 +538,8 @@ ccl_device_inline void film_apply_pass_pixel_overlays_rgba( ccl_global const float *ccl_restrict buffer, ccl_private float *ccl_restrict pixel) { - if (kfilm_convert->show_active_pixels && - kfilm_convert->pass_adaptive_aux_buffer != PASS_UNUSED) { + if (kfilm_convert->show_active_pixels && kfilm_convert->pass_adaptive_aux_buffer != PASS_UNUSED) + { if (buffer[kfilm_convert->pass_adaptive_aux_buffer + 3] == 0.0f) { const float3 active_rgb = make_float3(1.0f, 0.0f, 0.0f); const float3 mix_rgb = interp(make_float3(pixel[0], pixel[1], pixel[2]), active_rgb, 0.5f); diff --git a/intern/cycles/kernel/geom/attribute.h b/intern/cycles/kernel/geom/attribute.h index 3a0ee1b09d1..a5700b6d093 100644 --- a/intern/cycles/kernel/geom/attribute.h +++ b/intern/cycles/kernel/geom/attribute.h @@ -77,7 +77,8 @@ find_attribute(KernelGlobals kg, int object, int prim, int type, uint64_t id) desc.element = (AttributeElement)attr_map.element; if (prim == PRIM_NONE && desc.element != ATTR_ELEMENT_MESH && - desc.element != ATTR_ELEMENT_VOXEL && desc.element != ATTR_ELEMENT_OBJECT) { + desc.element != ATTR_ELEMENT_VOXEL && desc.element != ATTR_ELEMENT_OBJECT) + { return attribute_not_found(); } diff --git a/intern/cycles/kernel/geom/primitive.h b/intern/cycles/kernel/geom/primitive.h index 04b04ff5985..c1d27f9eb04 100644 --- a/intern/cycles/kernel/geom/primitive.h +++ b/intern/cycles/kernel/geom/primitive.h @@ -318,7 +318,8 @@ ccl_device_forceinline float4 primitive_motion_vector(KernelGlobals kg, } else #endif - if (sd->type & PRIMITIVE_TRIANGLE) { + if (sd->type & PRIMITIVE_TRIANGLE) + { /* Triangle */ if (subd_triangle_patch(kg, sd->prim) == ~0) { motion_pre = triangle_attribute_float3(kg, sd, desc, NULL, NULL); diff --git a/intern/cycles/kernel/geom/shader_data.h b/intern/cycles/kernel/geom/shader_data.h index eb05121b7cd..fbaa169b7ad 100644 --- a/intern/cycles/kernel/geom/shader_data.h +++ b/intern/cycles/kernel/geom/shader_data.h @@ -65,7 +65,8 @@ ccl_device_inline void shader_setup_from_ray(KernelGlobals kg, else #endif #ifdef __POINTCLOUD__ - if (sd->type & PRIMITIVE_POINT) { + if (sd->type & PRIMITIVE_POINT) + { /* point */ point_shader_setup(kg, sd, isect, ray); } diff --git a/intern/cycles/kernel/geom/subd_triangle.h b/intern/cycles/kernel/geom/subd_triangle.h index 8666408fe2b..08186b8c812 100644 --- a/intern/cycles/kernel/geom/subd_triangle.h +++ b/intern/cycles/kernel/geom/subd_triangle.h @@ -135,7 +135,8 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals kg, } else #endif /* __PATCH_EVAL__ */ - if (desc.element == ATTR_ELEMENT_FACE) { + if (desc.element == ATTR_ELEMENT_FACE) + { if (dx) *dx = 0.0f; if (dy) @@ -275,7 +276,8 @@ ccl_device_noinline float2 subd_triangle_attribute_float2(KernelGlobals kg, } else #endif /* __PATCH_EVAL__ */ - if (desc.element == ATTR_ELEMENT_FACE) { + if (desc.element == ATTR_ELEMENT_FACE) + { if (dx) *dx = make_float2(0.0f, 0.0f); if (dy) @@ -416,7 +418,8 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals kg, } else #endif /* __PATCH_EVAL__ */ - if (desc.element == ATTR_ELEMENT_FACE) { + if (desc.element == ATTR_ELEMENT_FACE) + { if (dx) *dx = make_float3(0.0f, 0.0f, 0.0f); if (dy) @@ -562,7 +565,8 @@ ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals kg, } else #endif /* __PATCH_EVAL__ */ - if (desc.element == ATTR_ELEMENT_FACE) { + if (desc.element == ATTR_ELEMENT_FACE) + { if (dx) *dx = zero_float4(); if (dy) diff --git a/intern/cycles/kernel/geom/triangle.h b/intern/cycles/kernel/geom/triangle.h index 9198a9d9dd3..05af44c1535 100644 --- a/intern/cycles/kernel/geom/triangle.h +++ b/intern/cycles/kernel/geom/triangle.h @@ -307,7 +307,8 @@ ccl_device float4 triangle_attribute_float4(KernelGlobals kg, ccl_private float4 *dy) { if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION | ATTR_ELEMENT_CORNER | - ATTR_ELEMENT_CORNER_BYTE)) { + ATTR_ELEMENT_CORNER_BYTE)) + { float4 f0, f1, f2; if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION)) { diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h index 1ad2469cfa0..d42848ce3c0 100644 --- a/intern/cycles/kernel/integrator/guiding.h +++ b/intern/cycles/kernel/integrator/guiding.h @@ -264,7 +264,8 @@ ccl_device_forceinline void guiding_record_volume_transmission(KernelGlobals kg, (transmittance_weight[1] < 0.f || !std::isfinite(transmittance_weight[1]) || std::isnan(transmittance_weight[1])) || (transmittance_weight[2] < 0.f || !std::isfinite(transmittance_weight[2]) || - std::isnan(transmittance_weight[2]))) { + std::isnan(transmittance_weight[2]))) + { } else { openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, @@ -459,7 +460,8 @@ ccl_device_forceinline bool guiding_bsdf_init(KernelGlobals kg, kg->opgl_guiding_field, guiding_point3f(P), rand)) { # else if (kg->opgl_surface_sampling_distribution->Init( - kg->opgl_guiding_field, guiding_point3f(P), rand, true)) { + kg->opgl_guiding_field, guiding_point3f(P), rand, true)) + { # endif kg->opgl_surface_sampling_distribution->ApplyCosineProduct(guiding_point3f(N)); return true; @@ -516,7 +518,8 @@ ccl_device_forceinline bool guiding_phase_init(KernelGlobals kg, kg->opgl_guiding_field, guiding_point3f(P), rand)) { # else if (kg->opgl_volume_sampling_distribution->Init( - kg->opgl_guiding_field, guiding_point3f(P), rand, true)) { + kg->opgl_guiding_field, guiding_point3f(P), rand, true)) + { # endif kg->opgl_volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(guiding_vec3f(D), g); diff --git a/intern/cycles/kernel/integrator/intersect_shadow.h b/intern/cycles/kernel/integrator/intersect_shadow.h index a5572f51dea..79e7c03bd92 100644 --- a/intern/cycles/kernel/integrator/intersect_shadow.h +++ b/intern/cycles/kernel/integrator/intersect_shadow.h @@ -77,7 +77,8 @@ ccl_device_inline void sort_shadow_intersections(IntegratorShadowState state, ui swapped = false; for (int j = 0; j < num_hits - 1; ++j) { if (INTEGRATOR_STATE_ARRAY(state, shadow_isect, j, t) > - INTEGRATOR_STATE_ARRAY(state, shadow_isect, j + 1, t)) { + INTEGRATOR_STATE_ARRAY(state, shadow_isect, j + 1, t)) + { struct Intersection tmp_j ccl_optional_struct_init; struct Intersection tmp_j_1 ccl_optional_struct_init; integrator_state_read_shadow_isect(state, &tmp_j, j); diff --git a/intern/cycles/kernel/integrator/intersect_volume_stack.h b/intern/cycles/kernel/integrator/intersect_volume_stack.h index 493d29f4f10..dc583cdce9f 100644 --- a/intern/cycles/kernel/integrator/intersect_volume_stack.h +++ b/intern/cycles/kernel/integrator/intersect_volume_stack.h @@ -153,7 +153,8 @@ ccl_device void integrator_volume_stack_init(KernelGlobals kg, IntegratorState s int step = 0; while (stack_index < volume_stack_size - 1 && enclosed_index < MAX_VOLUME_STACK_SIZE - 1 && - step < 2 * volume_stack_size) { + step < 2 * volume_stack_size) + { Intersection isect; if (!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) { break; diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index d0012b0bfec..ed3ae781095 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -87,7 +87,8 @@ ccl_device_forceinline bool integrate_surface_holdout(KernelGlobals kg, const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag); if (((sd->flag & SD_HOLDOUT) || (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) && - (path_flag & PATH_RAY_TRANSPARENT_BACKGROUND)) { + (path_flag & PATH_RAY_TRANSPARENT_BACKGROUND)) + { const Spectrum holdout_weight = surface_shader_apply_holdout(kg, sd); const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput); const float transparent = average(holdout_weight * throughput); @@ -160,7 +161,8 @@ ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg, sd->flag, bounce, path_flag, - &ls)) { + &ls)) + { return; } } diff --git a/intern/cycles/kernel/integrator/shade_volume.h b/intern/cycles/kernel/integrator/shade_volume.h index e1c87c5140a..e00f0ff6f67 100644 --- a/intern/cycles/kernel/integrator/shade_volume.h +++ b/intern/cycles/kernel/integrator/shade_volume.h @@ -441,7 +441,8 @@ ccl_device_forceinline void volume_integrate_step_scattering( /* Equiangular sampling for direct lighting. */ if (vstate.direct_sample_method == VOLUME_SAMPLE_EQUIANGULAR && !result.direct_scatter) { if (result.direct_t >= vstate.tmin && result.direct_t <= vstate.tmax && - vstate.equiangular_pdf > VOLUME_SAMPLE_PDF_CUTOFF) { + vstate.equiangular_pdf > VOLUME_SAMPLE_PDF_CUTOFF) + { const float new_dt = result.direct_t - vstate.tmin; const Spectrum new_transmittance = volume_color_transmittance(coeff.sigma_t, new_dt); @@ -720,7 +721,8 @@ ccl_device_forceinline bool integrate_volume_equiangular_sample_light( ray->tmax - ray->tmin, bounce, path_flag, - &ls)) { + &ls)) + { return false; } @@ -784,7 +786,8 @@ ccl_device_forceinline void integrate_volume_direct_light( SD_BSDF_HAS_TRANSMISSION, bounce, path_flag, - &ls)) { + &ls)) + { return; } } diff --git a/intern/cycles/kernel/integrator/surface_shader.h b/intern/cycles/kernel/integrator/surface_shader.h index 19e1845ce67..a0fa9255628 100644 --- a/intern/cycles/kernel/integrator/surface_shader.h +++ b/intern/cycles/kernel/integrator/surface_shader.h @@ -66,7 +66,8 @@ ccl_device_inline void surface_shader_prepare_guiding(KernelGlobals kg, /* Init guiding (diffuse BSDFs only for now). */ if (!(diffuse_sampling_fraction > 0.0f && - guiding_bsdf_init(kg, state, sd->P, sd->N, rand_bsdf_guiding))) { + guiding_bsdf_init(kg, state, sd->P, sd->N, rand_bsdf_guiding))) + { state->guiding.use_surface_guiding = false; return; } @@ -106,12 +107,14 @@ ccl_device_inline void surface_shader_prepare_closures(KernelGlobals kg, (CLOSURE_IS_BSDF_GLOSSY(sc->type) && (kernel_data.integrator.filter_closures & FILTER_CLOSURE_GLOSSY)) || (CLOSURE_IS_BSDF_TRANSMISSION(sc->type) && - (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSMISSION))) { + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSMISSION))) + { sc->type = CLOSURE_NONE_ID; sc->sample_weight = 0.0f; } else if ((CLOSURE_IS_BSDF_TRANSPARENT(sc->type) && - (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSPARENT))) { + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSPARENT))) + { sc->type = CLOSURE_HOLDOUT_ID; sc->sample_weight = 0.0f; sd->flag |= SD_HOLDOUT; @@ -127,7 +130,8 @@ ccl_device_inline void surface_shader_prepare_closures(KernelGlobals kg, * a good heuristic. */ if (INTEGRATOR_STATE(state, path, bounce) + INTEGRATOR_STATE(state, path, transparent_bounce) == 0 && - sd->num_closure > 1) { + sd->num_closure > 1) + { float sum = 0.0f; for (int i = 0; i < sd->num_closure; i++) { @@ -153,7 +157,8 @@ ccl_device_inline void surface_shader_prepare_closures(KernelGlobals kg, #ifdef __MNEE__ && !(INTEGRATOR_STATE(state, path, mnee) & PATH_MNEE_VALID) #endif - ) { + ) + { float blur_pdf = kernel_data.integrator.filter_glossy * INTEGRATOR_STATE(state, path, min_ray_pdf); diff --git a/intern/cycles/kernel/light/area.h b/intern/cycles/kernel/light/area.h index 9391cc49858..b2c853dc5c7 100644 --- a/intern/cycles/kernel/light/area.h +++ b/intern/cycles/kernel/light/area.h @@ -277,7 +277,8 @@ ccl_device_inline bool area_light_sample(const ccl_global KernelLight *klight, &sample_axis_v, &sample_len_v, klight->area.tan_half_spread, - &sample_rectangle)) { + &sample_rectangle)) + { return false; } } @@ -424,7 +425,8 @@ ccl_device_inline bool area_light_sample_from_intersection( &sample_axis_v, &sample_len_v, klight->area.tan_half_spread, - &sample_rectangle)) { + &sample_rectangle)) + { return false; } } diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index 301c3d7db9c..c451d70e365 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -140,7 +140,8 @@ ccl_device_noinline bool light_sample(KernelGlobals kg, /* Exclude synthetic meshes from shadow catcher pass. */ if ((path_flag & PATH_RAY_SHADOW_CATCHER_PASS) && - !(kernel_data_fetch(object_flag, object) & SD_OBJECT_SHADOW_CATCHER)) { + !(kernel_data_fetch(object_flag, object) & SD_OBJECT_SHADOW_CATCHER)) + { return false; } @@ -192,7 +193,8 @@ ccl_device bool lights_intersect(KernelGlobals kg, /* This path should have been resolved with mnee, it will * generate a firefly for small lights since it is improbable. */ if ((INTEGRATOR_STATE(state, path, mnee) & PATH_MNEE_CULL_LIGHT_CONNECTION) && - klight->use_caustics) { + klight->use_caustics) + { continue; } #endif @@ -227,7 +229,8 @@ ccl_device bool lights_intersect(KernelGlobals kg, } if (t < isect->t && - !(last_prim == lamp && last_object == OBJECT_NONE && last_type == PRIMITIVE_LAMP)) { + !(last_prim == lamp && last_object == OBJECT_NONE && last_type == PRIMITIVE_LAMP)) + { isect->t = t; isect->u = u; isect->v = v; diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 9122f4f68f3..b160b4614b8 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -29,7 +29,8 @@ ccl_device float light_tree_cos_bounding_box_angle(const BoundingBox bbox, const float3 point_to_centroid) { if (P.x > bbox.min.x && P.y > bbox.min.y && P.z > bbox.min.z && P.x < bbox.max.x && - P.y < bbox.max.y && P.z < bbox.max.z) { + P.y < bbox.max.y && P.z < bbox.max.z) + { /* If P is inside the bbox, `theta_u` covers the whole sphere. */ return -1.0f; } @@ -189,7 +190,8 @@ ccl_device void light_tree_importance(const float3 N_or_D, cos_min_outgoing_angle = 1.0f; } else if ((bcone.theta_o + bcone.theta_e > M_PI_F) || - (cos_theta_minus_theta_u > cos(bcone.theta_o + bcone.theta_e))) { + (cos_theta_minus_theta_u > cos(bcone.theta_o + bcone.theta_e))) + { /* theta' = theta - theta_o - theta_u < theta_e */ kernel_assert( (fast_acosf(cos_theta) - bcone.theta_o - fast_acosf(cos_theta_u) - bcone.theta_e) < 5e-4f); @@ -218,7 +220,8 @@ ccl_device void light_tree_importance(const float3 N_or_D, float cos_max_outgoing_angle; const float cos_theta_plus_theta_u = cos_theta * cos_theta_u - sin_theta * sin_theta_u; if (bcone.theta_e - bcone.theta_o < 0 || cos_theta < 0 || cos_theta_u < 0 || - cos_theta_plus_theta_u < cos(bcone.theta_e - bcone.theta_o)) { + cos_theta_plus_theta_u < cos(bcone.theta_e - bcone.theta_o)) + { min_importance = 0.0f; } else { @@ -279,8 +282,8 @@ ccl_device bool compute_emitter_centroid_and_dir(KernelGlobals kg, dir = -dir; } const int object_flag = kernel_data_fetch(object_flag, object); - if ((object_flag & SD_OBJECT_TRANSFORM_APPLIED) && - (object_flag & SD_OBJECT_NEGATIVE_SCALE)) { + if ((object_flag & SD_OBJECT_TRANSFORM_APPLIED) && (object_flag & SD_OBJECT_NEGATIVE_SCALE)) + { dir = -dir; } } @@ -393,8 +396,8 @@ ccl_device void light_tree_emitter_importance(KernelGlobals kg, float2 distance; /* distance.x = max_distance, distance.y = mix_distance */ float3 centroid, point_to_centroid, P_c; - if (!compute_emitter_centroid_and_dir( - kg, kemitter, P, centroid, bcone.axis)) { + if (!compute_emitter_centroid_and_dir(kg, kemitter, P, centroid, bcone.axis)) + { return; } @@ -706,7 +709,8 @@ ccl_device_noinline bool light_tree_sample(KernelGlobals kg, float left_prob; if (!get_left_probability( - kg, local_P, N_or_D, t, has_transmission, left_index, right_index, left_prob)) { + kg, local_P, N_or_D, t, has_transmission, left_index, right_index, left_prob)) + { return false; /* Both child nodes have zero importance. */ } @@ -825,7 +829,8 @@ ccl_device float light_tree_pdf( float left_prob; if (!get_left_probability( - kg, P, N, 0, has_transmission, left_index, right_index, left_prob)) { + kg, P, N, 0, has_transmission, left_index, right_index, left_prob)) + { return 0.0f; } diff --git a/intern/cycles/kernel/light/triangle.h b/intern/cycles/kernel/light/triangle.h index 8cca66e5f20..5a69ac784bd 100644 --- a/intern/cycles/kernel/light/triangle.h +++ b/intern/cycles/kernel/light/triangle.h @@ -221,8 +221,8 @@ ccl_device_forceinline bool triangle_light_sample(KernelGlobals kg, ls->D = z * B + sin_from_cos(z) * safe_normalize(C_ - dot(C_, B) * B); /* calculate intersection with the planar triangle */ - if (!ray_triangle_intersect( - P, ls->D, 0.0f, FLT_MAX, V[0], V[1], V[2], &ls->u, &ls->v, &ls->t)) { + if (!ray_triangle_intersect(P, ls->D, 0.0f, FLT_MAX, V[0], V[1], V[2], &ls->u, &ls->v, &ls->t)) + { ls->pdf = 0.0f; return false; } diff --git a/intern/cycles/kernel/osl/closures_setup.h b/intern/cycles/kernel/osl/closures_setup.h index 462d1405064..549ab3b6b21 100644 --- a/intern/cycles/kernel/osl/closures_setup.h +++ b/intern/cycles/kernel/osl/closures_setup.h @@ -52,7 +52,8 @@ ccl_device_forceinline bool osl_closure_skip(KernelGlobals kg, /* caustic options */ if ((scattering & LABEL_GLOSSY) && (path_flag & PATH_RAY_DIFFUSE)) { if ((!kernel_data.integrator.caustics_reflective && (scattering & LABEL_REFLECT)) || - (!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT))) { + (!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT))) + { return true; } } @@ -215,7 +216,8 @@ ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg, /* GGX */ if (closure->distribution == make_string("ggx", 11253504724482777663ull) || - closure->distribution == make_string("default", 4430693559278735917ull)) { + closure->distribution == make_string("default", 4430693559278735917ull)) + { if (has_reflection && has_transmission) { sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf); } @@ -274,7 +276,8 @@ ccl_device void osl_closure_conductor_bsdf_setup(KernelGlobals kg, /* GGX */ if (closure->distribution == make_string("ggx", 11253504724482777663ull) || - closure->distribution == make_string("default", 4430693559278735917ull)) { + closure->distribution == make_string("default", 4430693559278735917ull)) + { sd->flag |= bsdf_microfacet_ggx_setup(bsdf); } /* Beckmann */ @@ -324,7 +327,8 @@ ccl_device void osl_closure_generalized_schlick_bsdf_setup( /* GGX */ if (closure->distribution == make_string("ggx", 11253504724482777663ull) || - closure->distribution == make_string("default", 4430693559278735917ull)) { + closure->distribution == make_string("default", 4430693559278735917ull)) + { if (has_reflection && has_transmission) { sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf); } diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index ea4356b6c0f..e17d5268388 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -429,7 +429,8 @@ static bool set_attribute_float2(float2 f[3], TypeDesc type, bool derivatives, v return true; } else if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || - type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) { + type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) + { float *fval = (float *)val; fval[0] = f[0].x; @@ -499,7 +500,8 @@ static bool set_attribute_float3(float3 f[3], TypeDesc type, bool derivatives, v return true; } else if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || - type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) { + type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) + { float *fval = (float *)val; fval[0] = f[0].x; @@ -575,7 +577,8 @@ static bool set_attribute_float4(float4 f[3], TypeDesc type, bool derivatives, v return true; } else if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || - type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) { + type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) + { fval[0] = f[0].x; fval[1] = f[0].y; fval[2] = f[0].z; @@ -639,7 +642,8 @@ static bool set_attribute_float(float f[3], TypeDesc type, bool derivatives, voi return true; } else if (type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || - type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) { + type == TypeDesc::TypeNormal || type == TypeDesc::TypeColor) + { float *fval = (float *)val; fval[0] = f[0]; fval[1] = f[0]; @@ -930,7 +934,8 @@ bool OSLRenderServices::get_object_standard_attribute(const KernelGlobalsCPU *kg return set_attribute_int(3, type, derivatives, val); } else if ((name == u_geom_trianglevertices || name == u_geom_polyvertices) && - sd->type & PRIMITIVE_TRIANGLE) { + sd->type & PRIMITIVE_TRIANGLE) + { float3 P[3]; if (sd->type & PRIMITIVE_MOTION) { @@ -1070,7 +1075,8 @@ bool OSLRenderServices::get_background_attribute(const KernelGlobalsCPU *kg, float3 ndc[3]; if ((globals->raytype & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE && - kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { + kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) + { ndc[0] = camera_world_to_ndc(kg, sd, sd->ray_P); if (derivatives) { diff --git a/intern/cycles/kernel/osl/services_gpu.h b/intern/cycles/kernel/osl/services_gpu.h index 24547e4c766..30fad3244c9 100644 --- a/intern/cycles/kernel/osl/services_gpu.h +++ b/intern/cycles/kernel/osl/services_gpu.h @@ -810,16 +810,16 @@ ccl_device_inline bool set_attribute_float(ccl_private float fval[3], const int type_arraylen = type >> 32; if (type_basetype == 11 /* TypeDesc::FLOAT */) { - if ((type_aggregate == 2 /* TypeDesc::VEC2 */) || - (type_aggregate == 1 && type_arraylen == 2)) { + if ((type_aggregate == 2 /* TypeDesc::VEC2 */) || (type_aggregate == 1 && type_arraylen == 2)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 2 + 0] = fval[i]; static_cast(val)[i * 2 + 1] = fval[i]; } return true; } - if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || - (type_aggregate == 1 && type_arraylen == 3)) { + if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 3 + 0] = fval[i]; static_cast(val)[i * 3 + 1] = fval[i]; @@ -827,8 +827,8 @@ ccl_device_inline bool set_attribute_float(ccl_private float fval[3], } return true; } - if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || - (type_aggregate == 1 && type_arraylen == 4)) { + if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 4 + 0] = fval[i]; static_cast(val)[i * 4 + 1] = fval[i]; @@ -870,16 +870,16 @@ ccl_device_inline bool set_attribute_float2(ccl_private float2 fval[3], const int type_arraylen = type >> 32; if (type_basetype == 11 /* TypeDesc::FLOAT */) { - if ((type_aggregate == 2 /* TypeDesc::VEC2 */) || - (type_aggregate == 1 && type_arraylen == 2)) { + if ((type_aggregate == 2 /* TypeDesc::VEC2 */) || (type_aggregate == 1 && type_arraylen == 2)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 2 + 0] = fval[i].x; static_cast(val)[i * 2 + 1] = fval[i].y; } return true; } - if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || - (type_aggregate == 1 && type_arraylen == 3)) { + if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 3 + 0] = fval[i].x; static_cast(val)[i * 3 + 1] = fval[i].y; @@ -887,8 +887,8 @@ ccl_device_inline bool set_attribute_float2(ccl_private float2 fval[3], } return true; } - if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || - (type_aggregate == 1 && type_arraylen == 4)) { + if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 4 + 0] = fval[i].x; static_cast(val)[i * 4 + 1] = fval[i].y; @@ -917,8 +917,8 @@ ccl_device_inline bool set_attribute_float3(ccl_private float3 fval[3], const int type_arraylen = type >> 32; if (type_basetype == 11 /* TypeDesc::FLOAT */) { - if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || - (type_aggregate == 1 && type_arraylen == 3)) { + if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 3 + 0] = fval[i].x; static_cast(val)[i * 3 + 1] = fval[i].y; @@ -926,8 +926,8 @@ ccl_device_inline bool set_attribute_float3(ccl_private float3 fval[3], } return true; } - if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || - (type_aggregate == 1 && type_arraylen == 4)) { + if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 4 + 0] = fval[i].x; static_cast(val)[i * 4 + 1] = fval[i].y; @@ -969,8 +969,8 @@ ccl_device_inline bool set_attribute_float4(ccl_private float4 fval[3], const int type_arraylen = type >> 32; if (type_basetype == 11 /* TypeDesc::FLOAT */) { - if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || - (type_aggregate == 1 && type_arraylen == 3)) { + if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 3 + 0] = fval[i].x; static_cast(val)[i * 3 + 1] = fval[i].y; @@ -978,8 +978,8 @@ ccl_device_inline bool set_attribute_float4(ccl_private float4 fval[3], } return true; } - if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || - (type_aggregate == 1 && type_arraylen == 4)) { + if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4)) + { for (int i = 0; i < (derivatives ? 3 : 1); ++i) { static_cast(val)[i * 4 + 0] = fval[i].x; static_cast(val)[i * 4 + 1] = fval[i].y; diff --git a/intern/cycles/kernel/osl/shaders/node_normal_map.osl b/intern/cycles/kernel/osl/shaders/node_normal_map.osl index 7e41bbf1720..d5892da5bd1 100644 --- a/intern/cycles/kernel/osl/shaders/node_normal_map.osl +++ b/intern/cycles/kernel/osl/shaders/node_normal_map.osl @@ -31,7 +31,8 @@ shader node_normal_map(float Strength = 1.0, // get _unnormalized_ interpolated normal and tangent if (getattribute(attr_name, tangent) && getattribute(attr_sign_name, tangent_sign) && - (!is_smooth || getattribute("geom:normal_map_normal", ninterp))) { + (!is_smooth || getattribute("geom:normal_map_normal", ninterp))) + { // apply normal map vector B = tangent_sign * cross(ninterp, tangent); Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * ninterp); diff --git a/intern/cycles/kernel/svm/closure.h b/intern/cycles/kernel/svm/closure.h index 803cf33c358..2706d9e95f1 100644 --- a/intern/cycles/kernel/svm/closure.h +++ b/intern/cycles/kernel/svm/closure.h @@ -52,8 +52,7 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, return svm_node_closure_bsdf_skip(kg, offset, type); } } - else - { + else { return svm_node_closure_bsdf_skip(kg, offset, type); } @@ -256,7 +255,8 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, if (kernel_data.integrator.caustics_reflective || (path_flag & PATH_RAY_DIFFUSE) == 0) { #endif if (specular_weight > CLOSURE_WEIGHT_CUTOFF && - (specular > CLOSURE_WEIGHT_CUTOFF || metallic > CLOSURE_WEIGHT_CUTOFF)) { + (specular > CLOSURE_WEIGHT_CUTOFF || metallic > CLOSURE_WEIGHT_CUTOFF)) + { Spectrum spec_weight = weight * specular_weight; ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc( @@ -288,12 +288,14 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, fresnel->color = rgb_to_spectrum(base_color); /* setup bsdf */ - if (distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || - roughness <= 0.075f) { /* use single-scatter GGX */ + + /* Use single-scatter GGX. */ + if (distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID || roughness <= 0.075f) { sd->flag |= bsdf_microfacet_ggx_setup(bsdf); bsdf_microfacet_setup_fresnel_principledv1(bsdf, sd, fresnel); - } - else { /* use multi-scatter GGX */ + } /* Use multi-scatter GGX. */ + else { + bsdf->fresnel = fresnel; sd->flag |= bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd); } @@ -306,14 +308,16 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, /* BSDF */ #ifdef __CAUSTICS_TRICKS__ if (kernel_data.integrator.caustics_reflective || - kernel_data.integrator.caustics_refractive || (path_flag & PATH_RAY_DIFFUSE) == 0) { + kernel_data.integrator.caustics_refractive || (path_flag & PATH_RAY_DIFFUSE) == 0) + { #endif if (final_transmission > CLOSURE_WEIGHT_CUTOFF) { Spectrum glass_weight = weight * final_transmission; float3 cspec0 = base_color * specular_tint + make_float3(1.0f - specular_tint); - if (roughness <= 5e-2f || - distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID) { /* use single-scatter GGX */ + /* Use single-scatter GGX. */ + if (roughness <= 5e-2f || distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID) { + float refl_roughness = roughness; /* reflection */ @@ -376,8 +380,8 @@ ccl_device_noinline int svm_node_closure_bsdf(KernelGlobals kg, sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf); } } - } - else { /* use multi-scatter GGX */ + } /* Use multi-scatter GGX. */ + else { ccl_private MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)bsdf_alloc( sd, sizeof(MicrofacetBsdf), glass_weight); ccl_private FresnelPrincipledV1 *fresnel = diff --git a/intern/cycles/kernel/svm/displace.h b/intern/cycles/kernel/svm/displace.h index 844f7afa90b..29009266ac7 100644 --- a/intern/cycles/kernel/svm/displace.h +++ b/intern/cycles/kernel/svm/displace.h @@ -73,8 +73,7 @@ ccl_device_noinline void svm_node_set_bump(KernelGlobals kg, stack_store_float3(stack, node.w, normal_out); } - else - { + else { stack_store_float3(stack, node.w, zero_float3()); } #endif @@ -128,8 +127,7 @@ ccl_device_noinline void svm_node_displacement(KernelGlobals kg, stack_store_float3(stack, node.z, dP); } - else - { + else { stack_store_float3(stack, node.z, zero_float3()); } } @@ -183,8 +181,7 @@ ccl_device_noinline int svm_node_vector_displacement( stack_store_float3(stack, displacement_offset, dP); } - else - { + else { stack_store_float3(stack, displacement_offset, zero_float3()); (void)data_node; } diff --git a/intern/cycles/kernel/svm/math.h b/intern/cycles/kernel/svm/math.h index 50bf2fda145..673b7c678a4 100644 --- a/intern/cycles/kernel/svm/math.h +++ b/intern/cycles/kernel/svm/math.h @@ -47,7 +47,8 @@ ccl_device_noinline int svm_node_vector_math(KernelGlobals kg, /* 3 Vector Operators */ if (type == NODE_VECTOR_MATH_WRAP || type == NODE_VECTOR_MATH_FACEFORWARD || - type == NODE_VECTOR_MATH_MULTIPLY_ADD) { + type == NODE_VECTOR_MATH_MULTIPLY_ADD) + { uint4 extra_node = read_node(kg, &offset); c = stack_load_float3(stack, extra_node.x); } diff --git a/intern/cycles/kernel/svm/sky.h b/intern/cycles/kernel/svm/sky.h index a9838624066..41f1dcc2ce8 100644 --- a/intern/cycles/kernel/svm/sky.h +++ b/intern/cycles/kernel/svm/sky.h @@ -144,7 +144,8 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals kg, /* If the ray is inside the sun disc, render it, otherwise render the sky. * Alternatively, ignore the sun if we're evaluating the background texture. */ if (sun_disc && sun_dir_angle < half_angular && - !((path_flag & PATH_RAY_IMPORTANCE_BAKE) && kernel_data.background.use_sun_guiding)) { + !((path_flag & PATH_RAY_IMPORTANCE_BAKE) && kernel_data.background.use_sun_guiding)) + { /* get 2 pixels data */ float y; diff --git a/intern/cycles/kernel/svm/vector_transform.h b/intern/cycles/kernel/svm/vector_transform.h index 9ee44f35329..2c69e6c7b63 100644 --- a/intern/cycles/kernel/svm/vector_transform.h +++ b/intern/cycles/kernel/svm/vector_transform.h @@ -49,7 +49,8 @@ ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg, /* From camera */ else if (from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) { if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || - to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) { + to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) + { tfm = kernel_data.cam.cameratoworld; if (is_direction) in = transform_direction(&tfm, in); @@ -68,7 +69,8 @@ ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg, else if (from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT) { if ((to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD || to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) && - is_object) { + is_object) + { if (is_direction) object_dir_transform(kg, sd, &in); else diff --git a/intern/cycles/scene/alembic.cpp b/intern/cycles/scene/alembic.cpp index 3b88cd58f30..152a520ea61 100644 --- a/intern/cycles/scene/alembic.cpp +++ b/intern/cycles/scene/alembic.cpp @@ -254,7 +254,8 @@ static M44d convert_yup_zup(const M44d &mtx, float scale_mult) rotation, translation, true, - IMATH_INTERNAL_NAMESPACE::Euler::XZY)) { + IMATH_INTERNAL_NAMESPACE::Euler::XZY)) + { return mtx; } @@ -806,7 +807,8 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress) /* Check if the shaders were modified. */ if (object->used_shaders_is_modified() && object->get_object() && - object->get_object()->get_geometry()) { + object->get_object()->get_geometry()) + { Geometry *geometry = object->get_object()->get_geometry(); array used_shaders = object->get_used_shaders(); geometry->set_used_shaders(used_shaders); @@ -908,7 +910,8 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress) /* skip constant objects */ if (object->is_constant() && !object->is_modified() && !object->need_shader_update && - !scale_is_modified()) { + !scale_is_modified()) + { continue; } @@ -994,7 +997,8 @@ void AlembicProcedural::load_objects(Progress &progress) geometry = scene_->create_node(); } else if (abc_object->schema_type == AlembicObject::POLY_MESH || - abc_object->schema_type == AlembicObject::SUBD) { + abc_object->schema_type == AlembicObject::SUBD) + { geometry = scene_->create_node(); } else { @@ -1469,7 +1473,8 @@ void AlembicProcedural::build_caches(Progress &progress) } else if (object->schema_type == AlembicObject::CURVES) { if (!object->has_data_loaded() || default_radius_is_modified() || - object->radius_scale_is_modified()) { + object->radius_scale_is_modified()) + { ICurves curves(object->iobject, Alembic::Abc::kWrapExisting); ICurvesSchema schema = curves.getSchema(); object->load_data_in_cache(object->get_cached_data(), this, schema, progress); @@ -1477,7 +1482,8 @@ void AlembicProcedural::build_caches(Progress &progress) } else if (object->schema_type == AlembicObject::POINTS) { if (!object->has_data_loaded() || default_radius_is_modified() || - object->radius_scale_is_modified()) { + object->radius_scale_is_modified()) + { IPoints points(object->iobject, Alembic::Abc::kWrapExisting); IPointsSchema schema = points.getSchema(); object->load_data_in_cache(object->get_cached_data(), this, schema, progress); diff --git a/intern/cycles/scene/alembic_read.cpp b/intern/cycles/scene/alembic_read.cpp index 26a4153a825..e6f8ed1d4c6 100644 --- a/intern/cycles/scene/alembic_read.cpp +++ b/intern/cycles/scene/alembic_read.cpp @@ -470,7 +470,8 @@ static void add_subd_edge_creases(CachedData &cached_data, chrono_t time) { if (!(data.crease_indices.valid() && data.crease_lengths.valid() && - data.crease_sharpnesses.valid())) { + data.crease_sharpnesses.valid())) + { return; } @@ -519,7 +520,8 @@ static void add_subd_vertex_creases(CachedData &cached_data, const FloatArraySamplePtr creases_sharpnesses = data.crease_sharpnesses.getValue(iss); if (!(creases_indices && creases_sharpnesses) || - creases_indices->size() != creases_sharpnesses->size()) { + creases_indices->size() != creases_sharpnesses->size()) + { return; } diff --git a/intern/cycles/scene/attribute.cpp b/intern/cycles/scene/attribute.cpp index 5a9bec6af46..42c3f7ea806 100644 --- a/intern/cycles/scene/attribute.cpp +++ b/intern/cycles/scene/attribute.cpp @@ -278,9 +278,11 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b) return true; if (a == TypeDesc::TypeColor || a == TypeDesc::TypePoint || a == TypeDesc::TypeVector || - a == TypeDesc::TypeNormal) { + a == TypeDesc::TypeNormal) + { if (b == TypeDesc::TypeColor || b == TypeDesc::TypePoint || b == TypeDesc::TypeVector || - b == TypeDesc::TypeNormal) { + b == TypeDesc::TypeNormal) + { return true; } } diff --git a/intern/cycles/scene/colorspace.cpp b/intern/cycles/scene/colorspace.cpp index a66fddbf7d4..14b35e2d8cf 100644 --- a/intern/cycles/scene/colorspace.cpp +++ b/intern/cycles/scene/colorspace.cpp @@ -72,7 +72,8 @@ ColorSpaceProcessor *ColorSpaceManager::get_processor(ustring colorspace) bool ColorSpaceManager::colorspace_is_data(ustring colorspace) { if (colorspace == u_colorspace_auto || colorspace == u_colorspace_raw || - colorspace == u_colorspace_srgb) { + colorspace == u_colorspace_srgb) + { return false; } @@ -200,14 +201,16 @@ void ColorSpaceManager::is_builtin_colorspace(ustring colorspace, /* Make sure that there is no channel crosstalk. */ if (fabsf(cR[1]) > 1e-5f || fabsf(cR[2]) > 1e-5f || fabsf(cG[0]) > 1e-5f || - fabsf(cG[2]) > 1e-5f || fabsf(cB[0]) > 1e-5f || fabsf(cB[1]) > 1e-5f) { + fabsf(cG[2]) > 1e-5f || fabsf(cB[0]) > 1e-5f || fabsf(cB[1]) > 1e-5f) + { is_scene_linear = false; is_srgb = false; break; } /* Make sure that the three primaries combine linearly. */ if (!compare_floats(cR[0], cW[0], 1e-6f, 64) || !compare_floats(cG[1], cW[1], 1e-6f, 64) || - !compare_floats(cB[2], cW[2], 1e-6f, 64)) { + !compare_floats(cB[2], cW[2], 1e-6f, 64)) + { is_scene_linear = false; is_srgb = false; break; diff --git a/intern/cycles/scene/constant_fold.cpp b/intern/cycles/scene/constant_fold.cpp index 224c8774cc6..21e28698edd 100644 --- a/intern/cycles/scene/constant_fold.cpp +++ b/intern/cycles/scene/constant_fold.cpp @@ -570,7 +570,8 @@ void ConstantFolder::fold_mapping(NodeMappingType type) const /* Check all use values are zero, note location is not used by vector and normal types. */ (is_zero(location_in) || type == NODE_MAPPING_TYPE_VECTOR || type == NODE_MAPPING_TYPE_NORMAL) && - is_zero(rotation_in) && is_one(scale_in)) { + is_zero(rotation_in) && is_one(scale_in)) + { try_bypass_or_make_constant(vector_in); } } diff --git a/intern/cycles/scene/film.cpp b/intern/cycles/scene/film.cpp index 1861dae2590..fcb34bcf5bb 100644 --- a/intern/cycles/scene/film.cpp +++ b/intern/cycles/scene/film.cpp @@ -471,7 +471,8 @@ void Film::update_passes(Scene *scene, bool add_sample_count_pass) Integrator *integrator = scene->integrator; if (!is_modified() && !object_manager->need_update() && !integrator->is_modified() && - !background->is_modified()) { + !background->is_modified()) + { return; } @@ -669,7 +670,8 @@ void Film::finalize_passes(Scene *scene, const bool use_denoise) /* If both passes have a name and the names are different, don't merge. * If either pass has a name, we'll use that name. */ if (!pass->get_name().empty() && !new_pass->get_name().empty() && - pass->get_name() != new_pass->get_name()) { + pass->get_name() != new_pass->get_name()) + { continue; } @@ -711,7 +713,8 @@ uint Film::get_kernel_features(const Scene *scene) const const PassMode pass_mode = pass->get_mode(); if (pass_mode == PassMode::DENOISED || pass_type == PASS_DENOISING_NORMAL || - pass_type == PASS_DENOISING_ALBEDO || pass_type == PASS_DENOISING_DEPTH) { + pass_type == PASS_DENOISING_ALBEDO || pass_type == PASS_DENOISING_DEPTH) + { kernel_features |= KERNEL_FEATURE_DENOISING; } diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 8c6c8b7cc51..421688ad44f 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -421,7 +421,8 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro DeviceScene *dscene = &scene->dscene; if (device_update_flags & (DEVICE_MESH_DATA_NEEDS_REALLOC | DEVICE_CURVE_DATA_NEEDS_REALLOC | - DEVICE_POINT_DATA_NEEDS_REALLOC)) { + DEVICE_POINT_DATA_NEEDS_REALLOC)) + { delete scene->bvh; scene->bvh = nullptr; @@ -914,7 +915,36 @@ void GeometryManager::device_update(Device *device, VLOG_INFO << "Rendering using " << num_scenes << " devices"; /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ - device->upload_changed(); + vector buffers { + // Geometry buffers + &dscene->tri_verts, + &dscene->tri_shader, + &dscene->tri_vnormal, + &dscene->tri_vindex, + &dscene->tri_patch, + &dscene->tri_patch_uv, + + &dscene->curve_keys, + &dscene->curves, + &dscene->curve_segments, + + &dscene->points, + &dscene->points_shader, + + &dscene->patches, + + // Attribute buffers + &dscene->attributes_map, + &dscene->attributes_float, + &dscene->attributes_float2, + &dscene->attributes_float3, + &dscene->attributes_float4, + &dscene->attributes_uchar4, + + &dscene->objects + }; + + device->upload_changed(buffers); parallel_for( size_t(0), num_scenes, [=, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, diff --git a/intern/cycles/scene/geometry_mesh.cpp b/intern/cycles/scene/geometry_mesh.cpp index 6408ea0ec3a..ff785418863 100644 --- a/intern/cycles/scene/geometry_mesh.cpp +++ b/intern/cycles/scene/geometry_mesh.cpp @@ -66,7 +66,8 @@ void GeometryManager::device_update_mesh_preprocess( Mesh *mesh = static_cast(geom); if (mesh->shader_is_modified() || mesh->smooth_is_modified() || - mesh->triangles_is_modified() || copy_all_data) { + mesh->triangles_is_modified() || copy_all_data) + { mesh->pack_shaders(scene, &tri_shader[mesh->prim_offset]); } @@ -75,7 +76,8 @@ void GeometryManager::device_update_mesh_preprocess( } if (mesh->verts_is_modified() || mesh->triangles_is_modified() || - mesh->vert_patch_uv_is_modified() || copy_all_data) { + mesh->vert_patch_uv_is_modified() || copy_all_data) + { mesh->pack_verts(&tri_verts[mesh->vert_offset], &tri_vindex[mesh->prim_offset], &tri_patch[mesh->prim_offset], diff --git a/intern/cycles/scene/image.cpp b/intern/cycles/scene/image.cpp index 3fbfcdd2c24..94626b402bd 100644 --- a/intern/cycles/scene/image.cpp +++ b/intern/cycles/scene/image.cpp @@ -799,7 +799,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } #ifdef WITH_NANOVDB else if (type == IMAGE_DATA_TYPE_NANOVDB_FLOAT || type == IMAGE_DATA_TYPE_NANOVDB_FLOAT3 || - type == IMAGE_DATA_TYPE_NANOVDB_FPN || type == IMAGE_DATA_TYPE_NANOVDB_FP16) { + type == IMAGE_DATA_TYPE_NANOVDB_FPN || type == IMAGE_DATA_TYPE_NANOVDB_FP16) + { thread_scoped_lock device_lock(device_mutex); void *pixels = img->mem->alloc(img->metadata.byte_size, 0); diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index 27a17ffe0ac..502a6884272 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -189,7 +189,8 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene foreach (Shader *shader, scene->shaders) { /* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */ if ((shader->has_surface_transparent && shader->get_use_transparent_shadow()) || - shader->has_volume) { + shader->has_volume) + { kintegrator->transparent_shadows = true; break; } @@ -266,7 +267,8 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene next_power_of_two(aa_samples - 1), MIN_TAB_SOBOL_SAMPLES, MAX_TAB_SOBOL_SAMPLES); if (kintegrator->sampling_pattern == SAMPLING_PATTERN_TABULATED_SOBOL && dscene->sample_pattern_lut.size() != - (sequence_size * NUM_TAB_SOBOL_PATTERNS * NUM_TAB_SOBOL_DIMENSIONS)) { + (sequence_size * NUM_TAB_SOBOL_PATTERNS * NUM_TAB_SOBOL_DIMENSIONS)) + { kintegrator->tabulated_sobol_sequence_size = sequence_size; if (dscene->sample_pattern_lut.size() != 0) { diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 023d2d67f9a..4d93fb1721f 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -235,7 +235,8 @@ void LightManager::test_enabled_lights(Scene *scene) } if (last_background_enabled != background_enabled || - last_background_resolution != background_resolution) { + last_background_resolution != background_resolution) + { last_background_enabled = background_enabled; last_background_resolution = background_resolution; need_update_background = true; @@ -724,7 +725,8 @@ void LightManager::device_update_background(Device *device, if (vec_in && vec_in->link && vec_in->link->parent) { ShaderNode *vec_src = vec_in->link->parent; if ((vec_src->type != TextureCoordinateNode::get_node_type()) || - (vec_in->link != vec_src->output("Generated"))) { + (vec_in->link != vec_src->output("Generated"))) + { environment_res.x = max(environment_res.x, 4096); environment_res.y = max(environment_res.y, 2048); continue; diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index 385410d7e7a..c625d488a83 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -122,7 +122,8 @@ LightTreeEmitter::LightTreeEmitter(Scene *scene, measure.bcone.axis = -measure.bcone.axis; } if ((need_transformation || mesh->transform_applied) && - transform_negative_scale(object->get_tfm())) { + transform_negative_scale(object->get_tfm())) + { measure.bcone.axis = -measure.bcone.axis; } measure.bcone.theta_o = 0; diff --git a/intern/cycles/scene/mesh_displace.cpp b/intern/cycles/scene/mesh_displace.cpp index a9f97f31df5..16292a2d77b 100644 --- a/intern/cycles/scene/mesh_displace.cpp +++ b/intern/cycles/scene/mesh_displace.cpp @@ -183,7 +183,8 @@ bool GeometryManager::displace(Device *device, Scene *scene, Mesh *mesh, Progres num_verts, 3, function_bind(&fill_shader_input, scene, mesh, object_index, _1), - function_bind(&read_shader_output, scene, mesh, _1))) { + function_bind(&read_shader_output, scene, mesh, _1))) + { return false; } diff --git a/intern/cycles/scene/object.cpp b/intern/cycles/scene/object.cpp index 9a8f276718f..f1e693602de 100644 --- a/intern/cycles/scene/object.cpp +++ b/intern/cycles/scene/object.cpp @@ -296,7 +296,8 @@ float Object::compute_volume_step_size() const Shader *shader = static_cast(node); if (shader->has_volume) { if ((shader->get_heterogeneous_volume() && shader->has_volume_spatial_varying) || - (shader->has_volume_attribute_dependency)) { + (shader->has_volume_attribute_dependency)) + { step_rate = fminf(shader->get_volume_step_rate(), step_rate); } } @@ -473,8 +474,8 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s } else if (geom->is_volume()) { Volume *volume = static_cast(geom); - if (volume->attributes.find(ATTR_STD_VOLUME_VELOCITY) && - volume->get_velocity_scale() != 0.0f) { + if (volume->attributes.find(ATTR_STD_VOLUME_VELOCITY) && volume->get_velocity_scale() != 0.0f) + { flag |= SD_OBJECT_HAS_VOLUME_MOTION; kobject.velocity_scale = volume->get_velocity_scale(); } @@ -598,7 +599,8 @@ void ObjectManager::device_update_prim_offsets(Device *device, DeviceScene *dsce BVHLayoutMask layout_mask = device->get_bvh_layout_mask(dscene->data.kernel_features); if (layout_mask != BVH_LAYOUT_METAL && layout_mask != BVH_LAYOUT_MULTI_METAL && layout_mask != BVH_LAYOUT_MULTI_METAL_EMBREE && layout_mask != BVH_LAYOUT_HIPRT && - layout_mask != BVH_LAYOUT_MULTI_HIPRT && layout_mask != BVH_LAYOUT_MULTI_HIPRT_EMBREE) { + layout_mask != BVH_LAYOUT_MULTI_HIPRT && layout_mask != BVH_LAYOUT_MULTI_HIPRT_EMBREE) + { return; } } diff --git a/intern/cycles/scene/pass.cpp b/intern/cycles/scene/pass.cpp index 582e59c2889..8718a466c46 100644 --- a/intern/cycles/scene/pass.cpp +++ b/intern/cycles/scene/pass.cpp @@ -402,7 +402,8 @@ int Pass::get_offset(const vector &passes, const Pass *pass) /* Note that pass name is allowed to be empty. This is why we check for type and mode. */ if (current_pass->get_type() == pass->get_type() && current_pass->get_mode() == pass->get_mode() && - current_pass->get_name() == pass->get_name()) { + current_pass->get_name() == pass->get_name()) + { if (current_pass->is_written()) { return pass_offset; } diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 000d6161711..c3b64ee3769 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -368,7 +368,8 @@ bool Scene::need_global_attribute(AttributeStandard std) else if (std == ATTR_STD_MOTION_VERTEX_NORMAL) return need_motion() == MOTION_BLUR; else if (std == ATTR_STD_VOLUME_VELOCITY || std == ATTR_STD_VOLUME_VELOCITY_X || - std == ATTR_STD_VOLUME_VELOCITY_Y || std == ATTR_STD_VOLUME_VELOCITY_Z) { + std == ATTR_STD_VOLUME_VELOCITY_Y || std == ATTR_STD_VOLUME_VELOCITY_Z) + { return need_motion() != MOTION_NONE; } diff --git a/intern/cycles/scene/shader.cpp b/intern/cycles/scene/shader.cpp index 0b419989f7c..8289070c913 100644 --- a/intern/cycles/scene/shader.cpp +++ b/intern/cycles/scene/shader.cpp @@ -131,7 +131,8 @@ static float3 output_estimate_emission(ShaderOutput *output, bool &is_constant) return zero_float3(); } else if (node->type == EmissionNode::get_node_type() || - node->type == BackgroundNode::get_node_type()) { + node->type == BackgroundNode::get_node_type()) + { /* Emission and Background node. */ ShaderInput *color_in = node->input("Color"); ShaderInput *strength_in = node->input("Strength"); @@ -166,7 +167,8 @@ static float3 output_estimate_emission(ShaderOutput *output, bool &is_constant) return estimate; } else if (node->type == LightFalloffNode::get_node_type() || - node->type == IESLightNode::get_node_type()) { + node->type == IESLightNode::get_node_type()) + { /* Get strength from Light Falloff and IES texture node. */ ShaderInput *strength_in = node->input("Strength"); is_constant = false; diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index 695588c6aa7..803dd4efac8 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -2182,7 +2182,8 @@ void ConvertNode::constant_fold(const ConstantFolder &folder) ShaderInput *prev_in = prev->inputs[0]; if (SocketType::is_float3(from) && (to == SocketType::FLOAT || SocketType::is_float3(to)) && - prev_in->link) { + prev_in->link) + { folder.bypass(prev_in->link); } } @@ -2841,7 +2842,8 @@ void PrincipledBsdfNode::expand(ShaderGraph *graph) ShaderInput *emission_in = input("Emission"); ShaderInput *emission_strength_in = input("Emission Strength"); if ((emission_in->link || emission != zero_float3()) && - (emission_strength_in->link || emission_strength != 0.0f)) { + (emission_strength_in->link || emission_strength != 0.0f)) + { /* Create add closure and emission, and relink inputs. */ AddClosureNode *add = graph->create_node(); EmissionNode *emission_node = graph->create_node(); @@ -5820,7 +5822,8 @@ void AttributeNode::attributes(Shader *shader, AttributeRequestSet *attributes) ShaderOutput *alpha_out = output("Alpha"); if (!color_out->links.empty() || !vector_out->links.empty() || !fac_out->links.empty() || - !alpha_out->links.empty()) { + !alpha_out->links.empty()) + { attributes->add_standard(attribute); } @@ -6619,7 +6622,8 @@ void VectorMathNode::compile(SVMCompiler &compiler) /* 3 Vector Operators */ if (math_type == NODE_VECTOR_MATH_WRAP || math_type == NODE_VECTOR_MATH_FACEFORWARD || - math_type == NODE_VECTOR_MATH_MULTIPLY_ADD) { + math_type == NODE_VECTOR_MATH_MULTIPLY_ADD) + { ShaderInput *vector3_in = input("Vector3"); int vector3_stack_offset = compiler.stack_assign(vector3_in); compiler.add_node( diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index 7b2f267b609..c43570bbf42 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -262,7 +262,8 @@ int SVMCompiler::stack_assign(ShaderInput *input) add_node(NODE_VALUE_F, node->get_int(input->socket_type), input->stack_offset); } else if (input->type() == SocketType::VECTOR || input->type() == SocketType::NORMAL || - input->type() == SocketType::POINT || input->type() == SocketType::COLOR) { + input->type() == SocketType::POINT || input->type() == SocketType::COLOR) + { add_node(NODE_VALUE_V, input->stack_offset); add_node(NODE_VALUE_V, node->get_float3(input->socket_type)); @@ -413,7 +414,8 @@ void SVMCompiler::find_dependencies(ShaderNodeSet &dependencies, { ShaderNode *node = (input->link) ? input->link->parent : NULL; if (node != NULL && done.find(node) == done.end() && node != skip_node && - dependencies.find(node) == dependencies.end()) { + dependencies.find(node) == dependencies.end()) + { foreach (ShaderInput *in, node->inputs) { find_dependencies(dependencies, done, in, skip_node); } diff --git a/intern/cycles/scene/volume.cpp b/intern/cycles/scene/volume.cpp index 573800fcf80..c015f0918ab 100644 --- a/intern/cycles/scene/volume.cpp +++ b/intern/cycles/scene/volume.cpp @@ -428,7 +428,8 @@ void VolumeMeshBuilder::convert_quads_to_tris(const vector &quads, bool VolumeMeshBuilder::empty_grid() const { #ifdef WITH_OPENVDB - return !topology_grid || topology_grid->tree().leafCount() == 0; + return !topology_grid || + (!topology_grid->tree().hasActiveTiles() && topology_grid->tree().leafCount() == 0); #else return true; #endif diff --git a/intern/cycles/session/buffers.cpp b/intern/cycles/session/buffers.cpp index c447952754a..10362b63de6 100644 --- a/intern/cycles/session/buffers.cpp +++ b/intern/cycles/session/buffers.cpp @@ -230,12 +230,14 @@ bool BufferParams::modified(const BufferParams &other) const } if (full_x != other.full_x || full_y != other.full_y || full_width != other.full_width || - full_height != other.full_height) { + full_height != other.full_height) + { return true; } if (window_x != other.window_x || window_y != other.window_y || - window_width != other.window_width || window_height != other.window_height) { + window_width != other.window_width || window_height != other.window_height) + { return true; } @@ -249,7 +251,8 @@ bool BufferParams::modified(const BufferParams &other) const if (exposure != other.exposure || use_approximate_shadow_catcher != other.use_approximate_shadow_catcher || - use_transparent_background != other.use_transparent_background) { + use_transparent_background != other.use_transparent_background) + { return true; } @@ -352,7 +355,8 @@ void render_buffers_host_copy_denoised(RenderBuffers *dst, float *dst_pixel = dst->buffer.data(); for (int i = 0; i < dst_num_pixels; - ++i, src_pixel += src_pass_stride, dst_pixel += dst_pass_stride) { + ++i, src_pixel += src_pass_stride, dst_pixel += dst_pass_stride) + { for (int pass_offset_idx = 0; pass_offset_idx < num_passes; ++pass_offset_idx) { const int dst_pass_offset = pass_offsets[pass_offset_idx].dst_offset; const int src_pass_offset = pass_offsets[pass_offset_idx].src_offset; diff --git a/intern/cycles/session/merge.cpp b/intern/cycles/session/merge.cpp index d9d189ebd2b..4993e8b5495 100644 --- a/intern/cycles/session/merge.cpp +++ b/intern/cycles/session/merge.cpp @@ -77,12 +77,14 @@ struct MergeImage { static MergeChannelOp parse_channel_operation(const string &pass_name) { if (pass_name == "Depth" || pass_name == "IndexMA" || pass_name == "IndexOB" || - string_startswith(pass_name, "Crypto")) { + string_startswith(pass_name, "Crypto")) + { return MERGE_CHANNEL_COPY; } else if (string_startswith(pass_name, "Debug BVH") || string_startswith(pass_name, "Debug Ray") || - string_startswith(pass_name, "Debug Render Time")) { + string_startswith(pass_name, "Debug Render Time")) + { return MERGE_CHANNEL_SUM; } else if (string_startswith(pass_name, "Debug Sample Count")) { @@ -263,7 +265,8 @@ static bool open_images(const vector &filepaths, vector &ima if (base_spec.width != spec.width || base_spec.height != spec.height || base_spec.depth != spec.depth || base_spec.format != spec.format || - base_spec.deep != spec.deep) { + base_spec.deep != spec.deep) + { error = "Images do not have matching size and data layout."; return false; } @@ -436,7 +439,8 @@ static bool merge_pixels(const vector &images, const auto &samples = layer_samples.at(layer.name); for (size_t i = 0; offset < num_pixels; - offset += stride, sample_pass_offset += stride, out_offset += out_stride, i++) { + offset += stride, sample_pass_offset += stride, out_offset += out_stride, i++) + { const float total_samples = samples.per_pixel[i]; float layer_samples; diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp index 39b7853cec2..8e2609936d7 100644 --- a/intern/cycles/session/session.cpp +++ b/intern/cycles/session/session.cpp @@ -490,7 +490,8 @@ int2 Session::get_effective_tile_size() const const int64_t actual_tile_area = static_cast(tile_size) * tile_size; if (actual_tile_area >= image_area && image_width <= TileManager::MAX_TILE_SIZE && - image_height <= TileManager::MAX_TILE_SIZE) { + image_height <= TileManager::MAX_TILE_SIZE) + { return make_int2(image_width, image_height); } diff --git a/intern/cycles/session/tile.cpp b/intern/cycles/session/tile.cpp index 5283f9883ae..15f570287bf 100644 --- a/intern/cycles/session/tile.cpp +++ b/intern/cycles/session/tile.cpp @@ -521,7 +521,8 @@ bool TileManager::write_tile(const RenderBuffers &tile_buffers) * Our task reference: #93008. */ if (tile_params.window_x || tile_params.window_y || tile_params.window_width != tile_params.width || - tile_params.window_height != tile_params.height) { + tile_params.window_height != tile_params.height) + { pixel_storage.resize(pass_stride * tile_params.window_width * tile_params.window_height); float *pixels_continuous = pixel_storage.data(); @@ -561,7 +562,8 @@ bool TileManager::write_tile(const RenderBuffers &tile_buffers) pixels, xstride, ystride, - zstride)) { + zstride)) + { LOG(ERROR) << "Error writing tile " << write_state_.tile_out->geterror(); return false; } @@ -586,7 +588,8 @@ void TileManager::finish_write_tiles() vector pixel_storage(tile_size_.x * tile_size_.y * buffer_params_.pass_stride); for (int tile_index = write_state_.num_tiles_written; tile_index < tile_state_.num_tiles; - ++tile_index) { + ++tile_index) + { const Tile tile = get_tile_for_index(tile_index); const int tile_x = tile.x + tile.window_x; diff --git a/intern/cycles/subd/patch_table.cpp b/intern/cycles/subd/patch_table.cpp index a2dff0d0889..3c78d51ea7a 100644 --- a/intern/cycles/subd/patch_table.cpp +++ b/intern/cycles/subd/patch_table.cpp @@ -95,8 +95,8 @@ static void build_patch_map(PackedPatchTable &table, for (int array = 0; array < table.num_arrays; array++) { Far::ConstPatchParamArray params = patch_table->GetPatchParams(array); - for (int i = 0; i < patch_table->GetNumPatches(array); - i++, handle_index += PATCH_HANDLE_SIZE) { + for (int i = 0; i < patch_table->GetNumPatches(array); i++, handle_index += PATCH_HANDLE_SIZE) + { const Far::PatchParam ¶m = params[i]; unsigned short depth = param.GetDepth(); diff --git a/intern/cycles/subd/split.cpp b/intern/cycles/subd/split.cpp index a9a5b4c990b..073ae3d0a49 100644 --- a/intern/cycles/subd/split.cpp +++ b/intern/cycles/subd/split.cpp @@ -692,7 +692,8 @@ void DiagSplit::post_split() /* Add to map */ if (params.mesh->vert_to_stitching_key_map.find(vert) == - params.mesh->vert_to_stitching_key_map.end()) { + params.mesh->vert_to_stitching_key_map.end()) + { params.mesh->vert_to_stitching_key_map[vert] = key; params.mesh->vert_stitching_map.insert({key, vert}); } diff --git a/intern/cycles/util/math_matrix.h b/intern/cycles/util/math_matrix.h index b10d9b3c938..39186798378 100644 --- a/intern/cycles/util/math_matrix.h +++ b/intern/cycles/util/math_matrix.h @@ -277,7 +277,8 @@ ccl_device void math_matrix_jacobi_eigendecomposition(ccl_private float *A, /* If we're in a later sweep and the element already is very small, * just set it to zero and skip the rotation. */ if (sweep > 3 && abs_element <= singular_epsilon * fabsf(MAT(A, n, row, row)) && - abs_element <= singular_epsilon * fabsf(MAT(A, n, col, col))) { + abs_element <= singular_epsilon * fabsf(MAT(A, n, col, col))) + { MAT(A, n, row, col) = 0.0f; continue; } diff --git a/intern/cycles/util/md5.cpp b/intern/cycles/util/md5.cpp index 62a9e62652d..0ff4ba67f24 100644 --- a/intern/cycles/util/md5.cpp +++ b/intern/cycles/util/md5.cpp @@ -95,8 +95,7 @@ void MD5Hash::process(const uint8_t *data /*[64]*/) */ static const int w = 1; - if (*((const uint8_t *)&w)) /* dynamic little-endian */ - { + if (*((const uint8_t *)&w)) /* dynamic little-endian */ { /* * On little-endian machines, we can process properly aligned * data without copying it. diff --git a/intern/cycles/util/path.cpp b/intern/cycles/util/path.cpp index 190a979af79..5cb72d875b7 100644 --- a/intern/cycles/util/path.cpp +++ b/intern/cycles/util/path.cpp @@ -236,7 +236,8 @@ class directory_iterator { bool skip_dots() { while (strcmp(name_list_[cur_entry_]->d_name, ".") == 0 || - strcmp(name_list_[cur_entry_]->d_name, "..") == 0) { + strcmp(name_list_[cur_entry_]->d_name, "..") == 0) + { if (!step()) { return false; } @@ -478,12 +479,14 @@ static string path_unc_to_short(const string &path) { size_t len = path.size(); if ((len > 3) && (path[0] == DIR_SEP) && (path[1] == DIR_SEP) && (path[2] == '?') && - ((path[3] == DIR_SEP) || (path[3] == DIR_SEP_ALT))) { + ((path[3] == DIR_SEP) || (path[3] == DIR_SEP_ALT))) + { if ((len > 5) && (path[5] == ':')) { return path.substr(4, len - 4); } else if ((len > 7) && (path.substr(4, 3) == "UNC") && - ((path[7] == DIR_SEP) || (path[7] == DIR_SEP_ALT))) { + ((path[7] == DIR_SEP) || (path[7] == DIR_SEP_ALT))) + { return "\\\\" + path.substr(8, len - 8); } } diff --git a/intern/cycles/util/transform.h b/intern/cycles/util/transform.h index 0c39901a63c..6ec867a8bff 100644 --- a/intern/cycles/util/transform.h +++ b/intern/cycles/util/transform.h @@ -339,7 +339,8 @@ ccl_device_inline bool transform_uniform_scale(const Transform &tfm, float &scal float stz = len_squared(transform_get_column(&tfm, 2)); if (fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && fabsf(sx - stx) < eps && - fabsf(sx - sty) < eps && fabsf(sx - stz) < eps) { + fabsf(sx - sty) < eps && fabsf(sx - stz) < eps) + { scale = sx; return true; } diff --git a/intern/dualcon/intern/octree.cpp b/intern/dualcon/intern/octree.cpp index 03f143a0a94..4204de2f841 100644 --- a/intern/dualcon/intern/octree.cpp +++ b/intern/dualcon/intern/octree.cpp @@ -1258,7 +1258,8 @@ Node *Octree::connectFace( PathElement *newEleN; if (curEleN->pos[0] != stN[0] || curEleN->pos[1] != stN[1] || curEleN->pos[2] != stN[2]) { if (curEleN->next->pos[0] != stN[0] || curEleN->next->pos[1] != stN[1] || - curEleN->next->pos[2] != stN[2]) { + curEleN->next->pos[2] != stN[2]) + { newEleN = new PathElement; newEleN->next = curEleN->next; newEleN->pos[0] = stN[0]; @@ -2302,7 +2303,8 @@ void Octree::computeMinimizer(const LeafNode *leaf, int st[3], int len, float rv if (rvalue[0] < st[0] - nh1 || rvalue[1] < st[1] - nh1 || rvalue[2] < st[2] - nh1 || - rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2) { + rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2) + { // Use mass point instead rvalue[0] = mp[0]; rvalue[1] = mp[1]; diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 5a81abb928f..53f28239760 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -282,7 +282,8 @@ int av_image_deinterlace( if (pix_fmt != AV_PIX_FMT_YUV420P && pix_fmt != AV_PIX_FMT_YUVJ420P && pix_fmt != AV_PIX_FMT_YUV422P && pix_fmt != AV_PIX_FMT_YUVJ422P && pix_fmt != AV_PIX_FMT_YUV444P && pix_fmt != AV_PIX_FMT_YUV411P && - pix_fmt != AV_PIX_FMT_GRAY8) { + pix_fmt != AV_PIX_FMT_GRAY8) + { return -1; } if ((width & 3) != 0 || (height & 3) != 0) { diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index 88674b0ec9c..e20e3c2b093 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -403,8 +403,8 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() } } const int max_ctx_attempts = increasedSamplerLimit ? 2 : 1; - for (int ctx_create_attempt = 0; ctx_create_attempt < max_ctx_attempts; - ctx_create_attempt++) { + for (int ctx_create_attempt = 0; ctx_create_attempt < max_ctx_attempts; ctx_create_attempt++) + { attribs.clear(); attribs.reserve(40); @@ -756,7 +756,8 @@ void GHOST_ContextCGL::metalUpdateFramebuffer() /* NOTE(Metal): Metal API Path. */ if (m_defaultFramebufferMetalTexture[current_swapchain_index].texture && m_defaultFramebufferMetalTexture[current_swapchain_index].texture.width == width && - m_defaultFramebufferMetalTexture[current_swapchain_index].texture.height == height) { + m_defaultFramebufferMetalTexture[current_swapchain_index].texture.height == height) + { return; } diff --git a/intern/ghost/intern/GHOST_ContextEGL.cc b/intern/ghost/intern/GHOST_ContextEGL.cc index 2530827b6ae..5236898be06 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cc +++ b/intern/ghost/intern/GHOST_ContextEGL.cc @@ -342,7 +342,8 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() } if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)) || - (egl_major == 0 && egl_minor == 0)) { + (egl_major == 0 && egl_minor == 0)) + { /* We failed to create a regular render window, retry and see if we can create a headless * render context. */ ::eglTerminate(m_display); @@ -351,7 +352,8 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() assert(egl_extension_st != nullptr); assert(strstr(egl_extension_st, "EGL_MESA_platform_surfaceless") != nullptr); if (egl_extension_st == nullptr || - strstr(egl_extension_st, "EGL_MESA_platform_surfaceless") == nullptr) { + strstr(egl_extension_st, "EGL_MESA_platform_surfaceless") == nullptr) + { goto error; } @@ -407,7 +409,8 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() (m_contextMajorVersion == 2 && epoxy_egl_version(m_display) >= 13) || (m_contextMajorVersion == 3 && epoxy_has_egl_extension(m_display, "KHR_create_context")) || - (m_contextMajorVersion == 3 && epoxy_egl_version(m_display) >= 15))) { + (m_contextMajorVersion == 3 && epoxy_egl_version(m_display) >= 15))) + { fprintf(stderr, "Warning! May not be able to create a version %d.%d ES context with version %d.%d " "of EGL\n", diff --git a/intern/ghost/intern/GHOST_ContextGLX.cc b/intern/ghost/intern/GHOST_ContextGLX.cc index 04021d05cda..83510079587 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cc +++ b/intern/ghost/intern/GHOST_ContextGLX.cc @@ -113,7 +113,8 @@ GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext() (glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB( (const GLubyte *)"glXCreateContextAttribsARB")) == nullptr || (glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glXGetProcAddressARB( - (const GLubyte *)"glXCreatePbuffer")) == nullptr) { + (const GLubyte *)"glXCreatePbuffer")) == nullptr) + { extStart = (GLubyte *)""; } } diff --git a/intern/ghost/intern/GHOST_ContextVK.cc b/intern/ghost/intern/GHOST_ContextVK.cc index 74cc42e9176..85d90b15095 100644 --- a/intern/ghost/intern/GHOST_ContextVK.cc +++ b/intern/ghost/intern/GHOST_ContextVK.cc @@ -424,7 +424,8 @@ static void enableLayer(vector &layers_available, { #define PUSH_VKLAYER(name, name2) \ if (vklayer_config_exist("VkLayer_" #name ".json") && \ - checkLayerSupport(layers_available, "VK_LAYER_" #name2)) { \ + checkLayerSupport(layers_available, "VK_LAYER_" #name2)) \ + { \ layers_enabled.push_back("VK_LAYER_" #name2); \ enabled = true; \ } \ @@ -579,7 +580,8 @@ static GHOST_TSuccess getGraphicQueueFamily(VkPhysicalDevice device, uint32_t *r * and compute pipelines. We select this one; compute only queue family hints at async compute * implementations. */ if ((queue_family.queueFlags & VK_QUEUE_GRAPHICS_BIT) && - (queue_family.queueFlags & VK_QUEUE_COMPUTE_BIT)) { + (queue_family.queueFlags & VK_QUEUE_COMPUTE_BIT)) + { return GHOST_kSuccess; } (*r_queue_index)++; diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cc b/intern/ghost/intern/GHOST_DisplayManagerWin32.cc index 69624dcf8b2..12bc1ccb546 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cc +++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cc @@ -110,7 +110,8 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::setCurrentDisplaySetting( int i = 0; while (::EnumDisplaySettings(display_device.DeviceName, i++, &dm)) { if ((dm.dmBitsPerPel == match.bpp) && (dm.dmPelsWidth == match.xPixels) && - (dm.dmPelsHeight == match.yPixels) && (dm.dmDisplayFrequency == match.frequency)) { + (dm.dmPelsHeight == match.yPixels) && (dm.dmDisplayFrequency == match.frequency)) + { break; } } diff --git a/intern/ghost/intern/GHOST_DisplayManagerX11.cc b/intern/ghost/intern/GHOST_DisplayManagerX11.cc index a6a632a1efb..53496bf3eba 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerX11.cc +++ b/intern/ghost/intern/GHOST_DisplayManagerX11.cc @@ -171,13 +171,15 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting( if (best_fit == -1 || (vidmodes[i]->hdisplay < vidmodes[best_fit]->hdisplay) || (vidmodes[i]->hdisplay == vidmodes[best_fit]->hdisplay && - vidmodes[i]->vdisplay < vidmodes[best_fit]->vdisplay)) { + vidmodes[i]->vdisplay < vidmodes[best_fit]->vdisplay)) + { best_fit = i; continue; } if ((vidmodes[i]->hdisplay == vidmodes[best_fit]->hdisplay) && - (vidmodes[i]->vdisplay == vidmodes[best_fit]->vdisplay)) { + (vidmodes[i]->vdisplay == vidmodes[best_fit]->vdisplay)) + { if (!setting.frequency) { /* Higher is better, right? */ if (calculate_rate(vidmodes[i]) > calculate_rate(vidmodes[best_fit])) { @@ -186,7 +188,8 @@ GHOST_TSuccess GHOST_DisplayManagerX11::setCurrentDisplaySetting( } else { if (abs(calculate_rate(vidmodes[i]) - int(setting.frequency)) < - abs(calculate_rate(vidmodes[best_fit]) - int(setting.frequency))) { + abs(calculate_rate(vidmodes[best_fit]) - int(setting.frequency))) + { best_fit = i; } } diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cc b/intern/ghost/intern/GHOST_DropTargetWin32.cc index b21bd5fabad..41a630eb10f 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cc +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cc @@ -338,7 +338,8 @@ void printLastError(void) 0, (LPTSTR)&s, 0, - NULL)) { + NULL)) + { printf("\nLastError: (%d) %s\n", int(err), s); LocalFree(s); } diff --git a/intern/ghost/intern/GHOST_DropTargetX11.cc b/intern/ghost/intern/GHOST_DropTargetX11.cc index f3b42a1da93..a721d9e8bdb 100644 --- a/intern/ghost/intern/GHOST_DropTargetX11.cc +++ b/intern/ghost/intern/GHOST_DropTargetX11.cc @@ -210,7 +210,8 @@ bool GHOST_DropTargetX11::GHOST_HandleClientMessage(XEvent *event) &dropBufferSize, &dropType, &dropX, - &dropY)) { + &dropY)) + { void *data = getGhostData(dropType, dropBuffer, dropBufferSize); if (data) { diff --git a/intern/ghost/intern/GHOST_ImeWin32.cc b/intern/ghost/intern/GHOST_ImeWin32.cc index 54171130ca3..92276ae7c00 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cc +++ b/intern/ghost/intern/GHOST_ImeWin32.cc @@ -325,7 +325,8 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c target_start = 0; } if (target_start != -1 && target_start < attribute_size && - attribute_data[target_start] == ATTR_TARGET_NOTCONVERTED) { + attribute_data[target_start] == ATTR_TARGET_NOTCONVERTED) + { composition->cursor_position = target_start; } } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 117d72225d6..c94c8dbc8a7 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -965,7 +965,8 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) // special hotkeys to switch between views, so override directly if ([event type] == NSEventTypeKeyDown && [event keyCode] == kVK_Tab && - ([event modifierFlags] & NSEventModifierFlagControl)) { + ([event modifierFlags] & NSEventModifierFlagControl)) + { handleKeyEvent(event); } else { @@ -1257,7 +1258,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType return GHOST_kFailure; if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0) && - ![bitmapImage isPlanar]) { + ![bitmapImage isPlanar]) + { /* Try a fast copy if the image is a meshed RGBA 32bit bitmap. */ toIBuf = (uint8_t *)ibuf->rect; rasterRGB = (uint8_t *)[bitmapImage bitmapData]; @@ -1918,8 +1920,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) GHOST_kKeyLeftControl, false)); } - if ((modifiers & NSEventModifierFlagOption) != - (m_modifierMask & NSEventModifierFlagOption)) { + if ((modifiers & NSEventModifierFlagOption) != (m_modifierMask & NSEventModifierFlagOption)) + { pushEvent(new GHOST_EventKey( [event timestamp] * 1000, (modifiers & NSEventModifierFlagOption) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index 3a8786dd716..1919a9abcfd 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -1672,7 +1672,8 @@ static int ghost_wl_display_event_pump(struct wl_display *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( - wl_display_get_fd(wl_display), GWL_IOR_READ | GWL_IOR_NO_RETRY, 0) > 0) { + wl_display_get_fd(wl_display), GWL_IOR_READ | GWL_IOR_NO_RETRY, 0) > 0) + { err = wl_display_read_events(wl_display); } else { @@ -2139,7 +2140,8 @@ static void data_source_handle_send(void *data, auto write_file_fn = [](GWL_Seat *seat, const int fd) { if (UNLIKELY(write(fd, seat->data_source->buffer_out.data, - seat->data_source->buffer_out.data_size) < 0)) { + seat->data_source->buffer_out.data_size) < 0)) + { CLOG_WARN(LOG, "error writing to clipboard: %s", std::strerror(errno)); } close(fd); @@ -3974,7 +3976,8 @@ static void keyboard_handle_key(void *data, if (key_repeat_payload == nullptr) { /* Start timer for repeating key, if applicable. */ if ((seat->key_repeat.rate > 0) && (etype == GHOST_kEventKeyDown) && - xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb_state), key_code)) { + xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb_state), key_code)) + { key_repeat_payload = new GWL_KeyRepeatPlayload(); key_repeat_payload->seat = seat; key_repeat_payload->key_code = key_code; @@ -4175,7 +4178,8 @@ static void primary_selection_source_send(void *data, auto write_file_fn = [](GWL_PrimarySelection *primary, const int fd) { if (UNLIKELY(write(fd, primary->data_source->buffer_out.data, - primary->data_source->buffer_out.data_size) < 0)) { + primary->data_source->buffer_out.data_size) < 0)) + { CLOG_WARN(LOG, "error writing to primary clipboard: %s", std::strerror(errno)); } close(fd); @@ -4468,7 +4472,8 @@ static void xdg_output_handle_logical_size(void *data, * done (we can't match exactly because fractional scaling can't be * detected otherwise), then override if necessary. */ if ((output->size_logical[0] == width) && - (output->scale_fractional == (1 * FRACTIONAL_DENOMINATOR))) { + (output->scale_fractional == (1 * FRACTIONAL_DENOMINATOR))) + { GHOST_PRINT("xdg_output scale did not match, overriding with wl_output scale\n"); #ifdef USE_GNOME_CONFINE_HACK @@ -5313,7 +5318,8 @@ static int gwl_registry_handler_interface_slot_max() static int gwl_registry_handler_interface_slot_from_string(const char *interface) { for (const GWL_RegistryHandler *handler = gwl_registry_handlers; handler->interface_p != nullptr; - handler++) { + handler++) + { if (STREQ(interface, *handler->interface_p)) { return int(handler - gwl_registry_handlers); } @@ -5438,7 +5444,8 @@ static void *gwl_display_event_thread_fn(void *display_voidp) while (display->events_pthread_is_active) { /* Wait for an event, this thread is dedicated to event handling. */ if (ghost_wl_display_event_pump_from_thread( - display->wl_display, fd, display->system->server_mutex) == -1) { + display->wl_display, fd, display->system->server_mutex) == -1) + { break; } } @@ -7317,7 +7324,8 @@ bool ghost_wl_dynload_libraries_init() if (wayland_dynload_client_init(verbose) && /* `libwayland-client`. */ wayland_dynload_cursor_init(verbose) && /* `libwayland-cursor`. */ wayland_dynload_egl_init(verbose) /* `libwayland-egl`. */ - ) { + ) + { # ifdef WITH_GHOST_WAYLAND_LIBDECOR has_libdecor = wayland_dynload_libdecor_init(verbose); /* `libdecor-0`. */ # endif diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 60970cb263d..55efddbe7a5 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -958,7 +958,8 @@ void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window) * event queue. */ MSG msg; if (PeekMessage(&msg, window->getHWND(), message, message, PM_REMOVE | PM_NOYIELD) && - msg.message != WM_QUIT) { + msg.message != WM_QUIT) + { WINTAB_PRINTF(" ... associated to system button\n"); window->updateMouseCapture(MouseReleased); @@ -2311,7 +2312,8 @@ void GHOST_SystemWin32::putClipboard(const char *buffer, bool selection) const GHOST_TSuccess GHOST_SystemWin32::hasClipboardImage(void) const { if (IsClipboardFormatAvailable(CF_DIBV5) || - IsClipboardFormatAvailable(RegisterClipboardFormat("PNG"))) { + IsClipboardFormatAvailable(RegisterClipboardFormat("PNG"))) + { return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_SystemX11.cc b/intern/ghost/intern/GHOST_SystemX11.cc index d960a049e98..9b2952d92a3 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cc +++ b/intern/ghost/intern/GHOST_SystemX11.cc @@ -852,11 +852,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe) if (xe->type == xi_presence) { XDevicePresenceNotifyEvent *notify_event = (XDevicePresenceNotifyEvent *)xe; - if (ELEM(notify_event->devchange, - DeviceEnabled, - DeviceDisabled, - DeviceAdded, - DeviceRemoved)) { + if (ELEM(notify_event->devchange, DeviceEnabled, DeviceDisabled, DeviceAdded, DeviceRemoved)) + { refreshXInputDevices(); /* update all window events */ @@ -1058,7 +1055,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe) const uint mode_switch_mask = XkbKeysymToModifiers(xke->display, XK_Mode_switch); const uint number_hack_forbidden_kmods_mask = mode_switch_mask | ShiftMask; if ((xke->keycode >= 10 && xke->keycode < 20) && - ((xke->state & number_hack_forbidden_kmods_mask) == 0)) { + ((xke->state & number_hack_forbidden_kmods_mask) == 0)) + { key_sym = XLookupKeysym(xke, ShiftMask); if (!((key_sym >= XK_0) && (key_sym <= XK_9))) { key_sym = XLookupKeysym(xke, 0); @@ -1129,7 +1127,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe) * The modified key is sent in the 'ascii's variable anyway. */ if ((xke->keycode >= 10 && xke->keycode < 20) && - ((key_sym = XLookupKeysym(xke, ShiftMask)) >= XK_0) && (key_sym <= XK_9)) { + ((key_sym = XLookupKeysym(xke, ShiftMask)) >= XK_0) && (key_sym <= XK_9)) + { /* Pass (keep shifted `key_sym`). */ } else { @@ -1640,7 +1639,8 @@ GHOST_TSuccess GHOST_SystemX11::getButtons(GHOST_Buttons &buttons) const &ry, &wx, &wy, - &mask_return) == True) { + &mask_return) == True) + { buttons.set(GHOST_kButtonMaskLeft, (mask_return & Button1Mask) != 0); buttons.set(GHOST_kButtonMaskMiddle, (mask_return & Button2Mask) != 0); buttons.set(GHOST_kButtonMaskRight, (mask_return & Button3Mask) != 0); @@ -1671,7 +1671,8 @@ static GHOST_TSuccess getCursorPosition_impl(Display *display, &ry, &wx, &wy, - &mask_return) == False) { + &mask_return) == False) + { return GHOST_kFailure; } diff --git a/intern/ghost/intern/GHOST_TrackpadWin32.cc b/intern/ghost/intern/GHOST_TrackpadWin32.cc index d19b0469123..2aa51a317ce 100644 --- a/intern/ghost/intern/GHOST_TrackpadWin32.cc +++ b/intern/ghost/intern/GHOST_TrackpadWin32.cc @@ -179,7 +179,8 @@ void GHOST_DirectManipulationHelper::onPointerHitTest(UINT32 pointerId) void GHOST_DirectManipulationHelper::update() { if (m_directManipulationEventHandler->dm_status == DIRECTMANIPULATION_RUNNING || - m_directManipulationEventHandler->dm_status == DIRECTMANIPULATION_INERTIA) { + m_directManipulationEventHandler->dm_status == DIRECTMANIPULATION_INERTIA) + { [[maybe_unused]] HRESULT hr = m_directManipulationUpdateManager->Update(nullptr); GHOST_ASSERT(SUCCEEDED(hr), "DirectManipulationUpdateManager update failed\n"); } @@ -257,7 +258,8 @@ HRESULT GHOST_DirectManipulationViewportEventHandler::OnViewportStatusChanged( } if (previous == DIRECTMANIPULATION_ENABLED || current == DIRECTMANIPULATION_READY || - (previous == DIRECTMANIPULATION_INERTIA && current != DIRECTMANIPULATION_INERTIA)) { + (previous == DIRECTMANIPULATION_INERTIA && current != DIRECTMANIPULATION_INERTIA)) + { resetViewport(viewport); } @@ -288,7 +290,8 @@ HRESULT GHOST_DirectManipulationViewportEventHandler::OnContentUpdated( /* Ignore repeating or incorrect input. */ if ((fabs(scale - last_scale) <= EPS && fabs(x - last_x) <= EPS && fabs(y - last_y) <= EPS) || - scale == 0.0f) { + scale == 0.0f) + { GHOST_PRINT("Ignoring touchpad input\n"); return hr; } diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 4f90484d240..44284155734 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -484,10 +484,12 @@ void GHOST_WindowCocoa::setTitle(const char *title) associatedFileName = [windowTitle substringWithRange:fileStrRange]; [m_window setTitle:[associatedFileName lastPathComponent]]; - @try { + @try + { [m_window setRepresentedFilename:associatedFileName]; } - @catch (NSException *e) { + @catch (NSException *e) + { printf("\nInvalid file path given in window title"); } } diff --git a/intern/ghost/intern/GHOST_WindowViewCocoa.hh b/intern/ghost/intern/GHOST_WindowViewCocoa.hh index 29653bd5ea2..9e8479cb107 100644 --- a/intern/ghost/intern/GHOST_WindowViewCocoa.hh +++ b/intern/ghost/intern/GHOST_WindowViewCocoa.hh @@ -99,7 +99,8 @@ /* Start or continue composing? */ if ([[event characters] length] == 0 || [[event charactersIgnoringModifiers] length] == 0 || - composing || ime_process) { + composing || ime_process) + { composing = YES; // interpret event to call insertText diff --git a/intern/ghost/intern/GHOST_WindowWayland.cc b/intern/ghost/intern/GHOST_WindowWayland.cc index d4a113ee979..22e00823f8a 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cc +++ b/intern/ghost/intern/GHOST_WindowWayland.cc @@ -587,7 +587,8 @@ static void gwl_window_frame_pending_fractional_scale_set(GWL_Window *win, bool *r_surface_needs_buffer_scale) { if (win->frame_pending.fractional_scale == win->frame.fractional_scale && - win->frame_pending.buffer_scale == win->frame.buffer_scale) { + win->frame_pending.buffer_scale == win->frame.buffer_scale) + { return; } @@ -631,7 +632,8 @@ static void gwl_window_frame_pending_size_set(GWL_Window *win, win->frame.size[1] = win->frame_pending.size[1]; if (win->frame_pending.fractional_scale != win->frame.fractional_scale || - win->frame_pending.buffer_scale != win->frame.buffer_scale) { + win->frame_pending.buffer_scale != win->frame.buffer_scale) + { gwl_window_frame_pending_fractional_scale_set( win, r_surface_needs_commit, r_surface_needs_buffer_scale); } @@ -717,7 +719,8 @@ static void gwl_window_frame_update_from_pending_no_lock(GWL_Window *win) if (win->frame_pending.size[0] != 0 && win->frame_pending.size[1] != 0) { if ((win->frame.size[0] != win->frame_pending.size[0]) || - (win->frame.size[1] != win->frame_pending.size[1])) { + (win->frame.size[1] != win->frame_pending.size[1])) + { gwl_window_frame_pending_size_set( win, &surface_needs_commit, &surface_needs_egl_resize, &surface_needs_buffer_scale); } @@ -1460,7 +1463,8 @@ GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mo bounds, m_cursorGrabAxis, window_->wl_surface, - this->scale_params())) { + this->scale_params())) + { return GHOST_kSuccess; } return GHOST_kFailure; @@ -2021,7 +2025,8 @@ bool GHOST_WindowWayland::outputs_changed_update_scale() if ((fractional_scale_prev != fractional_scale_next) || (window_->frame_pending.buffer_scale != window_->frame.buffer_scale) || - (force_frame_update == true)) { + (force_frame_update == true)) + { /* Resize the window failing to do so results in severe flickering with a * multi-monitor setup when multiple monitors have different scales. * diff --git a/intern/ghost/intern/GHOST_WindowWin32.cc b/intern/ghost/intern/GHOST_WindowWin32.cc index 1a17926f2a1..c0c26557f8b 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cc +++ b/intern/ghost/intern/GHOST_WindowWin32.cc @@ -561,7 +561,8 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order) } if (hWndToRaise && - ::SetWindowPos(hWndToRaise, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) { + ::SetWindowPos(hWndToRaise, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) + { return GHOST_kFailure; } return GHOST_kSuccess; @@ -1057,7 +1058,8 @@ void GHOST_WindowWin32::ThemeRefresh() RRF_RT_REG_DWORD, NULL, &lightMode, - &pcbData) == ERROR_SUCCESS) { + &pcbData) == ERROR_SUCCESS) + { BOOL DarkMode = !lightMode; /* `20 == DWMWA_USE_IMMERSIVE_DARK_MODE` in Windows 11 SDK. diff --git a/intern/ghost/intern/GHOST_WindowX11.cc b/intern/ghost/intern/GHOST_WindowX11.cc index 8a539f8a930..a5e501b7815 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cc +++ b/intern/ghost/intern/GHOST_WindowX11.cc @@ -1453,8 +1453,8 @@ GHOST_TSuccess GHOST_WindowX11::setWindowCursorGrab(GHOST_TGrabCursorMode mode) * properly unless the user moves the mouse */ #if defined(WITH_X11_XINPUT) && defined(USE_X11_XINPUT_WARP) - if ((m_system->m_xinput_version.present) && - (m_system->m_xinput_version.major_version >= 2)) { + if ((m_system->m_xinput_version.present) && (m_system->m_xinput_version.major_version >= 2)) + { int device_id; if (XIGetClientPointer(m_display, None, &device_id) != False) { XIWarpPointer(m_display, device_id, None, None, 0, 0, 0, 0, 0, 0); diff --git a/intern/ghost/intern/GHOST_Wintab.cc b/intern/ghost/intern/GHOST_Wintab.cc index 784b71d21ef..1045debf279 100644 --- a/intern/ghost/intern/GHOST_Wintab.cc +++ b/intern/ghost/intern/GHOST_Wintab.cc @@ -404,7 +404,8 @@ GHOST_TButton GHOST_Wintab::mapWintabToGhostButton(uint cursor, WORD physicalBut BYTE systemButtons[numButtons] = {0}; if (!m_fpInfo(WTI_CURSORS + cursor, CSR_BUTTONMAP, &logicalButtons) || - !m_fpInfo(WTI_CURSORS + cursor, CSR_SYSBTNMAP, &systemButtons)) { + !m_fpInfo(WTI_CURSORS + cursor, CSR_SYSBTNMAP, &systemButtons)) + { return GHOST_kButtonMaskNone; } diff --git a/intern/ghost/intern/GHOST_XrContext.cc b/intern/ghost/intern/GHOST_XrContext.cc index 66ebb3c01c6..b5e71f7ec88 100644 --- a/intern/ghost/intern/GHOST_XrContext.cc +++ b/intern/ghost/intern/GHOST_XrContext.cc @@ -207,7 +207,8 @@ void GHOST_XrContext::initDebugMessenger() XR_FAILED(xrGetInstanceProcAddr( m_oxr->instance, "xrDestroyDebugUtilsMessengerEXT", - (PFN_xrVoidFunction *)&m_oxr->s_xrDestroyDebugUtilsMessengerEXT_fn))) { + (PFN_xrVoidFunction *)&m_oxr->s_xrDestroyDebugUtilsMessengerEXT_fn))) + { m_oxr->s_xrCreateDebugUtilsMessengerEXT_fn = nullptr; m_oxr->s_xrDestroyDebugUtilsMessengerEXT_fn = nullptr; @@ -227,7 +228,8 @@ void GHOST_XrContext::initDebugMessenger() create_info.userCallback = debug_messenger_func; if (XR_FAILED(m_oxr->s_xrCreateDebugUtilsMessengerEXT_fn( - m_oxr->instance, &create_info, &m_oxr->debug_messenger))) { + m_oxr->instance, &create_info, &m_oxr->debug_messenger))) + { fprintf(stderr, "Failed to create OpenXR debug messenger. Not a fatal error, continuing without the " "messenger.\n"); @@ -487,7 +489,8 @@ GHOST_TXrGraphicsBinding GHOST_XrContext::determineGraphicsBindingTypeToUse( /* The SteamVR OpenGL backend currently fails for NVIDIA GPU's. Disable it and allow falling * back to the DirectX one. */ if ((m_runtime_id == OPENXR_RUNTIME_STEAMVR) && (type == GHOST_kXrGraphicsOpenGL) && - ((create_info->context_flag & GHOST_kXrContextGpuNVIDIA) != 0)) { + ((create_info->context_flag & GHOST_kXrContextGpuNVIDIA) != 0)) + { continue; } #else diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cc b/intern/ghost/intern/GHOST_XrControllerModel.cc index 55b76f51237..8855ccdfbb1 100644 --- a/intern/ghost/intern/GHOST_XrControllerModel.cc +++ b/intern/ghost/intern/GHOST_XrControllerModel.cc @@ -51,7 +51,8 @@ static void validate_accessor(const tinygltf::Accessor &accessor, { /* Make sure the accessor does not go out of range of the buffer view. */ if (accessor.byteOffset + (accessor.count - 1) * byte_stride + element_size > - buffer_view.byteLength) { + buffer_view.byteLength) + { throw GHOST_XrException("glTF: Accessor goes out of range of bufferview."); } @@ -141,9 +142,8 @@ static void read_indices(const tinygltf::Accessor &accessor, } constexpr size_t component_size_bytes = sizeof(TSrcIndex); - if (buffer_view.byteStride != 0 && - buffer_view.byteStride != - component_size_bytes) { /* Index buffer must be packed per glTF spec. */ + /* Index buffer must be packed per glTF spec. */ + if (buffer_view.byteStride != 0 && buffer_view.byteStride != component_size_bytes) { throw GHOST_XrException( "glTF: Accessor for indices uses bufferview with invalid 'byteStride'."); } @@ -302,7 +302,8 @@ static void load_node(const tinygltf::Model &gltf_model, for (size_t i = 0; i < node_properties.size(); ++i) { if ((node_state_indices[i] < 0) && (parent_name == node_properties[i].parentNodeName) && - (gltf_node.name == node_properties[i].nodeName)) { + (gltf_node.name == node_properties[i].nodeName)) + { node_state_indices[i] = node_idx; break; } diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cc b/intern/ghost/intern/GHOST_XrGraphicsBinding.cc index 70099ac4dcc..0cbd70756ee 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cc +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cc @@ -94,10 +94,11 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { s_xrGetOpenGLGraphicsRequirementsKHR_fn = nullptr; //} if (!s_xrGetOpenGLGraphicsRequirementsKHR_fn && - XR_FAILED(xrGetInstanceProcAddr( - instance, - "xrGetOpenGLGraphicsRequirementsKHR", - (PFN_xrVoidFunction *)&s_xrGetOpenGLGraphicsRequirementsKHR_fn))) { + XR_FAILED( + xrGetInstanceProcAddr(instance, + "xrGetOpenGLGraphicsRequirementsKHR", + (PFN_xrVoidFunction *)&s_xrGetOpenGLGraphicsRequirementsKHR_fn))) + { s_xrGetOpenGLGraphicsRequirementsKHR_fn = nullptr; return false; } @@ -352,10 +353,11 @@ class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { s_xrGetD3D11GraphicsRequirementsKHR_fn = nullptr; //} if (!s_xrGetD3D11GraphicsRequirementsKHR_fn && - XR_FAILED(xrGetInstanceProcAddr( - instance, - "xrGetD3D11GraphicsRequirementsKHR", - (PFN_xrVoidFunction *)&s_xrGetD3D11GraphicsRequirementsKHR_fn))) { + XR_FAILED( + xrGetInstanceProcAddr(instance, + "xrGetD3D11GraphicsRequirementsKHR", + (PFN_xrVoidFunction *)&s_xrGetD3D11GraphicsRequirementsKHR_fn))) + { s_xrGetD3D11GraphicsRequirementsKHR_fn = nullptr; return false; } diff --git a/intern/ghost/intern/GHOST_XrSession.cc b/intern/ghost/intern/GHOST_XrSession.cc index 6a874a7f2c0..9a80094bfbb 100644 --- a/intern/ghost/intern/GHOST_XrSession.cc +++ b/intern/ghost/intern/GHOST_XrSession.cc @@ -225,7 +225,8 @@ void GHOST_XrSession::start(const GHOST_XrSessionBeginInfo *begin_info) m_gpu_binding = GHOST_XrGraphicsBindingCreateFromType(m_context->getGraphicsBindingType(), *m_gpu_ctx); if (!m_gpu_binding->checkVersionRequirements( - *m_gpu_ctx, m_context->getInstance(), m_oxr->system_id, &requirement_str)) { + *m_gpu_ctx, m_context->getInstance(), m_oxr->system_id, &requirement_str)) + { std::ostringstream strstream; strstream << "Available graphics context version does not meet the following requirements: " << requirement_str; diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp index 8800fa7ac86..4b2e52f71d8 100644 --- a/intern/locale/boost_locale_wrapper.cpp +++ b/intern/locale/boost_locale_wrapper.cpp @@ -33,8 +33,8 @@ static void bl_locale_global_cache() locale_global = std::locale(); facet_global = &std::use_facet(locale_global); } - catch (const std::bad_cast - &e) { /* if std::has_facet(l) == false, LC_ALL = "C" case */ + /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ + catch (const std::bad_cast &e) { #ifndef NDEBUG std::cout << "bl_locale_global_cache:" << e.what() << " \n"; #endif diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index 8627ecdc1fe..d89dc1d3a31 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -2322,6 +2322,6 @@ string MANTA::getFile( string path = getDirectory(fmd, subdirectory); string filename = fname + "_####" + extension; BLI_path_join(targetFile, sizeof(targetFile), path.c_str(), filename.c_str()); - BLI_path_frame(targetFile, framenr, 0); + BLI_path_frame(targetFile, sizeof(targetFile), framenr, 0); return targetFile; } diff --git a/intern/mikktspace/mikktspace.hh b/intern/mikktspace/mikktspace.hh index 14f7b26a311..136d8055f59 100644 --- a/intern/mikktspace/mikktspace.hh +++ b/intern/mikktspace/mikktspace.hh @@ -701,7 +701,8 @@ template class Mikktspace { // determines its orientation. // This is the only existing order dependency in the code!! if (triangle.group[0] == UNSET_ENTRY && triangle.group[1] == UNSET_ENTRY && - triangle.group[2] == UNSET_ENTRY) { + triangle.group[2] == UNSET_ENTRY) + { triangle.orientPreserving = group.orientPreserving; } } diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h index 10b574f5ff4..6775921a105 100644 --- a/intern/opencolorio/ocio_capi.h +++ b/intern/opencolorio/ocio_capi.h @@ -11,9 +11,8 @@ extern "C" { typedef struct OCIO_GPUShader OCIO_GPUShader; #define OCIO_DECLARE_HANDLE(name) \ - typedef struct name##__ { \ - int unused; \ - } * name + struct name; \ + typedef struct name *name##Ptr; #define OCIO_ROLE_DATA "data" #define OCIO_ROLE_SCENE_LINEAR "scene_linear" @@ -23,13 +22,13 @@ typedef struct OCIO_GPUShader OCIO_GPUShader; #define OCIO_ROLE_DEFAULT_FLOAT "default_float" #define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer" -OCIO_DECLARE_HANDLE(OCIO_ConstConfigRcPtr); -OCIO_DECLARE_HANDLE(OCIO_ConstColorSpaceRcPtr); -OCIO_DECLARE_HANDLE(OCIO_ConstProcessorRcPtr); -OCIO_DECLARE_HANDLE(OCIO_ConstCPUProcessorRcPtr); -OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr); +OCIO_DECLARE_HANDLE(OCIO_ConstConfigRc); +OCIO_DECLARE_HANDLE(OCIO_ConstColorSpaceRc); +OCIO_DECLARE_HANDLE(OCIO_ConstProcessorRc); +OCIO_DECLARE_HANDLE(OCIO_ConstCPUProcessorRc); +OCIO_DECLARE_HANDLE(OCIO_ConstContextRc); OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc); -OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr); +OCIO_DECLARE_HANDLE(OCIO_ConstLookRc); /* Standard XYZ (D65) to linear Rec.709 transform. */ static const float OCIO_XYZ_TO_REC709[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f}, @@ -151,9 +150,10 @@ OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *cpu_processor); OCIO_ConstCPUProcessorRcPtr *OCIO_processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor); -void OCIO_cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img); +void OCIO_cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, + struct OCIO_PackedImageDesc *img); void OCIO_cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, - OCIO_PackedImageDesc *img); + struct OCIO_PackedImageDesc *img); void OCIO_cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel); void OCIO_cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel); void OCIO_cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, @@ -175,15 +175,15 @@ OCIO_ConstProcessorRcPtr *OCIO_createDisplayProcessor(OCIO_ConstConfigRcPtr *con const float exponent, const bool inverse); -OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, - long width, - long height, - long numChannels, - long chanStrideBytes, - long xStrideBytes, - long yStrideBytes); +struct OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, + long width, + long height, + long numChannels, + long chanStrideBytes, + long xStrideBytes, + long yStrideBytes); -void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p); +void OCIO_PackedImageDescRelease(struct OCIO_PackedImageDesc *p); bool OCIO_supportGPUShader(void); bool OCIO_gpuDisplayShaderBind(OCIO_ConstConfigRcPtr *config, diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc index 20ef6ebaaf1..7af21d0a6dc 100644 --- a/intern/opencolorio/ocio_impl.cc +++ b/intern/opencolorio/ocio_impl.cc @@ -477,14 +477,16 @@ void OCIOImpl::colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config_, /* Make sure that there is no channel crosstalk. */ if (fabsf(cR[1]) > 1e-5f || fabsf(cR[2]) > 1e-5f || fabsf(cG[0]) > 1e-5f || - fabsf(cG[2]) > 1e-5f || fabsf(cB[0]) > 1e-5f || fabsf(cB[1]) > 1e-5f) { + fabsf(cG[2]) > 1e-5f || fabsf(cB[0]) > 1e-5f || fabsf(cB[1]) > 1e-5f) + { is_scene_linear = false; is_srgb = false; break; } /* Make sure that the three primaries combine linearly. */ if (!compare_floats(cR[0], cW[0], 1e-6f, 64) || !compare_floats(cG[1], cW[1], 1e-6f, 64) || - !compare_floats(cB[2], cW[2], 1e-6f, 64)) { + !compare_floats(cB[2], cW[2], 1e-6f, 64)) + { is_scene_linear = false; is_srgb = false; break; diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index d1716eeb6d8..2ecef115194 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -325,7 +325,8 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures, const float *values; shader_desc->getTextureValues(index, values); if (texture_name == nullptr || sampler_name == nullptr || width == 0 || height == 0 || - values == nullptr) { + values == nullptr) + { return false; } @@ -569,9 +570,11 @@ static OCIO_GPUDisplayShader &getGPUDisplayShader( const bool use_curve_mapping = (curve_mapping_settings != nullptr); for (std::list::iterator it = SHADER_CACHE.begin(); it != SHADER_CACHE.end(); - it++) { + it++) + { if (it->input == input && it->view == view && it->display == display && it->look == look && - it->use_curve_mapping == use_curve_mapping) { + it->use_curve_mapping == use_curve_mapping) + { /* Move to front of the cache to mark as most recently used. */ if (it != SHADER_CACHE.begin()) { SHADER_CACHE.splice(SHADER_CACHE.begin(), SHADER_CACHE, it); @@ -642,7 +645,8 @@ static OCIO_GPUDisplayShader &getGPUDisplayShader( display_shader.textures, shaderdesc_to_scene_linear, shaderdesc_to_display, - use_curve_mapping)) { + use_curve_mapping)) + { display_shader.valid = true; } } diff --git a/intern/opensubdiv/internal/base/util.cc b/intern/opensubdiv/internal/base/util.cc index 6b19954e274..f5e315ef21c 100644 --- a/intern/opensubdiv/internal/base/util.cc +++ b/intern/opensubdiv/internal/base/util.cc @@ -44,7 +44,8 @@ void stringSplit(vector *tokens, } // Append token which might be at the end of the string. if ((token_length != 0) || - (!skip_empty && token_start > 0 && separators.find(str[token_start - 1]) != string::npos)) { + (!skip_empty && token_start > 0 && separators.find(str[token_start - 1]) != string::npos)) + { string token = str.substr(token_start, token_length); tokens->push_back(token); } diff --git a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc index 18c3890bbf2..d1e518dd1ac 100644 --- a/intern/opensubdiv/internal/evaluator/evaluator_impl.cc +++ b/intern/opensubdiv/internal/evaluator/evaluator_impl.cc @@ -495,7 +495,8 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( vector all_face_varying_stencils; all_face_varying_stencils.reserve(num_face_varying_channels); for (int face_varying_channel = 0; face_varying_channel < num_face_varying_channels; - ++face_varying_channel) { + ++face_varying_channel) + { StencilTableFactory::Options face_varying_stencil_options; face_varying_stencil_options.generateOffsets = stencil_generate_offsets; face_varying_stencil_options.generateIntermediateLevels = stencil_generate_intermediate_levels; @@ -532,7 +533,8 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal( } } for (int face_varying_channel = 0; face_varying_channel < num_face_varying_channels; - ++face_varying_channel) { + ++face_varying_channel) + { const StencilTable *table = StencilTableFactory::AppendLocalPointStencilTableFaceVarying( *refiner, all_face_varying_stencils[face_varying_channel], diff --git a/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc b/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc index 76b03843952..c44c12814c0 100644 --- a/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc +++ b/intern/opensubdiv/internal/evaluator/gl_compute_evaluator.cc @@ -243,13 +243,15 @@ bool GLComputeEvaluator::Compile(BufferDescriptor const &srcDesc, // create a stencil kernel if (!_stencilKernel.Compile( - srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc, _workGroupSize)) { + srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc, _workGroupSize)) + { return false; } // create a patch kernel if (!_patchKernel.Compile( - srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc, _workGroupSize)) { + srcDesc, dstDesc, duDesc, dvDesc, duuDesc, duvDesc, dvvDesc, _workGroupSize)) + { return false; } diff --git a/intern/opensubdiv/internal/topology/mesh_topology_compare.cc b/intern/opensubdiv/internal/topology/mesh_topology_compare.cc index f83d1088faf..3b8c56a66d3 100644 --- a/intern/opensubdiv/internal/topology/mesh_topology_compare.cc +++ b/intern/opensubdiv/internal/topology/mesh_topology_compare.cc @@ -133,7 +133,8 @@ bool isEqualGeometry(const MeshTopology &mesh_topology, const OpenSubdiv_Convert float getEffectiveVertexSharpness(const OpenSubdiv_Converter *converter, const int vertex_index) { if (converter->isInfiniteSharpVertex != nullptr && - converter->isInfiniteSharpVertex(converter, vertex_index)) { + converter->isInfiniteSharpVertex(converter, vertex_index)) + { return OpenSubdiv::Sdc::Crease::SHARPNESS_INFINITE; } diff --git a/intern/rigidbody/rb_convex_hull_api.cpp b/intern/rigidbody/rb_convex_hull_api.cpp index 5d72984470d..7196ce483b7 100644 --- a/intern/rigidbody/rb_convex_hull_api.cpp +++ b/intern/rigidbody/rb_convex_hull_api.cpp @@ -70,7 +70,8 @@ int plConvexHullGetFaceSize(plConvexHull hull, int n) for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0; count == 0 || e != e_orig; - e = e->getNextEdgeOfFace(), count++) { + e = e->getNextEdgeOfFace(), count++) + { ; } return count; @@ -84,7 +85,8 @@ void plConvexHullGetFaceLoops(plConvexHull hull, int n, int *loops) for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0; count == 0 || e != e_orig; - e = e->getNextEdgeOfFace(), count++) { + e = e->getNextEdgeOfFace(), count++) + { loops[count] = e - &computer->edges[0]; } } @@ -97,7 +99,8 @@ void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices) for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0; count == 0 || e != e_orig; - e = e->getNextEdgeOfFace(), count++) { + e = e->getNextEdgeOfFace(), count++) + { vertices[count] = e->getTargetVertex(); } } diff --git a/source/blender/asset_system/intern/asset_catalog.cc b/source/blender/asset_system/intern/asset_catalog.cc index b3e476cda3f..167de79718a 100644 --- a/source/blender/asset_system/intern/asset_catalog.cc +++ b/source/blender/asset_system/intern/asset_catalog.cc @@ -542,7 +542,7 @@ CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing( /* Determine the default CDF path in the same directory of the blend file. */ char blend_dir_path[PATH_MAX]; - BLI_split_dir_part(blend_file_path.c_str(), blend_dir_path, sizeof(blend_dir_path)); + BLI_path_split_dir_part(blend_file_path.c_str(), blend_dir_path, sizeof(blend_dir_path)); const CatalogFilePath cdf_path_next_to_blend = asset_definition_default_file_path_from_dir( blend_dir_path); return cdf_path_next_to_blend; @@ -856,7 +856,7 @@ bool AssetCatalogDefinitionFile::write_to_disk(const CatalogFilePath &dest_file_ bool AssetCatalogDefinitionFile::write_to_disk_unsafe(const CatalogFilePath &dest_file_path) const { char directory[PATH_MAX]; - BLI_split_dir_part(dest_file_path.c_str(), directory, sizeof(directory)); + BLI_path_split_dir_part(dest_file_path.c_str(), directory, sizeof(directory)); if (!ensure_directory_exists(directory)) { /* TODO(Sybren): pass errors to the UI somehow. */ return false; diff --git a/source/blender/asset_system/intern/asset_catalog_path.cc b/source/blender/asset_system/intern/asset_catalog_path.cc index 5b972b55634..fca4bea094b 100644 --- a/source/blender/asset_system/intern/asset_catalog_path.cc +++ b/source/blender/asset_system/intern/asset_catalog_path.cc @@ -174,7 +174,8 @@ void AssetCatalogPath::iterate_components(ComponentIteratorFn callback) const for (const char *path_component = this->path_.data(); path_component && path_component[0]; /* Jump to one after the next slash if there is any. */ - path_component = next_slash_ptr ? next_slash_ptr + 1 : nullptr) { + path_component = next_slash_ptr ? next_slash_ptr + 1 : nullptr) + { /* Note that this also treats backslashes as component separators, which * helps in cleaning up backslash-separated paths. */ next_slash_ptr = BLI_path_slash_find(path_component); diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc index 7455c924598..3873e7d6f85 100644 --- a/source/blender/asset_system/intern/asset_library.cc +++ b/source/blender/asset_system/intern/asset_library.cc @@ -75,12 +75,13 @@ std::string AS_asset_library_find_suitable_root_path_from_path( const blender::StringRefNull input_path) { if (bUserAssetLibrary *preferences_lib = BKE_preferences_asset_library_containing_path( - &U, input_path.c_str())) { + &U, input_path.c_str())) + { return preferences_lib->path; } char buffer[FILE_MAXDIR]; - BLI_split_dir_part(input_path.c_str(), buffer, FILE_MAXDIR); + BLI_path_split_dir_part(input_path.c_str(), buffer, FILE_MAXDIR); return buffer; } diff --git a/source/blender/asset_system/tests/asset_library_service_test.cc b/source/blender/asset_system/tests/asset_library_service_test.cc index fbf05f00600..56955c5fb95 100644 --- a/source/blender/asset_system/tests/asset_library_service_test.cc +++ b/source/blender/asset_system/tests/asset_library_service_test.cc @@ -141,7 +141,8 @@ TEST_F(AssetLibraryServiceTest, library_path_trailing_slashes) /* Ensure #asset_lib_no_slash has no trailing slash, regardless of what was passed on the CLI to * the unit test. */ while (strlen(asset_lib_no_slash) && - ELEM(asset_lib_no_slash[strlen(asset_lib_no_slash) - 1], SEP, ALTSEP)) { + ELEM(asset_lib_no_slash[strlen(asset_lib_no_slash) - 1], SEP, ALTSEP)) + { asset_lib_no_slash[strlen(asset_lib_no_slash) - 1] = '\0'; } diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index c1baa071e5c..dcd1ce70496 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -43,28 +43,36 @@ void BLF_cache_flush_set_fn(void (*cache_flush_fn)(void)); /** * Loads a font, or returns an already loaded font and increments its reference count. */ -int BLF_load(const char *name) ATTR_NONNULL(); -int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(); -bool BLF_is_loaded(const char *name) ATTR_NONNULL(); +int BLF_load(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 2); -int BLF_load_unique(const char *name) ATTR_NONNULL(); -int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(); +bool BLF_is_loaded(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +bool BLF_is_loaded_mem(const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); + +int BLF_load_unique(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) + ATTR_NONNULL(1, 2); + +void BLF_unload(const char *filepath) ATTR_NONNULL(1); +#if 0 /* Not needed at the moment. */ +void BLF_unload_mem(const char *name) ATTR_NONNULL(1); +#endif -void BLF_unload(const char *name) ATTR_NONNULL(); void BLF_unload_id(int fontid); void BLF_unload_all(void); -char *BLF_display_name_from_file(const char *filepath); +char *BLF_display_name_from_file(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /** * Check if font supports a particular glyph. */ -bool BLF_has_glyph(int fontid, unsigned int unicode); +bool BLF_has_glyph(int fontid, unsigned int unicode) ATTR_WARN_UNUSED_RESULT; /** * Attach a file with metrics information from memory. */ -void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size); +void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) ATTR_NONNULL(2); void BLF_aspect(int fontid, float x, float y, float z); void BLF_position(int fontid, float x, float y, float z); @@ -140,7 +148,7 @@ void BLF_boundbox_foreach_glyph(int fontid, size_t BLF_str_offset_from_cursor_position(int fontid, const char *str, size_t str_len, - int location_x); + int location_x) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2); /** * Return bounds of the glyph rect at the string offset. @@ -148,18 +156,25 @@ size_t BLF_str_offset_from_cursor_position(int fontid, bool BLF_str_offset_to_glyph_bounds(int fontid, const char *str, size_t str_offset, - struct rcti *glyph_bounds); + struct rcti *glyph_bounds) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(2, 4); /** * Get the string byte offset that fits within a given width. */ -size_t BLF_width_to_strlen( - int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_NONNULL(2); +size_t BLF_width_to_strlen(int fontid, + const char *str, + size_t str_len, + float width, + float *r_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2); /** * Same as BLF_width_to_strlen but search from the string end. */ -size_t BLF_width_to_rstrlen( - int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_NONNULL(2); +size_t BLF_width_to_rstrlen(int fontid, + const char *str, + size_t str_len, + float width, + float *r_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2); /** * This function return the bounding box of the string @@ -269,26 +284,6 @@ void BLF_draw_buffer_ex(int fontid, const char *str, size_t str_len, struct Resu ATTR_NONNULL(2); void BLF_draw_buffer(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2); -/** - * Add a path to the font dir paths. - */ -void BLF_dir_add(const char *path) ATTR_NONNULL(); - -/** - * Remove a path from the font dir paths. - */ -void BLF_dir_rem(const char *path) ATTR_NONNULL(); - -/** - * Return an array with all the font dir (this can be used for file-selector). - */ -char **BLF_dir_get(int *ndir) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); - -/** - * Free the data return by #BLF_dir_get. - */ -void BLF_dir_free(char **dirs, int count) ATTR_NONNULL(); - /* blf_thumbs.c */ /** diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 457007a7f12..4ed4f688410 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -21,6 +21,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_string.h" #include "BLI_threads.h" @@ -93,11 +94,26 @@ bool blf_font_id_is_valid(int fontid) return blf_get(fontid) != NULL; } -static int blf_search(const char *name) +static int blf_search_by_mem_name(const char *mem_name) { for (int i = 0; i < BLF_MAX_FONT; i++) { const FontBLF *font = global_font[i]; - if (font && STREQ(font->name, name)) { + if (font == NULL || font->mem_name == NULL) { + continue; + } + if (font && STREQ(font->mem_name, mem_name)) { + return i; + } + } + + return -1; +} + +static int blf_search_by_filepath(const char *filepath) +{ + for (int i = 0; i < BLF_MAX_FONT; i++) { + const FontBLF *font = global_font[i]; + if (font && STREQ(font->filepath, filepath)) { return i; } } @@ -125,25 +141,30 @@ bool BLF_has_glyph(int fontid, uint unicode) return false; } -bool BLF_is_loaded(const char *name) +bool BLF_is_loaded(const char *filepath) { - return blf_search(name) >= 0; + return blf_search_by_filepath(filepath) >= 0; } -int BLF_load(const char *name) +bool BLF_is_loaded_mem(const char *name) +{ + return blf_search_by_mem_name(name) >= 0; +} + +int BLF_load(const char *filepath) { /* check if we already load this font. */ - int i = blf_search(name); + int i = blf_search_by_filepath(filepath); if (i >= 0) { FontBLF *font = global_font[i]; font->reference_count++; return i; } - return BLF_load_unique(name); + return BLF_load_unique(filepath); } -int BLF_load_unique(const char *name) +int BLF_load_unique(const char *filepath) { /* Don't search in the cache!! make a new * object font, this is for keep fonts threads safe. @@ -154,18 +175,17 @@ int BLF_load_unique(const char *name) return -1; } - char *filepath = blf_dir_search(name); - if (!filepath) { - printf("Can't find font: %s\n", name); + /* This isn't essential, it will just cause confusing behavior to load a font + * that appears to succeed, then doesn't show up. */ + if (!BLI_exists(filepath)) { + printf("Can't find font: %s\n", filepath); return -1; } - FontBLF *font = blf_font_new(name, filepath); - - MEM_freeN(filepath); + FontBLF *font = blf_font_new_from_filepath(filepath); if (!font) { - printf("Can't load font: %s\n", name); + printf("Can't load font: %s\n", filepath); return -1; } @@ -185,7 +205,7 @@ void BLF_metrics_attach(int fontid, uchar *mem, int mem_size) int BLF_load_mem(const char *name, const uchar *mem, int mem_size) { - int i = blf_search(name); + int i = blf_search_by_mem_name(name); if (i >= 0) { // font = global_font[i]; /* UNUSED */ return i; @@ -221,12 +241,15 @@ int BLF_load_mem_unique(const char *name, const uchar *mem, int mem_size) return i; } -void BLF_unload(const char *name) +void BLF_unload(const char *filepath) { for (int i = 0; i < BLF_MAX_FONT; i++) { FontBLF *font = global_font[i]; + if (font == NULL || font->filepath == NULL) { + continue; + } - if (font && STREQ(font->name, name)) { + if (STREQ(font->filepath, filepath)) { BLI_assert(font->reference_count > 0); font->reference_count--; @@ -918,7 +941,8 @@ void BLF_state_print(int fontid) FontBLF *font = blf_get(fontid); if (font) { printf("fontid %d %p\n", fontid, (void *)font); - printf(" name: '%s'\n", font->name); + printf(" mem_name: '%s'\n", font->mem_name ? font->mem_name : ""); + printf(" filepath: '%s'\n", font->filepath ? font->filepath : ""); printf(" size: %f\n", font->size); printf(" pos: %d %d %d\n", UNPACK3(font->pos)); printf(" aspect: (%d) %.6f %.6f %.6f\n", diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 3efe34bc3bc..f32241477da 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -21,116 +21,10 @@ #include "DNA_vec_types.h" #include "BLI_fileops.h" -#include "BLI_listbase.h" -#include "BLI_path_util.h" #include "BLI_string.h" -#include "BLI_threads.h" -#include "BLI_utildefines.h" #include "BLF_api.h" #include "blf_internal.h" -#include "blf_internal_types.h" - -static ListBase global_font_dir = {NULL, NULL}; - -static DirBLF *blf_dir_find(const char *path) -{ - DirBLF *p; - - p = global_font_dir.first; - while (p) { - if (BLI_path_cmp(p->path, path) == 0) { - return p; - } - p = p->next; - } - return NULL; -} - -void BLF_dir_add(const char *path) -{ - DirBLF *dir; - - dir = blf_dir_find(path); - if (dir) { /* already in the list ? just return. */ - return; - } - - dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add"); - dir->path = BLI_strdup(path); - BLI_addhead(&global_font_dir, dir); -} - -void BLF_dir_rem(const char *path) -{ - DirBLF *dir; - - dir = blf_dir_find(path); - if (dir) { - BLI_remlink(&global_font_dir, dir); - MEM_freeN(dir->path); - MEM_freeN(dir); - } -} - -char **BLF_dir_get(int *ndir) -{ - DirBLF *p; - char **dirs; - char *path; - int i, count; - - count = BLI_listbase_count(&global_font_dir); - if (!count) { - return NULL; - } - - dirs = (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get"); - p = global_font_dir.first; - i = 0; - while (p) { - path = BLI_strdup(p->path); - dirs[i] = path; - p = p->next; - } - *ndir = i; - return dirs; -} - -void BLF_dir_free(char **dirs, int count) -{ - for (int i = 0; i < count; i++) { - char *path = dirs[i]; - MEM_freeN(path); - } - MEM_freeN(dirs); -} - -char *blf_dir_search(const char *file) -{ - BLI_assert_msg(!BLI_path_is_rel(file), "Relative paths must always be expanded!"); - - DirBLF *dir; - char full_path[FILE_MAX]; - char *s = NULL; - - for (dir = global_font_dir.first; dir; dir = dir->next) { - BLI_path_join(full_path, sizeof(full_path), dir->path, file); - if (BLI_exists(full_path)) { - s = BLI_strdup(full_path); - break; - } - } - - if (!s) { - /* This may be an absolute path which exists. */ - if (BLI_exists(file)) { - s = BLI_strdup(file); - } - } - - return s; -} char *blf_dir_metrics_search(const char *filepath) { diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index b69599b0a53..2c2588e1bbd 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -518,7 +518,8 @@ static void blf_glyph_draw_buffer(FontBufInfoBLF *buf_info, chx >= buf_info->dims[0] || /* Out of bounds: right. */ (ft_pix_to_int(pen_y) + g->dims[1]) < 0 || /* Out of bounds: bottom. */ ft_pix_to_int(pen_y) >= buf_info->dims[1] /* Out of bounds: top. */ - ) { + ) + { return; } @@ -692,7 +693,8 @@ size_t blf_font_width_to_strlen( const int width_i = (int)width; for (i_prev = i = 0, width_new = pen_x = 0, g_prev = NULL; (i < str_len) && str[i]; - i_prev = i, width_new = pen_x, g_prev = g) { + i_prev = i, width_new = pen_x, g_prev = g) + { g = blf_glyph_from_utf8_and_step(font, gc, str, str_len, &i); if (blf_font_width_to_strlen_glyph_process(font, g_prev, g, &pen_x, width_i)) { @@ -727,7 +729,8 @@ size_t blf_font_width_to_rstrlen( i_tmp = i; g = blf_glyph_from_utf8_and_step(font, gc, str, str_len, &i_tmp); for (width_new = pen_x = 0; (s != NULL); - i = i_prev, s = s_prev, g = g_prev, g_prev = NULL, width_new = pen_x) { + i = i_prev, s = s_prev, g = g_prev, g_prev = NULL, width_new = pen_x) + { s_prev = BLI_str_find_prev_char_utf8(s, str); i_prev = (size_t)(s_prev - str); @@ -1505,15 +1508,20 @@ static const struct FaceDetails static_face_details[] = { {"NotoSansThai-VariableFont_wdth,wght.woff2", TT_UCR_THAI, 0, 0, 0}, }; -FontBLF *blf_font_new_ex(const char *name, - const char *filepath, - const uchar *mem, - const size_t mem_size, - void *ft_library) +/** + * Create a new font from filename OR memory pointer. + * For normal operation pass NULL as FT_Library object. Pass a custom FT_Library if you + * want to use the font without its lifetime being managed by the FreeType cache subsystem. + */ +static FontBLF *blf_font_new_impl(const char *filepath, + const char *mem_name, + const uchar *mem, + const size_t mem_size, + void *ft_library) { FontBLF *font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); - font->name = BLI_strdup(name); + font->mem_name = mem_name ? BLI_strdup(mem_name) : NULL; font->filepath = filepath ? BLI_strdup(filepath) : NULL; if (mem) { font->mem = (void *)mem; @@ -1540,7 +1548,7 @@ FontBLF *blf_font_new_ex(const char *name, const struct FaceDetails *static_details = NULL; char filename[256]; for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) { - BLI_split_file_part(font->filepath, filename, sizeof(filename)); + BLI_path_split_file_part(font->filepath, filename, sizeof(filename)); if (STREQ(static_face_details[i].name, filename)) { static_details = &static_face_details[i]; font->unicode_ranges[0] = static_details->coverage1; @@ -1562,21 +1570,22 @@ FontBLF *blf_font_new_ex(const char *name, /* Detect "Last resort" fonts. They have everything. Usually except last 5 bits. */ if (font->unicode_ranges[0] == 0xffffffffU && font->unicode_ranges[1] == 0xffffffffU && - font->unicode_ranges[2] == 0xffffffffU && font->unicode_ranges[3] >= 0x7FFFFFFU) { + font->unicode_ranges[2] == 0xffffffffU && font->unicode_ranges[3] >= 0x7FFFFFFU) + { font->flags |= BLF_LAST_RESORT; } return font; } -FontBLF *blf_font_new(const char *name, const char *filepath) +FontBLF *blf_font_new_from_filepath(const char *filepath) { - return blf_font_new_ex(name, filepath, NULL, 0, NULL); + return blf_font_new_impl(filepath, NULL, NULL, 0, NULL); } -FontBLF *blf_font_new_from_mem(const char *name, const uchar *mem, const size_t mem_size) +FontBLF *blf_font_new_from_mem(const char *mem_name, const uchar *mem, const size_t mem_size) { - return blf_font_new_ex(name, NULL, mem, mem_size, NULL); + return blf_font_new_impl(NULL, mem_name, mem, mem_size, NULL); } void blf_font_attach_from_mem(FontBLF *font, const uchar *mem, const size_t mem_size) @@ -1617,8 +1626,8 @@ void blf_font_free(FontBLF *font) if (font->filepath) { MEM_freeN(font->filepath); } - if (font->name) { - MEM_freeN(font->name); + if (font->mem_name) { + MEM_freeN(font->mem_name); } BLI_mutex_end(&font->glyph_cache_mutex); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 7a9d4075ca0..02711b062b4 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -70,7 +70,8 @@ static GlyphCacheBLF *blf_glyph_cache_find(const FontBLF *font, const float size if (gc->size == size && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && (gc->italic == ((font->flags & BLF_ITALIC) != 0)) && (gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && - (gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { + (gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) + { return gc; } gc = gc->next; @@ -637,7 +638,8 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode FontBLF *f = global_font[i]; if (!f || f == *font || !(f->face) || !(f->flags & BLF_DEFAULT) || (!((*font)->flags & BLF_MONOSPACED) && (f->flags & BLF_MONOSPACED)) || - f->flags & BLF_LAST_RESORT) { + f->flags & BLF_LAST_RESORT) + { continue; } if (coverage_bit < 0 || blf_font_has_coverage_bit(f, coverage_bit)) { @@ -654,7 +656,8 @@ static FT_UInt blf_glyph_index_from_charcode(FontBLF **font, const uint charcode FontBLF *f = global_font[i]; if (!f || f == *font || (f->face) || !(f->flags & BLF_DEFAULT) || (!((*font)->flags & BLF_MONOSPACED) && (f->flags & BLF_MONOSPACED)) || - f->flags & BLF_LAST_RESORT) { + f->flags & BLF_LAST_RESORT) + { continue; } if (coverage_bit < 0 || blf_font_has_coverage_bit(f, coverage_bit)) { diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 73c69d901e1..55515c9f793 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -42,14 +42,11 @@ void blf_batch_draw(void); unsigned int blf_next_p2(unsigned int x); unsigned int blf_hash(unsigned int val); - -char *blf_dir_search(const char *file); /** * Some font have additional file with metrics information, * in general, the extension of the file is: `.afm` or `.pfm` */ char *blf_dir_metrics_search(const char *filepath); -// int blf_dir_split(const char *str, char *file, int *size); /*UNUSED*/ int blf_font_init(void); void blf_font_exit(void); @@ -70,18 +67,7 @@ void blf_ensure_size(struct FontBLF *font); void blf_draw_buffer__start(struct FontBLF *font); void blf_draw_buffer__end(void); -/** - * Create a new font from filename OR memory pointer. - * For normal operation pass NULL as FT_Library object. Pass a custom FT_Library if you - * want to use the font without its lifetime being managed by the FreeType cache subsystem. - */ -struct FontBLF *blf_font_new_ex(const char *name, - const char *filepath, - const unsigned char *mem, - size_t mem_size, - void *ft_library); - -struct FontBLF *blf_font_new(const char *name, const char *filepath); +struct FontBLF *blf_font_new_from_filepath(const char *filepath); struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, size_t mem_size); void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, size_t mem_size); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index fe184066efa..5b0810ca4ef 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -238,15 +238,14 @@ typedef struct FontBufInfoBLF { } FontBufInfoBLF; typedef struct FontBLF { - /** Font name. */ - char *name; - /** Full path to font file or NULL if from memory. */ char *filepath; /** Pointer to in-memory font, or NULL if from file. */ void *mem; size_t mem_size; + /** Handle for in-memory fonts to avoid loading them multiple times. */ + char *mem_name; /** * Copied from the SFNT OS/2 table. Bit flags for unicode blocks and ranges @@ -342,11 +341,3 @@ typedef struct FontBLF { /** Mutex lock for glyph cache. */ ThreadMutex glyph_cache_mutex; } FontBLF; - -typedef struct DirBLF { - struct DirBLF *next; - struct DirBLF *prev; - - /** Full path where search fonts. */ - char *path; -} DirBLF; diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index 417fd815284..98f0fcde559 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -248,7 +248,8 @@ static const char32_t *blf_get_sample_text(FT_Face face) /* Detect "Last resort" fonts. They have everything, except the last 5 bits. */ if (os2_table->ulUnicodeRange1 == 0xffffffffU && os2_table->ulUnicodeRange2 == 0xffffffffU && - os2_table->ulUnicodeRange3 == 0xffffffffU && os2_table->ulUnicodeRange4 >= 0x7FFFFFFU) { + os2_table->ulUnicodeRange3 == 0xffffffffU && os2_table->ulUnicodeRange4 >= 0x7FFFFFFU) + { return U"\xE000\xFFFF"; } @@ -386,13 +387,14 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int UNUSE int glyph_count = 0; /* How many are successfully loaded and rendered. */ for (int i = 0; i < BLF_SAMPLE_LEN && glyph_ids[i]; i++) { - if (FT_Load_Glyph(face, glyph_ids[i], FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING) != - FT_Err_Ok) { + if (FT_Load_Glyph(face, glyph_ids[i], FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING) != FT_Err_Ok) + { break; } if (FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL) != FT_Err_Ok || - face->glyph->format != FT_GLYPH_FORMAT_BITMAP) { + face->glyph->format != FT_GLYPH_FORMAT_BITMAP) + { break; } diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index eff05e471aa..e97fa51ec11 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -560,7 +560,8 @@ void BKE_pchan_bbone_deform_segment_index(const struct bPoseChannel *pchan, #define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan) \ for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first; _pchan; _pchan = _pchan->next) { \ if (PBONE_VISIBLE(((bArmature *)(_ob)->data), (_pchan)->bone) && \ - ((_pchan)->bone->flag & BONE_SELECTED)) { + ((_pchan)->bone->flag & BONE_SELECTED)) \ + { #define FOREACH_PCHAN_SELECTED_IN_OBJECT_END \ } \ } \ diff --git a/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h index 9d30edd2b99..d162a5883b5 100644 --- a/source/blender/blenkernel/BKE_asset.h +++ b/source/blender/blenkernel/BKE_asset.h @@ -42,7 +42,8 @@ struct AssetTagEnsureResult { bool is_new; }; -struct AssetTag *BKE_asset_metadata_tag_add(struct AssetMetaData *asset_data, const char *name); +struct AssetTag *BKE_asset_metadata_tag_add(struct AssetMetaData *asset_data, const char *name) + ATTR_NONNULL(1, 2); /** * Make sure there is a tag with name \a name, create one if needed. */ diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index ba870cd7882..d2ffabc0ea4 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -25,7 +25,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 6 +#define BLENDER_FILE_SUBVERSION 7 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index cf376883d55..77fec1d4504 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -335,7 +335,8 @@ typedef void (*BKE_scene_collections_Cb)(struct Collection *ob, void *data); OB_HIDE_RENDER; \ int _base_id = 0; \ for (Base *_base = (Base *)BKE_collection_object_cache_get(_collection).first; _base; \ - _base = _base->next, _base_id++) { \ + _base = _base->next, _base_id++) \ + { \ Object *_object = _base->object; \ if ((_base->flag & _base_flag) && \ (_object->visibility_flag & _object_visibility_flag) == 0) { @@ -348,7 +349,8 @@ typedef void (*BKE_scene_collections_Cb)(struct Collection *ob, void *data); #define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object) \ for (Base *_base = (Base *)BKE_collection_object_cache_get(_collection).first; _base; \ - _base = _base->next) { \ + _base = _base->next) \ + { \ Object *_object = _base->object; \ BLI_assert(_object != NULL); diff --git a/source/blender/blenkernel/BKE_curves_utils.hh b/source/blender/blenkernel/BKE_curves_utils.hh index 9549a643c05..3bcd14469c7 100644 --- a/source/blender/blenkernel/BKE_curves_utils.hh +++ b/source/blender/blenkernel/BKE_curves_utils.hh @@ -133,8 +133,10 @@ class IndexRangeCyclic { } const int num_remaining = iterator_size - num_until_loop; - const int num_full_cycles = num_remaining / - iterable_range_size; /* Integer division (rounded down). */ + + /* Integer division (rounded down). */ + const int num_full_cycles = num_remaining / iterable_range_size; + const int end_index = num_remaining - num_full_cycles * iterable_range_size; return IndexRangeCyclic(start_index, end_index, iterable_range_size, num_full_cycles + 1); } diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index ee38250a056..3d7aa88cd8c 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -240,6 +240,10 @@ void BKE_fcurves_free(ListBase *list); */ void BKE_fcurves_copy(ListBase *dst, ListBase *src); +/* Set fcurve modifier name and ensure uniqueness. + * Pass new name string when it's been edited otherwise pass empty string. */ +void BKE_fmodifier_name_set(struct FModifier *fcm, const char *name); + /** * Callback used by lib_query to walk over all ID usages * (mimics `foreach_id` callback of #IDTypeInfo structure). diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 722173e7012..2441234d806 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -72,15 +72,20 @@ void IDP_FreeArray(struct IDProperty *prop); /** * \param st: The string to assign. * \param name: The property name. - * \param maxlen: The size of the new string (including the \0 terminator). + * \param maxncpy: The maximum size of the string (including the `\0` terminator). * \return The new string property. */ -struct IDProperty *IDP_NewString(const char *st, - const char *name, - int maxlen) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(2 /* 'name 'arg */); /* maxlen excludes '\0' */ -void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) - ATTR_NONNULL(); /* maxlen excludes '\0' */ +struct IDProperty *IDP_NewStringMaxSize(const char *st, + const char *name, + int maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2); +struct IDProperty *IDP_NewString(const char *st, const char *name) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(2); +/** + * \param st: The string to assign. + * \param maxncpy: The maximum size of the string (including the `\0` terminator). + */ +void IDP_AssignStringMaxSize(struct IDProperty *prop, const char *st, int maxncpy) ATTR_NONNULL(); +void IDP_AssignString(struct IDProperty *prop, const char *st) ATTR_NONNULL(); void IDP_ConcatStringC(struct IDProperty *prop, const char *st) ATTR_NONNULL(); void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append) ATTR_NONNULL(); void IDP_FreeString(struct IDProperty *prop) ATTR_NONNULL(); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 8fe510e119b..fc602e6bffb 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -86,29 +86,29 @@ bool BKE_imbuf_alpha_test(struct ImBuf *ibuf); int BKE_imbuf_write_stamp(const struct Scene *scene, const struct RenderResult *rr, struct ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf); /** * \note imf->planes is ignored here, its assumed the image channels are already set. */ -int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, const struct ImageFormatData *imf); +int BKE_imbuf_write(struct ImBuf *ibuf, const char *filepath, const struct ImageFormatData *imf); /** * Same as #BKE_imbuf_write() but crappy workaround not to permanently modify _some_, * values in the imbuf. */ int BKE_imbuf_write_as(struct ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf, bool save_copy); /** * Used by sequencer too. */ -struct anim *openanim(const char *name, +struct anim *openanim(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); -struct anim *openanim_noload(const char *name, +struct anim *openanim_noload(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); @@ -237,11 +237,13 @@ void BKE_image_ensure_viewer_views(const struct RenderData *rd, */ void BKE_image_user_frame_calc(struct Image *ima, struct ImageUser *iuser, int cfra); int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, bool *r_is_in_range); -void BKE_image_user_file_path(const struct ImageUser *iuser, const struct Image *ima, char *path); +void BKE_image_user_file_path(const struct ImageUser *iuser, + const struct Image *ima, + char *filepath); void BKE_image_user_file_path_ex(const struct Main *bmain, const struct ImageUser *iuser, const struct Image *ima, - char *path, + char *filepath, const bool resolve_udim, const bool resolve_multiview); void BKE_image_editors_update_frame(const struct Main *bmain, int cfra); @@ -477,7 +479,7 @@ bool BKE_image_has_loaded_ibuf(struct Image *image); * References the result, #BKE_image_release_ibuf is to be called to de-reference. * Use lock=NULL when calling #BKE_image_release_ibuf(). */ -struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *name); +struct ImBuf *BKE_image_get_ibuf_with_name(struct Image *image, const char *filepath); /** * References the result, #BKE_image_release_ibuf is to be called to de-reference. * Use lock=NULL when calling #BKE_image_release_ibuf(). diff --git a/source/blender/blenkernel/BKE_image_format.h b/source/blender/blenkernel/BKE_image_format.h index e3254c59ca4..d742a82159d 100644 --- a/source/blender/blenkernel/BKE_image_format.h +++ b/source/blender/blenkernel/BKE_image_format.h @@ -29,7 +29,7 @@ void BKE_image_format_blend_write(struct BlendWriter *writer, struct ImageFormat /* File Paths */ -void BKE_image_path_from_imformat(char *string, +void BKE_image_path_from_imformat(char *filepath, const char *base, const char *relbase, int frame, @@ -37,7 +37,7 @@ void BKE_image_path_from_imformat(char *string, bool use_ext, bool use_frames, const char *suffix); -void BKE_image_path_from_imtype(char *string, +void BKE_image_path_from_imtype(char *filepath, const char *base, const char *relbase, int frame, @@ -45,8 +45,9 @@ void BKE_image_path_from_imtype(char *string, bool use_ext, bool use_frames, const char *suffix); -int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format); -int BKE_image_path_ensure_ext_from_imtype(char *string, char imtype); +int BKE_image_path_ensure_ext_from_imformat(char *filepath, + const struct ImageFormatData *im_format); +int BKE_image_path_ensure_ext_from_imtype(char *filepath, char imtype); /* File Types */ diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 27b454d4d75..b7723c958c6 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -447,7 +447,8 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter); Base *_base; \ BKE_view_layer_synced_ensure(scene, view_layer); \ for (_base = (Base *)BKE_view_layer_object_bases_get(view_layer)->first; _base; \ - _base = _base->next) { \ + _base = _base->next) \ + { \ _instance = _base->object; #define FOREACH_OBJECT_END \ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8553f2fd0fe..49529d2513d 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -474,7 +474,8 @@ struct GHashIterator *ntreeTypeGetIterator(void); { \ GHashIterator *__node_tree_type_iter__ = ntreeTypeGetIterator(); \ for (; !BLI_ghashIterator_done(__node_tree_type_iter__); \ - BLI_ghashIterator_step(__node_tree_type_iter__)) { \ + BLI_ghashIterator_step(__node_tree_type_iter__)) \ + { \ bNodeTreeType *ntype = (bNodeTreeType *)BLI_ghashIterator_getValue(__node_tree_type_iter__); #define NODE_TREE_TYPES_END \ @@ -649,7 +650,8 @@ const char *nodeSocketSubTypeLabel(int subtype); { \ GHashIterator *__node_socket_type_iter__ = nodeSocketTypeGetIterator(); \ for (; !BLI_ghashIterator_done(__node_socket_type_iter__); \ - BLI_ghashIterator_step(__node_socket_type_iter__)) { \ + BLI_ghashIterator_step(__node_socket_type_iter__)) \ + { \ bNodeSocketType *stype = (bNodeSocketType *)BLI_ghashIterator_getValue( \ __node_socket_type_iter__); diff --git a/source/blender/blenkernel/BKE_packedFile.h b/source/blender/blenkernel/BKE_packedFile.h index 893aa2a5b1c..63b809a708e 100644 --- a/source/blender/blenkernel/BKE_packedFile.h +++ b/source/blender/blenkernel/BKE_packedFile.h @@ -45,7 +45,7 @@ enum ePF_FileStatus { struct PackedFile *BKE_packedfile_duplicate(const struct PackedFile *pf_src); struct PackedFile *BKE_packedfile_new(struct ReportList *reports, - const char *filepath, + const char *filepath_rel, const char *basepath); struct PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 8dc14d5c370..c34f118e3b6 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -9,6 +9,7 @@ */ #include "BLI_buffer.h" +#include "BLI_compiler_attrs.h" #include "BLI_utildefines.h" #include "DNA_particle_types.h" @@ -376,7 +377,8 @@ void psys_reset(struct ParticleSystem *psys, int mode); void psys_find_parents(struct ParticleSimulationData *sim, bool use_render_params); -void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname); +void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname) + ATTR_NONNULL(1, 2, 3); /** * Calculates paths ready for drawing/rendering diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh index 2963b27f81c..b079f9f2c02 100644 --- a/source/blender/blenkernel/BKE_pbvh_pixels.hh +++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh @@ -376,7 +376,8 @@ struct CopyPixelTile { const CopyPixelGroup &group = groups[group_index]; CopyPixelCommand copy_command(group); for (const DeltaCopyPixelCommand &item : Span( - &command_deltas[group.start_delta_index], group.num_deltas)) { + &command_deltas[group.start_delta_index], group.num_deltas)) + { copy_command.apply(item); copy_command.mix_source_and_write_destination(image_buffer); } diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index 0dff56ee60b..f9ac5caeee9 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -99,7 +99,7 @@ typedef struct StudioLight { int index; int flag; char name[FILE_MAXFILE]; - char path[FILE_MAX]; + char filepath[FILE_MAX]; char *path_irr_cache; char *path_sh_cache; int icon_id_irradiance; @@ -142,8 +142,8 @@ struct ListBase *BKE_studiolight_listbase(void); */ void BKE_studiolight_ensure_flag(StudioLight *sl, int flag); void BKE_studiolight_refresh(void); -StudioLight *BKE_studiolight_load(const char *path, int type); -StudioLight *BKE_studiolight_create(const char *path, +StudioLight *BKE_studiolight_load(const char *filepath, int type); +StudioLight *BKE_studiolight_create(const char *filepath, const SolidLight light[4], const float light_ambient[3]); /** diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index e1bbffb11e1..b6391b74fc3 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -38,7 +38,7 @@ typedef struct bMovieHandle { void (*end_movie)(void *context_v); /* Optional function. */ - void (*get_movie_path)(char *string, + void (*get_movie_path)(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); @@ -52,7 +52,7 @@ bMovieHandle *BKE_movie_handle_get(char imtype); /** * \note Similar to #BKE_image_path_from_imformat() */ -void BKE_movie_filepath_get(char *string, +void BKE_movie_filepath_get(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index cfe246eb470..d5cc6e0a4de 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -64,7 +64,7 @@ int BKE_ffmpeg_append(void *context_v, int recty, const char *suffix, struct ReportList *reports); -void BKE_ffmpeg_filepath_get(char *string, +void BKE_ffmpeg_filepath_get(char *filepath, const struct RenderData *rd, bool preview, const char *suffix); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index f5d46236c39..58d2d3d206e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -394,7 +394,8 @@ CCGError ccgSubSurf_setUseAgeCounts( if (useAgeCounts) { if ((vertUserOffset + 4 > ss->meshIFC.vertUserSize) || (edgeUserOffset + 4 > ss->meshIFC.edgeUserSize) || - (faceUserOffset + 4 > ss->meshIFC.faceUserSize)) { + (faceUserOffset + 4 > ss->meshIFC.faceUserSize)) + { return eCCGError_InvalidValue; } ss->useAgeCounts = 1; @@ -553,7 +554,8 @@ CCGError ccgSubSurf_syncVert( v->flags = Vert_eEffected | seamflag; } else if (!VertDataEqual(vertData, ccg_vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || - ((v->flags & Vert_eSeam) != seamflag)) { + ((v->flags & Vert_eSeam) != seamflag)) + { int i, j; VertDataCopy(ccg_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); @@ -585,7 +587,8 @@ CCGError ccgSubSurf_syncVert( v->flags = Vert_eEffected | seamflag; } else if (!VertDataEqual(vertData, ccg_vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || - ((v->flags & Vert_eSeam) != seamflag)) { + ((v->flags & Vert_eSeam) != seamflag)) + { *prevp = v->next; ccg_ehash_insert(ss->vMap, (EHEntry *)v); VertDataCopy(ccg_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); @@ -696,7 +699,8 @@ CCGError ccgSubSurf_syncFace( if (f) { if (f->numVerts != numVerts || memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) != 0 || - memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) { + memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) + { topologyChanged = 1; } } @@ -767,7 +771,8 @@ CCGError ccgSubSurf_syncFace( if (f) { if (f->numVerts != numVerts || memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) != 0 || - memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) { + memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts) != 0) + { topologyChanged = 1; } } diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c index ff58819a442..35da8edd3b7 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c @@ -174,8 +174,8 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb( NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 1), no); } if (xPlusOk && yPlusOk) { - if (x < gridSize - 2 || y < gridSize - 2 || - FACE_getVerts(f)[S]->flags & Vert_eEffected) { + if (x < gridSize - 2 || y < gridSize - 2 || FACE_getVerts(f)[S]->flags & Vert_eEffected) + { NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 1), no); } } diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index c17e0d79118..13f43b43a74 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -1667,7 +1667,8 @@ Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); if ((mesh_eval == nullptr) || !CustomData_MeshMasks_are_matching(&(ob->runtime.last_data_mask), &cddata_masks) || - (need_mapping && !ob->runtime.last_need_mapping)) { + (need_mapping && !ob->runtime.last_need_mapping)) + { CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask); makeDerivedMesh(depsgraph, scene, ob, dataMask); @@ -1709,7 +1710,8 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, if (!ob->runtime.mesh_deform_eval || !CustomData_MeshMasks_are_matching(&(ob->runtime.last_data_mask), &cddata_masks) || - (need_mapping && !ob->runtime.last_need_mapping)) { + (need_mapping && !ob->runtime.last_need_mapping)) + { CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask); mesh_build_data( depsgraph, scene, ob, &cddata_masks, need_mapping || ob->runtime.last_need_mapping); @@ -1767,7 +1769,8 @@ Mesh *editbmesh_get_eval_cage(struct Depsgraph *depsgraph, object_get_datamask(depsgraph, obedit, &cddata_masks, nullptr); if (!obedit->runtime.editmesh_eval_cage || - !CustomData_MeshMasks_are_matching(&(obedit->runtime.last_data_mask), &cddata_masks)) { + !CustomData_MeshMasks_are_matching(&(obedit->runtime.last_data_mask), &cddata_masks)) + { editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks); } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index dea3319ac68..7c6c97db73b 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -116,7 +116,8 @@ static void action_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, /* Fix group links (kind of bad list-in-list search, but this is the most reliable way). */ for (group_dst = action_dst->groups.first, group_src = action_src->groups.first; group_dst && group_src; - group_dst = group_dst->next, group_src = group_src->next) { + group_dst = group_dst->next, group_src = group_src->next) + { if (fcurve_src->grp == group_src) { fcurve_dst->grp = group_dst; diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index e84e0874484..18d26c02e53 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -816,7 +816,8 @@ static bool drivers_path_rename_fix(ID *owner_id, if (strstr(prefix, "bones")) { if (((dtar->id) && (GS(dtar->id->name) == ID_OB) && (!ref_id || ((Object *)(dtar->id))->data == ref_id)) && - (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name)) { + (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name)) + { is_changed = true; BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); } @@ -992,13 +993,15 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, /* Active action and temp action. */ if (adt->action != NULL) { if (fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &adt->action->curves, verify_paths)) { + owner_id, prefix, oldName, newName, oldN, newN, &adt->action->curves, verify_paths)) + { DEG_id_tag_update(&adt->action->id, ID_RECALC_COPY_ON_WRITE); } } if (adt->tmpact) { if (fcurves_path_rename_fix( - owner_id, prefix, oldName, newName, oldN, newN, &adt->tmpact->curves, verify_paths)) { + owner_id, prefix, oldName, newName, oldN, newN, &adt->tmpact->curves, verify_paths)) + { DEG_id_tag_update(&adt->tmpact->id, ID_RECALC_COPY_ON_WRITE); } } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e81fa183e4b..9d6d034fabe 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -2053,7 +2053,8 @@ static void nlaevalchan_blend_value(NlaEvalChannelSnapshot *lower_necs, { nlaevalchan_assert_blendOrcombine_compatible(lower_necs, upper_necs, r_blended_necs); if (nlaevalchan_blendOrcombine_try_copy_from_lower( - lower_necs, upper_necs, upper_influence, r_blended_necs)) { + lower_necs, upper_necs, upper_influence, r_blended_necs)) + { return; } @@ -2082,7 +2083,8 @@ static void nlaevalchan_combine_value(NlaEvalChannelSnapshot *lower_necs, { nlaevalchan_assert_blendOrcombine_compatible(lower_necs, upper_necs, r_blended_necs); if (nlaevalchan_blendOrcombine_try_copy_from_lower( - lower_necs, upper_necs, upper_influence, r_blended_necs)) { + lower_necs, upper_necs, upper_influence, r_blended_necs)) + { return; } @@ -2115,7 +2117,8 @@ static void nlaevalchan_combine_quaternion(NlaEvalChannelSnapshot *lower_necs, { nlaevalchan_assert_blendOrcombine_compatible_quaternion(lower_necs, upper_necs, r_blended_necs); if (nlaevalchan_blendOrcombine_try_copy_from_lower( - lower_necs, upper_necs, upper_influence, r_blended_necs)) { + lower_necs, upper_necs, upper_influence, r_blended_necs)) + { return; } @@ -2347,7 +2350,8 @@ static void nlaevalchan_blend_value_get_inverted_lower_evalchan( nlaevalchan_assert_blendOrcombine_compatible(r_lower_necs, upper_necs, blended_necs); if (nlaevalchan_blendOrcombine_try_copy_to_lower( - blended_necs, upper_necs, upper_influence, r_lower_necs)) { + blended_necs, upper_necs, upper_influence, r_lower_necs)) + { return; } @@ -2386,7 +2390,8 @@ static void nlaevalchan_combine_value_get_inverted_lower_evalchan( nlaevalchan_assert_blendOrcombine_compatible(r_lower_necs, upper_necs, blended_necs); if (nlaevalchan_blendOrcombine_try_copy_to_lower( - blended_necs, upper_necs, upper_influence, r_lower_necs)) { + blended_necs, upper_necs, upper_influence, r_lower_necs)) + { return; } @@ -2432,7 +2437,8 @@ static void nlaevalchan_combine_quaternion_get_inverted_lower_evalchan( } if (nlaevalchan_blendOrcombine_try_copy_to_lower( - blended_necs, upper_necs, upper_influence, r_lower_necs)) { + blended_necs, upper_necs, upper_influence, r_lower_necs)) + { return; } @@ -3493,7 +3499,8 @@ static void animsys_evaluate_nla_for_keyframing(PointerRNA *ptr, /* If tweak strip is full REPLACE, then lower strips not needed. */ if (r_context->strip.blendmode == NLASTRIP_MODE_REPLACE && - IS_EQF(r_context->strip.influence, 1.0f)) { + IS_EQF(r_context->strip.influence, 1.0f)) + { BLI_freelistN(&lower_estrips); return; } @@ -3659,7 +3666,8 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context( { /* No remapping needed if NLA is off or no action. */ if ((adt == NULL) || (adt->action == NULL) || (adt->nla_tracks.first == NULL) || - (adt->flag & ADT_NLA_EVAL_OFF)) { + (adt->flag & ADT_NLA_EVAL_OFF)) + { return NULL; } @@ -3667,7 +3675,8 @@ NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context( * evaluated. */ if (!(adt->flag & ADT_NLA_EDIT_ON) && (adt->act_blendmode == NLASTRIP_MODE_REPLACE && adt->act_influence == 1.0f) && - (adt->flag & ADT_NLA_EVAL_UPPER_TRACKS) == 0) { + (adt->flag & ADT_NLA_EVAL_UPPER_TRACKS) == 0) + { return NULL; } @@ -3733,7 +3742,8 @@ void BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, float influence = context->strip.influence; if (blend_mode == NLASTRIP_MODE_REPLACE && influence == 1.0f && - BLI_listbase_is_empty(&context->upper_estrips)) { + BLI_listbase_is_empty(&context->upper_estrips)) + { BLI_bitmap_copy_all(r_successful_remaps, remap_domain, count); MEM_freeN(remap_domain); return; @@ -3772,7 +3782,8 @@ void BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, */ const bool can_force_all = r_force_all != NULL; if (blended_necs->channel->mix_mode == NEC_MIX_QUATERNION && - ELEM(blend_mode, NLASTRIP_MODE_COMBINE, NLASTRIP_MODE_REPLACE) && can_force_all) { + ELEM(blend_mode, NLASTRIP_MODE_COMBINE, NLASTRIP_MODE_REPLACE) && can_force_all) + { *r_force_all = true; index = -1; diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index ea1a179b3b0..c7ed3721779 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -749,7 +749,8 @@ const char *BKE_appdir_folder_id_create(const int folder_id, const char *subfold BLENDER_USER_DATAFILES, BLENDER_USER_CONFIG, BLENDER_USER_SCRIPTS, - BLENDER_USER_AUTOSAVE)) { + BLENDER_USER_AUTOSAVE)) + { BLI_assert_unreachable(); return NULL; } @@ -811,13 +812,13 @@ const char *BKE_appdir_resource_path_id(const int folder_id, const bool check_is * adds the correct extension (`.com` `.exe` etc) from * `$PATHEXT` if necessary. Also on Windows it translates * the name to its 8.3 version to prevent problems with - * spaces and stuff. Final result is returned in \a fullname. + * spaces and stuff. Final result is returned in \a program_filepath. * - * \param fullname: The full path and full name of the executable + * \param program_filepath: The full path and full name of the executable * (must be #FILE_MAX minimum) * \param name: The name of the executable (usually `argv[0]`) to be checked */ -static void where_am_i(char *fullname, const size_t maxlen, const char *name) +static void where_am_i(char *program_filepath, const size_t maxlen, const char *program_name) { # ifdef WITH_BINRELOC /* Linux uses `binreloc` since `argv[0]` is not reliable, call `br_init(NULL)` first. */ @@ -825,7 +826,7 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) const char *path = NULL; path = br_find_exe(NULL); if (path) { - BLI_strncpy(fullname, path, maxlen); + BLI_strncpy(program_filepath, path, maxlen); free((void *)path); return; } @@ -836,9 +837,9 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) { wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), "ProgramPath"); if (GetModuleFileNameW(0, fullname_16, maxlen)) { - conv_utf_16_to_8(fullname_16, fullname, maxlen); - if (!BLI_exists(fullname)) { - CLOG_ERROR(&LOG, "path can't be found: \"%.*s\"", (int)maxlen, fullname); + conv_utf_16_to_8(fullname_16, program_filepath, maxlen); + if (!BLI_exists(program_filepath)) { + CLOG_ERROR(&LOG, "path can't be found: \"%.*s\"", (int)maxlen, program_filepath); MessageBox( NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK); } @@ -851,31 +852,31 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) # endif /* Unix and non Linux. */ - if (name && name[0]) { + if (program_name && program_name[0]) { - BLI_strncpy(fullname, name, maxlen); - if (name[0] == '.') { - BLI_path_abs_from_cwd(fullname, maxlen); + BLI_strncpy(program_filepath, program_name, maxlen); + if (program_name[0] == '.') { + BLI_path_abs_from_cwd(program_filepath, maxlen); # ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + BLI_path_program_extensions_add_win32(program_filepath, maxlen); # endif } - else if (BLI_path_slash_rfind(name)) { + else if (BLI_path_slash_rfind(program_name)) { /* Full path. */ - BLI_strncpy(fullname, name, maxlen); + BLI_strncpy(program_filepath, program_name, maxlen); # ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + BLI_path_program_extensions_add_win32(program_filepath, maxlen); # endif } else { - BLI_path_program_search(fullname, maxlen, name); + BLI_path_program_search(program_filepath, maxlen, program_name); } /* Remove "/./" and "/../" so string comparisons can be used on the path. */ - BLI_path_normalize(fullname); + BLI_path_normalize(program_filepath); # if defined(DEBUG) - if (!STREQ(name, fullname)) { - CLOG_INFO(&LOG, 2, "guessing '%s' == '%s'", name, fullname); + if (!STREQ(program_name, program_filepath)) { + CLOG_INFO(&LOG, 2, "guessing '%s' == '%s'", program_name, program_filepath); } # endif } @@ -895,13 +896,14 @@ void BKE_appdir_program_path_init(const char *argv0) if (g_app.program_dirname[0] == '\0') { /* First time initializing, the file binary path isn't valid from a Python module. * Calling again must set the `filepath` and leave the directory as-is. */ - BLI_split_dir_part( + BLI_path_split_dir_part( g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname)); g_app.program_filepath[0] = '\0'; } #else where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0); - BLI_split_dir_part(g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname)); + BLI_path_split_dir_part( + g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname)); #endif } @@ -919,8 +921,8 @@ const char *BKE_appdir_program_dir(void) return g_app.program_dirname; } -bool BKE_appdir_program_python_search(char *fullpath, - const size_t fullpath_len, +bool BKE_appdir_program_python_search(char *program_filepath, + const size_t program_filepath_maxncpy, const int version_major, const int version_minor) { @@ -955,15 +957,16 @@ bool BKE_appdir_program_python_search(char *fullpath, if (python_bin_dir) { for (int i = 0; i < ARRAY_SIZE(python_names); i++) { - BLI_path_join(fullpath, fullpath_len, python_bin_dir, python_names[i]); + BLI_path_join(program_filepath, program_filepath_maxncpy, python_bin_dir, python_names[i]); if ( #ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullpath, fullpath_len) + BLI_path_program_extensions_add_win32(program_filepath, program_filepath_maxncpy) #else - BLI_exists(fullpath) + BLI_exists(program_filepath) #endif - ) { + ) + { is_found = true; break; } @@ -973,7 +976,7 @@ bool BKE_appdir_program_python_search(char *fullpath, if (is_found == false) { for (int i = 0; i < ARRAY_SIZE(python_names); i++) { - if (BLI_path_program_search(fullpath, fullpath_len, python_names[i])) { + if (BLI_path_program_search(program_filepath, program_filepath_maxncpy, python_names[i])) { is_found = true; break; } @@ -981,7 +984,7 @@ bool BKE_appdir_program_python_search(char *fullpath, } if (is_found == false) { - *fullpath = '\0'; + *program_filepath = '\0'; } return is_found; @@ -1013,7 +1016,8 @@ bool BKE_appdir_app_template_any(void) if (BKE_appdir_folder_id_ex(app_template_directory_id[i], app_template_directory_search[i], temp_dir, - sizeof(temp_dir))) { + sizeof(temp_dir))) + { return true; } } @@ -1060,7 +1064,8 @@ void BKE_appdir_app_templates(ListBase *templates) if (!BKE_appdir_folder_id_ex(app_template_directory_id[i], app_template_directory_search[i], subdir, - sizeof(subdir))) { + sizeof(subdir))) + { continue; } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e433c26cc54..fe2d8af8da7 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -404,7 +404,8 @@ static void copy_bonechildren(Bone *bone_dst, /* For each child in the list, update its children */ for (bone_src_child = bone_src->childbase.first, bone_dst_child = bone_dst->childbase.first; bone_src_child; - bone_src_child = bone_src_child->next, bone_dst_child = bone_dst_child->next) { + bone_src_child = bone_src_child->next, bone_dst_child = bone_dst_child->next) + { bone_dst_child->parent = bone_dst; copy_bonechildren(bone_dst_child, bone_src_child, bone_src_act, r_bone_dst_act, flag); } @@ -422,7 +423,8 @@ static void copy_bonechildren_custom_handles(Bone *bone_dst, bArmature *arm_dst) } for (bone_dst_child = bone_dst->childbase.first; bone_dst_child; - bone_dst_child = bone_dst_child->next) { + bone_dst_child = bone_dst_child->next) + { copy_bonechildren_custom_handles(bone_dst_child, arm_dst); } } @@ -2299,7 +2301,8 @@ static int rebuild_pose_bone( bPoseChannel *pchan_prev = pchan->prev; const Bone *last_visited_bone = *r_last_visited_bone_p; if ((pchan_prev == NULL && last_visited_bone != NULL) || - (pchan_prev != NULL && pchan_prev->bone != last_visited_bone)) { + (pchan_prev != NULL && pchan_prev->bone != last_visited_bone)) + { pchan_prev = last_visited_bone != NULL ? BKE_pose_channel_find_name(pose, last_visited_bone->name) : NULL; @@ -2676,7 +2679,8 @@ void BKE_pchan_minmax(const Object *ob, if (ob_custom) { float min[3], max[3]; if (use_empty_drawtype && (ob_custom->type == OB_EMPTY) && - BKE_object_minmax_empty_drawtype(ob_custom, min, max)) { + BKE_object_minmax_empty_drawtype(ob_custom, min, max)) + { memset(&bb_custom_buf, 0x0, sizeof(bb_custom_buf)); BKE_boundbox_init_from_minmax(&bb_custom_buf, min, max); bb_custom = &bb_custom_buf; @@ -2720,7 +2724,8 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden /* XXX pchan->bone may be NULL for duplicated bones, see duplicateEditBoneObjects() comment * (editarmature.c:2592)... Skip in this case too! */ if (pchan->bone && (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) && - !((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) { + !((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) + { BKE_pchan_minmax(ob, pchan, false, r_min, r_max); changed = true; diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index c1e1e63375d..1b1f97cd9d8 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -594,7 +594,8 @@ static void splineik_evaluate_bone( if (ik_data->xzScaleMode != CONSTRAINT_SPLINEIK_XZS_NONE) { /* First, apply the original scale if enabled. */ if (ik_data->xzScaleMode == CONSTRAINT_SPLINEIK_XZS_ORIGINAL || - (ik_data->flag & CONSTRAINT_SPLINEIK_USE_ORIGINAL_SCALE) != 0) { + (ik_data->flag & CONSTRAINT_SPLINEIK_USE_ORIGINAL_SCALE) != 0) + { float scale; /* X-axis scale. */ diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 919f413b98f..97fcff343da 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -265,7 +265,8 @@ bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname) BLI_strncpy_utf8(outname, name, maxlength); } - return BLI_uniquename_cb(unique_name_cb, &data, nullptr, '.', outname, maxlength); + const char *defname = ""; /* Dummy argument, never used as `name` is never zero length. */ + return BLI_uniquename_cb(unique_name_cb, &data, defname, '.', outname, maxlength); } CustomDataLayer *BKE_id_attribute_new(ID *id, @@ -539,7 +540,8 @@ CustomDataLayer *BKE_id_attribute_search(ID *id, get_domains(id, info); for (eAttrDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; - domain = static_cast(int(domain) + 1)) { + domain = static_cast(int(domain) + 1)) + { if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { continue; } @@ -752,7 +754,8 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id, for (int i = 0; i < customdata->totlayer; i++) { if (!(layer_mask & CD_TYPE_AS_MASK(customdata->layers[i].type)) || - (customdata->layers[i].flag & CD_FLAG_TEMPORARY)) { + (customdata->layers[i].flag & CD_FLAG_TEMPORARY)) + { continue; } @@ -873,16 +876,18 @@ CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const char *name) if (CustomDataLayer *layer = BKE_id_attribute_find(id, name, CD_PROP_COLOR, ATTR_DOMAIN_POINT)) { return layer; } - if (CustomDataLayer *layer = BKE_id_attribute_find( - id, name, CD_PROP_COLOR, ATTR_DOMAIN_CORNER)) { + if (CustomDataLayer *layer = BKE_id_attribute_find(id, name, CD_PROP_COLOR, ATTR_DOMAIN_CORNER)) + { return layer; } if (CustomDataLayer *layer = BKE_id_attribute_find( - id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_POINT)) { + id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_POINT)) + { return layer; } if (CustomDataLayer *layer = BKE_id_attribute_find( - id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_CORNER)) { + id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_CORNER)) + { return layer; } return nullptr; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 2b85178feca..a09ae77e81b 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -532,7 +532,8 @@ bool CustomDataAttributeProvider::try_delete(void *owner, const AttributeIDRef & for (const int i : IndexRange(custom_data->totlayer)) { const CustomDataLayer &layer = custom_data->layers[i]; if (this->type_is_supported((eCustomDataType)layer.type) && - custom_data_layer_matches_attribute_id(layer, attribute_id)) { + custom_data_layer_matches_attribute_id(layer, attribute_id)) + { CustomData_free_layer(custom_data, eCustomDataType(layer.type), element_num, i); return true; } @@ -932,7 +933,8 @@ bool MutableAttributeAccessor::rename(const AttributeIDRef &old_attribute_id, old_attribute.domain, type, AttributeInitShared{old_attribute.varray.get_internal_span().data(), - *old_attribute.sharing_info})) { + *old_attribute.sharing_info})) + { return false; } } @@ -940,7 +942,8 @@ bool MutableAttributeAccessor::rename(const AttributeIDRef &old_attribute_id, if (!this->add(new_attribute_id, old_attribute.domain, type, - AttributeInitVArray{old_attribute.varray})) { + AttributeInitVArray{old_attribute.varray})) + { return false; } } diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index 7d750773a50..e685272de6b 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -278,7 +278,8 @@ inline GAttributeReader lookup(const void *owner, const AttributeIDRef &attribut if (!attribute_id.is_anonymous()) { const StringRef name = attribute_id.name(); if (const BuiltinAttributeProvider *provider = - providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) { + providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) + { return provider->try_get_for_read(owner); } } @@ -296,8 +297,8 @@ inline bool for_all(const void *owner, FunctionRef fn) { Set handled_attribute_ids; - for (const BuiltinAttributeProvider *provider : - providers.builtin_attribute_providers().values()) { + for (const BuiltinAttributeProvider *provider : providers.builtin_attribute_providers().values()) + { if (provider->exists(owner)) { AttributeMetaData meta_data{provider->domain(), provider->data_type()}; if (!fn(provider->name(), meta_data)) { @@ -375,7 +376,8 @@ inline GAttributeWriter lookup_for_write(void *owner, const AttributeIDRef &attr if (!attribute_id.is_anonymous()) { const StringRef name = attribute_id.name(); if (const BuiltinAttributeProvider *provider = - providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) { + providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) + { return provider->try_get_for_write(owner); } } @@ -394,7 +396,8 @@ inline bool remove(void *owner, const AttributeIDRef &attribute_id) if (!attribute_id.is_anonymous()) { const StringRef name = attribute_id.name(); if (const BuiltinAttributeProvider *provider = - providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) { + providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) + { return provider->try_delete(owner); } } @@ -419,7 +422,8 @@ inline bool add(void *owner, if (!attribute_id.is_anonymous()) { const StringRef name = attribute_id.name(); if (const BuiltinAttributeProvider *provider = - providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) { + providers.builtin_attribute_providers().lookup_default_as(name, nullptr)) + { if (provider->domain() != domain) { return false; } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 305ac5f62cc..8d294d859d8 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -250,8 +250,8 @@ static void userdef_free_keymaps(UserDef *userdef) static void userdef_free_keyconfig_prefs(UserDef *userdef) { - for (wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first, *kpt_next; kpt; - kpt = kpt_next) { + for (wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first, *kpt_next; kpt; kpt = kpt_next) + { kpt_next = kpt->next; IDP_FreeProperty(kpt->prop); MEM_freeN(kpt); diff --git a/source/blender/blenkernel/intern/blendfile.cc b/source/blender/blenkernel/intern/blendfile.cc index 0d12ddf152e..7876d94b505 100644 --- a/source/blender/blenkernel/intern/blendfile.cc +++ b/source/blender/blenkernel/intern/blendfile.cc @@ -535,7 +535,8 @@ static void handle_subversion_warning(Main *main, BlendFileReadReport *reports) { if (main->minversionfile > BLENDER_FILE_VERSION || (main->minversionfile == BLENDER_FILE_VERSION && - main->minsubversionfile > BLENDER_FILE_SUBVERSION)) { + main->minsubversionfile > BLENDER_FILE_SUBVERSION)) + { BKE_reportf(reports->reports, RPT_WARNING, "File written by newer Blender binary (%d.%d), expect loss of data!", @@ -939,12 +940,13 @@ bool BKE_blendfile_workspace_config_write(Main *bmain, const char *filepath, Rep BKE_blendfile_write_partial_begin(bmain); for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; - workspace = static_cast(workspace->id.next)) { + workspace = static_cast(workspace->id.next)) + { BKE_blendfile_write_partial_tag_ID(&workspace->id, true); } - if (BKE_blendfile_write_partial( - bmain, filepath, fileflags, BLO_WRITE_PATH_REMAP_NONE, reports)) { + if (BKE_blendfile_write_partial(bmain, filepath, fileflags, BLO_WRITE_PATH_REMAP_NONE, reports)) + { retval = true; } diff --git a/source/blender/blenkernel/intern/blendfile_link_append.c b/source/blender/blenkernel/intern/blendfile_link_append.c index 7fe9f514e2a..8b5a3131cfb 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.c +++ b/source/blender/blenkernel/intern/blendfile_link_append.c @@ -194,8 +194,8 @@ void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_con BLI_ghash_free(lapp_context->new_id_to_item, NULL, NULL); } - for (LinkNode *liblink = lapp_context->libraries.list; liblink != NULL; - liblink = liblink->next) { + for (LinkNode *liblink = lapp_context->libraries.list; liblink != NULL; liblink = liblink->next) + { BlendfileLinkAppendContextLibrary *lib_context = liblink->link; link_append_context_library_blohandle_release(lapp_context, lib_context); } @@ -303,8 +303,8 @@ int BKE_blendfile_link_append_context_item_idtypes_from_library_add( while ((id_code = BKE_idtype_idcode_iter_step(&id_code_iter))) { if (!BKE_idtype_idcode_is_linkable(id_code) || - (id_types_filter != 0 && - (BKE_idtype_idcode_to_idfilter(id_code) & id_types_filter) == 0)) { + (id_types_filter != 0 && (BKE_idtype_idcode_to_idfilter(id_code) & id_types_filter) == 0)) + { continue; } @@ -379,11 +379,13 @@ void BKE_blendfile_link_append_context_item_foreach( BlendfileLinkAppendContextItem *item = itemlink->link; if ((flag & BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT) == 0 && - (item->tag & LINK_APPEND_TAG_INDIRECT) == 0) { + (item->tag & LINK_APPEND_TAG_INDIRECT) == 0) + { continue; } if ((flag & BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT) == 0 && - (item->tag & LINK_APPEND_TAG_INDIRECT) != 0) { + (item->tag & LINK_APPEND_TAG_INDIRECT) != 0) + { continue; } @@ -587,7 +589,8 @@ static bool loose_data_instantiate_collection_parents_check_recursive(Collection { for (CollectionParent *parent_collection = collection->runtime.parents.first; parent_collection != NULL; - parent_collection = parent_collection->next) { + parent_collection = parent_collection->next) + { if ((parent_collection->collection->id.tag & LIB_TAG_DOIT) != 0) { return true; } @@ -677,7 +680,8 @@ static void loose_data_instantiate_collection_process( /* When instantiated into view-layer, do not add collections if one of their parents is also * instantiated. */ if (!do_instantiate_as_empty && - loose_data_instantiate_collection_parents_check_recursive(collection)) { + loose_data_instantiate_collection_parents_check_recursive(collection)) + { continue; } /* When instantiated as empty, do not add indirectly linked (i.e. non-user-selected) @@ -924,7 +928,8 @@ static int foreach_libblock_link_append_callback(LibraryIDLinkCallbackData *cb_d /* NOTE: It is important to also skip liboverride references here, as those should never be made * local. */ if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING | IDWALK_CB_INTERNAL | - IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) { + IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) + { return IDWALK_RET_NOP; } @@ -1007,7 +1012,8 @@ static void blendfile_link_append_proxies_convert(Main *bmain, ReportList *repor BKE_lib_override_library_main_proxy_convert(bmain, &bf_reports); if (bf_reports.count.proxies_to_lib_overrides_success != 0 || - bf_reports.count.proxies_to_lib_overrides_failures != 0) { + bf_reports.count.proxies_to_lib_overrides_failures != 0) + { BKE_reportf(bf_reports.reports, RPT_WARNING, "Proxies have been removed from Blender (%d proxies were automatically converted " @@ -1091,7 +1097,8 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList * /* If we found a matching existing local id but are not re-using it, we need to properly clear * its weak reference to linked data. */ if (existing_local_id != NULL && - !ELEM(item->action, LINK_APPEND_ACT_KEEP_LINKED, LINK_APPEND_ACT_REUSE_LOCAL)) { + !ELEM(item->action, LINK_APPEND_ACT_KEEP_LINKED, LINK_APPEND_ACT_REUSE_LOCAL)) + { BKE_main_library_weak_reference_remove_item(lapp_context->library_weak_reference_mapping, id->lib->filepath, id->name, @@ -1238,7 +1245,8 @@ void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *re int lib_idx, item_idx; for (lib_idx = 0, liblink = lapp_context->libraries.list; liblink; - lib_idx++, liblink = liblink->next) { + lib_idx++, liblink = liblink->next) + { BlendfileLinkAppendContextLibrary *lib_context = liblink->link; char *libname = lib_context->path; BlendHandle *blo_handle = link_append_context_library_blohandle_ensure( @@ -1271,7 +1279,8 @@ void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *re /* For each lib file, we try to link all items belonging to that lib, * and tag those successful to not try to load them again with the other libraries. */ for (item_idx = 0, itemlink = lapp_context->items.list; itemlink; - item_idx++, itemlink = itemlink->next) { + item_idx++, itemlink = itemlink->next) + { BlendfileLinkAppendContextItem *item = itemlink->link; ID *new_id; @@ -1297,8 +1306,8 @@ void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *re (void)item_idx; /* Quiet set-but-unused warning (may be removed). */ /* Instantiate newly linked IDs as needed, if no append is scheduled. */ - if ((lapp_context->params->flag & FILE_LINK) != 0 && - lapp_context->params->context.scene != NULL) { + if ((lapp_context->params->flag & FILE_LINK) != 0 && lapp_context->params->context.scene != NULL) + { new_id_to_item_mapping_create(lapp_context); /* NOTE: Since we append items for IDs not already listed (i.e. implicitly linked indirect * dependencies), this list will grow and we will process those IDs later, leading to a flatten @@ -1364,7 +1373,8 @@ void BKE_blendfile_override(BlendfileLinkAppendContext *lapp_context, } /* Do not consider regular liboverrides if runtime ones are requested, and vice-versa. */ if ((set_runtime && (id_iter->tag & LIB_TAG_RUNTIME) == 0) || - (!set_runtime && (id_iter->tag & LIB_TAG_RUNTIME) != 0)) { + (!set_runtime && (id_iter->tag & LIB_TAG_RUNTIME) != 0)) + { continue; } @@ -1372,7 +1382,8 @@ void BKE_blendfile_override(BlendfileLinkAppendContext *lapp_context, ID **id_ptr; if (BLI_ghash_ensure_p(linked_ids_to_local_liboverrides, id_iter->override_library->reference, - (void ***)&id_ptr)) { + (void ***)&id_ptr)) + { continue; } *id_ptr = id_iter; @@ -1574,7 +1585,8 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, * We need to do this in a first, separated loop, otherwise some of those may not be handled by * ID remapping, which means they would still reference old data to be deleted... */ for (item_idx = 0, itemlink = lapp_context->items.list; itemlink; - item_idx++, itemlink = itemlink->next) { + item_idx++, itemlink = itemlink->next) + { BlendfileLinkAppendContextItem *item = itemlink->link; ID *old_id = item->userdata; @@ -1597,7 +1609,8 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, const int remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE); for (item_idx = 0, itemlink = lapp_context->items.list; itemlink; - item_idx++, itemlink = itemlink->next) { + item_idx++, itemlink = itemlink->next) + { BlendfileLinkAppendContextItem *item = itemlink->link; ID *old_id = item->userdata; ID *new_id = item->new_id; @@ -1641,7 +1654,8 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); for (item_idx = 0, itemlink = lapp_context->items.list; itemlink; - item_idx++, itemlink = itemlink->next) { + item_idx++, itemlink = itemlink->next) + { BlendfileLinkAppendContextItem *item = itemlink->link; ID *old_id = item->userdata; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 6a4e4ae8a9a..f09eef2ed84 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -112,7 +112,8 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, /* skip current object */ } else if (pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && - get_effector_data(cur, &cur_efd, &epoint, 0)) { + get_effector_data(cur, &cur_efd, &epoint, 0)) + { float temp = mul * pd->f_strength * effector_falloff(cur, &cur_efd, &epoint, bbd->part->effector_weights); @@ -146,10 +147,10 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, priority = 1.0f; } - /* then use that effector */ - if (priority > (rule->type == eBoidRuleType_Avoid ? - gabr->fear_factor : - 0.0f)) { /* with avoid, factor is "fear factor" */ + /* Then use that effector. */ + + /* With avoid, factor is "fear factor". */ + if (priority > (rule->type == eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { Object *eob = eff->ob; PartDeflect *pd = eff->pd; float surface = (pd && pd->shape == PFIELD_SHAPE_SURFACE) ? 1.0f : 0.0f; @@ -172,7 +173,8 @@ static bool rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, } } else if ((rule->type == eBoidRuleType_Avoid) && (bpa->data.mode == eBoidMode_Climbing) && - (priority > 2.0f * gabr->fear_factor)) { + (priority > 2.0f * gabr->fear_factor)) + { /* detach from surface and try to fly away from danger */ negate_v3_v3(efd.vec_to_point, bpa->gravity); } @@ -759,7 +761,8 @@ static bool rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Part /* check if boid doesn't want to fight */ bpa = pa->boid; if (bpa->data.health / bbd->part->boids->health * bbd->part->boids->aggression < - e_strength / f_strength) { + e_strength / f_strength) + { /* decide to flee */ if (closest_dist < fbr->flee_distance * fbr->distance) { negate_v3(bbd->wanted_co); @@ -938,8 +941,8 @@ static bool boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), Boi return false; } - if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && - rule->flag & BOIDRULE_ON_LAND) { + if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND) + { return true; } @@ -1015,7 +1018,8 @@ static bool apply_boid_rule( if (fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, - fuzziness * len_v3(pa->prev_state.vel)) == 0) { + fuzziness * len_v3(pa->prev_state.vel)) == 0) + { return true; } return false; @@ -1231,7 +1235,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* if boids can't fly they fall to the ground */ if ((boids->options & BOID_ALLOW_FLIGHT) == 0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) == 0 && - psys_uses_gravity(bbd->sim)) { + psys_uses_gravity(bbd->sim)) + { bpa->data.mode = eBoidMode_Falling; } @@ -1419,7 +1424,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* stick boid on goal when close enough */ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= - pa->size * boids->height) { + pa->size * boids->height) + { bpa->data.mode = eBoidMode_Climbing; bpa->ground = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); @@ -1454,7 +1460,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) if (boids->options & BOID_ALLOW_LAND) { /* stick boid on goal when close enough */ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= - pa->size * boids->height) { + pa->size * boids->height) + { bpa->data.mode = eBoidMode_Climbing; bpa->ground = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); @@ -1499,7 +1506,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) case eBoidMode_OnLand: { /* stick boid on goal when close enough */ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= - pa->size * boids->height) { + pa->size * boids->height) + { bpa->data.mode = eBoidMode_Climbing; bpa->ground = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 67f30f39dba..ab504dbabcf 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -93,8 +93,8 @@ void BKE_bpath_foreach_path_id(BPathForeachPathData *bpath_data, ID *id) return; } - if (id->library_weak_reference != NULL && - (flag & BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES) == 0) { + if (id->library_weak_reference != NULL && (flag & BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES) == 0) + { BKE_bpath_foreach_path_fixed_process(bpath_data, id->library_weak_reference->library_filepath); } @@ -174,7 +174,7 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da } if (bpath_data->callback_function(bpath_data, path_dst, (const char *)path_src)) { - BLI_split_dirfile(path_dst, path_dir, path_file, FILE_MAXDIR, FILE_MAXFILE); + BLI_path_split_dir_file(path_dst, path_dir, FILE_MAXDIR, path_file, FILE_MAXFILE); bpath_data->is_path_modified = true; return true; } diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index 7159c7a6633..d704fa7672c 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -614,7 +614,8 @@ bool BKE_brush_delete(Main *bmain, Brush *brush) return false; } if (ID_REAL_USERS(brush) <= 1 && ID_EXTRA_USERS(brush) == 0 && - BKE_library_ID_is_indirectly_used(bmain, brush)) { + BKE_library_ID_is_indirectly_used(bmain, brush)) + { return false; } @@ -2649,7 +2650,8 @@ bool BKE_brush_has_cube_tip(const Brush *brush, ePaintMode paint_mode) } if (ELEM(brush->sculpt_tool, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_PAINT) && - brush->tip_roundness < 1.0f) { + brush->tip_roundness < 1.0f) + { return true; } diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index e0a1e98f164..9b2cccb7690 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -400,7 +400,7 @@ bool BKE_cachefile_filepath_get(const Main *bmain, char ext[32]; BLI_path_frame_strip(r_filepath, ext, sizeof(ext)); - BLI_path_frame(r_filepath, frame, frame_len); + BLI_path_frame(r_filepath, FILE_MAX, frame, frame_len); BLI_path_extension_ensure(r_filepath, FILE_MAX, ext); /* TODO(kevin): store sequence range? */ @@ -422,7 +422,8 @@ bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file, Scene *s RenderEngineType *render_engine_type = RE_engines_find(scene->r.engine); if (cache_file->type != CACHEFILE_TYPE_ALEMBIC || - !RE_engine_supports_alembic_procedural(render_engine_type, scene)) { + !RE_engine_supports_alembic_procedural(render_engine_type, scene)) + { return false; } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 0ad00591d6d..297344f4627 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -710,7 +710,8 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params, } if (!isect_plane_plane_v3(plane_tx[Y_MIN], plane_tx[Y_MAX], plane_isect_1, plane_isect_1_no) || - !isect_plane_plane_v3(plane_tx[Z_MIN], plane_tx[Z_MAX], plane_isect_2, plane_isect_2_no)) { + !isect_plane_plane_v3(plane_tx[Z_MIN], plane_tx[Z_MAX], plane_isect_2, plane_isect_2_no)) + { return false; } @@ -722,7 +723,8 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params, plane_isect_2, plane_isect_2_other, plane_isect_pt_1, - plane_isect_pt_2)) { + plane_isect_pt_2)) + { return false; } @@ -1006,7 +1008,8 @@ bool BKE_camera_multiview_spherical_stereo(const RenderData *rd, const Object *c cam = camera->data; if ((rd->views_format == SCE_VIEWS_FORMAT_STEREO_3D) && ELEM(cam->type, CAM_PANO, CAM_PERSP) && - ((cam->stereo.flag & CAM_S3D_SPHERICAL) != 0)) { + ((cam->stereo.flag & CAM_S3D_SPHERICAL) != 0)) + { return true; } diff --git a/source/blender/blenkernel/intern/cloth.cc b/source/blender/blenkernel/intern/cloth.cc index 7e9aea008c4..ef4bd54f97c 100644 --- a/source/blender/blenkernel/intern/cloth.cc +++ b/source/blender/blenkernel/intern/cloth.cc @@ -233,7 +233,8 @@ static bool do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int ClothSimSettings *parms = clmd->sim_parms; if (parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE && - !(parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL)) { + !(parms->flags & CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL)) + { SIM_cloth_solver_set_volume(clmd); } @@ -288,7 +289,8 @@ static int do_step_cloth( cloth_apply_vgroup(clmd, result); if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) || - (clmd->sim_parms->vgroup_shrink > 0) || (clmd->sim_parms->shrink_min != 0.0f)) { + (clmd->sim_parms->vgroup_shrink > 0) || (clmd->sim_parms->shrink_min != 0.0f)) + { cloth_update_spring_lengths(clmd, result); } @@ -372,7 +374,8 @@ void clothModifier_do(ClothModifierData *clmd, cache_result = BKE_ptcache_read(&pid, float(framenr) + scene->r.subframe, can_simulate); if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED || - (!can_simulate && cache_result == PTCACHE_READ_OLD)) { + (!can_simulate && cache_result == PTCACHE_READ_OLD)) + { SIM_cloth_solver_set_positions(clmd); cloth_to_object(ob, clmd, vertexCos); @@ -391,15 +394,16 @@ void clothModifier_do(ClothModifierData *clmd, } else if ( /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ - /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { + /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) + { /* if baked and nothing in cache, do nothing */ BKE_ptcache_invalidate(cache); return; } /* if on second frame, write cache for first frame */ - if (cache->simframe == startframe && - (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) { + if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) + { BKE_ptcache_write(&pid, startframe); } @@ -754,7 +758,8 @@ static bool cloth_from_object( clmd->clothObject->sew_edge_graph = nullptr; if (clmd->sim_parms->shapekey_rest && - !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)) { + !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)) + { shapekey_rest = static_cast( CustomData_get_layer(&mesh->vdata, CD_CLOTH_ORCO)); } @@ -1143,7 +1148,8 @@ static void cloth_update_springs(ClothModifierData *clmd) /* Activate / Deactivate existing springs */ if (!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED) && - (cloth->verts[spring->ij].goal > ALMOST_ZERO)) { + (cloth->verts[spring->ij].goal > ALMOST_ZERO)) + { spring->flags &= ~CLOTH_SPRING_FLAG_DEACTIVATE; } else { @@ -1210,7 +1216,8 @@ static void cloth_update_spring_lengths(ClothModifierData *clmd, Mesh *mesh) if (spring->type != CLOTH_SPRING_TYPE_SEWING) { if (spring->type & (CLOTH_SPRING_TYPE_STRUCTURAL | CLOTH_SPRING_TYPE_SHEAR | - CLOTH_SPRING_TYPE_BENDING | CLOTH_SPRING_TYPE_INTERNAL)) { + CLOTH_SPRING_TYPE_BENDING | CLOTH_SPRING_TYPE_INTERNAL)) + { shrink_factor = cloth_shrink_factor(clmd, cloth->verts, spring->ij, spring->kl); } else { @@ -1523,7 +1530,8 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) /* If using the rest shape key, it's necessary to make a copy of the mesh. */ if (clmd->sim_parms->shapekey_rest && - !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)) { + !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH)) + { tmp_mesh = cloth_make_rest_mesh(clmd, mesh); } @@ -1543,7 +1551,8 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) clmd->sim_parms->internal_spring_max_length, clmd->sim_parms->internal_spring_max_diversion, (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL), - &tar_v_idx)) { + &tar_v_idx)) + { if (BLI_edgeset_haskey(existing_vert_pairs, i, tar_v_idx)) { /* We have already created a spring between these verts! */ continue; @@ -1611,7 +1620,8 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (spring) { spring_verts_ordered_set(spring, edges[i][0], edges[i][1]); if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW && loose_edges.count > 0 && - loose_edges.is_loose_bits[i]) { + loose_edges.is_loose_bits[i]) + { /* handle sewing (loose edges will be pulled together) */ spring->restlen = 0.0f; spring->lin_stiffness = 1.0f; @@ -1725,7 +1735,8 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (!cloth_bend_set_poly_vert_array( &spring->pa, spring->la, &corner_verts[polys[curr_ref->index].start()]) || !cloth_bend_set_poly_vert_array( - &spring->pb, spring->lb, &corner_verts[polys[i].start()])) { + &spring->pb, spring->lb, &corner_verts[polys[i].start()])) + { cloth_free_errorsprings(cloth, edgelist, spring_ref); return false; } diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 270f1583cb7..ac945f0491f 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -497,7 +497,8 @@ void BKE_collection_add_from_object(Main *bmain, FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { if (!ID_IS_LINKED(collection) && !ID_IS_OVERRIDABLE_LIBRARY(collection) && - BKE_collection_has_object(collection, ob_src)) { + BKE_collection_has_object(collection, ob_src)) + { collection_child_add(collection, collection_dst, 0, true); is_instantiated = true; } @@ -520,7 +521,8 @@ void BKE_collection_add_from_collection(Main *bmain, FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { if (!ID_IS_LINKED(collection) && !ID_IS_OVERRIDABLE_LIBRARY(collection) && - collection_find_child(collection, collection_src)) { + collection_find_child(collection, collection_src)) + { collection_child_add(collection, collection_dst, 0, true); is_instantiated = true; } @@ -921,7 +923,8 @@ void BKE_main_collections_object_cache_free(const Main *bmain) } for (Collection *collection = bmain->collections.first; collection != NULL; - collection = collection->id.next) { + collection = collection->id.next) + { collection_object_cache_free(collection); } } @@ -1271,7 +1274,8 @@ static Collection *collection_parent_editable_find_recursive(const ViewLayer *vi Collection *collection) { if (!ID_IS_LINKED(collection) && !ID_IS_OVERRIDE_LIBRARY(collection) && - (view_layer == NULL || BKE_view_layer_has_collection(view_layer, collection))) { + (view_layer == NULL || BKE_view_layer_has_collection(view_layer, collection))) + { return collection; } @@ -1281,9 +1285,11 @@ static Collection *collection_parent_editable_find_recursive(const ViewLayer *vi LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->runtime.parents) { if (!ID_IS_LINKED(collection_parent->collection) && - !ID_IS_OVERRIDE_LIBRARY(collection_parent->collection)) { + !ID_IS_OVERRIDE_LIBRARY(collection_parent->collection)) + { if (view_layer != NULL && - !BKE_view_layer_has_collection(view_layer, collection_parent->collection)) { + !BKE_view_layer_has_collection(view_layer, collection_parent->collection)) + { /* In case this parent collection is not in given view_layer, there is no point in * searching in its ancestors either, we can skip that whole parenting branch. */ continue; @@ -1306,7 +1312,8 @@ static bool collection_object_add( if (ob->instance_collection) { /* Cyclic dependency check. */ if ((ob->instance_collection == collection) || - collection_find_child_recursive(ob->instance_collection, collection)) { + collection_find_child_recursive(ob->instance_collection, collection)) + { return false; } } @@ -1431,7 +1438,8 @@ void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, O FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { if (!ID_IS_LINKED(collection) && !ID_IS_OVERRIDE_LIBRARY(collection) && - BKE_collection_has_object(collection, ob_src)) { + BKE_collection_has_object(collection, ob_src)) + { collection_object_add(bmain, collection, ob_dst, 0, true); is_instantiated = true; } @@ -1663,14 +1671,16 @@ static bool collection_instance_find_recursive(Collection *collection, LISTBASE_FOREACH (CollectionObject *, collection_object, &collection->gobject) { if (collection_object->ob != NULL && /* Object from a given collection should never instantiate that collection either. */ - ELEM(collection_object->ob->instance_collection, instance_collection, collection)) { + ELEM(collection_object->ob->instance_collection, instance_collection, collection)) + { return true; } } LISTBASE_FOREACH (CollectionChild *, collection_child, &collection->children) { if (collection_child->collection != NULL && - collection_instance_find_recursive(collection_child->collection, instance_collection)) { + collection_instance_find_recursive(collection_child->collection, instance_collection)) + { return true; } } @@ -1705,8 +1715,8 @@ static bool collection_instance_fix_recursive(Collection *parent_collection, bool cycles_found = false; LISTBASE_FOREACH (CollectionObject *, collection_object, &parent_collection->gobject) { - if (collection_object->ob != NULL && - collection_object->ob->instance_collection == collection) { + if (collection_object->ob != NULL && collection_object->ob->instance_collection == collection) + { id_us_min(&collection->id); collection_object->ob->instance_collection = NULL; cycles_found = true; diff --git a/source/blender/blenkernel/intern/collision.cc b/source/blender/blenkernel/intern/collision.cc index 82536cc1b29..1e28d3e737a 100644 --- a/source/blender/blenkernel/intern/collision.cc +++ b/source/blender/blenkernel/intern/collision.cc @@ -289,7 +289,8 @@ static float compute_collision_point_tri_tri(const float a1[3], for (int j = 0; j < 3; j++) { if (isect_line_plane_v3(tmp_co1, a[j], a[next_ind(j)], b[i], dir) && point_in_slice_seg(tmp_co1, a[j], a[next_ind(j)]) && - point_in_slice_seg(tmp_co1, b[i], b[next_ind(i)])) { + point_in_slice_seg(tmp_co1, b[i], b[next_ind(i)])) + { closest_to_line_v3(tmp_co2, tmp_co1, b[i], b[next_ind(i)]); sub_v3_v3v3(tmp_vec, tmp_co1, tmp_co2); tmp = len_v3(tmp_vec); @@ -476,7 +477,8 @@ static float compute_collision_point_edge_tri(const float a1[3], if (isect_line_plane_v3(tmp_co1, a[0], a[1], b[i], dir) && point_in_slice_seg(tmp_co1, a[0], a[1]) && - point_in_slice_seg(tmp_co1, b[i], b[next_ind(i)])) { + point_in_slice_seg(tmp_co1, b[i], b[next_ind(i)])) + { closest_to_line_v3(tmp_co2, tmp_co1, b[i], b[next_ind(i)]); sub_v3_v3v3(tmp_vec, tmp_co1, tmp_co2); tmp = len_v3(tmp_vec); @@ -1685,8 +1687,8 @@ int cloth_bvh_collision( collisions = (CollPair *)MEM_mallocN(sizeof(CollPair) * coll_count_self, "collision array"); - if (cloth_bvh_selfcollisions_nearcheck( - clmd, collisions, coll_count_self, overlap_self)) { + if (cloth_bvh_selfcollisions_nearcheck(clmd, collisions, coll_count_self, overlap_self)) + { ret += cloth_bvh_selfcollisions_resolve(clmd, collisions, coll_count_self, dt); ret2 += ret; } diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c index 99236ed81ea..0a66e2febf9 100644 --- a/source/blender/blenkernel/intern/colorband.c +++ b/source/blender/blenkernel/intern/colorband.c @@ -189,7 +189,8 @@ static void colorband_init_from_table_rgba_resample(ColorBand *coba, } while ((carr_len > 1 && !BLI_heap_is_empty(heap)) && - ((carr_len >= MAXCOLORBAND) || (BLI_heap_top_value(heap) <= eps_2x))) { + ((carr_len >= MAXCOLORBAND) || (BLI_heap_top_value(heap) <= eps_2x))) + { c = BLI_heap_pop_min(heap); struct ColorResampleElem *c_next = c->next, *c_prev = c->prev; c_prev->next = c_next; @@ -416,7 +417,8 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4]) out[3] = cbd1->a; } else if ((in <= cbd1->pos) && - ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) { + ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) + { /* We are before first color stop. */ out[0] = cbd1->r; out[1] = cbd1->g; @@ -449,7 +451,8 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4]) } if ((a == coba->tot) && - ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) { + ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE, COLBAND_INTERP_CONSTANT)) + { /* We are after last color stop. */ out[0] = cbd2->r; out[1] = cbd2->g; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 2a26a65c852..75af451d7b6 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -354,10 +354,8 @@ void BKE_constraint_mat_convertspace(Object *ob, } /* use pose-space as stepping stone for other spaces */ - if (ELEM(to, - CONSTRAINT_SPACE_WORLD, - CONSTRAINT_SPACE_PARLOCAL, - CONSTRAINT_SPACE_CUSTOM)) { + if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL, CONSTRAINT_SPACE_CUSTOM)) + { /* call self with slightly different values */ BKE_constraint_mat_convertspace( ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale); @@ -399,7 +397,8 @@ void BKE_constraint_mat_convertspace(Object *ob, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_OWNLOCAL, - CONSTRAINT_SPACE_CUSTOM)) { + CONSTRAINT_SPACE_CUSTOM)) + { /* call self with slightly different values */ BKE_constraint_mat_convertspace( ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale); @@ -1509,7 +1508,8 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph), NULL, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, - NULL)) { /* quat_pt is quat or NULL. */ + NULL)) + { float totmat[4][4]; unit_m4(totmat); @@ -4230,7 +4230,8 @@ static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), ShrinkwrapTreeData tree; if (BKE_shrinkwrap_init_tree( - &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) { + &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) + { BLI_space_transform_from_matrices(&transform, cob->matrix, ct->tar->object_to_world); switch (scon->shrinkType) { diff --git a/source/blender/blenkernel/intern/context.cc b/source/blender/blenkernel/intern/context.cc index 36eec388622..13aae983dd1 100644 --- a/source/blender/blenkernel/intern/context.cc +++ b/source/blender/blenkernel/intern/context.cc @@ -410,7 +410,8 @@ static int ctx_data_base_collection_get(const bContext *C, const char *member, L { ListBase ctx_object_list; if ((ctx_data_collection_get(C, member, &ctx_object_list) == false) || - BLI_listbase_is_empty(&ctx_object_list)) { + BLI_listbase_is_empty(&ctx_object_list)) + { BLI_listbase_clear(list); return 0; } @@ -426,7 +427,8 @@ static int ctx_data_base_collection_get(const bContext *C, const char *member, L CollectionPointerLink *ctx_object; for (ctx_object = static_cast(ctx_object_list.first); ctx_object; - ctx_object = ctx_object->next) { + ctx_object = ctx_object->next) + { Object *ob = static_cast(ctx_object->ptr.data); Base *base = BKE_view_layer_base_find(view_layer, ob); if (base != nullptr) { diff --git a/source/blender/blenkernel/intern/crazyspace.cc b/source/blender/blenkernel/intern/crazyspace.cc index 7202066b563..2b38713cc78 100644 --- a/source/blender/blenkernel/intern/crazyspace.cc +++ b/source/blender/blenkernel/intern/crazyspace.cc @@ -142,7 +142,8 @@ void BKE_crazyspace_set_quats_editmesh(BMEditMesh *em, do { if (BM_elem_flag_test(l_iter->v, BM_ELEM_HIDDEN) || BM_elem_flag_test(l_iter->v, BM_ELEM_TAG) || - (use_select && !BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT))) { + (use_select && !BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT))) + { continue; } @@ -291,7 +292,8 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra for (; md && i <= cageIndex; md = md->next, i++) { if (editbmesh_modifier_is_enabled(scene, ob, md, me != nullptr) && - BKE_modifier_is_correctable_deformed(md)) { + BKE_modifier_is_correctable_deformed(md)) + { modifiers_left_num++; } } @@ -522,7 +524,8 @@ void BKE_crazyspace_api_eval(Depsgraph *depsgraph, struct ReportList *reports) { if (object->runtime.crazyspace_deform_imats != nullptr || - object->runtime.crazyspace_deform_cos != nullptr) { + object->runtime.crazyspace_deform_cos != nullptr) + { return; } diff --git a/source/blender/blenkernel/intern/cryptomatte.cc b/source/blender/blenkernel/intern/cryptomatte.cc index 8e441681d2c..94dad4ee60e 100644 --- a/source/blender/blenkernel/intern/cryptomatte.cc +++ b/source/blender/blenkernel/intern/cryptomatte.cc @@ -262,7 +262,8 @@ void BKE_cryptomatte_matte_id_to_entries(NodeCryptomatte *node_storage, const ch /* Update the matte_id so the files can be opened in versions that don't * use `CryptomatteEntry`. */ if (matte_id != node_storage->matte_id && node_storage->matte_id && - STREQ(node_storage->matte_id, matte_id)) { + STREQ(node_storage->matte_id, matte_id)) + { MEM_SAFE_FREE(node_storage->matte_id); node_storage->matte_id = static_cast(MEM_dupallocN(matte_id)); } @@ -330,7 +331,8 @@ void BKE_cryptomatte_store_metadata(const struct CryptomatteSession *session, const ViewLayer *view_layer) { for (const blender::MapItem item : - session->layers.items()) { + session->layers.items()) + { const blender::StringRefNull layer_name(item.key); const blender::bke::cryptomatte::CryptomatteLayer &layer = item.value; diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 7981de7e6eb..d3a7f6eb95a 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -558,7 +558,8 @@ void BKE_curve_texspace_calc(Curve *cu) void BKE_curve_texspace_ensure(Curve *cu) { if ((cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO) && - (cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO_EVALUATED) == 0) { + (cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO_EVALUATED) == 0) + { BKE_curve_texspace_calc(cu); } } @@ -3290,7 +3291,8 @@ static void calchandleNurb_intern(BezTriple *bezt, /* When one handle is free, aligning makes no sense, see: #35952 */ ELEM(HD_FREE, bezt->h1, bezt->h2) || /* Also when no handles are aligned, skip this step. */ - (!ELEM(HD_ALIGN, bezt->h1, bezt->h2) && !ELEM(HD_ALIGN_DOUBLESIDE, bezt->h1, bezt->h2))) { + (!ELEM(HD_ALIGN, bezt->h1, bezt->h2) && !ELEM(HD_ALIGN_DOUBLESIDE, bezt->h1, bezt->h2))) + { /* Handles need to be updated during animation and applying stuff like hooks, * but in such situations it's quite difficult to distinguish in which order * align handles should be aligned so skip them for now. */ diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 2e50a906c17..fc3829b422c 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -656,7 +656,8 @@ static void write_sharp_bezier_edges(const CurvesInfo &curves_info, const VArraySpan handle_types_left{profile.handle_types_left()}; const VArraySpan handle_types_right{profile.handle_types_right()}; if (!handle_types_left.contains(BEZIER_HANDLE_VECTOR) && - !handle_types_right.contains(BEZIER_HANDLE_VECTOR)) { + !handle_types_right.contains(BEZIER_HANDLE_VECTOR)) + { return; } @@ -801,7 +802,8 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, main_attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) { if (!should_add_attribute_to_mesh( - main_attributes, mesh_attributes, id, meta_data, propagation_info)) { + main_attributes, mesh_attributes, id, meta_data, propagation_info)) + { return true; } main_attributes_set.add_new(id); @@ -839,7 +841,8 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, return true; } if (!should_add_attribute_to_mesh( - profile_attributes, mesh_attributes, id, meta_data, propagation_info)) { + profile_attributes, mesh_attributes, id, meta_data, propagation_info)) + { return true; } const eAttrDomain src_domain = meta_data.domain; diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 828018fe633..93bc61f3647 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -737,7 +737,8 @@ Span CurvesGeometry::evaluated_tangents() const const float epsilon = 1e-6f; if (!math::almost_equal_relative( - handles_right[points.first()], positions[points.first()], epsilon)) { + handles_right[points.first()], positions[points.first()], epsilon)) + { tangents[evaluated_points.first()] = math::normalize(handles_right[points.first()] - positions[points.first()]); } @@ -1442,7 +1443,8 @@ void CurvesGeometry::reverse_curves(const IndexMask curves_to_reverse) * the left does, but there's no need to count on it, so check for both attributes. */ if (attributes.contains(ATTR_HANDLE_POSITION_LEFT) && - attributes.contains(ATTR_HANDLE_POSITION_RIGHT)) { + attributes.contains(ATTR_HANDLE_POSITION_RIGHT)) + { reverse_swap_curve_point_data(*this, curves_to_reverse, this->handle_positions_left_for_write(), diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index d489b79047b..3d1919c57db 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2258,7 +2258,8 @@ static bool customdata_merge_internal(const CustomData *source, continue; } if ((max_current_type_layer_count != -1) && - (current_type_layer_count >= max_current_type_layer_count)) { + (current_type_layer_count >= max_current_type_layer_count)) + { /* Don't merge this layer because the maximum amount of layers of this type is reached. */ continue; } @@ -3945,7 +3946,8 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source, /* if we found a matching layer, copy the data */ if (dest->layers[dest_i].type == source->layers[src_i].type && - STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) { + STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) + { if (no_mask || ((CD_TYPE_AS_MASK(dest->layers[dest_i].type) & mask_exclude) == 0)) { const void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset); void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset); @@ -4018,7 +4020,8 @@ bool CustomData_layer_has_math(const CustomData *data, const int layer_n) const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(data->layers[layer_n].type)); if (typeInfo->equal && typeInfo->add && typeInfo->multiply && typeInfo->initminmax && - typeInfo->dominmax) { + typeInfo->dominmax) + { return true; } @@ -4385,7 +4388,8 @@ int CustomData_name_max_length_calc(const blender::StringRef name) return MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX; } for (const blender::StringRef prefix : - {"." UV_VERTSEL_NAME, UV_EDGESEL_NAME ".", UV_PINNED_NAME "."}) { + {"." UV_VERTSEL_NAME, UV_EDGESEL_NAME ".", UV_PINNED_NAME "."}) + { if (name.startswith(prefix)) { return MAX_CUSTOMDATA_LAYER_NAME; } @@ -4412,7 +4416,8 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index) STRNCPY(nlayer->name, DATA_(typeInfo->defaultname)); } - BLI_uniquename_cb(customdata_unique_check, &data_arg, nullptr, '.', nlayer->name, max_length); + const char *defname = ""; /* Dummy argument, never used as `name` is never zero length. */ + BLI_uniquename_cb(customdata_unique_check, &data_arg, defname, '.', nlayer->name, max_length); } void CustomData_validate_layer_name(const CustomData *data, @@ -4469,7 +4474,8 @@ bool CustomData_verify_versions(CustomData *data, const int index) CD_FACEMAP, CD_MTEXPOLY, CD_SCULPT_FACE_SETS, - CD_CREASE)) { + CD_CREASE)) + { keeplayer = false; CLOG_WARN(&LOG, ".blend file read: removing a data layer that should not have been written"); } @@ -4828,8 +4834,8 @@ static void copy_bit_flag(void *dst, const void *src, const size_t data_size, co { #define COPY_BIT_FLAG(_type, _dst, _src, _f) \ { \ - const _type _val = *((_type *)(_src)) & ((_type)(_f)); \ - *((_type *)(_dst)) &= ~((_type)(_f)); \ + const _type _val = *((_type *)(_src)) & (_type)(_f); \ + *((_type *)(_dst)) &= ~(_type)(_f); \ *((_type *)(_dst)) |= _val; \ } \ (void)0 @@ -4969,7 +4975,8 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye (mix_mode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && check_bit_flag(data_dst, data_size, data_flag)) || (mix_mode == CDT_MIX_REPLACE_BELOW_THRESHOLD && - !check_bit_flag(data_dst, data_size, data_flag)))) { + !check_bit_flag(data_dst, data_size, data_flag)))) + { copy_bit_flag(data_dst, tmp_dst, data_size, data_flag); } } @@ -5327,7 +5334,8 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, const int void CustomData_debug_info_from_layers(const CustomData *data, const char *indent, DynStr *dynstr) { for (eCustomDataType type = eCustomDataType(0); type < CD_NUMTYPES; - type = eCustomDataType(type + 1)) { + type = eCustomDataType(type + 1)) + { if (CustomData_has_layer(data, type)) { /* NOTE: doesn't account for multiple layers. */ const char *name = CustomData_layertype_name(type); diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index 6836524c38f..3e19f1f550d 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -267,25 +267,29 @@ static void data_transfer_mesh_attributes_transfer_active_color_string( if ((data_type == CD_PROP_COLOR) && !BKE_id_attribute_search(&const_cast(mesh_src->id), active_color_src, CD_MASK_PROP_COLOR, - ATTR_DOMAIN_MASK_COLOR)) { + ATTR_DOMAIN_MASK_COLOR)) + { return; } else if ((data_type == CD_PROP_BYTE_COLOR) && !BKE_id_attribute_search(&const_cast(mesh_src->id), active_color_src, CD_MASK_PROP_BYTE_COLOR, - ATTR_DOMAIN_MASK_COLOR)) { + ATTR_DOMAIN_MASK_COLOR)) + { return; } if ((data_type == CD_PROP_COLOR) && BKE_id_attribute_search( - &mesh_dst->id, active_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) { + &mesh_dst->id, active_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) + { mesh_dst->active_color_attribute = BLI_strdup(active_color_src); } else if ((data_type == CD_PROP_BYTE_COLOR) && BKE_id_attribute_search( - &mesh_dst->id, active_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) { + &mesh_dst->id, active_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) + { mesh_dst->active_color_attribute = BLI_strdup(active_color_src); } else { @@ -314,26 +318,29 @@ static void data_transfer_mesh_attributes_transfer_default_color_string( if ((data_type == CD_PROP_COLOR) && !BKE_id_attribute_search(&const_cast(mesh_src->id), default_color_src, CD_MASK_PROP_COLOR, - ATTR_DOMAIN_MASK_COLOR)) { + ATTR_DOMAIN_MASK_COLOR)) + { return; } else if ((data_type == CD_PROP_BYTE_COLOR) && !BKE_id_attribute_search(&const_cast(mesh_src->id), default_color_src, CD_MASK_PROP_BYTE_COLOR, - ATTR_DOMAIN_MASK_COLOR)) { + ATTR_DOMAIN_MASK_COLOR)) + { return; } if ((data_type == CD_PROP_COLOR) && BKE_id_attribute_search( - &mesh_dst->id, default_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) { + &mesh_dst->id, default_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) + { mesh_dst->default_color_attribute = BLI_strdup(default_color_src); } - else if ((data_type == CD_PROP_BYTE_COLOR) && BKE_id_attribute_search(&mesh_dst->id, - default_color_src, - CD_MASK_PROP_BYTE_COLOR, - ATTR_DOMAIN_MASK_COLOR)) { + else if ((data_type == CD_PROP_BYTE_COLOR) && + BKE_id_attribute_search( + &mesh_dst->id, default_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) + { mesh_dst->default_color_attribute = BLI_strdup(default_color_src); } else { @@ -465,7 +472,8 @@ float data_transfer_interp_float_do(const int mix_mode, float val_ret; if ((mix_mode == CDT_MIX_REPLACE_ABOVE_THRESHOLD && (val_dst < mix_factor)) || - (mix_mode == CDT_MIX_REPLACE_BELOW_THRESHOLD && (val_dst > mix_factor))) { + (mix_mode == CDT_MIX_REPLACE_BELOW_THRESHOLD && (val_dst > mix_factor))) + { return val_dst; /* Do not affect destination. */ } @@ -935,7 +943,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, fromlayers, tolayers, interp, - interp_data)) { + interp_data)) + { /* We handle specific source selection cases here. */ return false; } @@ -987,7 +996,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, fromlayers, tolayers, interp, - interp_data)) { + interp_data)) + { /* We handle specific source selection cases here. */ return false; } @@ -1060,7 +1070,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, fromlayers, tolayers, interp, - interp_data)) { + interp_data)) + { /* We handle specific source selection cases here. */ return false; } @@ -1091,7 +1102,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map, fromlayers, tolayers, interp, - interp_data)) { + interp_data)) + { /* We handle specific source selection cases here. */ return false; } @@ -1348,7 +1360,8 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, me_src = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_src); if (me_src == nullptr || - !CustomData_MeshMasks_are_matching(&ob_src->runtime.last_data_mask, &me_src_mask)) { + !CustomData_MeshMasks_are_matching(&ob_src->runtime.last_data_mask, &me_src_mask)) + { CLOG_WARN(&LOG, "Data Transfer: source mesh data is not ready - dependency cycle?"); return changed; } @@ -1465,13 +1478,15 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, use_delete, fromlayers, tolayers, - space_transform)) { + space_transform)) + { CustomDataTransferLayerMap *lay_mapit; changed |= (lay_map.first != nullptr); for (lay_mapit = static_cast(lay_map.first); lay_mapit; - lay_mapit = lay_mapit->next) { + lay_mapit = lay_mapit->next) + { CustomData_data_transfer(&geom_map[VDATA], lay_mapit); } @@ -1550,13 +1565,15 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, use_delete, fromlayers, tolayers, - space_transform)) { + space_transform)) + { CustomDataTransferLayerMap *lay_mapit; changed |= (lay_map.first != nullptr); for (lay_mapit = static_cast(lay_map.first); lay_mapit; - lay_mapit = lay_mapit->next) { + lay_mapit = lay_mapit->next) + { CustomData_data_transfer(&geom_map[EDATA], lay_mapit); } @@ -1577,8 +1594,8 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, if (!geom_map_init[LDATA]) { const int num_loops_src = me_src->totloop; - if ((map_loop_mode == MREMAP_MODE_TOPOLOGY) && - (corner_verts_dst.size() != num_loops_src)) { + if ((map_loop_mode == MREMAP_MODE_TOPOLOGY) && (corner_verts_dst.size() != num_loops_src)) + { BKE_report(reports, RPT_ERROR, "Source and destination meshes do not have the same amount of face corners, " @@ -1651,13 +1668,15 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, use_delete, fromlayers, tolayers, - space_transform)) { + space_transform)) + { CustomDataTransferLayerMap *lay_mapit; changed |= (lay_map.first != nullptr); for (lay_mapit = static_cast(lay_map.first); lay_mapit; - lay_mapit = lay_mapit->next) { + lay_mapit = lay_mapit->next) + { CustomData_data_transfer(&geom_map[LDATA], lay_mapit); } @@ -1737,13 +1756,15 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph, use_delete, fromlayers, tolayers, - space_transform)) { + space_transform)) + { CustomDataTransferLayerMap *lay_mapit; changed |= (lay_map.first != nullptr); for (lay_mapit = static_cast(lay_map.first); lay_mapit; - lay_mapit = lay_mapit->next) { + lay_mapit = lay_mapit->next) + { CustomData_data_transfer(&geom_map[PDATA], lay_mapit); } diff --git a/source/blender/blenkernel/intern/deform.cc b/source/blender/blenkernel/intern/deform.cc index e9f27430985..b191866a4a5 100644 --- a/source/blender/blenkernel/intern/deform.cc +++ b/source/blender/blenkernel/intern/deform.cc @@ -1301,7 +1301,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map, for (idx_src = 0, dg_src = static_cast(src_list->first); idx_src < num_layers_src; - idx_src++, dg_src = dg_src->next) { + idx_src++, dg_src = dg_src->next) + { if (!use_layers_src[idx_src]) { continue; } @@ -1610,7 +1611,8 @@ void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdv /* Convert to vertex group allocation system. */ MDeformWeight *dw; if (mdverts->dw && - (dw = static_cast(BLO_read_get_new_data_address(reader, mdverts->dw)))) { + (dw = static_cast(BLO_read_get_new_data_address(reader, mdverts->dw)))) + { const size_t dw_len = sizeof(MDeformWeight) * mdverts->totweight; void *dw_tmp = MEM_mallocN(dw_len, __func__); memcpy(dw_tmp, dw, dw_len); diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 45e8abe2a53..3e6cd9e86b0 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -603,7 +603,8 @@ void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph, if (pretessellatePoint) { VirtualModifierData virtualModifierData; for (ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); md; - md = md->next) { + md = md->next) + { const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type); if (!BKE_modifier_is_enabled(scene, md, required_mode)) { @@ -1039,13 +1040,15 @@ static void calc_bevfac_mapping(const Curve *cu, if ((BKE_nurb_check_valid_u(nu) == false) || /* not essential, but skips unnecessary calculation */ - (min_ff(cu->bevfac1, cu->bevfac2) == 0.0f && max_ff(cu->bevfac1, cu->bevfac2) == 1.0f)) { + (min_ff(cu->bevfac1, cu->bevfac2) == 0.0f && max_ff(cu->bevfac1, cu->bevfac2) == 1.0f)) + { calc_bevfac_mapping_default(bl, r_start, r_firstblend, r_steps, r_lastblend); return; } if (ELEM(cu->bevfac1_mapping, CU_BEVFAC_MAP_SEGMENT, CU_BEVFAC_MAP_SPLINE) || - ELEM(cu->bevfac2_mapping, CU_BEVFAC_MAP_SEGMENT, CU_BEVFAC_MAP_SPLINE)) { + ELEM(cu->bevfac2_mapping, CU_BEVFAC_MAP_SEGMENT, CU_BEVFAC_MAP_SPLINE)) + { for (i = 0; i < SEGMENTSU(nu); i++) { total_length += bl->seglen[i]; } @@ -1128,7 +1131,8 @@ static GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, BKE_curve_bevelList_make(ob, deformed_nurbs, for_render); if ((cu->flag & CU_PATH) || - DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) { + DEG_get_eval_flags_for_id(depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH) + { BKE_anim_path_calc_data(ob); } diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index 3b107c04118..05063ef6b6d 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -354,9 +354,11 @@ static bool surface_duplicateOutputExists(void *arg, const char *name) for (; surface; surface = surface->next) { if (surface != t_surface && surface->type == t_surface->type && - surface->format == t_surface->format) { + surface->format == t_surface->format) + { if ((surface->output_name[0] != '\0' && !BLI_path_cmp(name, surface->output_name)) || - (surface->output_name2[0] != '\0' && !BLI_path_cmp(name, surface->output_name2))) { + (surface->output_name2[0] != '\0' && !BLI_path_cmp(name, surface->output_name2))) + { return true; } } @@ -447,7 +449,8 @@ static int surface_totalSamples(DynamicPaintSurface *surface) return (surface->data->total_points * 5); } if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX && surface->flags & MOD_DPAINT_ANTIALIAS && - surface->data->adj_data) { + surface->data->adj_data) + { return (surface->data->total_points + surface->data->adj_data->total_targets); } @@ -794,7 +797,8 @@ static void surfaceGenerateGrid(DynamicPaintSurface *surface) /* in case of an allocation failure abort here */ if (!grid->bounds || !grid->s_pos || !grid->s_num || !grid->t_index || !temp_s_num || - !temp_t_index) { + !temp_t_index) + { error = 1; } @@ -930,7 +934,8 @@ static void surface_freeUnusedData(DynamicPaintSurface *surface) /* Free bake-data if not active or surface is baked. */ if (!(surface->flags & MOD_DPAINT_ACTIVE) || - (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) { + (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) + { free_bakeData(surface->data); } } @@ -1210,7 +1215,8 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd, /* copy existing surfaces */ for (surface = static_cast(pmd->canvas->surfaces.first); surface; - surface = surface->next) { + surface = surface->next) + { DynamicPaintSurface *t_surface = dynamicPaint_createNewSurface(tpmd->canvas, nullptr); if (flag & LIB_ID_COPY_SET_COPIED_ON_WRITE) { /* TODO(sergey): Consider passing some tips to the surface @@ -1775,8 +1781,8 @@ bool dynamicPaint_resetSurface(const Scene *scene, DynamicPaintSurface *surface) /* make sure allocated surface size matches current requirements */ static bool dynamicPaint_checkSurfaceData(const Scene *scene, DynamicPaintSurface *surface) { - if (!surface->data || - (dynamicPaint_surfaceNumOfPoints(surface) != surface->data->total_points)) { + if (!surface->data || (dynamicPaint_surfaceNumOfPoints(surface) != surface->data->total_points)) + { return dynamicPaint_resetSurface(scene, surface); } return true; @@ -1907,13 +1913,15 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object * Mesh *result = BKE_mesh_copy_for_eval(mesh); if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING) && - pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) { + pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) + { DynamicPaintSurface *surface; /* loop through surfaces */ for (surface = static_cast(pmd->canvas->surfaces.first); surface; - surface = surface->next) { + surface = surface->next) + { PaintSurfaceData *sData = surface->data; if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) { @@ -2115,7 +2123,8 @@ static void dynamicPaint_frameUpdate( CLAMP(current_frame, surface->start_frame, surface->end_frame); if (no_surface_data || current_frame != surface->current_frame || - int(scene->r.cfra) == surface->start_frame) { + int(scene->r.cfra) == surface->start_frame) + { PointCache *cache = surface->pointcache; PTCacheID pid; surface->current_frame = current_frame; @@ -2149,7 +2158,8 @@ static void dynamicPaint_frameUpdate( /* restore canvas mesh if required */ if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE && - surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) { + surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) + { canvas_copyMesh(canvas, mesh); } @@ -2255,7 +2265,8 @@ static void dynamic_paint_create_uv_surface_direct_cb(void *__restrict userdata, for (const int i : looptris.index_range()) { /* Check uv bb */ if ((faceBB[i].min[0] > point[sample][0]) || (faceBB[i].min[1] > point[sample][1]) || - (faceBB[i].max[0] < point[sample][0]) || (faceBB[i].max[1] < point[sample][1])) { + (faceBB[i].max[0] < point[sample][0]) || (faceBB[i].max[1] < point[sample][1])) + { continue; } @@ -3308,7 +3319,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, /* Validate output file path */ BLI_path_abs(output_file, BKE_main_blendfile_path_from_global()); - BLI_make_existing_file(output_file); + BLI_file_ensure_parent_dir_exists(output_file); /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); @@ -3634,7 +3645,8 @@ static void dynamicPaint_updatePointData(const DynamicPaintSurface *surface, /* Sample velocity colorband if required */ if (brush->flags & - (MOD_DPAINT_VELOCITY_ALPHA | MOD_DPAINT_VELOCITY_COLOR | MOD_DPAINT_VELOCITY_DEPTH)) { + (MOD_DPAINT_VELOCITY_ALPHA | MOD_DPAINT_VELOCITY_COLOR | MOD_DPAINT_VELOCITY_DEPTH)) + { float coba_res[4]; vel_factor /= brush->max_velocity; CLAMP(vel_factor, 0.0f, 1.0f); @@ -4054,7 +4066,8 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata, /* Check proximity collision */ if (ELEM(brush->collision, MOD_DPAINT_COL_DIST, MOD_DPAINT_COL_VOLDIST) && - (!hit_found || (brush->flags & MOD_DPAINT_INVERSE_PROX))) { + (!hit_found || (brush->flags & MOD_DPAINT_INVERSE_PROX))) + { float proxDist = -1.0f; float hitCo[3] = {0.0f, 0.0f, 0.0f}; int tri = 0; @@ -4138,7 +4151,8 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata, else if (hit_found == HIT_PROXIMITY) { /* apply falloff curve to the proximity_factor */ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && - BKE_colorband_evaluate(brush->paint_ramp, (1.0f - proximity_factor), prox_colorband)) { + BKE_colorband_evaluate(brush->paint_ramp, (1.0f - proximity_factor), prox_colorband)) + { proximity_factor = prox_colorband[3]; } else if (brush->proximity_falloff == MOD_DPAINT_PRFALL_CONSTANT) { @@ -4189,7 +4203,8 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata, /* if brush has smudge enabled store brush velocity */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE && - bData->brush_velocity) { + bData->brush_velocity) + { copy_v3_v3(&bData->brush_velocity[index * 4], velocity); bData->brush_velocity[index * 4 + 3] = velocity_val; } @@ -4326,7 +4341,8 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph, for (c_index = 0; c_index < total_cells; c_index++) { /* check grid cell bounding box */ if (!grid->s_num[c_index] || - !meshBrush_boundsIntersect(&grid->bounds[c_index], &mesh_bb, brush, brush_radius)) { + !meshBrush_boundsIntersect(&grid->bounds[c_index], &mesh_bb, brush, brush_radius)) + { continue; } @@ -4481,7 +4497,8 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex( /* If inside solid range and no disp depth required, no need to seek further */ if ((s_range < 0.0f) && - !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE)) { + !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE)) + { break; } } @@ -4529,7 +4546,8 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex( /* store brush velocity for smudge */ if ((surface->type == MOD_DPAINT_SURFACE_T_PAINT) && - (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity)) { + (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity)) + { copy_v3_v3(&bData->brush_velocity[index * 4], velocity); bData->brush_velocity[index * 4 + 3] = velocity_val; } @@ -4587,7 +4605,8 @@ static bool dynamicPaint_paintParticles(DynamicPaintSurface *surface, for (ParticleData *pa = psys->particles; p < psys->totpart; p++, pa++) { /* Proceed only if particle is active */ if ((pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) || - (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) || (pa->flag & PARS_UNEXIST)) { + (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) || (pa->flag & PARS_UNEXIST)) + { continue; } @@ -4704,7 +4723,8 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata, /* color ramp */ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && - BKE_colorband_evaluate(brush->paint_ramp, (1.0f - strength), colorband)) { + BKE_colorband_evaluate(brush->paint_ramp, (1.0f - strength), colorband)) + { strength = colorband[3]; } @@ -4722,7 +4742,8 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata, /* store brush velocity for smudge */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE && - bData->brush_velocity) { + bData->brush_velocity) + { mul_v3_v3fl(&bData->brush_velocity[index * 4], velocity, 1.0f / velocity_val); bData->brush_velocity[index * 4 + 3] = velocity_val; } @@ -5363,7 +5384,8 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata, const uint epointlock_idx = n_trgt / 8; const uint8_t epointlock_bitmask = 1 << (n_trgt & 7); /* 7 == 0b111 */ while (atomic_fetch_and_or_uint8(&point_locks[epointlock_idx], epointlock_bitmask) & - epointlock_bitmask) { + epointlock_bitmask) + { /* pass */ } @@ -5410,7 +5432,8 @@ static void dynamic_paint_effect_drip_cb(void *__restrict userdata, const uint ppointlock_idx = index / 8; const uint8_t ppointlock_bitmask = 1 << (index & 7); /* 7 == 0b111 */ while (atomic_fetch_and_or_uint8(&point_locks[ppointlock_idx], ppointlock_bitmask) & - ppointlock_bitmask) { + ppointlock_bitmask) + { /* pass */ } @@ -5865,7 +5888,8 @@ static void dynamic_paint_surface_pre_step_cb(void *__restrict userdata, } /* dissolve for float types */ else if (surface->flags & MOD_DPAINT_DISSOLVE && - ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WEIGHT)) { + ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WEIGHT)) + { float *point = &((float *)sData->type_data)[index]; /* log or linear */ value_dissolve( @@ -6266,7 +6290,8 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph, PART_FLUID_SPRAYBUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE) && - psys_check_enabled(brushObj, brush->psys, for_render)) { + psys_check_enabled(brushObj, brush->psys, for_render)) + { /* Paint a particle system */ dynamicPaint_paintParticles(surface, brush->psys, brush, timescale); } @@ -6295,8 +6320,8 @@ static int dynamicPaint_doStep(Depsgraph *depsgraph, /* process special brush effects, like smudge */ if (bData->brush_velocity) { - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && - brush->flags & MOD_DPAINT_DO_SMUDGE) { + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && brush->flags & MOD_DPAINT_DO_SMUDGE) + { dynamicPaint_doSmudge(surface, brush, timescale); } MEM_freeN(bData->brush_velocity); diff --git a/source/blender/blenkernel/intern/editmesh.cc b/source/blender/blenkernel/intern/editmesh.cc index 25531786aab..4ad882d3343 100644 --- a/source/blender/blenkernel/intern/editmesh.cc +++ b/source/blender/blenkernel/intern/editmesh.cc @@ -89,8 +89,8 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em, if ((em->looptris != nullptr) && // (*em->tottri >= looptris_tot)) /* Check against allocated size in case we over allocated a little. */ - ((looptris_tot_prev_alloc >= looptris_tot) && - (looptris_tot_prev_alloc <= looptris_tot * 2))) { + ((looptris_tot_prev_alloc >= looptris_tot) && (looptris_tot_prev_alloc <= looptris_tot * 2))) + { looptris = em->looptris; } else { @@ -234,7 +234,8 @@ const float (*BKE_editmesh_vert_coords_when_deformed(Depsgraph *depsgraph, coords = me->runtime->edit_data->vertexCos; } else if ((editmesh_eval_final != nullptr) && - (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH)) { + (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH)) + { /* If this is an edit-mesh type, leave nullptr as we can use the vertex coords. */ } else { diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc index ff57653d334..cb552b26b08 100644 --- a/source/blender/blenkernel/intern/editmesh_tangent.cc +++ b/source/blender/blenkernel/intern/editmesh_tangent.cc @@ -192,7 +192,8 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em, } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && - CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) { + CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) + { CustomData_add_layer_named( loopdata_out, CD_TANGENT, CD_SET_DEFAULT, int(loopdata_out_len), ""); } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 64b305accdd..0db431764ba 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -147,7 +147,8 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef Curve *cu = eff->ob->data; if (cu->flag & CU_PATH) { if (eff->ob->runtime.curve_cache == NULL || - eff->ob->runtime.curve_cache->anim_path_accum_length == NULL) { + eff->ob->runtime.curve_cache->anim_path_accum_length == NULL) + { BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, false); } @@ -511,7 +512,8 @@ static float eff_calc_visibility(ListBase *colliders, &hit, eff_tri_ray_hit, NULL, - raycast_flag) != -1) { + raycast_flag) != -1) + { absorption = col->ob->pd->absorption; /* visibility is only between 0 and 1, calculated from 1-absorption */ diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index b0b926b877f..7e1b95ac6b1 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -22,6 +22,7 @@ #include "BLI_ghash.h" #include "BLI_math.h" #include "BLI_sort_utils.h" +#include "BLI_string_utils.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" @@ -157,6 +158,18 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src) } } +void BKE_fmodifier_name_set(FModifier *fcm, const char *name) +{ + /* Copy new Modifier name. */ + BLI_strncpy(fcm->name, name, sizeof(fcm->name)); + + /* Set default modifier name when name parameter is an empty string. + * Ensure the name is unique. */ + const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(fcm->type); + ListBase list = BLI_listbase_from_link((Link *)fcm); + BLI_uniquename(&list, fcm, fmi->name, '.', offsetof(FModifier, name), sizeof(fcm->name)); +} + void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data) { ChannelDriver *driver = fcu->driver; @@ -251,7 +264,8 @@ FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_i /* 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 && - fcu->rna_path[0] == rna_path[0] && STREQ(fcu->rna_path, rna_path))) { + fcu->rna_path[0] == rna_path[0] && STREQ(fcu->rna_path, rna_path))) + { return fcu; } } @@ -1143,7 +1157,8 @@ void fcurve_samples_to_keyframes(FCurve *fcu, const int start, const int end) /* Copy actual sample points. */ for (; keyframes_to_insert && sample_points; - cur_pos++, bezt++, keyframes_to_insert--, fpt++, sample_points--) { + cur_pos++, bezt++, keyframes_to_insert--, fpt++, sample_points--) + { init_unbaked_bezt_data(bezt); copy_v2_v2(bezt->vec[1], fpt->vec); } @@ -1186,13 +1201,14 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve *fcu) FMod_Cycles *data = (FMod_Cycles *)fcm->data; if (data && data->after_cycles == 0 && data->before_cycles == 0) { - if (data->before_mode == FCM_EXTRAPOLATE_CYCLIC && - data->after_mode == FCM_EXTRAPOLATE_CYCLIC) { + if (data->before_mode == FCM_EXTRAPOLATE_CYCLIC && data->after_mode == FCM_EXTRAPOLATE_CYCLIC) + { return FCU_CYCLE_PERFECT; } if (ELEM(data->before_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET) && - ELEM(data->after_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET)) { + ELEM(data->after_mode, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET)) + { return FCU_CYCLE_OFFSET; } } @@ -1298,7 +1314,8 @@ void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag) /* If cyclic extrapolation and Auto Clamp has triggered, ensure it is symmetric. */ if (cycle && (first->auto_handle_type != HD_AUTOTYPE_NORMAL || - last->auto_handle_type != HD_AUTOTYPE_NORMAL)) { + last->auto_handle_type != HD_AUTOTYPE_NORMAL)) + { first->vec[0][1] = first->vec[2][1] = first->vec[1][1]; last->vec[0][1] = last->vec[2][1] = last->vec[1][1]; first->auto_handle_type = last->auto_handle_type = HD_AUTOTYPE_LOCKED_FINAL; @@ -1634,7 +1651,8 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple *bezt, prev_handle_right[0], next_handle_left[0], next_coords[0], - roots)) { + roots)) + { return false; } @@ -1930,12 +1948,14 @@ void BKE_fcurve_deduplicate_keys(FCurve *fcu) static float fcurve_eval_keyframes_extrapolate( FCurve *fcu, BezTriple *bezts, float evaltime, int endpoint_offset, int direction_to_neighbor) { - const BezTriple *endpoint_bezt = bezts + endpoint_offset; /* The first/last keyframe. */ - const BezTriple *neighbor_bezt = endpoint_bezt + - direction_to_neighbor; /* The second (to last) keyframe. */ + /* The first/last keyframe. */ + const BezTriple *endpoint_bezt = bezts + endpoint_offset; + /* The second (to last) keyframe. */ + const BezTriple *neighbor_bezt = endpoint_bezt + direction_to_neighbor; if (endpoint_bezt->ipo == BEZT_IPO_CONST || fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT || - (fcu->flag & FCURVE_DISCRETE_VALUES) != 0) { + (fcu->flag & FCURVE_DISCRETE_VALUES) != 0) + { /* Constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation, so just extend the * endpoint's value. */ return endpoint_bezt->vec[1][1]; @@ -2035,8 +2055,8 @@ static float fcurve_eval_keyframes_interpolate(const FCurve *fcu, const float period = prevbezt->period; /* Value depends on interpolation mode. */ - if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES) || - (duration == 0)) { + if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES) || (duration == 0)) + { /* Constant (evaltime not relevant, so no interpolation needed). */ return prevbezt->vec[1][1]; } @@ -2059,7 +2079,8 @@ static float fcurve_eval_keyframes_interpolate(const FCurve *fcu, v4[1] = bezt->vec[1][1]; if (fabsf(v1[1] - v4[1]) < FLT_EPSILON && fabsf(v2[1] - v3[1]) < FLT_EPSILON && - fabsf(v3[1] - v4[1]) < FLT_EPSILON) { + fabsf(v3[1] - v4[1]) < FLT_EPSILON) + { /* Optimization: If all the handles are flat/at the same values, * the value is simply the shared value (see #40372 -> F91346). */ @@ -2372,7 +2393,8 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) { /* If there are range-restrictions, we must definitely block #36950. */ if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || - (fcm->sfra <= evaltime && fcm->efra >= evaltime)) { + (fcm->sfra <= evaltime && fcm->efra >= evaltime)) + { /* Within range: here it probably doesn't matter, * though we'd want to check on additive. */ } diff --git a/source/blender/blenkernel/intern/fcurve_driver.c b/source/blender/blenkernel/intern/fcurve_driver.c index eba37751072..d7705dc7e81 100644 --- a/source/blender/blenkernel/intern/fcurve_driver.c +++ b/source/blender/blenkernel/intern/fcurve_driver.c @@ -177,7 +177,8 @@ static float dtar_get_prop_val(const AnimationEvalContext *anim_eval_context, int index = -1; float value = 0.0f; if (!RNA_path_resolve_property_full( - &property_ptr, dtar->rna_path, &value_ptr, &value_prop, &index)) { + &property_ptr, dtar->rna_path, &value_ptr, &value_prop, &index)) + { /* Path couldn't be resolved. */ if (G.debug & G_DEBUG) { CLOG_ERROR(&LOG, @@ -704,7 +705,8 @@ void BKE_driver_target_matrix_to_rot_channels( } } else if (rotation_mode >= DTAR_ROTMODE_SWING_TWIST_X && - rotation_mode <= DTAR_ROTMODE_SWING_TWIST_Z) { + rotation_mode <= DTAR_ROTMODE_SWING_TWIST_Z) + { int axis = rotation_mode - DTAR_ROTMODE_SWING_TWIST_X; float raw_quat[4], twist; @@ -1323,7 +1325,8 @@ static void evaluate_driver_python(PathResolvedRNA *anim_rna, driver, driver_orig, &driver->curval, - anim_eval_context->eval_time)) { + anim_eval_context->eval_time)) + { #ifdef WITH_PYTHON /* This evaluates the expression using Python, and returns its result: * - on errors it reports, then returns 0.0f. */ diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index a45bf709b31..e8f9680afc5 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -432,7 +432,8 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds, /* Prevent crash when initializing a plane as domain. */ if (!init_resolution || (size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || - (size[2] < FLT_EPSILON)) { + (size[2] < FLT_EPSILON)) + { return; } @@ -498,7 +499,8 @@ static bool fluid_modifier_init( /* Set resolutions. */ if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS && - fmd->domain->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) { + fmd->domain->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) + { res[0] = res[1] = res[2] = 1; /* Use minimum res for adaptive init. */ } else { @@ -615,7 +617,8 @@ static bool is_static_object(Object *ob) eModifierType_Ocean, eModifierType_ShapeKey, eModifierType_Softbody, - eModifierType_Nodes)) { + eModifierType_Nodes)) + { return false; } } @@ -751,7 +754,8 @@ static void bb_combineMaps(FluidObjectBB *output, /* Initialize with first input if in range. */ if (x >= bb1.min[0] && x < bb1.max[0] && y >= bb1.min[1] && y < bb1.max[1] && - z >= bb1.min[2] && z < bb1.max[2]) { + z >= bb1.min[2] && z < bb1.max[2]) + { int index_in = manta_get_index( x - bb1.min[0], bb1.res[0], y - bb1.min[1], bb1.res[1], z - bb1.min[2]); @@ -768,7 +772,8 @@ static void bb_combineMaps(FluidObjectBB *output, /* Apply second input if in range. */ if (x >= bb2->min[0] && x < bb2->max[0] && y >= bb2->min[1] && y < bb2->max[1] && - z >= bb2->min[2] && z < bb2->max[2]) { + z >= bb2->min[2] && z < bb2->max[2]) + { int index_in = manta_get_index( x - bb2->min[0], bb2->res[0], y - bb2->min[1], bb2->res[1], z - bb2->min[2]); @@ -856,12 +861,14 @@ static void update_velocities(FluidEffectorSettings *fes, * I.e. the unit cube diagonal or sqrt(3). * This value is our nearest neighbor search distance. */ const float surface_distance = 1.732; - nearest.dist_sq = surface_distance * surface_distance; /* find_nearest uses squared distance */ + /* find_nearest uses squared distance */ + nearest.dist_sq = surface_distance * surface_distance; /* Find the nearest point on the mesh. */ if (has_velocity && BLI_bvhtree_find_nearest( - tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) { + tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) + { float weights[3]; int v1, v2, v3, f_index = nearest.index; @@ -1698,8 +1705,8 @@ static void update_distances(int index, * I.e. the unit cube diagonal or sqrt(3). * This value is our nearest neighbor search distance. */ const float surface_distance = 1.732; - nearest.dist_sq = surface_distance * - surface_distance; /* find_nearest uses squared distance. */ + /* find_nearest uses squared distance. */ + nearest.dist_sq = surface_distance * surface_distance; /* Subtract optional surface thickness value and virtually increase the object size. */ if (surface_thickness) { @@ -1707,7 +1714,8 @@ static void update_distances(int index, } if (BLI_bvhtree_find_nearest( - tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) { + tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) + { float ray[3] = {0}; sub_v3_v3v3(ray, ray_start, nearest.co); min_dist = len_v3(ray); @@ -1819,7 +1827,8 @@ static void sample_mesh(FluidFlowSettings *ffs, * I.e. the unit cube diagonal or sqrt(3). * This value is our nearest neighbor search distance. */ const float surface_distance = 1.732; - nearest.dist_sq = surface_distance * surface_distance; /* find_nearest uses squared distance. */ + /* find_nearest uses squared distance. */ + nearest.dist_sq = surface_distance * surface_distance; bool is_gas_flow = ELEM( ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_FIRE, FLUID_FLOW_TYPE_SMOKEFIRE); @@ -1837,7 +1846,8 @@ static void sample_mesh(FluidFlowSettings *ffs, 0.0f, &hit, tree_data->raycast_callback, - tree_data) != -1) { + tree_data) != -1) + { float dot = ray_dir[0] * hit.no[0] + ray_dir[1] * hit.no[1] + ray_dir[2] * hit.no[2]; /* If ray and hit face normal are facing same direction hit point is inside a closed mesh. */ if (dot >= 0) { @@ -1863,7 +1873,8 @@ static void sample_mesh(FluidFlowSettings *ffs, /* Find the nearest point on the mesh. */ if (BLI_bvhtree_find_nearest( - tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) { + tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) + { float weights[3]; int v1, v2, v3, f_index = nearest.index; float hit_normal[3]; @@ -2553,10 +2564,10 @@ static void ensure_flowsfields(FluidDomainSettings *fds) /* Initialize all smoke with "active_color". */ manta_smoke_ensure_colors(fds->fluid, fds->fmd); } - if (fds->type == FLUID_DOMAIN_TYPE_LIQUID && - (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY || - fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM || - fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER)) { + if (fds->type == FLUID_DOMAIN_TYPE_LIQUID && (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY || + fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM || + fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER)) + { manta_liquid_ensure_sndparts(fds->fluid, fds->fmd); } manta_update_pointers(fds->fluid, fds->fmd, false); @@ -2610,12 +2621,13 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n } /* Activate fuel field if a flow object is of fire type. */ if (ffs->fuel_amount != 0.0 || ffs->type == FLUID_FLOW_TYPE_FIRE || - ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE) { + ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE) + { active_fields |= FLUID_DOMAIN_ACTIVE_FIRE; } /* Activate color field if flows add smoke with varying colors. */ - if (ffs->density != 0.0 && - ELEM(ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_SMOKEFIRE)) { + if (ffs->density != 0.0 && ELEM(ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_SMOKEFIRE)) + { if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) { copy_v3_v3(fds->active_color, ffs->color); active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET; @@ -3654,13 +3666,15 @@ static void fluid_modifier_processDomain(FluidModifierData *fmd, case FLUID_DOMAIN_CACHE_MODULAR: if (fds->cache_frame_offset > 0) { if (scene_framenr < fds->cache_frame_start || - scene_framenr > fds->cache_frame_end + fds->cache_frame_offset) { + scene_framenr > fds->cache_frame_end + fds->cache_frame_offset) + { escape = true; } } else { if (scene_framenr < fds->cache_frame_start + fds->cache_frame_offset || - scene_framenr > fds->cache_frame_end) { + scene_framenr > fds->cache_frame_end) + { escape = true; } } @@ -4097,7 +4111,8 @@ Mesh *BKE_fluid_modifier_do( baking_guide = fds->cache_flag & FLUID_DOMAIN_BAKING_GUIDE; if (with_mesh && !baking_data && !baking_noise && !baking_mesh && !baking_particles && - !baking_guide) { + !baking_guide) + { needs_viewport_update = true; } } @@ -4613,7 +4628,8 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings) FLUID_DOMAIN_FIELD_PHI, FLUID_DOMAIN_FIELD_PHI_IN, FLUID_DOMAIN_FIELD_PHI_OUT, - FLUID_DOMAIN_FIELD_PHI_OBSTACLE)) { + FLUID_DOMAIN_FIELD_PHI_OBSTACLE)) + { /* Defaulted to density for gas domain. */ settings->coba_field = FLUID_DOMAIN_FIELD_DENSITY; } @@ -4631,7 +4647,8 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings) FLUID_DOMAIN_FIELD_DENSITY, FLUID_DOMAIN_FIELD_FLAME, FLUID_DOMAIN_FIELD_FUEL, - FLUID_DOMAIN_FIELD_HEAT)) { + FLUID_DOMAIN_FIELD_HEAT)) + { /* Defaulted to phi for liquid domain. */ settings->coba_field = FLUID_DOMAIN_FIELD_PHI; } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index ae9b0f5e558..35216407495 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1109,6 +1109,9 @@ FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu) fcm->influence = 1.0f; BLI_addtail(modifiers, fcm); + /* Set modifier name and make sure it is unique. */ + BKE_fmodifier_name_set(fcm, ""); + /* tag modifier as "active" if no other modifiers exist in the stack yet */ if (BLI_listbase_is_single(modifiers)) { fcm->flag |= FMODIFIER_FLAG_ACTIVE; @@ -1426,7 +1429,8 @@ float evaluate_time_fmodifiers(FModifiersStackStorage *storage, * (whatever scale it is on, it won't affect the results) * hence we shouldn't bother seeing what it would do given the chance. */ if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) { + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) + { /* only evaluate if there's a callback for this */ if (fmi->evaluate_modifier_time) { if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { @@ -1475,7 +1479,8 @@ void evaluate_value_fmodifiers(FModifiersStackStorage *storage, /* Only evaluate if there's a callback for this, * and if F-Modifier can be evaluated on this frame. */ if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) { + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime))) + { if (fmi->evaluate_modifier) { if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { void *storage_ptr = POINTER_OFFSET(storage->buffer, diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c index db14d5069d6..afb32c4b50c 100644 --- a/source/blender/blenkernel/intern/freestyle.c +++ b/source/blender/blenkernel/intern/freestyle.c @@ -228,7 +228,8 @@ short BKE_freestyle_lineset_get_active_index(FreestyleConfig *config) short i; for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset; - lineset = lineset->next, i++) { + lineset = lineset->next, i++) + { if (lineset->flags & FREESTYLE_LINESET_CURRENT) { return i; } @@ -242,7 +243,8 @@ void BKE_freestyle_lineset_set_active_index(FreestyleConfig *config, short index short i; for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset; - lineset = lineset->next, i++) { + lineset = lineset->next, i++) + { if (i == index) { lineset->flags |= FREESTYLE_LINESET_CURRENT; } diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index ee86d2d0792..9eafdbf9177 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -138,22 +138,25 @@ GVArray GeometryFieldInput::get_varray_for_context(const fn::FieldContext &conte ResourceScope & /*scope*/) const { if (const GeometryFieldContext *geometry_context = dynamic_cast( - &context)) { + &context)) + { return this->get_varray_for_context(*geometry_context, mask); } if (const MeshFieldContext *mesh_context = dynamic_cast(&context)) { return this->get_varray_for_context({mesh_context->mesh(), mesh_context->domain()}, mask); } - if (const CurvesFieldContext *curve_context = dynamic_cast( - &context)) { + if (const CurvesFieldContext *curve_context = dynamic_cast(&context)) + { return this->get_varray_for_context({curve_context->curves(), curve_context->domain()}, mask); } if (const PointCloudFieldContext *point_context = dynamic_cast( - &context)) { + &context)) + { return this->get_varray_for_context({point_context->pointcloud()}, mask); } if (const InstancesFieldContext *instances_context = dynamic_cast( - &context)) { + &context)) + { return this->get_varray_for_context({instances_context->instances()}, mask); } return {}; @@ -170,7 +173,8 @@ GVArray MeshFieldInput::get_varray_for_context(const fn::FieldContext &context, ResourceScope & /*scope*/) const { if (const GeometryFieldContext *geometry_context = dynamic_cast( - &context)) { + &context)) + { if (const Mesh *mesh = geometry_context->mesh()) { return this->get_varray_for_context(*mesh, geometry_context->domain(), mask); } @@ -191,7 +195,8 @@ GVArray CurvesFieldInput::get_varray_for_context(const fn::FieldContext &context ResourceScope & /*scope*/) const { if (const GeometryFieldContext *geometry_context = dynamic_cast( - &context)) { + &context)) + { if (const CurvesGeometry *curves = geometry_context->curves()) { return this->get_varray_for_context(*curves, geometry_context->domain(), mask); } @@ -214,13 +219,15 @@ GVArray PointCloudFieldInput::get_varray_for_context(const fn::FieldContext &con ResourceScope & /*scope*/) const { if (const GeometryFieldContext *geometry_context = dynamic_cast( - &context)) { + &context)) + { if (const PointCloud *pointcloud = geometry_context->pointcloud()) { return this->get_varray_for_context(*pointcloud, mask); } } if (const PointCloudFieldContext *point_context = dynamic_cast( - &context)) { + &context)) + { return this->get_varray_for_context(point_context->pointcloud(), mask); } return {}; @@ -231,13 +238,15 @@ GVArray InstancesFieldInput::get_varray_for_context(const fn::FieldContext &cont ResourceScope & /*scope*/) const { if (const GeometryFieldContext *geometry_context = dynamic_cast( - &context)) { + &context)) + { if (const Instances *instances = geometry_context->instances()) { return this->get_varray_for_context(*instances, mask); } } if (const InstancesFieldContext *instances_context = dynamic_cast( - &context)) { + &context)) + { return this->get_varray_for_context(instances_context->instances(), mask); } return {}; @@ -352,7 +361,8 @@ uint64_t AnonymousAttributeFieldInput::hash() const bool AnonymousAttributeFieldInput::is_equal_to(const fn::FieldNode &other) const { if (const AnonymousAttributeFieldInput *other_typed = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return anonymous_id_.get() == other_typed->anonymous_id_.get() && type_ == other_typed->type_; } return false; diff --git a/source/blender/blenkernel/intern/gpencil_curve_legacy.c b/source/blender/blenkernel/intern/gpencil_curve_legacy.c index c6a1cb1474a..be6ca7e4ec4 100644 --- a/source/blender/blenkernel/intern/gpencil_curve_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_curve_legacy.c @@ -157,7 +157,8 @@ static Material *gpencil_add_from_curve_material(Main *bmain, /* Check at least one is enabled. */ if (((gp_style->flag & GP_MATERIAL_STROKE_SHOW) == 0) && - ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0)) { + ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0)) + { gp_style->flag |= GP_MATERIAL_STROKE_SHOW; } @@ -1123,7 +1124,8 @@ void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps) bGPDcurve_point *gpc_pt_next = &gpc->curve_points[i + 1]; /* update handle if point or neighbor is selected */ if (gpc_pt->flag & GP_CURVE_POINT_SELECT || gpc_pt_prev->flag & GP_CURVE_POINT_SELECT || - gpc_pt_next->flag & GP_CURVE_POINT_SELECT) { + gpc_pt_next->flag & GP_CURVE_POINT_SELECT) + { BezTriple *bezt = &gpc_pt->bezt; BezTriple *bezt_prev = &gpc_pt_prev->bezt; BezTriple *bezt_next = &gpc_pt_next->bezt; diff --git a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc index 86caad72296..9b65e6b00be 100644 --- a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc @@ -315,7 +315,8 @@ static int stroke_march_next_point_no_interp(const bGPDstroke *gps, if (next_point_index < gps->totpoints - 1 && angle_v3v3v3(&gps->points[next_point_index - 1].x, &gps->points[next_point_index].x, - &gps->points[next_point_index + 1].x) < sharp_threshold) { + &gps->points[next_point_index + 1].x) < sharp_threshold) + { copy_v3_v3(result, &pt->x); pt->flag |= GP_SPOINT_TEMP_TAG; next_point_index++; @@ -367,7 +368,8 @@ static int stroke_march_count(const bGPDstroke *gps, const float dist, const flo } while ((next_point_index = stroke_march_next_point_no_interp( - gps, next_point_index, point, dist, sharp_threshold, point)) > -1) { + gps, next_point_index, point, dist, sharp_threshold, point)) > -1) + { point_count++; if (next_point_index == 0) { break; /* last point finished */ @@ -523,7 +525,8 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd, &uv_rot, &ratio_result, &index_from, - &index_to)) > -1) { + &index_to)) > -1) + { if (is_cyclic && next_point_index == 0) { break; /* last point finished */ } @@ -2306,7 +2309,8 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, bGPDstroke *gps, int level, int float mid[3]; /* extreme points are not changed */ for (int i = cyclic ? 0 : 2, j = cyclic ? gps->totpoints - 2 : 0; i < gps->totpoints - 2; - j = i, i += 2) { + j = i, i += 2) + { bGPDspoint *prev = &gps->points[j + 1]; bGPDspoint *pt = &gps->points[i]; bGPDspoint *next = &gps->points[i + 1]; @@ -2655,7 +2659,8 @@ static Material *gpencil_add_material(Main *bmain, /* Check at least one is enabled. */ if (((gp_style->flag & GP_MATERIAL_STROKE_SHOW) == 0) && - ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0)) { + ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0)) + { gp_style->flag |= GP_MATERIAL_STROKE_SHOW; } @@ -2705,7 +2710,8 @@ bool BKE_gpencil_convert_mesh(Main *bmain, using namespace blender; using namespace blender::bke; if (ELEM(nullptr, ob_gp, ob_mesh) || (ob_gp->type != OB_GPENCIL_LEGACY) || - (ob_gp->data == nullptr)) { + (ob_gp->data == nullptr)) + { return false; } diff --git a/source/blender/blenkernel/intern/gpencil_legacy.c b/source/blender/blenkernel/intern/gpencil_legacy.c index 26528558f4a..6a889cc20f3 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_legacy.c @@ -1383,7 +1383,8 @@ bGPDframe *BKE_gpencil_layer_frame_get(bGPDlayer *gpl, int cframe, eGP_GetFrame_ /* Don't select first frame if greater than current frame. */ if ((gpl->actframe != NULL) && (gpl->actframe == gpl->frames.first) && - (gpl->actframe->framenum > cframe)) { + (gpl->actframe->framenum > cframe)) + { gpl->actframe = NULL; } @@ -1673,7 +1674,8 @@ Material *BKE_gpencil_brush_material_get(Brush *brush) Material *ma = NULL; if ((brush != NULL) && (brush->gpencil_settings != NULL) && - (brush->gpencil_settings->material != NULL)) { + (brush->gpencil_settings->material != NULL)) + { ma = brush->gpencil_settings->material; } @@ -1744,7 +1746,8 @@ Material *BKE_gpencil_object_material_new(Main *bmain, Object *ob, const char *n Material *BKE_gpencil_object_material_from_brush_get(Object *ob, Brush *brush) { if ((brush) && (brush->gpencil_settings) && - (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) { + (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED)) + { Material *ma = BKE_gpencil_brush_material_get(brush); return ma; } @@ -1878,7 +1881,8 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup) } /* Keep a valid active index if we still have some vertex groups. */ if (!BLI_listbase_is_empty(&gpd->vertex_group_names) && - BKE_object_defgroup_active_index_get(ob) < 1) { + BKE_object_defgroup_active_index_get(ob) < 1) + { BKE_object_defgroup_active_index_set(ob, 1); } @@ -2022,7 +2026,8 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob, } for (int idx_secondary = 0; idx_secondary < *totcol; idx_secondary++) { if ((idx_secondary == idx_primary) || - BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary))) { + BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary))) + { continue; } if (BLI_ghash_haskey(mat_used, POINTER_FROM_INT(idx_secondary))) { @@ -2031,15 +2036,16 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob, /* Read secondary material to compare with primary material. */ ma_secondary = BKE_gpencil_material(ob, idx_secondary + 1); - if ((ma_secondary == NULL) || - BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary))) { + if ((ma_secondary == NULL) || BLI_ghash_haskey(r_mat_table, POINTER_FROM_INT(idx_secondary))) + { continue; } gp_style_primary = ma_primary->gp_style; gp_style_secondary = ma_secondary->gp_style; if ((gp_style_primary == NULL) || (gp_style_secondary == NULL) || - (gp_style_secondary->flag & GP_MATERIAL_LOCKED)) { + (gp_style_secondary->flag & GP_MATERIAL_LOCKED)) + { continue; } @@ -2050,18 +2056,21 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob, /* Check materials have same stroke and fill attributes. */ if ((gp_style_primary->flag & GP_MATERIAL_STROKE_SHOW) != - (gp_style_secondary->flag & GP_MATERIAL_STROKE_SHOW)) { + (gp_style_secondary->flag & GP_MATERIAL_STROKE_SHOW)) + { continue; } if ((gp_style_primary->flag & GP_MATERIAL_FILL_SHOW) != - (gp_style_secondary->flag & GP_MATERIAL_FILL_SHOW)) { + (gp_style_secondary->flag & GP_MATERIAL_FILL_SHOW)) + { continue; } /* Check materials have the same type. */ if ((gp_style_primary->stroke_style != gp_style_secondary->stroke_style) || - (gp_style_primary->fill_style != gp_style_secondary->fill_style)) { + (gp_style_primary->fill_style != gp_style_secondary->fill_style)) + { continue; } @@ -2092,7 +2101,8 @@ bool BKE_gpencil_merge_materials_table_get(Object *ob, gp_style_secondary->stroke_rgba[3], val_threshold) || !compare_ff( - gp_style_primary->fill_rgba[3], gp_style_secondary->fill_rgba[3], val_threshold)) { + gp_style_primary->fill_rgba[3], gp_style_secondary->fill_rgba[3], val_threshold)) + { continue; } @@ -2463,7 +2473,8 @@ void BKE_gpencil_visible_stroke_advanced_iter(ViewLayer *view_layer, * generate renders, putting only selected GP layers for each View Layer. * This is used only in final render and never in Viewport. */ if ((view_layer != NULL) && (gpl->viewlayername[0] != '\0') && - !STREQ(view_layer->name, gpl->viewlayername)) { + !STREQ(view_layer->name, gpl->viewlayername)) + { /* Do not skip masks when rendering the view-layer so that it can still be used to clip * other layers. Instead set their opacity to zero. */ if (gpencil_is_layer_mask(view_layer, gpd, gpl)) { @@ -2843,7 +2854,8 @@ int BKE_gpencil_material_find_index_by_name_prefix(Object *ob, const char *name_ for (int i = 0; i < ob->totcol; i++) { Material *ma = BKE_object_material_get(ob, i + 1); if ((ma != NULL) && (ma->gp_style != NULL) && - STREQLEN(ma->id.name + 2, name_prefix, name_prefix_len)) { + STREQLEN(ma->id.name + 2, name_prefix, name_prefix_len)) + { return i; } } @@ -2863,7 +2875,8 @@ void BKE_gpencil_frame_selected_hash(bGPdata *gpd, struct GHash *r_list) LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_iter->frames) { if (((gpf == gpl->actframe) && (!is_multiedit)) || - ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { + ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) + { if (!BLI_ghash_lookup(r_list, POINTER_FROM_INT(gpf->framenum))) { BLI_ghash_insert(r_list, POINTER_FROM_INT(gpf->framenum), gpf); } diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c index 0fe854a7c3b..af6954d4cd1 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c @@ -201,7 +201,8 @@ bool BKE_gpencil_has_transform_modifiers(Object *ob) eGpencilModifierType_Armature, eGpencilModifierType_Hook, eGpencilModifierType_Lattice, - eGpencilModifierType_Offset)) { + eGpencilModifierType_Offset)) + { return true; } } @@ -435,7 +436,8 @@ const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType { /* type unsigned, no need to check < 0 */ if (type < NUM_GREASEPENCIL_MODIFIER_TYPES && type > 0 && - modifier_gpencil_types[type]->name[0] != '\0') { + modifier_gpencil_types[type]->name[0] != '\0') + { return modifier_gpencil_types[type]; } diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index ec8111a0359..9a32d713f20 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -221,7 +221,8 @@ void BKE_icons_deferred_free() for (DeferredIconDeleteNode *node = (DeferredIconDeleteNode *)BLI_linklist_lockfree_begin(&g_icon_delete_queue); node != nullptr; - node = node->next) { + node = node->next) + { BLI_ghash_remove(gIcons, POINTER_FROM_INT(node->icon_id), nullptr, icon_free); } BLI_linklist_lockfree_clear(&g_icon_delete_queue, MEM_freeN); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 38e8e111fa0..d60d7adbcb7 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -342,7 +342,7 @@ static IDProperty *IDP_CopyArray(const IDProperty *prop, const int flag) /** \name String Functions (IDProperty String API) * \{ */ -IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) +IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy) { IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty string"); @@ -356,13 +356,16 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* include null terminator '\0' */ int stlen = (int)strlen(st) + 1; - if (maxlen > 0 && maxlen < stlen) { - stlen = maxlen; + if ((maxncpy > 0) && (maxncpy < stlen)) { + stlen = maxncpy; } prop->data.pointer = MEM_mallocN((size_t)stlen, "id property string 2"); prop->len = prop->totallen = stlen; - BLI_strncpy(prop->data.pointer, st, (size_t)stlen); + if (stlen > 0) { + memcpy(prop->data.pointer, st, (size_t)stlen); + IDP_String(prop)[stlen - 1] = '\0'; + } } prop->type = IDP_STRING; @@ -371,6 +374,11 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) return prop; } +IDProperty *IDP_NewString(const char *st, const char *name) +{ + return IDP_NewStringMaxSize(st, name, -1); +} + static IDProperty *IDP_CopyString(const IDProperty *prop, const int flag) { BLI_assert(prop->type == IDP_STRING); @@ -386,23 +394,26 @@ static IDProperty *IDP_CopyString(const IDProperty *prop, const int flag) return newp; } -void IDP_AssignString(IDProperty *prop, const char *st, int maxlen) +void IDP_AssignStringMaxSize(IDProperty *prop, const char *st, int maxncpy) { BLI_assert(prop->type == IDP_STRING); - int stlen = (int)strlen(st); - if (maxlen > 0 && maxlen < stlen) { - stlen = maxlen; + const bool is_byte = prop->subtype == IDP_STRING_SUB_BYTE; + int stlen = (int)strlen(st) + (is_byte ? 0 : 1); + if ((maxncpy > 0) && (maxncpy < stlen)) { + stlen = maxncpy; } - - if (prop->subtype == IDP_STRING_SUB_BYTE) { - IDP_ResizeArray(prop, stlen); + IDP_ResizeArray(prop, stlen); + if (stlen > 0) { memcpy(prop->data.pointer, st, (size_t)stlen); + if (is_byte == false) { + IDP_String(prop)[stlen - 1] = '\0'; + } } - else { - stlen++; - IDP_ResizeArray(prop, stlen); - BLI_strncpy(prop->data.pointer, st, (size_t)stlen); - } +} + +void IDP_AssignString(IDProperty *prop, const char *st) +{ + IDP_AssignStringMaxSize(prop, st, 0); } void IDP_ConcatStringC(IDProperty *prop, const char *st) @@ -529,7 +540,8 @@ void IDP_SyncGroupTypes(IDProperty *dest, const IDProperty *src, const bool do_a /* check of we should replace? */ if ((prop_dst->type != prop_src->type || prop_dst->subtype != prop_src->subtype) || (do_arraylen && ELEM(prop_dst->type, IDP_ARRAY, IDP_IDPARRAY) && - (prop_src->len != prop_dst->len))) { + (prop_src->len != prop_dst->len))) + { BLI_insertlinkreplace(&dest->data.group, prop_dst, IDP_CopyProperty(prop_src)); IDP_FreeProperty(prop_dst); } @@ -1556,7 +1568,8 @@ eIDPropertyUIDataType IDP_ui_data_type(const IDProperty *prop) return IDP_UI_DATA_TYPE_INT; } if (ELEM(prop->type, IDP_FLOAT, IDP_DOUBLE) || - (prop->type == IDP_ARRAY && ELEM(prop->subtype, IDP_FLOAT, IDP_DOUBLE))) { + (prop->type == IDP_ARRAY && ELEM(prop->subtype, IDP_FLOAT, IDP_DOUBLE))) + { return IDP_UI_DATA_TYPE_FLOAT; } if (prop->type == IDP_BOOLEAN || (prop->type == IDP_ARRAY && prop->subtype == IDP_BOOLEAN)) { diff --git a/source/blender/blenkernel/intern/idprop_create.cc b/source/blender/blenkernel/intern/idprop_create.cc index cac4f736c69..c496ff65d36 100644 --- a/source/blender/blenkernel/intern/idprop_create.cc +++ b/source/blender/blenkernel/intern/idprop_create.cc @@ -49,7 +49,7 @@ std::unique_ptr create(const StringRefNull prop_n std::unique_ptr create(const StringRefNull prop_name, const StringRefNull value) { - IDProperty *property = IDP_NewString(value.c_str(), prop_name.c_str(), value.size() + 1); + IDProperty *property = IDP_NewString(value.c_str(), prop_name.c_str()); return std::unique_ptr(property); } diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index 030bf9cb604..501588fc55e 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -114,7 +114,8 @@ const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code) int id_index = BKE_idtype_idcode_to_index(id_code); if (id_index >= 0 && id_index < ARRAY_SIZE(id_types) && id_types[id_index] != NULL && - id_types[id_index]->name[0] != '\0') { + id_types[id_index]->name[0] != '\0') + { return id_types[id_index]; } diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index d6a5000405c..d9bd0548931 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -280,7 +280,8 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data) * once to give it a meaningful value. */ /* TODO re-assess whether this behavior is desired in the new generic code context. */ if (!ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE, IMA_SRC_TILED) || - ima->filepath[0] == '\0') { + ima->filepath[0] == '\0') + { return; } @@ -290,7 +291,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data) if (ima->source == IMA_SRC_TILED && (flag & BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN) != 0) { char temp_path[FILE_MAX], orig_file[FILE_MAXFILE]; BLI_strncpy(temp_path, ima->filepath, sizeof(temp_path)); - BLI_split_file_part(temp_path, orig_file, sizeof(orig_file)); + BLI_path_split_file_part(temp_path, orig_file, sizeof(orig_file)); eUDIM_TILE_FORMAT tile_format; char *udim_pattern = BKE_image_get_tile_strformat(temp_path, &tile_format); @@ -302,7 +303,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data) if (result) { /* Put the filepath back together using the new directory and the original file name. */ char new_dir[FILE_MAXDIR]; - BLI_split_dir_part(temp_path, new_dir, sizeof(new_dir)); + BLI_path_split_dir_part(temp_path, new_dir, sizeof(new_dir)); BLI_path_join(ima->filepath, sizeof(ima->filepath), new_dir, orig_file); } } @@ -314,7 +315,8 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data) if (flag & BKE_BPATH_FOREACH_PATH_RELOAD_EDITED) { if (!BKE_image_has_packedfile(ima) && /* Image may have been painted onto (and not saved, #44543). */ - !BKE_image_is_dirty(ima)) { + !BKE_image_is_dirty(ima)) + { BKE_image_signal(bpath_data->bmain, ima, nullptr, IMA_SIGNAL_RELOAD); } } @@ -361,8 +363,8 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres BLO_write_id_struct(writer, Image, id_address, &ima->id); BKE_id_blend_write(writer, &ima->id); - for (imapf = static_cast(ima->packedfiles.first); imapf; - imapf = imapf->next) { + for (imapf = static_cast(ima->packedfiles.first); imapf; imapf = imapf->next) + { BLO_write_struct(writer, ImagePackedFile, imapf); BKE_packedfile_blend_write(writer, imapf->packedfile); } @@ -726,7 +728,8 @@ static void copy_image_packedfiles(ListBase *lb_dst, const ListBase *lb_src) BLI_listbase_clear(lb_dst); for (imapf_src = static_cast(lb_src->first); imapf_src; - imapf_src = imapf_src->next) { + imapf_src = imapf_src->next) + { ImagePackedFile *imapf_dst = static_cast( MEM_mallocN(sizeof(ImagePackedFile), "Image Packed Files (copy)")); @@ -973,12 +976,12 @@ int BKE_image_find_nearest_tile(const struct Image *image, const float co[2]) static void image_init_color_management(Image *ima) { ImBuf *ibuf; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_user_file_path(nullptr, ima, name); + BKE_image_user_file_path(nullptr, ima, filepath); /* Will set input color space to image format default's. */ - ibuf = IMB_loadiffname(name, IB_test | IB_alphamode_detect, ima->colorspace_settings.name); + ibuf = IMB_loadiffname(filepath, IB_test | IB_alphamode_detect, ima->colorspace_settings.name); if (ibuf) { if (ibuf->flags & IB_alphamode_premul) { @@ -1016,15 +1019,15 @@ Image *BKE_image_load(Main *bmain, const char *filepath) { Image *ima; int file; - char str[FILE_MAX]; + char filepath_abs[FILE_MAX]; - STRNCPY(str, filepath); - BLI_path_abs(str, BKE_main_blendfile_path(bmain)); + STRNCPY(filepath_abs, filepath); + BLI_path_abs(filepath_abs, BKE_main_blendfile_path(bmain)); /* exists? */ - file = BLI_open(str, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath_abs, O_BINARY | O_RDONLY, 0); if (file == -1) { - if (!BKE_image_tile_filepath_exists(str)) { + if (!BKE_image_tile_filepath_exists(filepath_abs)) { return nullptr; } } @@ -1047,19 +1050,20 @@ Image *BKE_image_load(Main *bmain, const char *filepath) Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exists) { Image *ima; - char str[FILE_MAX], strtest[FILE_MAX]; + char filepath_abs[FILE_MAX], filepath_test[FILE_MAX]; - STRNCPY(str, filepath); - BLI_path_abs(str, bmain->filepath); + STRNCPY(filepath_abs, filepath); + BLI_path_abs(filepath_abs, bmain->filepath); /* first search an identical filepath */ for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { if (!ELEM(ima->source, IMA_SRC_VIEWER, IMA_SRC_GENERATED)) { - STRNCPY(strtest, ima->filepath); - BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id)); + STRNCPY(filepath_test, ima->filepath); + BLI_path_abs(filepath_test, ID_BLEND_PATH(bmain, &ima->id)); - if (BLI_path_cmp(strtest, str) == 0) { + if (BLI_path_cmp(filepath_test, filepath_abs) == 0) { if ((BKE_image_has_anim(ima) == false) || (ima->id.us == 0)) { id_us_plus(&ima->id); /* officially should not, it doesn't link here! */ if (r_exists) { @@ -1169,7 +1173,7 @@ static ImBuf *add_ibuf_for_tile(Image *ima, ImageTile *tile) return nullptr; } - STRNCPY(ibuf->name, ima->filepath); + STRNCPY(ibuf->filepath, ima->filepath); /* Mark the tile itself as having been generated. */ tile->gen_flag |= IMA_GEN_TILE; @@ -1282,13 +1286,13 @@ static void image_colorspace_from_imbuf(Image *image, const ImBuf *ibuf) Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name) { if (name == nullptr) { - name = BLI_path_basename(ibuf->name); + name = BLI_path_basename(ibuf->filepath); } /* When the image buffer has valid path create a new image with "file" source and copy the path * from the image buffer. * Otherwise create "generated" image, avoiding invalid configuration with an empty file path. */ - const eImageSource source = ibuf->name[0] != '\0' ? IMA_SRC_FILE : IMA_SRC_GENERATED; + const eImageSource source = ibuf->filepath[0] != '\0' ? IMA_SRC_FILE : IMA_SRC_GENERATED; Image *ima = image_alloc(bmain, name, source, IMA_TYPE_IMAGE); @@ -1388,7 +1392,7 @@ bool BKE_image_memorypack(Image *ima) break; } - const char *filepath = ibuf->name; + const char *filepath = ibuf->filepath; if (is_tiled) { iuser.tile = tile->tile_number; BKE_image_user_file_path(&iuser, ima, tiled_filepath); @@ -1536,14 +1540,16 @@ void BKE_image_print_memlist(Main *bmain) uintptr_t size, totsize = 0; for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { totsize += image_mem_size(ima); } printf("\ntotal image memory len: %.3f MB\n", double(totsize) / double(1024 * 1024)); for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { size = image_mem_size(ima); if (size) { @@ -1571,7 +1577,8 @@ void BKE_image_free_all_textures(Main *bmain) #endif for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { ima->id.tag &= ~LIB_TAG_DOIT; } @@ -1583,7 +1590,8 @@ void BKE_image_free_all_textures(Main *bmain) } for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) { #ifdef CHECK_FREED_SIZE uintptr_t old_size = image_mem_size(ima); @@ -1625,7 +1633,8 @@ void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra) Image *ima; for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { if (BKE_image_is_animated(ima)) { BKE_image_free_anim_ibufs(ima, cfra); } @@ -2541,22 +2550,22 @@ bool BKE_imbuf_alpha_test(ImBuf *ibuf) return false; } -int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf) +int BKE_imbuf_write(ImBuf *ibuf, const char *filepath, const ImageFormatData *imf) { BKE_image_format_to_imbuf(ibuf, imf); - BLI_make_existing_file(name); + BLI_file_ensure_parent_dir_exists(filepath); - const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); + const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { - perror(name); + perror(filepath); } return ok; } int BKE_imbuf_write_as(ImBuf *ibuf, - const char *name, + const char *filepath, const ImageFormatData *imf, const bool save_copy) { @@ -2566,7 +2575,7 @@ int BKE_imbuf_write_as(ImBuf *ibuf, /* All data is RGBA anyway, this just controls how to save for some formats. */ ibuf->planes = imf->planes; - ok = BKE_imbuf_write(ibuf, name, imf); + ok = BKE_imbuf_write(ibuf, filepath, imf); if (save_copy) { /* note that we are not restoring _all_ settings */ @@ -2581,44 +2590,47 @@ int BKE_imbuf_write_as(ImBuf *ibuf, int BKE_imbuf_write_stamp(const Scene *scene, const struct RenderResult *rr, ImBuf *ibuf, - const char *name, + const char *filepath, const struct ImageFormatData *imf) { if (scene && scene->r.stamp & R_STAMP_ALL) { BKE_imbuf_stamp_info(rr, ibuf); } - return BKE_imbuf_write(ibuf, name, imf); + return BKE_imbuf_write(ibuf, filepath, imf); } -struct anim *openanim_noload(const char *name, +struct anim *openanim_noload(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) { struct anim *anim; - anim = IMB_open_anim(name, flags, streamindex, colorspace); + anim = IMB_open_anim(filepath, flags, streamindex, colorspace); return anim; } -struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) +struct anim *openanim(const char *filepath, + int flags, + int streamindex, + char colorspace[IMA_MAX_SPACE]) { struct anim *anim; struct ImBuf *ibuf; - anim = IMB_open_anim(name, flags, streamindex, colorspace); + anim = IMB_open_anim(filepath, flags, streamindex, colorspace); if (anim == nullptr) { return nullptr; } ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); if (ibuf == nullptr) { - if (BLI_exists(name)) { - printf("not an anim: %s\n", name); + if (BLI_exists(filepath)) { + printf("not an anim: %s\n", filepath); } else { - printf("anim file doesn't exist: %s\n", name); + printf("anim file doesn't exist: %s\n", filepath); } IMB_free_anim(anim); return nullptr; @@ -2656,7 +2668,8 @@ Image *BKE_image_ensure_viewer(Main *bmain, int type, const char *name) Image *ima; for (ima = static_cast(bmain->images.first); ima; - ima = static_cast(ima->id.next)) { + ima = static_cast(ima->id.next)) + { if (ima->source == IMA_SRC_VIEWER) { if (ima->type == type) { break; @@ -2893,47 +2906,56 @@ void BKE_image_walk_all_users( void callback(Image *ima, ID *iuser_id, ImageUser *iuser, void *customdata)) { for (Scene *scene = static_cast(mainp->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { image_walk_id_all_users(&scene->id, false, customdata, callback); } for (Object *ob = static_cast(mainp->objects.first); ob; - ob = static_cast(ob->id.next)) { + ob = static_cast(ob->id.next)) + { image_walk_id_all_users(&ob->id, false, customdata, callback); } for (bNodeTree *ntree = static_cast(mainp->nodetrees.first); ntree; - ntree = static_cast(ntree->id.next)) { + ntree = static_cast(ntree->id.next)) + { image_walk_id_all_users(&ntree->id, false, customdata, callback); } for (Material *ma = static_cast(mainp->materials.first); ma; - ma = static_cast(ma->id.next)) { + ma = static_cast(ma->id.next)) + { image_walk_id_all_users(&ma->id, false, customdata, callback); } for (Light *light = static_cast(mainp->materials.first); light; - light = static_cast(light->id.next)) { + light = static_cast(light->id.next)) + { image_walk_id_all_users(&light->id, false, customdata, callback); } for (World *world = static_cast(mainp->materials.first); world; - world = static_cast(world->id.next)) { + world = static_cast(world->id.next)) + { image_walk_id_all_users(&world->id, false, customdata, callback); } for (Tex *tex = static_cast(mainp->textures.first); tex; - tex = static_cast(tex->id.next)) { + tex = static_cast(tex->id.next)) + { image_walk_id_all_users(&tex->id, false, customdata, callback); } for (Camera *cam = static_cast(mainp->cameras.first); cam; - cam = static_cast(cam->id.next)) { + cam = static_cast(cam->id.next)) + { image_walk_id_all_users(&cam->id, false, customdata, callback); } - + /* Only ever 1 `wm`. */ for (wmWindowManager *wm = static_cast(mainp->wm.first); wm; - wm = static_cast(wm->id.next)) { /* only 1 wm */ + wm = static_cast(wm->id.next)) + { image_walk_id_all_users(&wm->id, false, customdata, callback); } } @@ -3251,8 +3273,8 @@ static RenderPass *image_render_pass_get(RenderLayer *rl, int rp_index = 0; const char *rp_name = ""; - for (rpass = static_cast(rl->passes.first); rpass; - rpass = rpass->next, rp_index++) { + for (rpass = static_cast(rl->passes.first); rpass; rpass = rpass->next, rp_index++) + { if (rp_index == pass) { rpass_ret = rpass; if (view == 0) { @@ -3300,7 +3322,7 @@ void BKE_image_get_tile_label(Image *ima, ImageTile *tile, char *label, int len_ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, int *r_tile_range) { char filename[FILE_MAXFILE], dirname[FILE_MAXDIR]; - BLI_split_dirfile(filepath, dirname, filename, sizeof(dirname), sizeof(filename)); + BLI_path_split_dir_file(filepath, dirname, sizeof(dirname), filename, sizeof(filename)); if (!BKE_image_is_filename_tokenized(filename)) { BKE_image_ensure_tile_token_filename_only(filename, sizeof(filename)); @@ -3321,8 +3343,8 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, continue; } - if (!BKE_image_get_tile_number_from_filepath( - dirs[i].relname, udim_pattern, tile_format, &id)) { + if (!BKE_image_get_tile_number_from_filepath(dirs[i].relname, udim_pattern, tile_format, &id)) + { continue; } @@ -3362,7 +3384,8 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la * We then insert before that to keep the list sorted. */ ImageTile *next_tile; for (next_tile = static_cast(ima->tiles.first); next_tile; - next_tile = next_tile->next) { + next_tile = next_tile->next) + { if (next_tile->tile_number == tile_number) { /* Tile already exists. */ return nullptr; @@ -3533,7 +3556,7 @@ bool BKE_image_tile_filepath_exists(const char *filepath) BLI_assert(!BLI_path_is_rel(filepath)); char dirname[FILE_MAXDIR]; - BLI_split_dir_part(filepath, dirname, sizeof(dirname)); + BLI_path_split_dir_part(filepath, dirname, sizeof(dirname)); eUDIM_TILE_FORMAT tile_format; char *udim_pattern = BKE_image_get_tile_strformat(filepath, &tile_format); @@ -4000,7 +4023,7 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i ia = static_cast(BLI_findlink(&ima->anims, view_id)); if (ia->anim == nullptr) { - char str[FILE_MAX]; + char filepath[FILE_MAX]; int flags = IB_rect; ImageUser iuser_t{}; @@ -4014,10 +4037,10 @@ static ImBuf *load_movie_single(Image *ima, ImageUser *iuser, int frame, const i iuser_t.view = view_id; - BKE_image_user_file_path(&iuser_t, ima, str); + BKE_image_user_file_path(&iuser_t, ima, filepath); /* FIXME: make several stream accessible in image editor, too. */ - ia->anim = openanim(str, flags, 0, ima->colorspace_settings.name); + ia->anim = openanim(filepath, flags, 0, ima->colorspace_settings.name); /* let's initialize this user */ if (ia->anim && iuser && iuser->frames == 0) { @@ -4242,7 +4265,8 @@ static ImBuf *image_load_image_file( /* multi-views/multi-layers OpenEXR files directly populate ima, and return null ibuf... */ if (BKE_image_is_stereo(ima) && ima->views_format == R_IMF_VIEWS_STEREO_3D && ibuf_arr[0] && - tot_viewfiles == 1 && totviews >= 2) { + tot_viewfiles == 1 && totviews >= 2) + { IMB_ImBufFromStereo3d(ima->stereo3d_format, ibuf_arr[0], ibuf_arr.data(), &ibuf_arr[1]); } @@ -4842,7 +4866,8 @@ void BKE_image_pool_free(ImagePool *pool) BLI_mutex_lock(&pool->mutex); for (ImagePoolItem *item = static_cast(pool->image_buffers.first); item != nullptr; - item = item->next) { + item = item->next) + { if (item->ibuf != nullptr) { BLI_mutex_lock(static_cast(item->image->runtime.cache_mutex)); IMB_freeImBuf(item->ibuf); @@ -5090,7 +5115,8 @@ static void image_user_id_eval_animation(Image *ima, Depsgraph *depsgraph = (Depsgraph *)customdata; if ((iuser->flag & IMA_ANIM_ALWAYS) || (iuser->flag & IMA_NEED_FRAME_RECALC) || - (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER)) { + (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER)) + { float cfra = DEG_get_ctime(depsgraph); BKE_image_user_frame_calc(ima, iuser, cfra); @@ -5185,7 +5211,8 @@ void BKE_image_get_size(Image *image, ImageUser *iuser, int *r_width, int *r_hei *r_height = ibuf->y; } else if (image != nullptr && image->type == IMA_TYPE_R_RESULT && iuser != nullptr && - iuser->scene != nullptr) { + iuser->scene != nullptr) + { BKE_render_resolution(&iuser->scene->r, true, r_width, r_height); } else { @@ -5401,7 +5428,7 @@ bool BKE_image_has_loaded_ibuf(Image *image) return has_loaded_ibuf; } -ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name) +ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *filepath) { ImBuf *ibuf = nullptr; @@ -5411,7 +5438,7 @@ ImBuf *BKE_image_get_ibuf_with_name(Image *image, const char *name) while (!IMB_moviecacheIter_done(iter)) { ImBuf *current_ibuf = IMB_moviecacheIter_getImBuf(iter); - if (current_ibuf != nullptr && STREQ(current_ibuf->name, name)) { + if (current_ibuf != nullptr && STREQ(current_ibuf->filepath, filepath)) { ibuf = current_ibuf; IMB_refImBuf(ibuf); break; @@ -5472,10 +5499,10 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) else { /* R_IMF_VIEWS_INDIVIDUAL */ char prefix[FILE_MAX] = {'\0'}; - char *name = ima->filepath; + char *filepath = ima->filepath; const char *ext = nullptr; - BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext); + BKE_scene_multiview_view_prefix_get(scene, filepath, prefix, &ext); if (prefix[0] == '\0') { BKE_image_free_views(ima); @@ -5485,9 +5512,9 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) /* create all the image views */ for (srv = static_cast(scene->r.views.first); srv; srv = srv->next) { if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { - char filepath[FILE_MAX]; - SNPRINTF(filepath, "%s%s%s", prefix, srv->suffix, ext); - image_add_view(ima, srv->name, filepath); + char filepath_view[FILE_MAX]; + SNPRINTF(filepath_view, "%s%s%s", prefix, srv->suffix, ext); + image_add_view(ima, srv->name, filepath_view); } } @@ -5495,13 +5522,13 @@ static void image_update_views_format(Image *ima, ImageUser *iuser) iv = static_cast(ima->views.last); while (iv) { int file; - char str[FILE_MAX]; + char filepath[FILE_MAX]; - STRNCPY(str, iv->filepath); - BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); + STRNCPY(filepath, iv->filepath); + BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); /* exists? */ - file = BLI_open(str, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { ImageView *iv_del = iv; iv = iv->prev; diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc index 9d134129c06..c508e034ab6 100644 --- a/source/blender/blenkernel/intern/image_format.cc +++ b/source/blender/blenkernel/intern/image_format.cc @@ -386,7 +386,7 @@ char BKE_imtype_from_arg(const char *imtype_arg) /* File Paths */ -static bool do_add_image_extension(char *string, +static bool do_add_image_extension(char *filepath, const char imtype, const ImageFormatData *im_format) { @@ -395,17 +395,17 @@ static bool do_add_image_extension(char *string, (void)im_format; /* may be unused, depends on build options */ if (imtype == R_IMF_IMTYPE_IRIS) { - if (!BLI_path_extension_check(string, extension_test = ".rgb")) { + if (!BLI_path_extension_check(filepath, extension_test = ".rgb")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_IRIZ) { - if (!BLI_path_extension_check(string, extension_test = ".rgb")) { + if (!BLI_path_extension_check(filepath, extension_test = ".rgb")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_RADHDR) { - if (!BLI_path_extension_check(string, extension_test = ".hdr")) { + if (!BLI_path_extension_check(filepath, extension_test = ".hdr")) { extension = extension_test; } } @@ -415,51 +415,52 @@ static bool do_add_image_extension(char *string, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID, - R_IMF_IMTYPE_AV1)) { - if (!BLI_path_extension_check(string, extension_test = ".png")) { + R_IMF_IMTYPE_AV1)) + { + if (!BLI_path_extension_check(filepath, extension_test = ".png")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_DDS) { - if (!BLI_path_extension_check(string, extension_test = ".dds")) { + if (!BLI_path_extension_check(filepath, extension_test = ".dds")) { extension = extension_test; } } else if (ELEM(imtype, R_IMF_IMTYPE_TARGA, R_IMF_IMTYPE_RAWTGA)) { - if (!BLI_path_extension_check(string, extension_test = ".tga")) { + if (!BLI_path_extension_check(filepath, extension_test = ".tga")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_BMP) { - if (!BLI_path_extension_check(string, extension_test = ".bmp")) { + if (!BLI_path_extension_check(filepath, extension_test = ".bmp")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_TIFF) { - if (!BLI_path_extension_check_n(string, extension_test = ".tif", ".tiff", nullptr)) { + if (!BLI_path_extension_check_n(filepath, extension_test = ".tif", ".tiff", nullptr)) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_PSD) { - if (!BLI_path_extension_check(string, extension_test = ".psd")) { + if (!BLI_path_extension_check(filepath, extension_test = ".psd")) { extension = extension_test; } } #ifdef WITH_OPENEXR else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { - if (!BLI_path_extension_check(string, extension_test = ".exr")) { + if (!BLI_path_extension_check(filepath, extension_test = ".exr")) { extension = extension_test; } } #endif #ifdef WITH_CINEON else if (imtype == R_IMF_IMTYPE_CINEON) { - if (!BLI_path_extension_check(string, extension_test = ".cin")) { + if (!BLI_path_extension_check(filepath, extension_test = ".cin")) { extension = extension_test; } } else if (imtype == R_IMF_IMTYPE_DPX) { - if (!BLI_path_extension_check(string, extension_test = ".dpx")) { + if (!BLI_path_extension_check(filepath, extension_test = ".dpx")) { extension = extension_test; } } @@ -468,12 +469,12 @@ static bool do_add_image_extension(char *string, else if (imtype == R_IMF_IMTYPE_JP2) { if (im_format) { if (im_format->jp2_codec == R_IMF_JP2_CODEC_JP2) { - if (!BLI_path_extension_check(string, extension_test = ".jp2")) { + if (!BLI_path_extension_check(filepath, extension_test = ".jp2")) { extension = extension_test; } } else if (im_format->jp2_codec == R_IMF_JP2_CODEC_J2K) { - if (!BLI_path_extension_check(string, extension_test = ".j2c")) { + if (!BLI_path_extension_check(filepath, extension_test = ".j2c")) { extension = extension_test; } } @@ -482,7 +483,7 @@ static bool do_add_image_extension(char *string, } } else { - if (!BLI_path_extension_check(string, extension_test = ".jp2")) { + if (!BLI_path_extension_check(filepath, extension_test = ".jp2")) { extension = extension_test; } } @@ -490,13 +491,13 @@ static bool do_add_image_extension(char *string, #endif #ifdef WITH_WEBP else if (imtype == R_IMF_IMTYPE_WEBP) { - if (!BLI_path_extension_check(string, extension_test = ".webp")) { + if (!BLI_path_extension_check(filepath, extension_test = ".webp")) { extension = extension_test; } } #endif else { // R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90 etc - if (!BLI_path_extension_check_n(string, extension_test = ".jpg", ".jpeg", nullptr)) { + if (!BLI_path_extension_check_n(filepath, extension_test = ".jpg", ".jpeg", nullptr)) { extension = extension_test; } } @@ -504,27 +505,27 @@ static bool do_add_image_extension(char *string, if (extension) { /* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */ /* remove any other known image extension */ - if (BLI_path_extension_check_array(string, imb_ext_image)) { - return BLI_path_extension_replace(string, FILE_MAX, extension); + if (BLI_path_extension_check_array(filepath, imb_ext_image)) { + return BLI_path_extension_replace(filepath, FILE_MAX, extension); } - return BLI_path_extension_ensure(string, FILE_MAX, extension); + return BLI_path_extension_ensure(filepath, FILE_MAX, extension); } return false; } -int BKE_image_path_ensure_ext_from_imformat(char *string, const ImageFormatData *im_format) +int BKE_image_path_ensure_ext_from_imformat(char *filepath, const ImageFormatData *im_format) { - return do_add_image_extension(string, im_format->imtype, im_format); + return do_add_image_extension(filepath, im_format->imtype, im_format); } -int BKE_image_path_ensure_ext_from_imtype(char *string, const char imtype) +int BKE_image_path_ensure_ext_from_imtype(char *filepath, const char imtype) { - return do_add_image_extension(string, imtype, nullptr); + return do_add_image_extension(filepath, imtype, nullptr); } -static void do_makepicstring(char *string, +static void do_makepicstring(char filepath[FILE_MAX], const char *base, const char *relbase, int frame, @@ -534,26 +535,26 @@ static void do_makepicstring(char *string, const bool use_frames, const char *suffix) { - if (string == nullptr) { + if (filepath == nullptr) { return; } - BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ - BLI_path_abs(string, relbase); + BLI_strncpy(filepath, base, FILE_MAX - 10); /* weak assumption */ + BLI_path_abs(filepath, relbase); if (use_frames) { - BLI_path_frame(string, frame, 4); + BLI_path_frame(filepath, FILE_MAX, frame, 4); } if (suffix) { - BLI_path_suffix(string, FILE_MAX, suffix, ""); + BLI_path_suffix(filepath, FILE_MAX, suffix, ""); } if (use_ext) { - do_add_image_extension(string, imtype, im_format); + do_add_image_extension(filepath, imtype, im_format); } } -void BKE_image_path_from_imformat(char *string, +void BKE_image_path_from_imformat(char *filepath, const char *base, const char *relbase, int frame, @@ -563,10 +564,10 @@ void BKE_image_path_from_imformat(char *string, const char *suffix) { do_makepicstring( - string, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix); + filepath, base, relbase, frame, im_format->imtype, im_format, use_ext, use_frames, suffix); } -void BKE_image_path_from_imtype(char *string, +void BKE_image_path_from_imtype(char *filepath, const char *base, const char *relbase, int frame, @@ -575,7 +576,7 @@ void BKE_image_path_from_imtype(char *string, const bool use_frames, const char *suffix) { - do_makepicstring(string, base, relbase, frame, imtype, nullptr, use_ext, use_frames, suffix); + do_makepicstring(filepath, base, relbase, frame, imtype, nullptr, use_ext, use_frames, suffix); } /* ImBuf Conversion */ @@ -602,7 +603,8 @@ void BKE_image_format_to_imbuf(ImBuf *ibuf, const ImageFormatData *imf) R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID, - R_IMF_IMTYPE_AV1)) { + R_IMF_IMTYPE_AV1)) + { ibuf->ftype = IMB_FTYPE_PNG; if (imtype == R_IMF_IMTYPE_PNG) { diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index aef64247346..9b05a7326d4 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -147,9 +147,11 @@ static void image_buf_fill_checker_slice( float h = 0.125f * floorf(x / checkerwidth); if ((abs((x % checkerwidth) - (checkerwidth / 2)) < 4) && - (abs((y % checkerwidth) - (checkerwidth / 2)) < 4)) { + (abs((y % checkerwidth) - (checkerwidth / 2)) < 4)) + { if ((abs((x % checkerwidth) - (checkerwidth / 2)) < 1) || - (abs((y % checkerwidth) - (checkerwidth / 2)) < 1)) { + (abs((y % checkerwidth) - (checkerwidth / 2)) < 1)) + { hsv[0] = fmodf(fabsf(h - hoffs), 1.0f); hsv_to_rgb_v(hsv, rgb); diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 0dd1cd1f18f..9ac513f310b 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -345,7 +345,8 @@ void BKE_image_ensure_gpu_texture(Image *image, ImageUser *image_user) /* Note that the image can cache both stereo views, so we only invalidate the cache if the view * index is more than 2. */ if (image->gpu_pass != image_user->pass || image->gpu_layer != image_user->layer || - (image->gpu_view != image_user->multi_index && image_user->multi_index >= 2)) { + (image->gpu_view != image_user->multi_index && image_user->multi_index >= 2)) + { BKE_image_partial_update_mark_full_update(image); } } @@ -375,7 +376,8 @@ static GPUTexture *image_get_gpu_texture(Image *ima, requested_view = 0; } if (ima->gpu_pass != requested_pass || ima->gpu_layer != requested_layer || - ima->gpu_view != requested_view) { + ima->gpu_view != requested_view) + { ima->gpu_pass = requested_pass; ima->gpu_layer = requested_layer; ima->gpu_view = requested_view; @@ -769,7 +771,8 @@ static void gpu_texture_update_from_ibuf( /* Non-color data, just store buffer as is. */ } else if (IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) || - IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) { + IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) + { /* sRGB or scene linear, store as byte texture that the GPU can decode directly. */ rect = (uchar *)MEM_mallocN(sizeof(uchar[4]) * w * h, __func__); if (rect == nullptr) { @@ -881,7 +884,8 @@ void BKE_image_update_gputexture_delayed(struct Image *ima, { /* Check for full refresh. */ if (ibuf != nullptr && ima->source != IMA_SRC_TILED && x == 0 && y == 0 && w == ibuf->x && - h == ibuf->y) { + h == ibuf->y) + { BKE_image_partial_update_mark_full_update(ima); } else { diff --git a/source/blender/blenkernel/intern/image_partial_update_test.cc b/source/blender/blenkernel/intern/image_partial_update_test.cc index 29a13e28f71..04d6b288ef2 100644 --- a/source/blender/blenkernel/intern/image_partial_update_test.cc +++ b/source/blender/blenkernel/intern/image_partial_update_test.cc @@ -340,7 +340,8 @@ TEST_F(ImagePartialUpdateTest, mark_multiple_chunks) PartialUpdateRegion changed_region; int num_chunks_found = 0; while (BKE_image_partial_update_get_next_change(partial_update_user, &changed_region) == - ePartialUpdateIterResult::ChangeAvailable) { + ePartialUpdateIterResult::ChangeAvailable) + { BLI_rcti_isect(&changed_region.region, ®ion, nullptr); num_chunks_found++; } diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 99fc6ff5923..83e32c39084 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -8,6 +8,7 @@ #include #include +#include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -217,7 +218,8 @@ void BKE_image_save_options_update(ImageSaveOptions *opts, const Image *image) } else if (opts->im_format.imtype != opts->prev_imtype && !IMB_colormanagement_space_name_is_data( - opts->im_format.linear_colorspace_settings.name)) { + opts->im_format.linear_colorspace_settings.name)) + { const bool linear_float_output = BKE_imtype_requires_linear_float(opts->im_format.imtype); /* TODO: detect if the colorspace is linear, not just equal to scene linear. */ @@ -279,7 +281,7 @@ static void image_save_post(ReportList *reports, } if (opts->do_newpath) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } /* The tiled image code-path must call this on its own. */ @@ -321,8 +323,9 @@ static void image_save_post(ReportList *reports, if (!opts->save_as_render || linear_float_output) { if (opts->im_format.linear_colorspace_settings.name[0] && - !BKE_color_managed_colorspace_settings_equals( - &ima->colorspace_settings, &opts->im_format.linear_colorspace_settings)) { + !BKE_color_managed_colorspace_settings_equals(&ima->colorspace_settings, + &opts->im_format.linear_colorspace_settings)) + { BKE_color_managed_colorspace_settings_copy(&ima->colorspace_settings, &opts->im_format.linear_colorspace_settings); *r_colorspace_changed = true; @@ -347,7 +350,7 @@ static void imbuf_save_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) /** * \return success. - * \note `ima->filepath` and `ibuf->name` should end up the same. + * \note `ima->filepath` and `ibuf->filepath` should end up the same. * \note for multi-view the first `ibuf` is important to get the settings. */ static bool image_save_single(ReportList *reports, @@ -384,7 +387,8 @@ static bool image_save_single(ReportList *reports, /* TODO: better solution, if a 24bit image is painted onto it may contain alpha. */ if ((opts->im_format.planes == R_IMF_PLANES_RGBA) && /* it has been painted onto */ - (ibuf->userflags & IB_BITMAPDIRTY)) { + (ibuf->userflags & IB_BITMAPDIRTY)) + { /* checks each pixel, not ideal */ ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? R_IMF_PLANES_RGBA : R_IMF_PLANES_RGB; } @@ -422,7 +426,8 @@ static bool image_save_single(ReportList *reports, /* It shouldn't ever happen. */ if ((BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)) == nullptr) || - (BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == nullptr)) { + (BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name)) == nullptr)) + { BKE_reportf(reports, RPT_ERROR, R"(Did not write, the image doesn't have a "%s" and "%s" views)", @@ -802,7 +807,8 @@ bool BKE_image_render_write_exr(ReportList *reports, LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) { /* Skip non-RGBA and Z passes if not using multi layer. */ if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") || - (STREQ(rp->name, RE_PASSNAME_Z) && write_z))) { + (STREQ(rp->name, RE_PASSNAME_Z) && write_z))) + { continue; } @@ -857,7 +863,7 @@ bool BKE_image_render_write_exr(ReportList *reports, errno = 0; - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); int compress = (imf ? imf->exr_codec : 0); bool success = IMB_exr_begin_write( @@ -945,8 +951,8 @@ bool BKE_image_render_write(ReportList *reports, /* mono, legacy code */ else if (is_mono || (image_format.views_format == R_IMF_VIEWS_INDIVIDUAL)) { int view_id = 0; - for (const RenderView *rv = (const RenderView *)rr->views.first; rv; - rv = rv->next, view_id++) { + for (const RenderView *rv = (const RenderView *)rr->views.first; rv; rv = rv->next, view_id++) + { char filepath[FILE_MAX]; if (is_mono) { STRNCPY(filepath, filepath_basis); diff --git a/source/blender/blenkernel/intern/image_test.cc b/source/blender/blenkernel/intern/image_test.cc index d2c41854c46..5219552cc9b 100644 --- a/source/blender/blenkernel/intern/image_test.cc +++ b/source/blender/blenkernel/intern/image_test.cc @@ -66,7 +66,8 @@ TEST(udim, image_ensure_tile_token) "test.u_v2.png", "test.u2v3.png", "test.u123_v1.png", - "test.u1_v12345.png"}) { + "test.u1_v12345.png"}) + { /* These should not result in modifications happening. */ verify(incorrect, incorrect); } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index e7009bbdb06..30cbf3caff8 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1614,7 +1614,8 @@ static void icu_to_fcurves(ID *id, * - we need radians for RNA to do the right thing */ if (((icu->blocktype == ID_OB) && ELEM(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) || - ((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))) { + ((icu->blocktype == ID_PO) && ELEM(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z))) + { const float fac = (float)M_PI / 18.0f; /* 10.0f * M_PI/180.0f; */ dst->vec[0][1] *= fac; @@ -1627,7 +1628,8 @@ static void icu_to_fcurves(ID *id, * - we now need as 'frames' */ if ((id) && (icu->blocktype == GS(id->name)) && - (fcu->rna_path && STREQ(fcu->rna_path, "eval_time"))) { + (fcu->rna_path && STREQ(fcu->rna_path, "eval_time"))) + { Curve *cu = (Curve *)id; dst->vec[0][1] *= cu->pathlen; @@ -1644,10 +1646,8 @@ static void icu_to_fcurves(ID *id, DriverVar *dvar = fcu->driver->variables.first; DriverTarget *dtar = &dvar->targets[0]; - if (ELEM(dtar->transChan, - DTAR_TRANSCHAN_ROTX, - DTAR_TRANSCHAN_ROTY, - DTAR_TRANSCHAN_ROTZ)) { + if (ELEM(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ)) + { const float fac = (float)M_PI / 18.0f; dst->vec[0][0] *= fac; diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 21348c5de52..3dcddffc166 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -61,7 +61,8 @@ static void shapekey_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, c for (kb_src = static_cast(key_src->block.first), kb_dst = static_cast(key_dst->block.first); kb_dst; - kb_src = kb_src->next, kb_dst = kb_dst->next) { + kb_src = kb_src->next, kb_dst = kb_dst->next) + { if (kb_dst->data) { kb_dst->data = MEM_dupallocN(kb_dst->data); } @@ -901,7 +902,8 @@ static void key_evaluate_relative(const int start, /* step 2: do it */ for (kb = static_cast(key->block.first), keyblock_index = 0; kb; - kb = kb->next, keyblock_index++) { + kb = kb->next, keyblock_index++) + { if (kb != key->refkey) { float icuval = kb->curval; @@ -1348,7 +1350,8 @@ static float **keyblock_get_per_block_weights(Object *ob, Key *key, WeightsArray MEM_mallocN(sizeof(*per_keyblock_weights) * key->totkey, "per keyblock weights")); for (keyblock = static_cast(key->block.first), keyblock_index = 0; keyblock; - keyblock = keyblock->next, keyblock_index++) { + keyblock = keyblock->next, keyblock_index++) + { per_keyblock_weights[keyblock_index] = get_weights_array(ob, keyblock->vgroup, cache); } @@ -1645,7 +1648,8 @@ int BKE_keyblock_element_count_from_shape(const Key *key, const int shape_index) int result = 0; int index = 0; for (const KeyBlock *kb = static_cast(key->block.first); kb; - kb = kb->next, index++) { + kb = kb->next, index++) + { if (ELEM(shape_index, -1, index)) { result += kb->totelem; } @@ -1680,7 +1684,8 @@ void BKE_keyblock_data_get_from_shape(const Key *key, float (*arr)[3], const int uint8_t *elements = (uint8_t *)arr; int index = 0; for (const KeyBlock *kb = static_cast(key->block.first); kb; - kb = kb->next, index++) { + kb = kb->next, index++) + { if (ELEM(shape_index, -1, index)) { const int block_elem_len = kb->totelem * key->elemsize; memcpy(elements, kb->data, block_elem_len); @@ -2154,7 +2159,8 @@ static void keyblock_data_convert_to_curve(const float *fp, ListBase *nurb, int if (nu->bezt != nullptr) { BezTriple *bezt = nu->bezt; for (int i = nu->pntsu; i && (totpoint -= KEYELEM_ELEM_LEN_BEZTRIPLE) >= 0; - i--, bezt++, fp += KEYELEM_FLOAT_LEN_BEZTRIPLE) { + i--, bezt++, fp += KEYELEM_FLOAT_LEN_BEZTRIPLE) + { for (int j = 0; j < 3; j++) { copy_v3_v3(bezt->vec[j], &fp[j * 3]); } @@ -2165,7 +2171,8 @@ static void keyblock_data_convert_to_curve(const float *fp, ListBase *nurb, int else { BPoint *bp = nu->bp; for (int i = nu->pntsu * nu->pntsv; i && (totpoint -= KEYELEM_ELEM_LEN_BPOINT) >= 0; - i--, bp++, fp += KEYELEM_FLOAT_LEN_BPOINT) { + i--, bp++, fp += KEYELEM_FLOAT_LEN_BPOINT) + { copy_v3_v3(bp->vec, fp); bp->tilt = fp[3]; bp->radius = fp[4]; @@ -2524,7 +2531,8 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index) for (kb = static_cast(rev ? key->block.last : key->block.first), i = (rev ? totkey - 1 : 0); kb; - kb = (rev ? kb->prev : kb->next), rev ? i-- : i++) { + kb = (rev ? kb->prev : kb->next), rev ? i-- : i++) + { if (i == org_index) { in_range = true; /* Start list items swapping... */ } diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index 69b4997c6e9..bcb52a9ddc9 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -900,7 +900,8 @@ static LayerCollectionResync *layer_collection_resync_find(LayerCollectionResync if (current_layer_resync->collection == child_collection && (current_layer_resync->parent_layer_resync == layer_resync || - (!current_layer_resync->is_used && !current_layer_resync->is_valid_as_child))) { + (!current_layer_resync->is_used && !current_layer_resync->is_valid_as_child))) + { /* This layer is a valid candidate, because its collection matches the seeked one, AND: * - It is a direct child of the initial given parent ('unchanged hierarchy' case), OR * - It is not currently used, and not part of a valid hierarchy (sub-)chain. @@ -909,9 +910,9 @@ static LayerCollectionResync *layer_collection_resync_find(LayerCollectionResync } /* Else, add all its direct children for further searching. */ - LISTBASE_FOREACH (LayerCollectionResync *, - child_layer_resync, - ¤t_layer_resync->children_layer_resync) { + LISTBASE_FOREACH ( + LayerCollectionResync *, child_layer_resync, ¤t_layer_resync->children_layer_resync) + { /* Add to tail of the queue. */ queue_tail->queue_next = child_layer_resync; child_layer_resync->queue_next = nullptr; @@ -926,7 +927,8 @@ static LayerCollectionResync *layer_collection_resync_find(LayerCollectionResync if (queue_head == nullptr && root_layer_resync->parent_layer_resync != nullptr) { LISTBASE_FOREACH (LayerCollectionResync *, sibling_layer_resync, - &root_layer_resync->parent_layer_resync->children_layer_resync) { + &root_layer_resync->parent_layer_resync->children_layer_resync) + { if (sibling_layer_resync == root_layer_resync) { continue; } @@ -951,7 +953,8 @@ static void layer_collection_resync_unused_layers_free(ViewLayer *view_layer, LayerCollectionResync *layer_resync) { LISTBASE_FOREACH ( - LayerCollectionResync *, child_layer_resync, &layer_resync->children_layer_resync) { + LayerCollectionResync *, child_layer_resync, &layer_resync->children_layer_resync) + { layer_collection_resync_unused_layers_free(view_layer, child_layer_resync); } @@ -998,7 +1001,8 @@ void BKE_scene_view_layers_synced_ensure(const Scene *scene) void BKE_main_view_layers_synced_ensure(const Main *bmain) { for (const Scene *scene = static_cast(bmain->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { BKE_scene_view_layers_synced_ensure(scene); } @@ -1205,7 +1209,8 @@ static void layer_collection_sync(ViewLayer *view_layer, } if (((child_layer->runtime_flag & LAYER_COLLECTION_HIDE_VIEWPORT) == 0) && - ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) { + ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) + { child_layer->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER; } } @@ -1276,7 +1281,8 @@ void BKE_layer_collection_doversion_2_80(const Scene *scene, ViewLayer *view_lay LayerCollection *first_layer_collection = static_cast( view_layer->layer_collections.first); if (BLI_listbase_count_at_most(&view_layer->layer_collections, 2) > 1 || - first_layer_collection->collection != scene->master_collection) { + first_layer_collection->collection != scene->master_collection) + { /* In some cases (from older files) we do have a master collection, but no matching layer, * instead all the children of the master collection have their layer collections in the * viewlayer's list. This is not a valid situation, add a layer for the master collection and @@ -1420,7 +1426,8 @@ void BKE_main_collection_sync(const Main *bmain) /* TODO: optimize for file load so only linked collections get checked? */ for (const Scene *scene = static_cast(bmain->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { BKE_scene_collection_sync(scene); } @@ -1439,7 +1446,8 @@ void BKE_main_collection_sync_remap(const Main *bmain) BKE_main_collections_object_cache_free(bmain); for (Scene *scene = static_cast(bmain->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { MEM_SAFE_FREE(view_layer->object_bases_array); @@ -1459,7 +1467,8 @@ void BKE_main_collection_sync_remap(const Main *bmain) } for (Collection *collection = static_cast(bmain->collections.first); collection; - collection = static_cast(collection->id.next)) { + collection = static_cast(collection->id.next)) + { DEG_id_tag_update_ex((Main *)bmain, &collection->id, ID_RECALC_COPY_ON_WRITE); } @@ -1526,7 +1535,8 @@ bool BKE_layer_collection_has_selected_objects(const Scene *scene, Base *base = BKE_view_layer_base_find(view_layer, cob->ob); if (base && (base->flag & BASE_SELECTED) && - (base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT)) { + (base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT)) + { return true; } } @@ -1623,7 +1633,8 @@ bool BKE_object_is_visible_in_viewport(const View3D *v3d, const Object *ob) } if ((v3d->flag & V3D_LOCAL_COLLECTIONS) && - ((v3d->local_collections_uuid & ob->runtime.local_collections_bits) == 0)) { + ((v3d->local_collections_uuid & ob->runtime.local_collections_bits) == 0)) + { return false; } @@ -2264,7 +2275,8 @@ void BKE_view_layer_bases_in_mode_iterator_next(BLI_Iterator *iter) while (base) { if ((base != data->base_active) && base_is_in_mode(data, base) && - BKE_base_is_visible(data->v3d, base)) { + BKE_base_is_visible(data->v3d, base)) + { iter->current = base; return; } diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 996eaa39c5f..036a1bb07f7 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -422,7 +422,8 @@ static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data) * Just skip it, shape key can only be either indirectly linked, or fully local, period. * And let's curse one more time that stupid useless shape-key ID type! */ if (*id_pointer && *id_pointer != id_self && - BKE_idtype_idcode_is_linkable(GS((*id_pointer)->name))) { + BKE_idtype_idcode_is_linkable(GS((*id_pointer)->name))) + { id_lib_extern(*id_pointer); } @@ -1487,7 +1488,8 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint) ID *id_sorting_hint_next = id_sorting_hint->next; if (BLI_strcasecmp(id_sorting_hint->name, id->name) < 0 && (id_sorting_hint_next == NULL || id_sorting_hint_next->lib != id->lib || - BLI_strcasecmp(id_sorting_hint_next->name, id->name) > 0)) { + BLI_strcasecmp(id_sorting_hint_next->name, id->name) > 0)) + { BLI_insertlinkafter(lb, id_sorting_hint, id); return; } @@ -1495,7 +1497,8 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint) ID *id_sorting_hint_prev = id_sorting_hint->prev; if (BLI_strcasecmp(id_sorting_hint->name, id->name) > 0 && (id_sorting_hint_prev == NULL || id_sorting_hint_prev->lib != id->lib || - BLI_strcasecmp(id_sorting_hint_prev->name, id->name) < 0)) { + BLI_strcasecmp(id_sorting_hint_prev->name, id->name) < 0)) + { BLI_insertlinkbefore(lb, id_sorting_hint, id); return; } @@ -1687,7 +1690,8 @@ static void library_make_local_copying_check(ID *id, MainIDRelationsEntry *entry = BLI_ghash_lookup(id_relations->relations_from_pointers, id); BLI_gset_insert(loop_tags, id); for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != NULL; - from_id_entry = from_id_entry->next) { + from_id_entry = from_id_entry->next) + { /* Our oh-so-beloved 'from' pointers... Those should always be ignored here, since the actual * relation we want to check is in the other way around. */ if (from_id_entry->usage_flag & IDWALK_CB_LOOPBACK) { @@ -1789,7 +1793,8 @@ void BKE_library_make_local(Main *bmain, id->flag &= ~LIB_INDIRECT_WEAK_LINK; if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && ELEM(lib, NULL, id->override_library->reference->lib) && - ((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) { + ((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) + { BKE_lib_override_library_make_local(id); } } @@ -1807,7 +1812,8 @@ void BKE_library_make_local(Main *bmain, * but complicates slightly the pre-processing of relations between IDs at step 2... */ else if (!do_skip && id->tag & (LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW) && ELEM(lib, NULL, id->lib) && - ((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) { + ((untagged_only == false) || !(id->tag & LIB_TAG_PRE_EXISTING))) + { BLI_linklist_prepend_arena(&todo_ids, id, linklist_mem); id->tag |= LIB_TAG_DOIT; @@ -1942,7 +1948,8 @@ void BKE_library_make_local(Main *bmain, * Try "make all local" in 04_01_H.lighting.blend from Agent327 without this, e.g. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { if (ob->data != NULL && ob->type == OB_ARMATURE && ob->pose != NULL && - ob->pose->flag & POSE_RECALC) { + ob->pose->flag & POSE_RECALC) + { BKE_pose_rebuild(bmain, ob, ob->data, true); } } diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index c7643c56212..c4200938cb9 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -353,7 +353,8 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion) id_next = id->next; if (id->tag & tag) { if (((id->tag & LIB_TAG_EXTRAUSER_SET) == 0 && ID_REAL_USERS(id) != 0) || - ((id->tag & LIB_TAG_EXTRAUSER_SET) != 0 && ID_REAL_USERS(id) != 1)) { + ((id->tag & LIB_TAG_EXTRAUSER_SET) != 0 && ID_REAL_USERS(id) != 1)) + { CLOG_ERROR(&LOG, "Deleting %s which still has %d users (including %d 'extra' shallow users)\n", id->name, diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 0d67b2d97e0..b61eb71f834 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -77,6 +77,14 @@ static void lib_override_library_property_clear(IDOverrideLibraryProperty *op); static void lib_override_library_property_operation_clear( IDOverrideLibraryPropertyOperation *opop); +BLI_INLINE IDOverrideLibraryRuntime *override_library_runtime_ensure(IDOverrideLibrary *override) +{ + if (override->runtime == nullptr) { + override->runtime = MEM_cnew(__func__); + } + return override->runtime; +} + /** Helper to preserve Pose mode on override objects. * A bit annoying to have this special case, but not much to be done here currently, since the * matching RNA property is read-only. */ @@ -138,7 +146,8 @@ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id) for (ancestor_id = reference_id; ancestor_id != nullptr && ancestor_id->override_library != nullptr && ancestor_id->override_library->reference != nullptr; - ancestor_id = ancestor_id->override_library->reference) { + ancestor_id = ancestor_id->override_library->reference) + { /* pass */ } @@ -157,10 +166,10 @@ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id) local_id->override_library = MEM_cnew(__func__); local_id->override_library->reference = reference_id; id_us_plus(local_id->override_library->reference); - local_id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK; + local_id->tag &= ~LIB_TAG_LIBOVERRIDE_REFOK; /* By default initialized liboverrides are 'system overrides', higher-level code is responsible * to unset this flag for specific IDs. */ - local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + local_id->override_library->flag |= LIBOVERRIDE_FLAG_SYSTEM_DEFINED; /* TODO: do we want to add tag or flag to referee to mark it as such? */ return local_id->override_library; } @@ -203,12 +212,13 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f *op_src = static_cast( src_id->override_library->properties.first); op_dst; - op_dst = op_dst->next, op_src = op_src->next) { + op_dst = op_dst->next, op_src = op_src->next) + { lib_override_library_property_copy(op_dst, op_src); } } - dst_id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK; + dst_id->tag &= ~LIB_TAG_LIBOVERRIDE_REFOK; } void BKE_lib_override_library_clear(IDOverrideLibrary *override, const bool do_id_user) @@ -303,10 +313,10 @@ bool BKE_lib_override_library_is_user_edited(const ID *id) LISTBASE_FOREACH (const IDOverrideLibraryProperty *, op, &id->override_library->properties) { LISTBASE_FOREACH (const IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if ((opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) != 0) { + if ((opop->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) != 0) { continue; } - if (opop->operation == IDOVERRIDE_LIBRARY_OP_NOOP) { + if (opop->operation == LIBOVERRIDE_OP_NOOP) { continue; } /* If an operation does not match the filters above, it is considered as a user-editing one, @@ -322,8 +332,7 @@ bool BKE_lib_override_library_is_system_defined(const Main *bmain, const ID *id) if (ID_IS_OVERRIDE_LIBRARY(id)) { const ID *override_owner_id; BKE_lib_override_library_get(bmain, id, nullptr, &override_owner_id); - return (override_owner_id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) != - 0; + return (override_owner_id->override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) != 0; } return false; } @@ -367,7 +376,8 @@ static int foreachid_is_hierarchy_leaf_fn(LibraryIDLinkCallbackData *cb_data) } if (id != nullptr && ID_IS_OVERRIDE_LIBRARY_REAL(id) && - id->override_library->hierarchy_root == id_owner->override_library->hierarchy_root) { + id->override_library->hierarchy_root == id_owner->override_library->hierarchy_root) + { *is_leaf = false; return IDWALK_RET_STOP_ITER; } @@ -397,8 +407,8 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain, /* We cannot allow automatic hierarchy resync on this ID, it is highly likely to generate a giant * mess in case there are a lot of hidden, non-instantiated, non-properly organized dependencies. * Ref #94650. */ - local_id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY; - local_id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + local_id->override_library->flag |= LIBOVERRIDE_FLAG_NO_HIERARCHY; + local_id->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; local_id->override_library->hierarchy_root = local_id; if (do_tagged_remap) { @@ -523,7 +533,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, /* Get all IDs we want to override. */ FOREACH_MAIN_ID_BEGIN (bmain, reference_id) { if ((reference_id->tag & LIB_TAG_DOIT) != 0 && reference_id->lib == reference_library && - BKE_idtype_idcode_is_linkable(GS(reference_id->name))) { + BKE_idtype_idcode_is_linkable(GS(reference_id->name))) + { todo_id_iter = MEM_cnew(__func__); todo_id_iter->data = reference_id; BLI_addtail(&todo_ids, todo_id_iter); @@ -533,7 +544,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, /* Override the IDs. */ for (todo_id_iter = static_cast(todo_ids.first); todo_id_iter != nullptr; - todo_id_iter = todo_id_iter->next) { + todo_id_iter = todo_id_iter->next) + { reference_id = static_cast(todo_id_iter->data); /* If `newid` is already set, assume it has been handled by calling code. @@ -549,7 +561,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, break; } if (do_fully_editable) { - reference_id->newid->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + reference_id->newid->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } } /* We also tag the new IDs so that in next step we can remap their pointers too. */ @@ -575,7 +587,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, } else if (id_root_reference->newid != nullptr && (id_hierarchy_root == nullptr || - id_hierarchy_root->override_library->reference == id_root_reference)) { + id_hierarchy_root->override_library->reference == id_root_reference)) + { id_hierarchy_root = id_root_reference->newid; } BLI_assert(id_hierarchy_root != nullptr); @@ -607,7 +620,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib != id_root_reference->lib) { BLI_linklist_prepend(&relinked_ids, other_id); if (ID_IS_OVERRIDE_LIBRARY_REAL(other_id) && - other_id->override_library->hierarchy_root == id_hierarchy_root) { + other_id->override_library->hierarchy_root == id_hierarchy_root) + { reference_id = other_id->override_library->reference; ID *local_id = reference_id->newid; if (other_id == local_id) { @@ -622,7 +636,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, FOREACH_MAIN_ID_END; for (todo_id_iter = static_cast(todo_ids.first); todo_id_iter != nullptr; - todo_id_iter = todo_id_iter->next) { + todo_id_iter = todo_id_iter->next) + { reference_id = static_cast(todo_id_iter->data); ID *local_id = reference_id->newid; @@ -647,7 +662,8 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, else { /* We need to cleanup potentially already created data. */ for (todo_id_iter = static_cast(todo_ids.first); todo_id_iter != nullptr; - todo_id_iter = todo_id_iter->next) { + todo_id_iter = todo_id_iter->next) + { reference_id = static_cast(todo_id_iter->data); BKE_id_delete(bmain, reference_id->newid); reference_id->newid = nullptr; @@ -689,7 +705,8 @@ static void lib_override_group_tag_data_object_to_collection_init_collection_pro LinkNodePair **collections_linkedlist_p; if (!BLI_ghash_ensure_p(data->linked_object_to_instantiating_collections, ob, - reinterpret_cast(&collections_linkedlist_p))) { + reinterpret_cast(&collections_linkedlist_p))) + { *collections_linkedlist_p = static_cast( BLI_memarena_calloc(data->mem_arena, sizeof(**collections_linkedlist_p))); } @@ -748,7 +765,8 @@ static void lib_override_hierarchy_dependencies_recursive_tag_from(LibOverrideGr entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED_FROM; for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != nullptr; - from_id_entry = from_id_entry->next) { + from_id_entry = from_id_entry->next) + { if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships ('from', 'parents', 'owner' etc. pointers) * as actual dependencies. */ @@ -757,7 +775,8 @@ static void lib_override_hierarchy_dependencies_recursive_tag_from(LibOverrideGr /* We only consider IDs from the same library. */ ID *from_id = from_id_entry->id_pointer.from; if (from_id == nullptr || from_id->lib != id->lib || - (is_override && !ID_IS_OVERRIDE_LIBRARY(from_id))) { + (is_override && !ID_IS_OVERRIDE_LIBRARY(from_id))) + { /* IDs from different libraries, or non-override IDs in case we are processing overrides, * are both barriers of dependency. */ continue; @@ -795,7 +814,8 @@ static bool lib_override_hierarchy_dependencies_recursive_tag(LibOverrideGroupTa entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED_TO; for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != nullptr; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships ('from', 'parents', 'owner' etc. pointers) as * actual dependencies. */ @@ -850,7 +870,8 @@ static void lib_override_linked_group_tag_recursive(LibOverrideGroupTagData *dat entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != nullptr; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships as actual dependencies. */ continue; @@ -895,7 +916,8 @@ static bool lib_override_linked_group_tag_collections_keep_tagged_check_recursiv for (CollectionObject *collection_object = static_cast(collection->gobject.first); collection_object != nullptr; - collection_object = collection_object->next) { + collection_object = collection_object->next) + { Object *object = collection_object->ob; if (object == nullptr) { continue; @@ -908,9 +930,11 @@ static bool lib_override_linked_group_tag_collections_keep_tagged_check_recursiv for (CollectionChild *collection_child = static_cast(collection->children.first); collection_child != nullptr; - collection_child = collection_child->next) { + collection_child = collection_child->next) + { if (lib_override_linked_group_tag_collections_keep_tagged_check_recursive( - data, collection_child->collection)) { + data, collection_child->collection)) + { return true; } } @@ -929,7 +953,8 @@ static void lib_override_linked_group_tag_clear_boneshapes_objects(LibOverrideGr if (ob->type == OB_ARMATURE && ob->pose != nullptr && (ob->id.tag & data->tag)) { for (bPoseChannel *pchan = static_cast(ob->pose->chanbase.first); pchan != nullptr; - pchan = pchan->next) { + pchan = pchan->next) + { if (pchan->custom != nullptr && &pchan->custom->id != id_root) { pchan->custom->id.tag &= ~data->tag; } @@ -1011,7 +1036,8 @@ static void lib_override_linked_group_tag(LibOverrideGroupTagData *data) if (instantiating_collection_linklist != nullptr) { for (LinkNode *instantiating_collection_linknode = instantiating_collection_linklist->list; instantiating_collection_linknode != nullptr; - instantiating_collection_linknode = instantiating_collection_linknode->next) { + instantiating_collection_linknode = instantiating_collection_linknode->next) + { instantiating_collection = static_cast( instantiating_collection_linknode->link); if (!ID_IS_LINKED(instantiating_collection)) { @@ -1052,7 +1078,8 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * ID *id_hierarchy_root = data->hierarchy_root_id; if (ID_IS_OVERRIDE_LIBRARY_REAL(id_owner) && - (id_owner->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) != 0) { + (id_owner->override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) != 0) + { return; } @@ -1072,7 +1099,8 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != nullptr; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships as actual dependencies. */ continue; @@ -1088,7 +1116,8 @@ static void lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData * continue; } if (ID_IS_OVERRIDE_LIBRARY_REAL(to_id) && - to_id->override_library->hierarchy_root != id_hierarchy_root) { + to_id->override_library->hierarchy_root != id_hierarchy_root) + { continue; } @@ -1231,7 +1260,8 @@ static void lib_override_library_create_post_process(Main *bmain, /* Instantiating the root collection or object should never be needed in resync case, since the * old override would be remapped to the new one. */ if (!is_resync && id_root != nullptr && id_root->newid != nullptr && - (!ID_IS_LINKED(id_root->newid) || id_root->newid->lib == owner_library)) { + (!ID_IS_LINKED(id_root->newid) || id_root->newid->lib == owner_library)) + { switch (GS(id_root->name)) { case ID_GR: { Object *ob_reference = id_instance_hint != nullptr && GS(id_instance_hint->name) == ID_OB ? @@ -1331,7 +1361,8 @@ static void lib_override_library_create_post_process(Main *bmain, (view_layer != nullptr ? BKE_view_layer_has_collection(view_layer, collection) : BKE_collection_has_collection(scene->master_collection, collection)) && - !ID_IS_LINKED(collection) && !ID_IS_OVERRIDE_LIBRARY(collection)) { + !ID_IS_LINKED(collection) && !ID_IS_OVERRIDE_LIBRARY(collection)) + { default_instantiating_collection = collection; } } @@ -1351,7 +1382,8 @@ static void lib_override_library_create_post_process(Main *bmain, } if (id_root != nullptr && - !ELEM(default_instantiating_collection, nullptr, scene->master_collection)) { + !ELEM(default_instantiating_collection, nullptr, scene->master_collection)) + { ID *id_ref = id_root->newid != nullptr ? id_root->newid : id_root; switch (GS(id_ref->name)) { case ID_GR: @@ -1485,7 +1517,8 @@ static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int ID *best_root_id_candidate = id; for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != nullptr; - from_id_entry = from_id_entry->next) { + from_id_entry = from_id_entry->next) + { if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships as actual dependencies. */ continue; @@ -1562,7 +1595,8 @@ static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID bool do_replace_root = false; for (MainIDRelationsEntryItem *from_id_entry = entry->from_ids; from_id_entry != nullptr; - from_id_entry = from_id_entry->next) { + from_id_entry = from_id_entry->next) + { if ((from_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships as actual dependencies. */ continue; @@ -1603,7 +1637,8 @@ static void lib_override_root_hierarchy_set(Main *bmain, ID *id_root, ID *id, ID BLI_assert(entry != nullptr); for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != nullptr; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships as actual dependencies. */ continue; @@ -1634,7 +1669,8 @@ void BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain) } if (id->override_library->hierarchy_root != nullptr) { if (!ID_IS_OVERRIDE_LIBRARY_REAL(id->override_library->hierarchy_root) || - id->override_library->hierarchy_root->lib != id->lib) { + id->override_library->hierarchy_root->lib != id->lib) + { CLOG_ERROR( &LOG, "Existing override hierarchy root ('%s') for ID '%s' is invalid, will try to find a " @@ -1765,7 +1801,8 @@ static bool lib_override_library_resync(Main *bmain, /* Only tag linked IDs from related linked reference hierarchy that are actually part of * the sub-trees of each detected sub-roots needing resync. */ for (LinkNode *resync_root_link = id_resync_roots; resync_root_link != nullptr; - resync_root_link = resync_root_link->next) { + resync_root_link = resync_root_link->next) + { ID *id_resync_root = static_cast(resync_root_link->link); BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_resync_root)); @@ -1828,7 +1865,8 @@ static bool lib_override_library_resync(Main *bmain, /* Unfortunately deleting obdata means deleting their objects too. Since there is no * guarantee that a valid override object using an obsolete override obdata gets properly * updated, we ignore those here for now. In practice this should not be a big issue. */ - !OB_DATA_SUPPORT_ID(GS(id->name))) { + !OB_DATA_SUPPORT_ID(GS(id->name))) + { id->tag |= LIB_TAG_MISSING; } @@ -1884,7 +1922,7 @@ static bool lib_override_library_resync(Main *bmain, bool do_break = false; LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if ((opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { + if ((opop->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { id->override_library->reference->tag |= LIB_TAG_DOIT; do_break = true; break; @@ -1941,7 +1979,7 @@ static bool lib_override_library_resync(Main *bmain, ID *id_override_new = id->newid; ID *id_override_old = static_cast(BLI_ghash_lookup(linkedref_to_old_override, id)); - BLI_assert((id_override_new->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0); + BLI_assert((id_override_new->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) == 0); /* We need to 'move back' newly created override into its proper library (since it was * duplicated from the reference ID with 'no main' option, it should currently be the same @@ -1972,6 +2010,10 @@ static bool lib_override_library_resync(Main *bmain, id_override_new->override_library->flag = id_override_old->override_library->flag; + /* NOTE: Since `runtime.tag` is not copied from old to new liboverride, the potenial + * `LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT` is kept on the old, to-be-freed + * liboverride, and the new one is assumed to be properly part of its hierarchy again. */ + /* Copy over overrides rules from old override ID to new one. */ BLI_duplicatelist(&id_override_new->override_library->properties, &id_override_old->override_library->properties); @@ -2008,8 +2050,8 @@ static bool lib_override_library_resync(Main *bmain, * remapped, and all new local override IDs have gotten their proper original names, otherwise * override operations based on those ID names would fail. */ FOREACH_MAIN_ID_BEGIN (bmain, id) { - if ((id->tag & LIB_TAG_DOIT) == 0 || id->newid == nullptr || - id->lib != id_root_reference->lib) { + if ((id->tag & LIB_TAG_DOIT) == 0 || id->newid == nullptr || id->lib != id_root_reference->lib) + { continue; } @@ -2031,14 +2073,15 @@ static bool lib_override_library_resync(Main *bmain, RNA_id_pointer_create(id_override_old, &rnaptr_src); RNA_id_pointer_create(id_override_new, &rnaptr_dst); - /* We remove any operation tagged with `IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE`, + /* We remove any operation tagged with `LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE`, * that way the potentially new pointer will be properly kept, when old one is still valid * too (typical case: assigning new ID to some usage, while old one remains used elsewhere * in the override hierarchy). */ LISTBASE_FOREACH_MUTABLE ( - IDOverrideLibraryProperty *, op, &id_override_new->override_library->properties) { + IDOverrideLibraryProperty *, op, &id_override_new->override_library->properties) + { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) { + if (opop->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) { lib_override_library_property_operation_clear(opop); BLI_freelinkN(&op->operations, opop); } @@ -2118,7 +2161,8 @@ static bool lib_override_library_resync(Main *bmain, do_delete = false; } else if (hierarchy_root != nullptr && - hierarchy_root->override_library->reference->tag & LIB_TAG_MISSING) { + hierarchy_root->override_library->reference->tag & LIB_TAG_MISSING) + { /* Do not delete overrides which root hierarchy reference is missing. This would typically * cause more harm than good. */ do_delete = false; @@ -2151,6 +2195,11 @@ static bool lib_override_library_resync(Main *bmain, id->tag |= LIB_TAG_DOIT; id->tag &= ~LIB_TAG_MISSING; } + else if (id->override_library->runtime != nullptr) { + /* Cleanup of this temporary tag, since that somewhat broken liboverride is explicitely + * kept for now. */ + id->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT; + } } } FOREACH_MAIN_ID_END; @@ -2202,7 +2251,9 @@ static bool lib_override_library_resync(Main *bmain, /* Cleanup. */ BKE_main_id_newptr_and_tag_clear(bmain); - BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); /* That one should not be needed in fact. */ + /* That one should not be needed in fact, as #BKE_id_multi_tagged_delete call above should have + * deleted all tagged IDs. */ + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); return success; } @@ -2280,8 +2331,8 @@ static bool lib_override_resync_tagging_finalize_recurse( { BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); - if (!lib_override_resync_id_lib_level_is_valid(id, library_indirect_level, false) && - !check_only) { + if (!lib_override_resync_id_lib_level_is_valid(id, library_indirect_level, false) && !check_only) + { CLOG_ERROR( &LOG, "While processing indirect level %d, ID %s from lib %s of indirect level %d detected " @@ -2290,7 +2341,7 @@ static bool lib_override_resync_tagging_finalize_recurse( id->name, id->lib->filepath, id->lib->temp_index); - id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + id->tag &= ~LIB_TAG_LIBOVERRIDE_NEED_RESYNC; return false; } @@ -2300,7 +2351,7 @@ static bool lib_override_resync_tagging_finalize_recurse( if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) { /* This ID has already been processed. */ - return (ID_IS_OVERRIDE_LIBRARY(id) && (id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) != 0); + return (ID_IS_OVERRIDE_LIBRARY(id) && (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) != 0); } /* This way we won't process again that ID, should we encounter it again through another @@ -2326,14 +2377,22 @@ static bool lib_override_resync_tagging_finalize_recurse( * * In the example above, the armature will become the resync root. */ - const int id_tag_need_resync = (id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC); - id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + const int id_tag_need_resync = (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC); + id->tag &= ~LIB_TAG_LIBOVERRIDE_NEED_RESYNC; + + /* Pre-set the 'isolated from root' tag, it will be cleared if a valid path to its root is found + * in its parents hierarchy. See comment below when this tag is checked for details. */ + override_library_runtime_ensure(id->override_library); + if (id != id->override_library->hierarchy_root) { + id->override_library->runtime->tag |= LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT; + } bool is_ancestor_tagged_for_resync = false; for (MainIDRelationsEntryItem *entry_item = entry->from_ids; entry_item != nullptr; - entry_item = entry_item->next) { - if (entry_item->usage_flag & - (IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE | IDWALK_CB_LOOPBACK)) { + entry_item = entry_item->next) + { + if (entry_item->usage_flag & (IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE | IDWALK_CB_LOOPBACK)) + { continue; } @@ -2341,11 +2400,18 @@ static bool lib_override_resync_tagging_finalize_recurse( /* Check if this ID has an override hierarchy ancestor already tagged for resync. */ if (id_from != id && ID_IS_OVERRIDE_LIBRARY_REAL(id_from) && id_from->lib == id->lib && - id_from->override_library->hierarchy_root == id->override_library->hierarchy_root) { + id_from->override_library->hierarchy_root == id->override_library->hierarchy_root) + { const bool is_ancestor_tagged_for_resync_prev = is_ancestor_tagged_for_resync; is_ancestor_tagged_for_resync |= lib_override_resync_tagging_finalize_recurse( bmain, id_from, id_roots, library_indirect_level, check_only); + /* If at least one parent is not cut from root, then this liboverride is not either. */ + if ((id_from->override_library->runtime->tag & LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT) == + 0) { + id->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT; + } + if (!check_only && is_ancestor_tagged_for_resync && !is_ancestor_tagged_for_resync_prev) { CLOG_INFO(&LOG, 4, @@ -2369,16 +2435,9 @@ static bool lib_override_resync_tagging_finalize_recurse( if (is_ancestor_tagged_for_resync) { /* If a tagged-for-resync ancestor was found, this id is not a resync sub-tree root, but it is * part of one, and therefore needs to be tagged for resync too. */ - id->tag |= LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + id->tag |= LIB_TAG_LIBOVERRIDE_NEED_RESYNC; } - else if (id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) { - CLOG_INFO(&LOG, - 4, - "ID %s (%p) is tagged as needing resync, but none of its override hierarchy " - "ancestors are tagged for resync, so it is a partial resync root", - id->name, - id->lib); - + else if (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) { /* If no tagged-for-resync ancestor was found, but this id is tagged for resync, then it is a * root of a resync sub-tree. Find the root of the whole override hierarchy and add this ID as * one of its resync sub-tree roots. */ @@ -2389,12 +2448,42 @@ static bool lib_override_resync_tagging_finalize_recurse( BLI_assert(id_root->override_library != nullptr); - LinkNodePair **id_resync_roots_p; - if (!BLI_ghash_ensure_p(id_roots, id_root, reinterpret_cast(&id_resync_roots_p))) { - *id_resync_roots_p = MEM_cnew(__func__); + /* This address a very intricated case. It can happen that the current (non-hierarchy root) + * override is not currently part of any liboverride hierarchy (it lost its parent(s) in it). + * + * For example, an object may have been moved from one sub-collection to another in the + * library. In such cases, its override in the local file will not be part of any liboverride + * collections of its hierarchy (the old one lost it, and since there has been no resync yet, + * its new liboverride collection currently uses its linked reference). + * + * Proper exact handling of such case is not obvious, for now simply consider it as needing + * tagging, and that it had a not-yet-known ancestor also tagged for resync, i.e. it is not a + * valid partial resync root. */ + if ((id->override_library->runtime->tag & LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT) != 0) { + BLI_assert(id != id_root); + CLOG_INFO(&LOG, + 3, + "ID %s (%p) is tagged as needing resync, but is cut from its hierarchy root ID %s " + "in its current override hierarchy. This could be the sign of a deleted or moved " + "around linked data, do not consider it as a partial resync root.", + id->name, + id->lib, + id_root->name); } + else { + CLOG_INFO(&LOG, + 3, + "ID %s (%p) is tagged as needing resync, but none of its override hierarchy " + "ancestors are tagged for resync, so it is a partial resync root", + id->name, + id->lib); - BLI_linklist_append(*id_resync_roots_p, id); + LinkNodePair **id_resync_roots_p; + if (!BLI_ghash_ensure_p(id_roots, id_root, reinterpret_cast(&id_resync_roots_p))) { + *id_resync_roots_p = MEM_cnew(__func__); + } + BLI_linklist_append(*id_resync_roots_p, id); + } is_ancestor_tagged_for_resync = true; } @@ -2418,9 +2507,9 @@ static bool lib_override_library_main_resync_id_skip_check(ID *id, return true; } - if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) { + if (id->override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) { /* This ID is not part of an override hierarchy. */ - BLI_assert((id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0); + BLI_assert((id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) == 0); return true; } @@ -2429,7 +2518,8 @@ static bool lib_override_library_main_resync_id_skip_check(ID *id, ID *hierarchy_root = id->override_library->hierarchy_root; if (hierarchy_root == nullptr || ((hierarchy_root->tag | hierarchy_root->override_library->reference->tag) & - LIB_TAG_MISSING) != 0) { + LIB_TAG_MISSING) != 0) + { return true; } @@ -2500,10 +2590,8 @@ static void lib_override_library_main_resync_on_library_indirect_level( continue; } - if (id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) { + if (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) { CLOG_INFO(&LOG, 4, "ID %s (%p) was already tagged as needing resync", id->name, id->lib); - lib_override_resync_tagging_finalize_recurse( - bmain, id, id_roots, library_indirect_level, false); continue; } @@ -2512,7 +2600,8 @@ static void lib_override_library_main_resync_on_library_indirect_level( BLI_assert(entry != nullptr); for (MainIDRelationsEntryItem *entry_item = entry->to_ids; entry_item != nullptr; - entry_item = entry_item->next) { + entry_item = entry_item->next) + { if (entry_item->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) { continue; } @@ -2520,7 +2609,6 @@ static void lib_override_library_main_resync_on_library_indirect_level( /* Case where this ID pointer was to a linked ID, that now needs to be overridden. */ if (ID_IS_LINKED(id_to) && (id_to->lib != id->lib) && (id_to->tag & LIB_TAG_DOIT) != 0) { - id->tag |= LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; CLOG_INFO(&LOG, 3, "ID %s (%p) now tagged as needing resync because they use linked %s (%p) that " @@ -2529,14 +2617,31 @@ static void lib_override_library_main_resync_on_library_indirect_level( id->lib, id_to->name, id_to->lib); - lib_override_resync_tagging_finalize_recurse( - bmain, id, id_roots, library_indirect_level, false); + id->tag |= LIB_TAG_LIBOVERRIDE_NEED_RESYNC; break; } } } FOREACH_MAIN_ID_END; + /* Handling hierarchy relations for final tagging needs to happen after all IDs in a given + * hierarchy have been tagged for resync in previous loop above. Otherwise, some resync roots may + * be missing, and other may be created that are not actually needed (when a liboverride is + * tagged for resync after being checked in #lib_override_resync_tagging_finalize_recurse as part + * of the parent hierarchy of another liboverride e.g.). */ + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (lib_override_library_main_resync_id_skip_check(id, library_indirect_level)) { + continue; + } + + if (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) { + lib_override_resync_tagging_finalize_recurse( + bmain, id, id_roots, library_indirect_level, false); + continue; + } + } + FOREACH_MAIN_ID_END; + #ifndef NDEBUG /* Check for validity/integrity of the computed set of root IDs, and their sub-branches defined * by their resync root IDs. */ @@ -2549,23 +2654,53 @@ static void lib_override_library_main_resync_on_library_indirect_level( BLI_ghashIterator_getValue(id_roots_iter)); CLOG_INFO( &LOG, 2, "Checking validity of computed TODO data for root '%s'... \n", id_root->name); + + if (id_root->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) { + LinkNode *id_resync_root_iter = id_resync_roots->list; + ID *id_resync_root = static_cast(id_resync_root_iter->link); + + if (id_resync_roots->list != id_resync_roots->last_node || id_resync_root != id_root) { + CLOG_ERROR(&LOG, + "Hierarchy root ID is tagged for resync, yet it is not the only partial " + "resync roots, this should not happen." + "\n\tRoot ID: %s" + "\n\tFirst Resync root ID: %s" + "\n\tLast Resync root ID: %s", + id_root->name, + static_cast(id_resync_roots->list->link)->name, + static_cast(id_resync_roots->last_node->link)->name); + } + } for (LinkNode *id_resync_root_iter = id_resync_roots->list; id_resync_root_iter != nullptr; - id_resync_root_iter = id_resync_root_iter->next) { + id_resync_root_iter = id_resync_root_iter->next) + { ID *id_resync_root = static_cast(id_resync_root_iter->link); BLI_assert(id_resync_root == id_root || !BLI_ghash_haskey(id_roots, id_resync_root)); if (id_resync_root == id_root) { - BLI_assert(id_resync_root_iter == id_resync_roots->list && - id_resync_root_iter == id_resync_roots->last_node); + if (id_resync_root_iter != id_resync_roots->list || + id_resync_root_iter != id_resync_roots->last_node) + { + CLOG_ERROR(&LOG, + "Resync root ID is same as root ID of the override hierarchy, yet other " + "resync root IDs are also defined, this should not happen at this point." + "\n\tRoot ID: %s" + "\n\tFirst Resync root ID: %s" + "\n\tLast Resync root ID: %s", + id_root->name, + static_cast(id_resync_roots->list->link)->name, + static_cast(id_resync_roots->last_node->link)->name); + } } if (lib_override_resync_tagging_finalize_recurse( - bmain, id_resync_root, id_roots, library_indirect_level, true)) { - CLOG_WARN(&LOG, - "Resync root ID still has ancestors tagged for resync, this should not happen " - "at this point." - "\n\tRoot ID: %s" - "\n\tResync root ID: %s", - id_root->name, - id_resync_root->name); + bmain, id_resync_root, id_roots, library_indirect_level, true)) + { + CLOG_ERROR(&LOG, + "Resync root ID still has ancestors tagged for resync, this should not " + "happen at this point." + "\n\tRoot ID: %s" + "\n\tResync root ID: %s", + id_root->name, + id_resync_root->name); } } BLI_ghashIterator_step(id_roots_iter); @@ -2610,7 +2745,8 @@ static void lib_override_library_main_resync_on_library_indirect_level( if (success) { reports->count.resynced_lib_overrides++; if (library_indirect_level > 0 && reports->do_resynced_lib_overrides_libraries_list && - BLI_linklist_index(reports->resynced_lib_overrides_libraries, library) < 0) { + BLI_linklist_index(reports->resynced_lib_overrides_libraries, library) < 0) + { BLI_linklist_prepend(&reports->resynced_lib_overrides_libraries, library); reports->resynced_lib_overrides_libraries_count++; } @@ -2626,33 +2762,72 @@ static void lib_override_library_main_resync_on_library_indirect_level( } BLI_listbase_clear(&no_main_ids_list); + /* Just in case, should not be needed in theory, since #lib_override_library_resync should have + * already cleared them all. */ + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + /* Check there are no left-over IDs needing resync from the current (or higher) level of indirect * library level. */ FOREACH_MAIN_ID_BEGIN (bmain, id) { - if (!ID_IS_OVERRIDE_LIBRARY(id)) { - continue; - } - /* Do not attempt to resync to/from missing data. */ - if (((id->tag | (ID_IS_OVERRIDE_LIBRARY_REAL(id) ? id->override_library->reference->tag : 0)) & - LIB_TAG_MISSING) != 0) { + if (lib_override_library_main_resync_id_skip_check(id, library_indirect_level)) { continue; } - const bool is_valid_tagged_need_resync = ((id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0 || - lib_override_resync_id_lib_level_is_valid( - id, library_indirect_level - 1, false)); - if (!is_valid_tagged_need_resync) { + const bool need_resync = (id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) != 0; + const bool is_isolated_from_root = (id->override_library->runtime != nullptr && + (id->override_library->runtime->tag & + LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT) != 0); + + if (need_resync && is_isolated_from_root) { + if (!BKE_lib_override_library_is_user_edited(id)) { + CLOG_WARN( + &LOG, + "Deleting unused ID override %s from library level %d, still found as needing " + "resync, and being isolated from its hierarchy root. This can happen when its " + "otherwise unchanged linked reference was moved around in the library file (e.g. if " + "an object was moved into another sub-collection of the same hierarchy).", + id->name, + ID_IS_LINKED(id) ? id->lib->temp_index : 0); + id->tag |= LIB_TAG_DOIT; + } + else { + CLOG_WARN( + &LOG, + "Keeping user-edited ID override %s from library level %d still found as " + "needing resync, and being isolated from its hierarchy root. This can happen when its " + "otherwise unchanged linked reference was moved around in the library file (e.g. if " + "an object was moved into another sub-collection of the same hierarchy).", + id->name, + ID_IS_LINKED(id) ? id->lib->temp_index : 0); + id->tag &= ~LIB_TAG_LIBOVERRIDE_NEED_RESYNC; + id->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT; + } + } + else if (need_resync) { CLOG_ERROR(&LOG, "ID override %s from library level %d still found as needing resync, when all " "IDs from that level should have been processed after tackling library level %d", id->name, ID_IS_LINKED(id) ? id->lib->temp_index : 0, library_indirect_level); - id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + id->tag &= ~LIB_TAG_LIBOVERRIDE_NEED_RESYNC; + } + else if (is_isolated_from_root) { + CLOG_ERROR( + &LOG, + "ID override %s from library level %d still tagged as isolated from its hierarchy root, " + "it should have been either properly resynced or removed at that point.", + id->name, + ID_IS_LINKED(id) ? id->lib->temp_index : 0); + id->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT; } } FOREACH_MAIN_ID_END; + /* Delete 'isolated from root' remaining IDs tagged in above check loop. */ + BKE_id_multi_tagged_delete(bmain); + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + BLI_ghash_free(id_roots, nullptr, MEM_freeN); /* In some fairly rare (and degenerate) cases, some root ID from other liboverrides may have been @@ -2881,26 +3056,18 @@ void BKE_lib_override_library_make_local(ID *id) } } -BLI_INLINE IDOverrideLibraryRuntime *override_library_rna_path_runtime_ensure( - IDOverrideLibrary *override) -{ - if (override->runtime == nullptr) { - override->runtime = MEM_cnew(__func__); - } - return override->runtime; -} - /* We only build override GHash on request. */ BLI_INLINE GHash *override_library_rna_path_mapping_ensure(IDOverrideLibrary *override) { - IDOverrideLibraryRuntime *override_runtime = override_library_rna_path_runtime_ensure(override); + IDOverrideLibraryRuntime *override_runtime = override_library_runtime_ensure(override); if (override_runtime->rna_path_to_override_properties == nullptr) { override_runtime->rna_path_to_override_properties = BLI_ghash_new( BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__); for (IDOverrideLibraryProperty *op = static_cast(override->properties.first); op != nullptr; - op = op->next) { + op = op->next) + { BLI_ghash_insert(override_runtime->rna_path_to_override_properties, op->rna_path, op); } } @@ -2961,7 +3128,8 @@ void lib_override_library_property_copy(IDOverrideLibraryProperty *op_dst, opop_dst = static_cast(op_dst->operations.first), *opop_src = static_cast(op_src->operations.first); opop_dst; - opop_dst = opop_dst->next, opop_src = opop_src->next) { + opop_dst = opop_dst->next, opop_src = opop_src->next) + { lib_override_library_property_operation_copy(opop_dst, opop_src); } } @@ -3049,7 +3217,8 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_ &override_property->operations, &subitem_locindex, sizeof(subitem_locindex), - offsetof(IDOverrideLibraryPropertyOperation, subitem_local_index))))) { + offsetof(IDOverrideLibraryPropertyOperation, subitem_local_index))))) + { return ELEM(subitem_refindex, -1, opop->subitem_reference_index) ? opop : nullptr; } @@ -3057,7 +3226,8 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_ &override_property->operations, &subitem_refindex, sizeof(subitem_refindex), - offsetof(IDOverrideLibraryPropertyOperation, subitem_reference_index))))) { + offsetof(IDOverrideLibraryPropertyOperation, subitem_reference_index))))) + { return ELEM(subitem_locindex, -1, opop->subitem_local_index) ? opop : nullptr; } @@ -3068,7 +3238,8 @@ IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_ &override_property->operations, &subitem_defindex, sizeof(subitem_defindex), - offsetof(IDOverrideLibraryPropertyOperation, subitem_local_index))))) { + offsetof(IDOverrideLibraryPropertyOperation, subitem_local_index))))) + { if (r_strict) { *r_strict = false; } @@ -3162,25 +3333,26 @@ bool BKE_lib_override_library_property_operation_operands_validate( PropertyRNA *prop_storage) { switch (override_property_operation->operation) { - case IDOVERRIDE_LIBRARY_OP_NOOP: + case LIBOVERRIDE_OP_NOOP: return true; - case IDOVERRIDE_LIBRARY_OP_ADD: + case LIBOVERRIDE_OP_ADD: ATTR_FALLTHROUGH; - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: + case LIBOVERRIDE_OP_SUBTRACT: ATTR_FALLTHROUGH; - case IDOVERRIDE_LIBRARY_OP_MULTIPLY: + case LIBOVERRIDE_OP_MULTIPLY: if (ptr_storage == nullptr || ptr_storage->data == nullptr || prop_storage == nullptr) { BLI_assert_msg(0, "Missing data to apply differential override operation."); return false; } ATTR_FALLTHROUGH; - case IDOVERRIDE_LIBRARY_OP_INSERT_AFTER: + case LIBOVERRIDE_OP_INSERT_AFTER: ATTR_FALLTHROUGH; - case IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE: + case LIBOVERRIDE_OP_INSERT_BEFORE: ATTR_FALLTHROUGH; - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: if ((ptr_dst == nullptr || ptr_dst->data == nullptr || prop_dst == nullptr) || - (ptr_src == nullptr || ptr_src->data == nullptr || prop_src == nullptr)) { + (ptr_src == nullptr || ptr_src->data == nullptr || prop_src == nullptr)) + { BLI_assert_msg(0, "Missing data to apply override operation."); return false; } @@ -3276,8 +3448,9 @@ bool BKE_lib_override_library_status_check_local(Main *bmain, ID *local) local->override_library, (eRNAOverrideMatch)(RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE | RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN), - nullptr)) { - local->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK; + nullptr)) + { + local->tag &= ~LIB_TAG_LIBOVERRIDE_REFOK; return false; } @@ -3297,12 +3470,12 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local) BLI_assert(GS(local->name) == GS(reference->name)); - if (reference->override_library && (reference->tag & LIB_TAG_OVERRIDE_LIBRARY_REFOK) == 0) { + if (reference->override_library && (reference->tag & LIB_TAG_LIBOVERRIDE_REFOK) == 0) { if (!BKE_lib_override_library_status_check_reference(bmain, reference)) { /* If reference is also an override of another data-block, and its status is not OK, * then this override is not OK either. * Note that this should only happen when reloading libraries. */ - local->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK; + local->tag &= ~LIB_TAG_LIBOVERRIDE_REFOK; return false; } } @@ -3332,8 +3505,9 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local) 0, local->override_library, RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, - nullptr)) { - local->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_REFOK; + nullptr)) + { + local->tag &= ~LIB_TAG_LIBOVERRIDE_REFOK; return false; } @@ -3417,8 +3591,9 @@ void BKE_lib_override_library_operations_create(Main *bmain, ID *local, int *r_r void BKE_lib_override_library_operations_restore(Main *bmain, ID *local, int *r_report_flags) { - if (!ID_IS_OVERRIDE_LIBRARY_REAL(local) || (local->override_library->runtime->tag & - IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE) == 0) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(local) || + (local->override_library->runtime->tag & LIBOVERRIDE_TAG_NEEDS_RESTORE) == 0) + { return; } @@ -3434,11 +3609,11 @@ void BKE_lib_override_library_operations_restore(Main *bmain, ID *local, int *r_ static_cast(RNA_OVERRIDE_APPLY_FLAG_SKIP_RESYNC_CHECK | RNA_OVERRIDE_APPLY_FLAG_RESTORE_ONLY)); - LISTBASE_FOREACH_MUTABLE ( - IDOverrideLibraryProperty *, op, &local->override_library->properties) { - if (op->tag & IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) { + LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryProperty *, op, &local->override_library->properties) + { + if (op->tag & LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->tag & IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) { + if (opop->tag & LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) { BKE_lib_override_library_property_operation_delete(op, opop); } } @@ -3446,12 +3621,11 @@ void BKE_lib_override_library_operations_restore(Main *bmain, ID *local, int *r_ BKE_lib_override_library_property_delete(local->override_library, op); } else { - BKE_lib_override_library_operations_tag( - op, IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE, false); + BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_TAG_NEEDS_RETORE, false); } } } - local->override_library->runtime->tag &= ~IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE; + local->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_NEEDS_RESTORE; if (r_report_flags != nullptr) { *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_RESTORED; @@ -3493,7 +3667,7 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, /* When force-auto is set, we also remove all unused existing override properties & operations. */ if (force_auto) { - BKE_lib_override_library_main_tag(bmain, IDOVERRIDE_LIBRARY_TAG_UNUSED, true); + BKE_lib_override_library_main_tag(bmain, LIBOVERRIDE_PROP_OP_TAG_UNUSED, true); } /* Usual pose bones issue, need to be done outside of the threaded process or we may run into @@ -3514,7 +3688,8 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, FOREACH_MAIN_ID_BEGIN (bmain, id) { if (!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY_REAL(id) && - (force_auto || (id->tag & LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH))) { + (force_auto || (id->tag & LIB_TAG_LIBOVERRIDE_AUTOREFRESH))) + { /* Usual issue with pose, it's quiet rare but sometimes they may not be up to date when this * function is called. */ if (GS(id->name) == ID_OB) { @@ -3532,16 +3707,16 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, } else { BKE_lib_override_library_properties_tag( - id->override_library, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + id->override_library, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); } } else { /* Clear 'unused' tag for un-processed IDs, otherwise e.g. linked overrides will loose their * list of overridden properties. */ BKE_lib_override_library_properties_tag( - id->override_library, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + id->override_library, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); } - id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + id->tag &= ~LIB_TAG_LIBOVERRIDE_AUTOREFRESH; } FOREACH_MAIN_ID_END; @@ -3575,8 +3750,8 @@ void BKE_lib_override_library_main_operations_restore(Main *bmain, int *r_report FOREACH_MAIN_ID_BEGIN (bmain, id) { if (!(!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY_REAL(id) && - (id->override_library->runtime->tag & IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE) != - 0)) { + (id->override_library->runtime->tag & LIBOVERRIDE_TAG_NEEDS_RESTORE) != 0)) + { continue; } @@ -3598,7 +3773,7 @@ static bool lib_override_library_id_reset_do(Main *bmain, bool was_op_deleted = false; if (do_reset_system_override) { - id_root->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id_root->override_library->flag |= LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } LISTBASE_FOREACH_MUTABLE ( @@ -3648,9 +3823,9 @@ static bool lib_override_library_id_reset_do(Main *bmain, if (was_op_deleted) { DEG_id_tag_update_ex(bmain, id_root, ID_RECALC_COPY_ON_WRITE); - IDOverrideLibraryRuntime *override_runtime = override_library_rna_path_runtime_ensure( + IDOverrideLibraryRuntime *override_runtime = override_library_runtime_ensure( id_root->override_library); - override_runtime->tag |= IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD; + override_runtime->tag |= LIBOVERRIDE_TAG_NEEDS_RELOAD; } return was_op_deleted; @@ -3666,10 +3841,10 @@ void BKE_lib_override_library_id_reset(Main *bmain, if (lib_override_library_id_reset_do(bmain, id_root, do_reset_system_override)) { if (id_root->override_library->runtime != nullptr && - (id_root->override_library->runtime->tag & IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD) != - 0) { + (id_root->override_library->runtime->tag & LIBOVERRIDE_TAG_NEEDS_RELOAD) != 0) + { BKE_lib_override_library_update(bmain, id_root); - id_root->override_library->runtime->tag &= ~IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD; + id_root->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_NEEDS_RELOAD; } } } @@ -3702,7 +3877,8 @@ static void lib_override_library_id_hierarchy_recursive_reset(Main *bmain, entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != nullptr; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) { /* Never consider non-overridable relationships ('from', 'parents', 'owner' etc. pointers) as * actual dependencies. */ @@ -3731,11 +3907,12 @@ void BKE_lib_override_library_id_hierarchy_reset(Main *bmain, ID *id; FOREACH_MAIN_ID_BEGIN (bmain, id) { if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || id->override_library->runtime == nullptr || - (id->override_library->runtime->tag & IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD) == 0) { + (id->override_library->runtime->tag & LIBOVERRIDE_TAG_NEEDS_RELOAD) == 0) + { continue; } BKE_lib_override_library_update(bmain, id); - id->override_library->runtime->tag &= ~IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD; + id->override_library->runtime->tag &= ~LIBOVERRIDE_TAG_NEEDS_RELOAD; } FOREACH_MAIN_ID_END; } @@ -3791,12 +3968,12 @@ void BKE_lib_override_library_id_unused_cleanup(ID *local) if (ID_IS_OVERRIDE_LIBRARY_REAL(local)) { LISTBASE_FOREACH_MUTABLE ( IDOverrideLibraryProperty *, op, &local->override_library->properties) { - if (op->tag & IDOVERRIDE_LIBRARY_TAG_UNUSED) { + if (op->tag & LIBOVERRIDE_PROP_OP_TAG_UNUSED) { BKE_lib_override_library_property_delete(local->override_library, op); } else { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->tag & IDOVERRIDE_LIBRARY_TAG_UNUSED) { + if (opop->tag & LIBOVERRIDE_PROP_OP_TAG_UNUSED) { BKE_lib_override_library_property_operation_delete(op, opop); } } @@ -3822,7 +3999,7 @@ static void lib_override_id_swap(Main *bmain, ID *id_local, ID *id_temp) BKE_lib_id_swap(bmain, id_local, id_temp, true, 0); /* We need to keep these tags from temp ID into orig one. * ID swap does not swap most of ID data itself. */ - id_local->tag |= (id_temp->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC); + id_local->tag |= (id_temp->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC); } void BKE_lib_override_library_update(Main *bmain, ID *local) @@ -3840,7 +4017,8 @@ void BKE_lib_override_library_update(Main *bmain, ID *local) /* Recursively do 'ancestor' overrides first, if any. */ if (local->override_library->reference->override_library && - (local->override_library->reference->tag & LIB_TAG_OVERRIDE_LIBRARY_REFOK) == 0) { + (local->override_library->reference->tag & LIB_TAG_LIBOVERRIDE_REFOK) == 0) + { BKE_lib_override_library_update(bmain, local->override_library->reference); } @@ -3951,7 +4129,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local) local->override_library->storage = nullptr; } - local->tag |= LIB_TAG_OVERRIDE_LIBRARY_REFOK; + local->tag |= LIB_TAG_LIBOVERRIDE_REFOK; /* NOTE: Since we reload full content from linked ID here, potentially from edited local * override, we do not really have a way to know *what* is changed, so we need to rely on the diff --git a/source/blender/blenkernel/intern/lib_override_proxy_conversion.c b/source/blender/blenkernel/intern/lib_override_proxy_conversion.c index 00afadc23a2..e247b05542b 100644 --- a/source/blender/blenkernel/intern/lib_override_proxy_conversion.c +++ b/source/blender/blenkernel/intern/lib_override_proxy_conversion.c @@ -63,7 +63,7 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain, ob_proxy->proxy->id.tag |= LIB_TAG_DOIT; ob_proxy->proxy->id.newid = &ob_proxy->id; BKE_lib_override_library_init(&ob_proxy->id, &ob_proxy->proxy->id); - ob_proxy->id.override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + ob_proxy->id.override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; ob_proxy->proxy->proxy_from = NULL; ob_proxy->proxy = ob_proxy->proxy_group = NULL; @@ -130,7 +130,8 @@ void BKE_lib_override_library_main_proxy_convert(Main *bmain, BlendFileReadRepor FOREACH_SCENE_OBJECT_END; for (LinkNode *proxy_object_iter = proxy_objects.list; proxy_object_iter != NULL; - proxy_object_iter = proxy_object_iter->next) { + proxy_object_iter = proxy_object_iter->next) + { Object *proxy_object = proxy_object_iter->link; lib_override_library_proxy_convert_do(bmain, scene, proxy_object, reports); } diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c index 30c25e3be93..3f0a1ceba24 100644 --- a/source/blender/blenkernel/intern/lib_query.c +++ b/source/blender/blenkernel/intern/lib_query.c @@ -174,7 +174,8 @@ void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp) } else { if (!library_foreach_ID_link( - data->bmain, data->owner_id, id, data->callback, data->user_data, data->flag, data)) { + data->bmain, data->owner_id, id, data->callback, data->user_data, data->flag, data)) + { data->status |= IDWALK_STOP; return; } @@ -280,7 +281,8 @@ static bool library_foreach_ID_link(Main *bmain, if (bmain != NULL && bmain->relations != NULL && (flag & IDWALK_READONLY) && (flag & (IDWALK_DO_INTERNAL_RUNTIME_POINTERS | IDWALK_DO_LIBRARY_POINTER)) == 0 && (((bmain->relations->flag & MAINIDRELATIONS_INCLUDE_UI) == 0) == - ((data.flag & IDWALK_INCLUDE_UI) == 0))) { + ((data.flag & IDWALK_INCLUDE_UI) == 0))) + { /* Note that this is minor optimization, even in worst cases (like id being an object with * lots of drivers and constraints and modifiers, or material etc. with huge node tree), * but we might as well use it (Main->relations is always assumed valid, @@ -289,7 +291,8 @@ static bool library_foreach_ID_link(Main *bmain, MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id); for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { BKE_lib_query_foreachid_process( &data, to_id_entry->id_pointer.to, to_id_entry->usage_flag); if (BKE_lib_query_foreachid_iter_stop(&data)) { @@ -718,9 +721,11 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain, * ID reaching this point of the function can be tagged. */ id->tag |= tag; for (MainIDRelationsEntryItem *id_from_item = id_relations->from_ids; id_from_item != NULL; - id_from_item = id_from_item->next) { + id_from_item = id_from_item->next) + { if ((id_from_item->usage_flag & ignored_usages) != 0 || - (id_from_item->usage_flag & required_usages) == 0) { + (id_from_item->usage_flag & required_usages) == 0) + { continue; } diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c index fe41803cc43..2f791aa484b 100644 --- a/source/blender/blenkernel/intern/lib_remap.c +++ b/source/blender/blenkernel/intern/lib_remap.c @@ -214,7 +214,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) /* Exit, when no modifications will be done; ensuring id->runtime counters won't changed. */ if (ELEM(expected_mapping_result, ID_REMAP_RESULT_SOURCE_UNAVAILABLE, - ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE)) { + ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE)) + { BLI_assert_msg(id_remap_data->type == ID_REMAP_TYPE_REMAP, "Cleanup should always do unassign."); return IDWALK_RET_NOP; @@ -260,7 +261,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) if ((violates_never_null && skip_never_null) || (is_obj_editmode && (((Object *)id_owner)->data == *id_p) && (expected_mapping_result == ID_REMAP_RESULT_SOURCE_REMAPPED)) || - (skip_indirect && is_indirect) || (is_reference && skip_reference)) { + (skip_indirect && is_indirect) || (is_reference && skip_reference)) + { foreach_libblock_remap_callback_skip(id_owner, id_p, cb_flag, @@ -432,7 +434,8 @@ static void libblock_remap_data_update_tags(ID *old_id, ID *new_id, void *user_d } if (new_id != NULL && (new_id->tag & LIB_TAG_INDIRECT) && - (new_id->runtime.remap.status & ID_REMAP_IS_LINKED_DIRECT)) { + (new_id->runtime.remap.status & ID_REMAP_IS_LINKED_DIRECT)) + { new_id->tag &= ~LIB_TAG_INDIRECT; new_id->flag &= ~LIB_INDIRECT_WEAK_LINK; new_id->tag |= LIB_TAG_EXTERN; @@ -562,7 +565,8 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ * count has actually been incremented for that, we have to decrease once more its user * count... unless we had to skip some 'user_one' cases. */ if ((old_id->tag & LIB_TAG_EXTRAUSER_SET) && - !(old_id->runtime.remap.status & ID_REMAP_IS_USER_ONE_SKIPPED)) { + !(old_id->runtime.remap.status & ID_REMAP_IS_USER_ONE_SKIPPED)) + { id_us_clear_real(old_id); } } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 7cb28f14f9e..c883f8747e1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -62,8 +62,8 @@ static void library_foreach_path(ID *id, BPathForeachPathData *bpath_data) /* FIXME: Find if we should respect #BKE_BPATH_FOREACH_PATH_SKIP_PACKED here, and if not, explain * why. */ - if (lib->packedfile != - NULL /*&& (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_PACKED) != 0 */) { + if (lib->packedfile != NULL /*&& (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_PACKED) != 0 */) + { return; } diff --git a/source/blender/blenkernel/intern/lightprobe.cc b/source/blender/blenkernel/intern/lightprobe.cc index 48e8449dd7d..f3e9f4a2118 100644 --- a/source/blender/blenkernel/intern/lightprobe.cc +++ b/source/blender/blenkernel/intern/lightprobe.cc @@ -156,9 +156,9 @@ static void lightprobe_grid_cache_frame_blend_write(BlendWriter *writer, static void lightprobe_grid_cache_frame_blend_read(BlendDataReader *reader, LightProbeGridCacheFrame *cache) { - if (!ELEM(cache->data_layout, - LIGHTPROBE_CACHE_ADAPTIVE_RESOLUTION, - LIGHTPROBE_CACHE_UNIFORM_GRID)) { + if (!ELEM( + cache->data_layout, LIGHTPROBE_CACHE_ADAPTIVE_RESOLUTION, LIGHTPROBE_CACHE_UNIFORM_GRID)) + { /* Do not try to read data from incompatible layout. Clear all pointers. */ memset(cache, 0, sizeof(*cache)); return; diff --git a/source/blender/blenkernel/intern/linestyle.cc b/source/blender/blenkernel/intern/linestyle.cc index de5cd553928..2b29d44e3c4 100644 --- a/source/blender/blenkernel/intern/linestyle.cc +++ b/source/blender/blenkernel/intern/linestyle.cc @@ -79,28 +79,32 @@ static void linestyle_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const BLI_listbase_clear(&linestyle_dst->color_modifiers); for (linestyle_modifier = (LineStyleModifier *)linestyle_src->color_modifiers.first; linestyle_modifier; - linestyle_modifier = linestyle_modifier->next) { + linestyle_modifier = linestyle_modifier->next) + { BKE_linestyle_color_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata); } BLI_listbase_clear(&linestyle_dst->alpha_modifiers); for (linestyle_modifier = (LineStyleModifier *)linestyle_src->alpha_modifiers.first; linestyle_modifier; - linestyle_modifier = linestyle_modifier->next) { + linestyle_modifier = linestyle_modifier->next) + { BKE_linestyle_alpha_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata); } BLI_listbase_clear(&linestyle_dst->thickness_modifiers); for (linestyle_modifier = (LineStyleModifier *)linestyle_src->thickness_modifiers.first; linestyle_modifier; - linestyle_modifier = linestyle_modifier->next) { + linestyle_modifier = linestyle_modifier->next) + { BKE_linestyle_thickness_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata); } BLI_listbase_clear(&linestyle_dst->geometry_modifiers); for (linestyle_modifier = (LineStyleModifier *)linestyle_src->geometry_modifiers.first; linestyle_modifier; - linestyle_modifier = linestyle_modifier->next) { + linestyle_modifier = linestyle_modifier->next) + { BKE_linestyle_geometry_modifier_copy(linestyle_dst, linestyle_modifier, flag_subdata); } } @@ -2010,8 +2014,8 @@ bool BKE_linestyle_use_textures(FreestyleLineStyle *linestyle, const bool use_sh if (linestyle && linestyle->use_nodes && linestyle->nodetree) { bNode *node; - for (node = static_cast(linestyle->nodetree->nodes.first); node; - node = node->next) { + for (node = static_cast(linestyle->nodetree->nodes.first); node; node = node->next) + { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { return true; } diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 6c5afa683fa..ab01dd36566 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -333,7 +333,8 @@ void BKE_main_relations_tag_set(struct Main *bmain, GHashIterator *gh_iter; for (gh_iter = BLI_ghashIterator_new(bmain->relations->relations_from_pointers); !BLI_ghashIterator_done(gh_iter); - BLI_ghashIterator_step(gh_iter)) { + BLI_ghashIterator_step(gh_iter)) + { MainIDRelationsEntry *entry = BLI_ghashIterator_getValue(gh_iter); if (value) { entry->tags |= tag; diff --git a/source/blender/blenkernel/intern/main_namemap.cc b/source/blender/blenkernel/intern/main_namemap.cc index 85f4c813dc7..b37eaac057e 100644 --- a/source/blender/blenkernel/intern/main_namemap.cc +++ b/source/blender/blenkernel/intern/main_namemap.cc @@ -203,7 +203,8 @@ void BKE_main_namemap_clear(Main *bmain) } for (Library *lib_iter = static_cast(bmain_iter->libraries.first); lib_iter != nullptr; - lib_iter = static_cast(lib_iter->id.next)) { + lib_iter = static_cast(lib_iter->id.next)) + { if (lib_iter->runtime.name_map != nullptr) { BKE_main_namemap_destroy(&lib_iter->runtime.name_map); } @@ -233,7 +234,7 @@ static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain, /* Get the name and number parts ("name.number"). */ int number = MIN_NUMBER; - BLI_split_name_num(key.name, &number, id->name + 2, '.'); + BLI_string_split_name_number(id->name + 2, '.', key.name, &number); /* Get and update the entry for this base name. */ UniqueName_Value &val = type_map->base_name_to_num_suffix.lookup_or_add_default(key); @@ -283,7 +284,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name) /* Get the name and number parts ("name.number"). */ int number = MIN_NUMBER; - size_t base_name_len = BLI_split_name_num(key.name, &number, name, '.'); + size_t base_name_len = BLI_string_split_name_number(name, '.', key.name, &number); bool added_new = false; UniqueName_Value &val = type_map->base_name_to_num_suffix.lookup_or_add_cb(key, [&]() { @@ -372,7 +373,7 @@ void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char type_map->full_names.remove(key); int number = MIN_NUMBER; - BLI_split_name_num(key.name, &number, name, '.'); + BLI_string_split_name_number(name, '.', key.name, &number); UniqueName_Value *val = type_map->base_name_to_num_suffix.lookup_ptr(key); if (val == nullptr) { return; @@ -460,7 +461,8 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix) if (name_map != nullptr) { int i = 0; for (short idcode = BKE_idtype_idcode_iter_step(&i); idcode != 0; - idcode = BKE_idtype_idcode_iter_step(&i)) { + idcode = BKE_idtype_idcode_iter_step(&i)) + { UniqueName_TypeMap *type_map = name_map->find_by_type(idcode); if (type_map != nullptr) { for (const UniqueName_Key &id_name : type_map->full_names) { diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 45ab6289c14..0179ef016fa 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -40,6 +40,8 @@ #include "DEG_depsgraph_build.h" +#include "DRW_engine.h" + #include "BLO_read_write.h" static CLG_LogRef LOG = {"bke.mask"}; @@ -57,6 +59,8 @@ static void mask_copy_data(Main *UNUSED(bmain), /* TODO: add unused flag to those as well. */ BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers); + BLI_listbase_clear((ListBase *)&mask_dst->drawdata); + /* enable fake user by default */ id_fake_user_set(&mask_dst->id); } @@ -67,6 +71,8 @@ static void mask_free_data(ID *id) /* free mask data */ BKE_mask_layer_free_list(&mask->masklayers); + + DRW_drawdata_free(id); } static void mask_foreach_id(ID *id, LibraryForeachIDData *data) @@ -123,7 +129,8 @@ static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address } for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { BLO_write_struct(writer, MaskLayerShape, masklay_shape); BLO_write_float_array( writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data); @@ -159,7 +166,8 @@ static void mask_blend_read_data(BlendDataReader *reader, ID *id) /* detect active point */ if ((act_point_search == NULL) && (masklay->act_point >= points_old) && - (masklay->act_point < points_old + spline->tot_point)) { + (masklay->act_point < points_old + spline->tot_point)) + { act_point_search = &spline->points[masklay->act_point - points_old]; } } @@ -324,7 +332,8 @@ MaskSplinePoint *BKE_mask_spline_point_array_from_point(MaskSpline *spline, } if ((point_ref >= spline->points_deform) && - (point_ref < &spline->points_deform[spline->tot_point])) { + (point_ref < &spline->points_deform[spline->tot_point])) + { return spline->points_deform; } @@ -426,7 +435,8 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay) } if (masklay->act_point >= spline->points && - masklay->act_point < spline->points + spline->tot_point) { + masklay->act_point < spline->points + spline->tot_point) + { const size_t point_index = masklay->act_point - spline->points; masklay_new->act_point = spline_new->points + point_index; } @@ -438,7 +448,8 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay) MaskLayerShape *masklay_shape_new; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { masklay_shape_new = MEM_callocN(sizeof(MaskLayerShape), "new mask layer shape"); masklay_shape_new->data = MEM_dupallocN(masklay_shape->data); @@ -568,7 +579,8 @@ void BKE_mask_spline_direction_switch(MaskLayer *masklay, MaskSpline *spline) const int spline_index = BKE_mask_layer_shape_spline_to_index(masklay, spline); for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { MaskLayerShapeElem *fp_arr = (MaskLayerShapeElem *)masklay_shape->data; for (i = 0; i < tot_point_half; i++) { @@ -605,7 +617,8 @@ float BKE_mask_spline_project_co(MaskSpline *spline, sub_v2_v2v2(v1, co, co1); if ((sign == MASK_PROJ_ANY) || ((sign == MASK_PROJ_NEG) && (dot_v2v2(v1, n1) <= 0.0f)) || - ((sign == MASK_PROJ_POS) && (dot_v2v2(v1, n1) >= 0.0f))) { + ((sign == MASK_PROJ_POS) && (dot_v2v2(v1, n1) >= 0.0f))) + { if (len_squared_v2(v1) > proj_eps_sq) { ang1 = angle_v2v2(v1, n1); @@ -631,7 +644,8 @@ float BKE_mask_spline_project_co(MaskSpline *spline, sub_v2_v2v2(v2, co, co2); if ((sign == MASK_PROJ_ANY) || ((sign == MASK_PROJ_NEG) && (dot_v2v2(v2, n2) <= 0.0f)) || - ((sign == MASK_PROJ_POS) && (dot_v2v2(v2, n2) >= 0.0f))) { + ((sign == MASK_PROJ_POS) && (dot_v2v2(v2, n2) >= 0.0f))) + { if (len_squared_v2(v2) > proj_eps_sq) { ang2 = angle_v2v2(v2, n2); @@ -1717,7 +1731,8 @@ MaskLayerShape *BKE_mask_layer_shape_find_frame(MaskLayer *masklay, const int fr MaskLayerShape *masklay_shape; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (frame == masklay_shape->frame) { return masklay_shape; } @@ -1737,7 +1752,8 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, MaskLayerShape *masklay_shape; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (frame == masklay_shape->frame) { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; @@ -1848,7 +1864,8 @@ int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline) MaskSpline *spline_iter; int i_abs = 0; for (spline_iter = masklay->splines.first; spline_iter && spline_iter != spline; - i_abs += spline_iter->tot_point, spline_iter = spline_iter->next) { + i_abs += spline_iter->tot_point, spline_iter = spline_iter->next) + { /* pass */ } @@ -1930,7 +1947,8 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, } for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (tot == masklay_shape->tot_vert) { float *data_resized; @@ -1993,7 +2011,8 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun int tot = BKE_mask_layer_shape_totvert(masklay); for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (tot == masklay_shape->tot_vert - count) { float *data_resized; diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index f71a0fe1d00..5adab377a13 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -844,7 +844,8 @@ void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime) MaskLayerShape *masklay_shape_b; int found; if ((found = BKE_mask_layer_shape_find_frame_range( - masklay, ctime, &masklay_shape_a, &masklay_shape_b))) { + masklay, ctime, &masklay_shape_a, &masklay_shape_b))) + { if (found == 1) { #if 0 printf("%s: exact %d %d (%d)\n", @@ -912,7 +913,8 @@ void BKE_mask_eval_animation(struct Depsgraph *depsgraph, Mask *mask) float ctime = DEG_get_ctime(depsgraph); DEG_debug_print_eval(depsgraph, __func__, mask->id.name, mask); for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL; - mask_layer = mask_layer->next) { + mask_layer = mask_layer->next) + { BKE_mask_layer_evaluate_animation(mask_layer, ctime); } } @@ -923,7 +925,8 @@ void BKE_mask_eval_update(struct Depsgraph *depsgraph, Mask *mask) float ctime = DEG_get_ctime(depsgraph); DEG_debug_print_eval(depsgraph, __func__, mask->id.name, mask); for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer != NULL; - mask_layer = mask_layer->next) { + mask_layer = mask_layer->next) + { BKE_mask_layer_evaluate_deform(mask_layer, ctime); } @@ -932,11 +935,13 @@ void BKE_mask_eval_update(struct Depsgraph *depsgraph, Mask *mask) for (MaskLayer *masklay_orig = mask_orig->masklayers.first, *masklay_eval = mask->masklayers.first; masklay_orig != NULL; - masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) { + masklay_orig = masklay_orig->next, masklay_eval = masklay_eval->next) + { for (MaskSpline *spline_orig = masklay_orig->splines.first, *spline_eval = masklay_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { for (int i = 0; i < spline_eval->tot_point; i++) { MaskSplinePoint *point_eval = &spline_eval->points[i]; MaskSplinePoint *point_orig = &spline_orig->points[i]; diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 97d51a0874e..ab022b2619c 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -346,7 +346,8 @@ static bool layer_bucket_isect_test(const MaskRasterLayer *layer, if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) || (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) || - (dist_squared_to_line_segment_v2(cent, v3, v1) < bucket_max_rad_squared)) { + (dist_squared_to_line_segment_v2(cent, v3, v1) < bucket_max_rad_squared)) + { return true; } @@ -369,7 +370,8 @@ static bool layer_bucket_isect_test(const MaskRasterLayer *layer, if ((dist_squared_to_line_segment_v2(cent, v1, v2) < bucket_max_rad_squared) || (dist_squared_to_line_segment_v2(cent, v2, v3) < bucket_max_rad_squared) || (dist_squared_to_line_segment_v2(cent, v3, v4) < bucket_max_rad_squared) || - (dist_squared_to_line_segment_v2(cent, v4, v1) < bucket_max_rad_squared)) { + (dist_squared_to_line_segment_v2(cent, v4, v1) < bucket_max_rad_squared)) + { return true; } @@ -510,7 +512,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) yi, bucket_size_x, bucket_size_y, - bucket_max_rad_squared)) { + bucket_max_rad_squared)) + { BLI_linklist_prepend_arena(&bucketstore[bucket_index], face_index_void, arena); bucketstore_tot[bucket_index]++; } @@ -581,7 +584,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); for (masklay = mask->masklayers.first, masklay_index = 0; masklay; - masklay = masklay->next, masklay_index++) { + masklay = masklay->next, masklay_index++) + { /* we need to store vertex ranges for open splines for filling */ uint tot_splines; @@ -937,7 +941,8 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, */ if ((masklay->flag & MASK_LAYERFLAG_FILL_OVERLAP) && (is_isect = BLI_scanfill_calc_self_isect( - &sf_ctx, &isect_remvertbase, &isect_remedgebase))) { + &sf_ctx, &isect_remvertbase, &isect_remedgebase))) + { uint sf_vert_tot_isect = (uint)BLI_listbase_count(&sf_ctx.fillvertbase); uint i = sf_vert_tot; @@ -1249,14 +1254,16 @@ static float maskrasterize_layer_isect(const uint *face, /* not essential but avoids unneeded extra lookups */ if ((cos[0][2] < dist_orig) || (cos[1][2] < dist_orig) || (cos[2][2] < dist_orig) || - (cos[3][2] < dist_orig)) { + (cos[3][2] < dist_orig)) + { /* needs work */ #if 1 /* quad check fails for bow-tie, so keep using 2 tri checks */ // if (isect_point_quad_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]])) if (isect_point_tri_v2(xy, cos[face[0]], cos[face[1]], cos[face[2]]) || - isect_point_tri_v2(xy, cos[face[0]], cos[face[2]], cos[face[3]])) { + isect_point_tri_v2(xy, cos[face[0]], cos[face[2]], cos[face[3]])) + { return maskrasterize_layer_z_depth_quad( xy, cos[face[0]], cos[face[1]], cos[face[2]], cos[face[3]]); } diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index fde5a40f765..6bcd3ad1313 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -1316,7 +1316,8 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob) const int actcol = ob->actcol; for (Object *obt = static_cast(bmain->objects.first); obt; - obt = static_cast(obt->id.next)) { + obt = static_cast(obt->id.next)) + { if (obt->data == ob->data) { /* Can happen when object material lists are used, see: #52953 */ if (actcol > obt->totcol) { @@ -1397,7 +1398,8 @@ static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree, const bool do_color_attributes = (slot_filter & PAINT_SLOT_COLOR_ATTRIBUTE) != 0; for (bNode *node : nodetree->all_nodes()) { if (do_image_nodes && node->typeinfo->nclass == NODE_CLASS_TEXTURE && - node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { + node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) + { if (!callback(node, userdata)) { return false; } @@ -1409,8 +1411,8 @@ static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree, } else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) { /* recurse into the node group and see if it contains any textures */ - if (!ntree_foreach_texnode_recursive( - (bNodeTree *)node->id, callback, userdata, slot_filter)) { + if (!ntree_foreach_texnode_recursive((bNodeTree *)node->id, callback, userdata, slot_filter)) + { return false; } } @@ -1576,7 +1578,8 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const struct Ob ma->paint_clone_slot != prev_paint_clone_slot || (ma->texpaintslot && prev_texpaintslot && memcmp(ma->texpaintslot, prev_texpaintslot, sizeof(*ma->texpaintslot) * ma->tot_slots) != - 0)) { + 0)) + { DEG_id_tag_update(&ma->id, ID_RECALC_SHADING | ID_RECALC_COPY_ON_WRITE); } diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc index f6222973a21..eed0c3ffa5f 100644 --- a/source/blender/blenkernel/intern/mball.cc +++ b/source/blender/blenkernel/intern/mball.cc @@ -305,8 +305,8 @@ bool BKE_mball_is_same_group(const Object *ob1, const Object *ob2) return false; } - BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); - BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); + BLI_string_split_name_number(ob1->id.name + 2, '.', basis1name, &basis1nr); + BLI_string_split_name_number(ob2->id.name + 2, '.', basis2name, &basis2nr); return STREQ(basis1name, basis2name); } @@ -377,7 +377,8 @@ void BKE_mball_properties_copy(Main *bmain, MetaBall *metaball_src) * think it would be worth it. */ for (Object *ob_src = static_cast(bmain->objects.first); - ob_src != nullptr && !ID_IS_LINKED(ob_src);) { + ob_src != nullptr && !ID_IS_LINKED(ob_src);) + { if (ob_src->data != metaball_src) { ob_src = static_cast(ob_src->id.next); continue; @@ -395,17 +396,18 @@ void BKE_mball_properties_copy(Main *bmain, MetaBall *metaball_src) Object *ob_iter = nullptr; int obactive_nr, ob_nr; char obactive_name[MAX_ID_NAME], ob_name[MAX_ID_NAME]; - BLI_split_name_num(obactive_name, &obactive_nr, ob_src->id.name + 2, '.'); + BLI_string_split_name_number(ob_src->id.name + 2, '.', obactive_name, &obactive_nr); for (ob_iter = static_cast(ob_src->id.prev); ob_iter != nullptr; - ob_iter = static_cast(ob_iter->id.prev)) { + ob_iter = static_cast(ob_iter->id.prev)) + { if (ob_iter->id.name[2] != obactive_name[0]) { break; } if (ob_iter->type != OB_MBALL || ob_iter->data == metaball_src) { continue; } - BLI_split_name_num(ob_name, &ob_nr, ob_iter->id.name + 2, '.'); + BLI_string_split_name_number(ob_iter->id.name + 2, '.', ob_name, &ob_nr); if (!STREQ(obactive_name, ob_name)) { break; } @@ -414,14 +416,15 @@ void BKE_mball_properties_copy(Main *bmain, MetaBall *metaball_src) } for (ob_iter = static_cast(ob_src->id.next); ob_iter != nullptr; - ob_iter = static_cast(ob_iter->id.next)) { + ob_iter = static_cast(ob_iter->id.next)) + { if (ob_iter->id.name[2] != obactive_name[0] || ID_IS_LINKED(ob_iter)) { break; } if (ob_iter->type != OB_MBALL || ob_iter->data == metaball_src) { continue; } - BLI_split_name_num(ob_name, &ob_nr, ob_iter->id.name + 2, '.'); + BLI_string_split_name_number(ob_iter->id.name + 2, '.', ob_name, &ob_nr); if (!STREQ(obactive_name, ob_name)) { break; } @@ -439,7 +442,7 @@ Object *BKE_mball_basis_find(Scene *scene, Object *object) int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; - BLI_split_name_num(basisname, &basisnr, object->id.name + 2, '.'); + BLI_string_split_name_number(object->id.name + 2, '.', basisname, &basisnr); LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { BKE_view_layer_synced_ensure(scene, view_layer); @@ -447,7 +450,7 @@ Object *BKE_mball_basis_find(Scene *scene, Object *object) Object *ob = base->object; if ((ob->type == OB_MBALL) && !(base->flag & BASE_FROM_DUPLI)) { if (ob != bob) { - BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); + BLI_string_split_name_number(ob->id.name + 2, '.', obname, &obnr); /* Object ob has to be in same "group" ... it means, * that it has to have same base of its name. */ diff --git a/source/blender/blenkernel/intern/mball_tessellate.cc b/source/blender/blenkernel/intern/mball_tessellate.cc index 96cb2cc7e52..7e6a66c6efe 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.cc +++ b/source/blender/blenkernel/intern/mball_tessellate.cc @@ -417,7 +417,8 @@ static float metaball(PROCESS *process, float x, float y, float z) for (int i = 0; i < 2; i++) { if ((node->bb[i].min[0] <= x) && (node->bb[i].max[0] >= x) && (node->bb[i].min[1] <= y) && - (node->bb[i].max[1] >= y) && (node->bb[i].min[2] <= z) && (node->bb[i].max[2] >= z)) { + (node->bb[i].max[1] >= y) && (node->bb[i].min[2] <= z) && (node->bb[i].max[2] >= z)) + { if (node->child[i]) { process->bvh_queue[front++] = node->child[i]; } @@ -1181,7 +1182,7 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje ob->object_to_world); /* to cope with duplicators from BKE_scene_base_iter_next */ invert_m4_m4(obinv, ob->object_to_world); - BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); + BLI_string_split_name_number(ob->id.name + 2, '.', obname, &obnr); /* make main array */ BKE_scene_base_iter_next(depsgraph, &iter, &sce_iter, 0, nullptr, nullptr); @@ -1194,7 +1195,8 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje * the instancer is visible too. */ if ((base->flag_legacy & OB_FROMDUPLI) == 0 && ob->parent != nullptr && (ob->parent->transflag & parenting_dupli_transflag) != 0 && - (BKE_object_visibility(ob->parent, deg_eval_mode) & OB_VISIBLE_SELF) == 0) { + (BKE_object_visibility(ob->parent, deg_eval_mode) & OB_VISIBLE_SELF) == 0) + { continue; } @@ -1212,7 +1214,7 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje char name[MAX_ID_NAME]; int nr; - BLI_split_name_num(name, &nr, bob->id.name + 2, '.'); + BLI_string_split_name_number(bob->id.name + 2, '.', name, &nr); if (STREQ(obname, name)) { mb = static_cast(bob->data); @@ -1438,7 +1440,8 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob) * the open movie "Sintel", using 0.00001f. */ if (ob->scale[0] < 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) || ob->scale[1] < 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) || - ob->scale[2] < 0.00001f * (process.allbb.max[2] - process.allbb.min[2])) { + ob->scale[2] < 0.00001f * (process.allbb.max[2] - process.allbb.min[2])) + { freepolygonize(&process); return nullptr; } diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 286c152ffe8..b4866067015 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -565,7 +565,8 @@ static int customdata_compare( for (int i = 0; i < c1->totlayer; i++) { l1 = &c1->layers[i]; if ((CD_TYPE_AS_MASK(l1->type) & cd_mask_all_attr) && l1->anonymous_id == nullptr && - !is_uv_bool_sublayer(*l1)) { + !is_uv_bool_sublayer(*l1)) + { layer_count1++; } } @@ -573,7 +574,8 @@ static int customdata_compare( for (int i = 0; i < c2->totlayer; i++) { l2 = &c2->layers[i]; if ((CD_TYPE_AS_MASK(l2->type) & cd_mask_all_attr) && l2->anonymous_id == nullptr && - !is_uv_bool_sublayer(*l2)) { + !is_uv_bool_sublayer(*l2)) + { layer_count2++; } } @@ -800,7 +802,8 @@ const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh) } if (!std::equal( - me1->poly_offsets().begin(), me1->poly_offsets().end(), me2->poly_offsets().begin())) { + me1->poly_offsets().begin(), me1->poly_offsets().end(), me2->poly_offsets().begin())) + { return "Face sizes don't match"; } @@ -1316,7 +1319,8 @@ void BKE_mesh_texspace_calc(Mesh *me) void BKE_mesh_texspace_ensure(Mesh *me) { if ((me->texspace_flag & ME_TEXSPACE_FLAG_AUTO) && - !(me->texspace_flag & ME_TEXSPACE_FLAG_AUTO_EVALUATED)) { + !(me->texspace_flag & ME_TEXSPACE_FLAG_AUTO_EVALUATED)) + { BKE_mesh_texspace_calc(me); } } diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index f7fba92f2a2..ef3ec26ac78 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -454,7 +454,8 @@ void BKE_mesh_calc_volume(const float (*vert_positions)[3], } if (!mesh_calc_center_centroid_ex( - vert_positions, mverts_num, looptri, looptri_num, corner_verts, center)) { + vert_positions, mverts_num, looptri, looptri_num, corner_verts, center)) + { return; } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 116e3db14bf..2da4be71ddc 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -211,7 +211,7 @@ void BKE_mesh_calc_edges_legacy(Mesh *me) mesh_calc_edges_mdata( verts.data(), - (MFace *)CustomData_get_layer(&me->fdata, CD_MFACE), + me->mface, static_cast(CustomData_get_layer_for_write(&me->ldata, CD_MLOOP, me->totloop)), static_cast(CustomData_get_layer(&me->pdata, CD_MPOLY)), verts.size(), @@ -234,6 +234,28 @@ void BKE_mesh_calc_edges_legacy(Mesh *me) BKE_mesh_strip_loose_faces(me); } +void BKE_mesh_strip_loose_faces(Mesh *me) +{ + /* NOTE: We need to keep this for edge creation (for now?), and some old `readfile.c` code. */ + MFace *f; + int a, b; + MFace *mfaces = me->mface; + + for (a = b = 0, f = mfaces; a < me->totface; a++, f++) { + if (f->v3) { + if (a != b) { + memcpy(&mfaces[b], f, sizeof(mfaces[b])); + CustomData_copy_data(&me->fdata, &me->fdata, a, b, 1); + } + b++; + } + } + if (a != b) { + CustomData_free_elem(&me->fdata, b, a - b); + me->totface = b; + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -417,7 +439,7 @@ static void convert_mfaces_to_mpolys(ID *id, int totface_i, int totloop_i, int totpoly_i, - MEdge *edges, + blender::int2 *edges, MFace *mface, int *r_totloop, int *r_totpoly) @@ -425,14 +447,10 @@ static void convert_mfaces_to_mpolys(ID *id, MFace *mf; MLoop *ml, *mloop; MPoly *poly, *mpoly; - MEdge *edge; EdgeHash *eh; int numTex, numCol; int i, j, totloop, totpoly, *polyindex; - /* old flag, clear to allow for reuse */ -#define ME_FGON (1 << 3) - /* just in case some of these layers are filled in (can happen with python created meshes) */ CustomData_free(ldata, totloop_i); CustomData_free(pdata, totpoly_i); @@ -474,13 +492,8 @@ static void convert_mfaces_to_mpolys(ID *id, eh = BLI_edgehash_new_ex(__func__, uint(totedge_i)); /* build edge hash */ - edge = edges; - for (i = 0; i < totedge_i; i++, edge++) { - BLI_edgehash_insert(eh, edge->v1, edge->v2, POINTER_FROM_UINT(i)); - - /* unrelated but avoid having the FGON flag enabled, - * so we can reuse it later for something else */ - edge->flag_legacy &= ~ME_FGON; + for (i = 0; i < totedge_i; i++) { + BLI_edgehash_insert(eh, edges[i][0], edges[i][1], POINTER_FROM_UINT(i)); } polyindex = (int *)CustomData_get_layer(fdata, CD_ORIGINDEX); @@ -534,8 +547,6 @@ static void convert_mfaces_to_mpolys(ID *id, *r_totpoly = totpoly; *r_totloop = totloop; - -#undef ME_FGON } static void update_active_fdata_layers(Mesh &mesh, CustomData *fdata, CustomData *ldata) @@ -691,12 +702,6 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) { - const blender::Span edges = mesh->edges(); - blender::Array legacy_edges(mesh->totedge); - for (const int i : legacy_edges.index_range()) { - legacy_edges[i].v1 = edges[i][0]; - legacy_edges[i].v2 = edges[i][1]; - } convert_mfaces_to_mpolys(&mesh->id, &mesh->fdata, &mesh->ldata, @@ -705,13 +710,14 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) mesh->totface, mesh->totloop, mesh->totpoly, - legacy_edges.data(), + mesh->edges_for_write().data(), (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE), &mesh->totloop, &mesh->totpoly); + BKE_mesh_legacy_convert_loops_to_corners(mesh); + BKE_mesh_legacy_convert_polys_to_offsets(mesh); mesh_ensure_tessellation_customdata(mesh); - BKE_mesh_legacy_convert_loops_to_corners(mesh); } /** @@ -755,19 +761,20 @@ static void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata, void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh) { - convert_mfaces_to_mpolys( - &mesh->id, - &mesh->fdata, - &mesh->ldata, - &mesh->pdata, - mesh->totedge, - mesh->totface, - mesh->totloop, - mesh->totpoly, - static_cast(CustomData_get_layer_for_write(&mesh->edata, CD_MEDGE, mesh->totedge)), - (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE), - &mesh->totloop, - &mesh->totpoly); + convert_mfaces_to_mpolys(&mesh->id, + &mesh->fdata, + &mesh->ldata, + &mesh->pdata, + mesh->totedge, + mesh->totface, + mesh->totloop, + mesh->totpoly, + mesh->edges_for_write().data(), + (MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE), + &mesh->totloop, + &mesh->totpoly); + BKE_mesh_legacy_convert_loops_to_corners(mesh); + BKE_mesh_legacy_convert_polys_to_offsets(mesh); CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata, &mesh->ldata); @@ -818,7 +825,8 @@ static void mesh_loops_to_tessdata(CustomData *fdata, CustomData_get_layer_n(ldata, CD_PROP_FLOAT2, i)); for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces; - pidx++, lidx++, findex++, texface++) { + pidx++, lidx++, findex++, texface++) + { for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) { copy_v2_v2(texface->uv[j], uv[(*lidx)[j]]); } @@ -877,7 +885,8 @@ static void mesh_loops_to_tessdata(CustomData *fdata, const float(*ltangents)[4] = (const float(*)[4])CustomData_get_layer(ldata, CD_TANGENT); for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces; - pidx++, lidx++, findex++) { + pidx++, lidx++, findex++) + { int nverts = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; for (j = nverts; j--;) { copy_v4_v4(ftangents[findex * 4 + j], ltangents[(*lidx)[j]]); @@ -910,7 +919,8 @@ int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata, int mfindex, if (nr == 3) { if ( /* real edges */ - mface->v1 == mface->v2 || mface->v2 == mface->v3 || mface->v3 == mface->v1) { + mface->v1 == mface->v2 || mface->v2 == mface->v3 || mface->v3 == mface->v1) + { return 0; } } @@ -920,7 +930,8 @@ int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata, int mfindex, mface->v1 == mface->v2 || mface->v2 == mface->v3 || mface->v3 == mface->v4 || mface->v4 == mface->v1 || /* across the face */ - mface->v1 == mface->v3 || mface->v2 == mface->v4) { + mface->v1 == mface->v3 || mface->v2 == mface->v4) + { return 0; } } @@ -1229,7 +1240,8 @@ void BKE_mesh_legacy_sharp_faces_to_flags(Mesh *mesh, blender::MutableSpan( - CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, "sharp_face"))) { + CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, "sharp_face"))) + { threading::parallel_for(legacy_polys.index_range(), 4096, [&](const IndexRange range) { for (const int i : range) { SET_FLAG_FROM_TEST(legacy_polys[i].flag_legacy, !sharp_faces[i], ME_SMOOTH); @@ -1255,7 +1267,8 @@ void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh) mesh->totpoly); if (std::any_of(polys.begin(), polys.end(), [](const MPoly &poly) { return !(poly.flag_legacy & ME_SMOOTH); - })) { + })) + { SpanAttributeWriter sharp_faces = attributes.lookup_or_add_for_write_only_span( "sharp_face", ATTR_DOMAIN_FACE); threading::parallel_for(polys.index_range(), 4096, [&](const IndexRange range) { @@ -1341,7 +1354,8 @@ void BKE_mesh_legacy_bevel_weight_from_layers(Mesh *mesh) using namespace blender; MutableSpan verts(mesh->mvert, mesh->totvert); if (const float *weights = static_cast( - CustomData_get_layer(&mesh->vdata, CD_BWEIGHT))) { + CustomData_get_layer(&mesh->vdata, CD_BWEIGHT))) + { mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; for (const int i : verts.index_range()) { verts[i].bweight_legacy = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; @@ -1355,7 +1369,8 @@ void BKE_mesh_legacy_bevel_weight_from_layers(Mesh *mesh) } MutableSpan edges(mesh->medge, mesh->totedge); if (const float *weights = static_cast( - CustomData_get_layer(&mesh->edata, CD_BWEIGHT))) { + CustomData_get_layer(&mesh->edata, CD_BWEIGHT))) + { mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; for (const int i : edges.index_range()) { edges[i].bweight_legacy = std::clamp(weights[i], 0.0f, 1.0f) * 255.0f; @@ -1406,7 +1421,8 @@ void BKE_mesh_legacy_edge_crease_from_layers(Mesh *mesh) using namespace blender; MutableSpan edges(mesh->medge, mesh->totedge); if (const float *creases = static_cast( - CustomData_get_layer(&mesh->edata, CD_CREASE))) { + CustomData_get_layer(&mesh->edata, CD_CREASE))) + { mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE; for (const int i : edges.index_range()) { edges[i].crease_legacy = std::clamp(creases[i], 0.0f, 1.0f) * 255.0f; @@ -1447,7 +1463,8 @@ void BKE_mesh_legacy_sharp_edges_to_flags(Mesh *mesh) using namespace blender; MutableSpan edges(mesh->medge, mesh->totedge); if (const bool *sharp_edges = static_cast( - CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, "sharp_edge"))) { + CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, "sharp_edge"))) + { threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) { for (const int i : range) { SET_FLAG_FROM_TEST(edges[i].flag_legacy, sharp_edges[i], ME_SHARP); @@ -1475,7 +1492,8 @@ void BKE_mesh_legacy_sharp_edges_from_flags(Mesh *mesh) } if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag_legacy & ME_SHARP; - })) { + })) + { SpanAttributeWriter sharp_edges = attributes.lookup_or_add_for_write_only_span( "sharp_edge", ATTR_DOMAIN_EDGE); threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) { @@ -1498,7 +1516,8 @@ void BKE_mesh_legacy_uv_seam_to_flags(Mesh *mesh) using namespace blender; MutableSpan edges(mesh->medge, mesh->totedge); if (const bool *uv_seams = static_cast( - CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, ".uv_seam"))) { + CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, ".uv_seam"))) + { threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) { for (const int i : range) { SET_FLAG_FROM_TEST(edges[i].flag_legacy, uv_seams[i], ME_SEAM); @@ -1526,7 +1545,8 @@ void BKE_mesh_legacy_uv_seam_from_flags(Mesh *mesh) } if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag_legacy & ME_SEAM; - })) { + })) + { SpanAttributeWriter uv_seams = attributes.lookup_or_add_for_write_only_span( ".uv_seam", ATTR_DOMAIN_EDGE); threading::parallel_for(edges.index_range(), 4096, [&](const IndexRange range) { @@ -1584,13 +1604,15 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh) using namespace blender::bke; MutableAttributeAccessor attributes = mesh->attributes_for_write(); if (!mesh->mvert || attributes.contains(".hide_vert") || attributes.contains(".hide_edge") || - attributes.contains(".hide_poly")) { + attributes.contains(".hide_poly")) + { return; } const Span verts(mesh->mvert, mesh->totvert); if (std::any_of(verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag_legacy & ME_HIDE; - })) { + })) + { SpanAttributeWriter hide_vert = attributes.lookup_or_add_for_write_only_span( ".hide_vert", ATTR_DOMAIN_POINT); threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) { @@ -1605,7 +1627,8 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh) const Span edges(mesh->medge, mesh->totedge); if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag_legacy & ME_HIDE; - })) { + })) + { SpanAttributeWriter hide_edge = attributes.lookup_or_add_for_write_only_span( ".hide_edge", ATTR_DOMAIN_EDGE); threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) { @@ -1621,7 +1644,8 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh) mesh->totpoly); if (std::any_of(polys.begin(), polys.end(), [](const MPoly &poly) { return poly.flag_legacy & ME_HIDE; - })) { + })) + { SpanAttributeWriter hide_poly = attributes.lookup_or_add_for_write_only_span( ".hide_poly", ATTR_DOMAIN_FACE); threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) { @@ -1665,7 +1689,8 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh) const Span polys(static_cast(CustomData_get_layer(&mesh->pdata, CD_MPOLY)), mesh->totpoly); if (std::any_of( - polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr_legacy != 0; })) { + polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr_legacy != 0; })) + { SpanAttributeWriter material_indices = attributes.lookup_or_add_for_write_only_span( "material_index", ATTR_DOMAIN_FACE); threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) { @@ -1933,14 +1958,15 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh) using namespace blender::bke; MutableAttributeAccessor attributes = mesh->attributes_for_write(); if (!mesh->mvert || attributes.contains(".select_vert") || attributes.contains(".select_edge") || - attributes.contains(".select_poly")) { + attributes.contains(".select_poly")) + { return; } const Span verts(mesh->mvert, mesh->totvert); - if (std::any_of(verts.begin(), verts.end(), [](const MVert &vert) { - return vert.flag_legacy & SELECT; - })) { + if (std::any_of( + verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag_legacy & SELECT; })) + { SpanAttributeWriter select_vert = attributes.lookup_or_add_for_write_only_span( ".select_vert", ATTR_DOMAIN_POINT); threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) { @@ -1955,7 +1981,8 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh) const Span edges(mesh->medge, mesh->totedge); if (std::any_of(edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag_legacy & SELECT; - })) { + })) + { SpanAttributeWriter select_edge = attributes.lookup_or_add_for_write_only_span( ".select_edge", ATTR_DOMAIN_EDGE); threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) { @@ -1971,7 +1998,8 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh) mesh->totpoly); if (std::any_of(polys.begin(), polys.end(), [](const MPoly &poly) { return poly.flag_legacy & ME_FACE_SEL; - })) { + })) + { SpanAttributeWriter select_poly = attributes.lookup_or_add_for_write_only_span( ".select_poly", ATTR_DOMAIN_FACE); threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) { @@ -2277,7 +2305,8 @@ void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh) { using namespace blender; if (CustomData_get_layer_named(&mesh->ldata, CD_PROP_INT32, ".corner_vert") && - CustomData_get_layer_named(&mesh->ldata, CD_PROP_INT32, ".corner_edge")) { + CustomData_get_layer_named(&mesh->ldata, CD_PROP_INT32, ".corner_edge")) + { return; } const Span loops(static_cast(CustomData_get_layer(&mesh->ldata, CD_MLOOP)), diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index 020c561a926..ad3cfbc482d 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -132,7 +132,8 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const blender::OffsetIndices polys, sub_v2_v2v2(uvdiff, uv2, uv); if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] && - (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) { + (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) + { if (lastv) { lastv->next = next; } @@ -824,8 +825,9 @@ int *BKE_mesh_calc_smoothgroups(const int totedge, const MeshElemMap &edge_poly_map_elem) { /* Edge is sharp if one of its polys is flat, or edge itself is sharp, * or edge is not used by exactly two polygons. */ - if ((poly_is_smooth(poly_index)) && !(sharp_edges && sharp_edges[edge_index]) && - (edge_user_count == 2)) { + if (poly_is_smooth(poly_index) && !(sharp_edges && sharp_edges[edge_index]) && + (edge_user_count == 2)) + { /* In that case, edge appears to be smooth, but we need to check its other poly too. */ const int other_poly_index = (poly_index == edge_poly_map_elem.indices[0]) ? edge_poly_map_elem.indices[1] : @@ -1033,7 +1035,8 @@ static bool mesh_calc_islands_loop_poly_uv(const int totedge, for (int i = 2; i < edge_to_loops.count; i += 2) { if (corner_verts[edge_to_loops.indices[i]] == v1) { if (!equals_v2v2(uvco_v1, luvs[edge_to_loops.indices[i]]) || - !equals_v2v2(uvco_v2, luvs[edge_to_loops.indices[i + 1]])) { + !equals_v2v2(uvco_v2, luvs[edge_to_loops.indices[i + 1]])) + { return true; } } @@ -1041,7 +1044,8 @@ static bool mesh_calc_islands_loop_poly_uv(const int totedge, BLI_assert(corner_verts[edge_to_loops.indices[i]] == v2); UNUSED_VARS_NDEBUG(v2); if (!equals_v2v2(uvco_v2, luvs[edge_to_loops.indices[i]]) || - !equals_v2v2(uvco_v1, luvs[edge_to_loops.indices[i + 1]])) { + !equals_v2v2(uvco_v1, luvs[edge_to_loops.indices[i + 1]])) + { return true; } } diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc index a4d9524b612..a135a7e7d55 100644 --- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc +++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc @@ -52,7 +52,8 @@ static int compare_v2_classify(const float uv_a[2], const float uv_b[2]) const int diff_ulp = 12; if (compare_ff_relative(uv_a[0], uv_b[0], diff_abs, diff_ulp) && - compare_ff_relative(uv_a[1], uv_b[1], diff_abs, diff_ulp)) { + compare_ff_relative(uv_a[1], uv_b[1], diff_abs, diff_ulp)) + { return CMP_CLOSE; } return CMP_APART; diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index 70a0429de4e..dbcef51eb8d 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -343,7 +343,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* handle uvs, * let tessface recalc handle updating the MTFace data */ if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V) || - (is_zero_v2(mmd->uv_offset_copy) == false)) { + (is_zero_v2(mmd->uv_offset_copy) == false)) + { const bool do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0; const bool do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0; /* If set, flip around center of each tile. */ @@ -383,7 +384,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* handle custom split normals */ if (ob->type == OB_MESH && (((Mesh *)ob->data)->flag & ME_AUTOSMOOTH) && - CustomData_has_layer(&result->ldata, CD_CUSTOMLOOPNORMAL) && result->totpoly > 0) { + CustomData_has_layer(&result->ldata, CD_CUSTOMLOOPNORMAL) && result->totpoly > 0) + { blender::Array loop_normals(result_corner_verts.size()); CustomData *ldata = &result->ldata; blender::short2 *clnors = static_cast( @@ -451,8 +453,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, ((*r_vert_merge_map)[i + src_verts_num] != -1)) { BKE_defvert_flip_merged(dvert - src_verts_num, flip_map, flip_map_len); } - else if (!use_correct_order_on_merge && do_vtargetmap && - ((*r_vert_merge_map)[i] != -1)) { + else if (!use_correct_order_on_merge && do_vtargetmap && ((*r_vert_merge_map)[i] != -1)) + { BKE_defvert_flip_merged(dvert, flip_map, flip_map_len); } else { diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 733db6c6591..817ebaa1e0a 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -479,7 +479,8 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float dtp_other = dot_v3v3(vec_other, lnor); if (UNLIKELY(fabsf(dtp_ref) >= LNOR_SPACE_TRIGO_THRESHOLD || - fabsf(dtp_other) >= LNOR_SPACE_TRIGO_THRESHOLD)) { + fabsf(dtp_other) >= LNOR_SPACE_TRIGO_THRESHOLD)) + { /* If vec_ref or vec_other are too much aligned with lnor, we can't build lnor space, * tag it as invalid and abort. */ lnor_space->ref_alpha = lnor_space->ref_beta = 0.0f; @@ -710,7 +711,7 @@ static void mesh_edges_sharp_tag(const OffsetIndices polys, /* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */ e2l[0] = loop_index; /* We have to check this here too, else we might miss some flat faces!!! */ - e2l[1] = (poly_is_smooth(poly_i)) ? INDEX_UNSET : INDEX_INVALID; + e2l[1] = poly_is_smooth(poly_i) ? INDEX_UNSET : INDEX_INVALID; } else if (e2l[1] == INDEX_UNSET) { const bool is_angle_sharp = (check_angle && @@ -723,7 +724,8 @@ static void mesh_edges_sharp_tag(const OffsetIndices polys, * same vertex, or angle between both its polys' normals is above split_angle value. */ if (!poly_is_smooth(poly_i) || (!sharp_edges.is_empty() && sharp_edges[edge_i]) || - vert_i == corner_verts[e2l[0]] || is_angle_sharp) { + vert_i == corner_verts[e2l[0]] || is_angle_sharp) + { /* NOTE: we are sure that loop != 0 here ;). */ e2l[1] = INDEX_INVALID; @@ -812,7 +814,8 @@ static void loop_manifold_fan_around_vert_next(const Span corner_verts, const int vert_fan_next = corner_verts[*r_mlfan_curr_index]; const IndexRange poly_fan_next = polys[*r_mpfan_curr_index]; if ((vert_fan_orig == vert_fan_next && vert_fan_orig == vert_pivot) || - !ELEM(vert_fan_orig, vert_fan_next, vert_pivot)) { + !ELEM(vert_fan_orig, vert_fan_next, vert_pivot)) + { /* 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) < poly_fan_next.start()) { @@ -1175,12 +1178,14 @@ static void loop_split_generator(LoopSplitTaskDataCommon *common_data, skip_loops, ml_curr_index, ml_prev_index, - poly_index))) { + poly_index))) + { // printf("SKIPPING!\n"); } else { if (IS_EDGE_SHARP(edge_to_loops[corner_edges[ml_curr_index]]) && - IS_EDGE_SHARP(edge_to_loops[corner_edges[ml_prev_index]])) { + IS_EDGE_SHARP(edge_to_loops[corner_edges[ml_prev_index]])) + { /* Simple case (both edges around that vertex are sharp in current polygon), * this corner just takes its poly normal. */ r_single_corners.append(ml_curr_index); diff --git a/source/blender/blenkernel/intern/mesh_remap.cc b/source/blender/blenkernel/intern/mesh_remap.cc index ef2c39af8f9..a8805705e82 100644 --- a/source/blender/blenkernel/intern/mesh_remap.cc +++ b/source/blender/blenkernel/intern/mesh_remap.cc @@ -500,8 +500,8 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(&treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { mesh_remap_item_define(r_map, i, hit_dist, 0, 1, &nearest.index, &full_weight); } else { @@ -525,8 +525,8 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(&treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { const blender::int2 &edge = edges_src[nearest.index]; const float *v1cos = positions_src[edge[0]]; const float *v2cos = positions_src[edge[1]]; @@ -561,7 +561,8 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, else if (ELEM(mode, MREMAP_MODE_VERT_POLY_NEAREST, MREMAP_MODE_VERT_POLYINTERP_NEAREST, - MREMAP_MODE_VERT_POLYINTERP_VNORPROJ)) { + MREMAP_MODE_VERT_POLYINTERP_VNORPROJ)) + { const blender::OffsetIndices polys_src = me_src->polys(); const blender::Span corner_verts_src = me_src->corner_verts(); const blender::Span positions_src = me_src->vert_positions(); @@ -588,7 +589,8 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, } if (mesh_remap_bvhtree_query_raycast( - &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) { + &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) + { const MLoopTri *lt = &treedata.looptri[rayhit.index]; const int sources_num = mesh_remap_interp_poly_data_get(polys_src[lt->poly], corner_verts_src, @@ -853,8 +855,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(&treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { mesh_remap_item_define(r_map, i, hit_dist, 0, 1, &nearest.index, &full_weight); } else { @@ -882,8 +884,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(&treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { const MLoopTri *lt = &treedata.looptri[nearest.index]; const blender::IndexRange poly_src = polys_src[lt->poly]; const int *corner_edge_src = &corner_edges_src[poly_src.start()]; @@ -969,8 +971,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode, grid_size = int((edge_dst_len / ray_radius) + 0.5f); CLAMP(grid_size, num_rays_min, num_rays_max); /* min 5 rays/edge, max 100. */ - grid_step = 1.0f / - float(grid_size); /* Not actual distance here, rather an interp fac... */ + /* Not actual distance here, rather an interp fac... */ + grid_step = 1.0f / float(grid_size); /* And now we can cast all our rays, and see what we get! */ for (j = 0; j < grid_size; j++) { @@ -984,7 +986,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode, while (n--) { if (mesh_remap_bvhtree_query_raycast( - &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) { + &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) + { weights[rayhit.index] += w; totweights += w; hit_dist_accum += hit_dist; @@ -1585,8 +1588,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { float(*nor_dst)[3]; blender::Span nors_src; float best_nor_dot = -2.0f; @@ -1696,7 +1699,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode, while (n--) { if (mesh_remap_bvhtree_query_raycast( - tdata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) { + tdata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) + { islands_res[tindex][plidx_dst].factor = (hit_dist ? (1.0f / hit_dist) : 1e18f) * w; islands_res[tindex][plidx_dst].hit_dist = hit_dist; islands_res[tindex][plidx_dst].index_src = int(tdata->looptri[rayhit.index].poly); @@ -1747,8 +1751,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { islands_res[tindex][plidx_dst].factor = hit_dist ? (1.0f / hit_dist) : 1e18f; islands_res[tindex][plidx_dst].hit_dist = hit_dist; islands_res[tindex][plidx_dst].index_src = int(tdata->looptri[nearest.index].poly); @@ -2165,8 +2169,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, BLI_space_transform_apply(space_transform, tmp_co); } - if (mesh_remap_bvhtree_query_nearest( - &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { + if (mesh_remap_bvhtree_query_nearest(&treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) + { const MLoopTri *lt = &treedata.looptri[nearest.index]; const int poly_index = int(lt->poly); mesh_remap_item_define(r_map, int(i), hit_dist, 0, 1, &poly_index, &full_weight); @@ -2193,7 +2197,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, } if (mesh_remap_bvhtree_query_raycast( - &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) { + &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) + { const MLoopTri *lt = &treedata.looptri[rayhit.index]; const int poly_index = int(lt->poly); @@ -2348,7 +2353,8 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, /* At this point, tmp_co is a point on our poly surface, in mesh_src space! */ while (n--) { if (mesh_remap_bvhtree_query_raycast( - &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) { + &treedata, &rayhit, tmp_co, tmp_no, ray_radius / w, max_dist, &hit_dist)) + { const MLoopTri *lt = &treedata.looptri[rayhit.index]; weights[lt->poly] += w; diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index be66df2e7e0..8b3808b5034 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -369,7 +369,8 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) int *target_lmap_mem = nullptr; while ((layer = BKE_id_attribute_from_index( - const_cast(&source->id), i++, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL))) { + const_cast(&source->id), i++, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL))) + { eAttrDomain domain = BKE_id_attribute_domain(&source->id, layer); const eCustomDataType type = eCustomDataType(layer->type); diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index 885410258af..b60eadf4e09 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -306,7 +306,8 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data, const char *layer_name) { if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 && - CustomData_get_named_layer_index(uv_data, CD_PROP_FLOAT2, layer_name) != -1) { + CustomData_get_named_layer_index(uv_data, CD_PROP_FLOAT2, layer_name) != -1) + { CustomData_add_layer_named(tan_data, CD_TANGENT, CD_SET_DEFAULT, numLoopData, layer_name); } } @@ -371,7 +372,8 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData, } } if (!add && ((*rcalc_act && ract_uv_name[0] && STREQ(ract_uv_name, name)) || - (*rcalc_ren && rren_uv_name[0] && STREQ(rren_uv_name, name)))) { + (*rcalc_ren && rren_uv_name[0] && STREQ(rren_uv_name, name)))) + { add = true; } if (add) { @@ -434,7 +436,8 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3], } } if ((tangent_mask & DM_TANGENT_MASK_ORCO) && - CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) { + CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) + { CustomData_add_layer_named( loopdata_out, CD_TANGENT, CD_SET_DEFAULT, int(loopdata_out_len), ""); } diff --git a/source/blender/blenkernel/intern/mesh_tessellate.cc b/source/blender/blenkernel/intern/mesh_tessellate.cc index fca2de49c8e..2f82196d149 100644 --- a/source/blender/blenkernel/intern/mesh_tessellate.cc +++ b/source/blender/blenkernel/intern/mesh_tessellate.cc @@ -66,7 +66,8 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const Span corner_vert if (UNLIKELY(is_quad_flip_v3_first_third_fast(positions[corner_verts[mlt_a->tri[0]]], positions[corner_verts[mlt_a->tri[1]]], positions[corner_verts[mlt_a->tri[2]]], - positions[corner_verts[mlt_b->tri[2]]]))) { + positions[corner_verts[mlt_b->tri[2]]]))) + { /* Flip out of degenerate 0-2 state. */ mlt_a->tri[2] = mlt_b->tri[2]; mlt_b->tri[0] = mlt_a->tri[1]; diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 31f2c9f3ca0..32e0d6176ae 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -642,7 +642,8 @@ bool BKE_mesh_validate_arrays(Mesh *mesh, else { const blender::int2 &edge = edges[edge_i]; if (IS_REMOVED_EDGE(edge) || - !((edge[0] == v1 && edge[1] == v2) || (edge[0] == v2 && edge[1] == v1))) { + !((edge[0] == v1 && edge[1] == v2) || (edge[0] == v2 && edge[1] == v1))) + { /* The pointed edge is invalid (tagged as removed, or vert idx mismatch), * and we already know from previous test that a valid one exists, * use it (if allowed)! */ @@ -1205,28 +1206,6 @@ bool BKE_mesh_validate_material_indices(Mesh *me) /** \name Mesh Stripping (removing invalid data) * \{ */ -void BKE_mesh_strip_loose_faces(Mesh *me) -{ - /* NOTE: We need to keep this for edge creation (for now?), and some old `readfile.c` code. */ - MFace *f; - int a, b; - MFace *mfaces = (MFace *)CustomData_get_layer_for_write(&me->fdata, CD_MFACE, me->totface); - - for (a = b = 0, f = mfaces; a < me->totface; a++, f++) { - if (f->v3) { - if (a != b) { - memcpy(&mfaces[b], f, sizeof(mfaces[b])); - CustomData_copy_data(&me->fdata, &me->fdata, a, b, 1); - } - b++; - } - } - if (a != b) { - CustomData_free_elem(&me->fdata, b, a - b); - me->totface = b; - } -} - void strip_loose_polysloops(Mesh *me, blender::BitSpan polys_to_remove) { MutableSpan poly_offsets = me->poly_offsets_for_write(); @@ -1376,7 +1355,8 @@ void BKE_mesh_calc_edges_tessface(Mesh *mesh) EdgeSetIterator *ehi = BLI_edgesetIterator_new(eh); for (int i = 0; BLI_edgesetIterator_isDone(ehi) == false; - BLI_edgesetIterator_step(ehi), i++, ege++, index++) { + BLI_edgesetIterator_step(ehi), i++, ege++, index++) + { BLI_edgesetIterator_getKey(ehi, &(*ege)[0], &(*ege)[1]); *index = ORIGINDEX_NONE; } diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index c329b2d14a5..8c94f6067d1 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -59,6 +59,7 @@ #include "BKE_multires.h" #include "BKE_object.h" #include "BKE_pointcache.h" +#include "BKE_screen.h" /* may move these, only for BKE_modifier_path_relbase */ #include "BKE_main.h" @@ -120,9 +121,7 @@ const ModifierTypeInfo *BKE_modifier_get_info(ModifierType type) void BKE_modifier_type_panel_id(ModifierType type, char *r_idname) { const ModifierTypeInfo *mti = BKE_modifier_get_info(type); - - strcpy(r_idname, MODIFIER_TYPE_PANEL_PREFIX); - strcat(r_idname, mti->name); + BLI_string_join(r_idname, sizeof(PanelType::idname), MODIFIER_TYPE_PANEL_PREFIX, mti->name); } void BKE_modifier_panel_expand(ModifierData *md) @@ -256,7 +255,8 @@ bool BKE_modifier_is_preview(ModifierData *md) /* Constructive modifiers are highly likely to also modify data like vgroups or vertex-colors! */ if (!((mti->flags & eModifierTypeFlag_UsesPreview) || - (mti->type == eModifierTypeType_Constructive))) { + (mti->type == eModifierTypeType_Constructive))) + { return false; } @@ -584,7 +584,8 @@ bool BKE_modifier_is_enabled(const struct Scene *scene, ModifierData *md, int re return false; } if (scene != nullptr && mti->isDisabled && - mti->isDisabled(scene, md, required_mode == eModifierMode_Render)) { + mti->isDisabled(scene, md, required_mode == eModifierMode_Render)) + { return false; } if (md->mode & eModifierMode_DisableTemporary) { diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 52957dcc790..81e7d398e56 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -515,7 +515,7 @@ static void get_proxy_filepath(const MovieClip *clip, char dir[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX]; int proxynr = framenr - clip->start_frame + 1 + clip->frame_offset; - BLI_split_dirfile(clip->filepath, clipdir, clipfile, FILE_MAX, FILE_MAX); + BLI_path_split_dir_file(clip->filepath, clipdir, FILE_MAX, clipfile, FILE_MAX); if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); @@ -544,9 +544,8 @@ static void get_proxy_filepath(const MovieClip *clip, } BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); - BLI_path_frame(filepath, 1, 0); - - strcat(filepath, ".jpg"); + BLI_path_frame(filepath, FILE_MAX, 1, 0); + BLI_strncat(filepath, ".jpg", FILE_MAX); } #ifdef WITH_OPENEXR @@ -1382,7 +1381,8 @@ static ImBuf *movieclip_get_postprocessed_ibuf( /* Fallback render in case proxies are not enabled or built */ if (!ibuf && user->render_flag & MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER && - user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL) { + user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL) + { MovieClipUser user_fallback = *user; user_fallback.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; @@ -1466,7 +1466,8 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, /* check for stabilization parameters */ if (tscale != cache->stabilized.scale || tangle != cache->stabilized.angle || - !equals_v2v2(tloc, cache->stabilized.loc)) { + !equals_v2v2(tloc, cache->stabilized.loc)) + { return NULL; } @@ -1880,7 +1881,7 @@ static void movieclip_build_proxy_ibuf( */ BLI_thread_lock(LOCK_MOVIECLIP); - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); if (IMB_saveiff(scaleibuf, filepath, IB_rect) == 0) { perror(filepath); } diff --git a/source/blender/blenkernel/intern/multires.cc b/source/blender/blenkernel/intern/multires.cc index 0cd8cf5079c..1c8ce0e60ae 100644 --- a/source/blender/blenkernel/intern/multires.cc +++ b/source/blender/blenkernel/intern/multires.cc @@ -412,7 +412,8 @@ void multires_flush_sculpt_updates(Object *object) SculptSession *sculpt_session = object->sculpt; if (BKE_pbvh_type(sculpt_session->pbvh) != PBVH_GRIDS || !sculpt_session->multires.active || - sculpt_session->multires.modifier == nullptr) { + sculpt_session->multires.modifier == nullptr) + { return; } diff --git a/source/blender/blenkernel/intern/multires_reshape.cc b/source/blender/blenkernel/intern/multires_reshape.cc index ae27c6cf0cd..75f28972727 100644 --- a/source/blender/blenkernel/intern/multires_reshape.cc +++ b/source/blender/blenkernel/intern/multires_reshape.cc @@ -43,7 +43,8 @@ bool multiresModifier_reshapeFromVertcos(Depsgraph *depsgraph, multires_reshape_store_original_grids(&reshape_context); multires_reshape_ensure_grids(static_cast(object->data), reshape_context.top.level); if (!multires_reshape_assign_final_coords_from_vertcos( - &reshape_context, vert_coords, num_vert_coords)) { + &reshape_context, vert_coords, num_vert_coords)) + { multires_reshape_context_free(&reshape_context); return false; } @@ -125,7 +126,8 @@ bool multiresModifier_reshapeFromCCG(const int tot_level, Mesh *coarse_mesh, Sub { MultiresReshapeContext reshape_context; if (!multires_reshape_context_create_from_ccg( - &reshape_context, subdiv_ccg, coarse_mesh, tot_level)) { + &reshape_context, subdiv_ccg, coarse_mesh, tot_level)) + { return false; } diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.cc b/source/blender/blenkernel/intern/multires_reshape_smooth.cc index c889f68911a..8eef74fab3b 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.cc +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.cc @@ -825,12 +825,14 @@ static void foreach_edge(const SubdivForeachContext *foreach_context, /* Ignore all inner face edges as they have sharpness of zero when using Catmull-Clark mode. In * simple mode, all edges have maximum sharpness, so they can't be skipped. */ if (coarse_edge_index == ORIGINDEX_NONE && - reshape_smooth_context->smoothing_type != MULTIRES_SUBDIVIDE_SIMPLE) { + reshape_smooth_context->smoothing_type != MULTIRES_SUBDIVIDE_SIMPLE) + { return; } /* Ignore all loose edges as well, as they are not communicated to the OpenSubdiv. */ if (!reshape_smooth_context->loose_base_edges.is_empty() && - reshape_smooth_context->loose_base_edges[coarse_edge_index]) { + reshape_smooth_context->loose_base_edges[coarse_edge_index]) + { return; } /* Edges without crease are to be ignored as well. */ diff --git a/source/blender/blenkernel/intern/multires_reshape_subdivide.cc b/source/blender/blenkernel/intern/multires_reshape_subdivide.cc index beac99e0a7c..3870da509f2 100644 --- a/source/blender/blenkernel/intern/multires_reshape_subdivide.cc +++ b/source/blender/blenkernel/intern/multires_reshape_subdivide.cc @@ -85,8 +85,8 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object, /* Convert the new grids to tangent displacement. */ multires_set_tot_level(object, mmd, new_top_level); - if (!multires_reshape_context_create_from_modifier( - &reshape_context, object, mmd, new_top_level)) { + if (!multires_reshape_context_create_from_modifier(&reshape_context, object, mmd, new_top_level)) + { return; } diff --git a/source/blender/blenkernel/intern/multires_reshape_util.cc b/source/blender/blenkernel/intern/multires_reshape_util.cc index 697b6a4e063..c43372f882a 100644 --- a/source/blender/blenkernel/intern/multires_reshape_util.cc +++ b/source/blender/blenkernel/intern/multires_reshape_util.cc @@ -52,7 +52,8 @@ Subdiv *multires_reshape_create_subdiv(Depsgraph *depsgraph, BKE_multires_subdiv_settings_init(&subdiv_settings, mmd); Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, base_mesh); if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) { + subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) + { BKE_subdiv_free(subdiv); return nullptr; } diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.cc b/source/blender/blenkernel/intern/multires_unsubdivide.cc index 61b40cf503c..6b2cb748ad0 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.cc +++ b/source/blender/blenkernel/intern/multires_unsubdivide.cc @@ -214,7 +214,8 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex BM_ITER_ELEM (neighbor_v, &iter_a, f, BM_VERTS_OF_FACE) { int neighbor_vertex_index = BM_elem_index_get(neighbor_v); if (!visited_verts[neighbor_vertex_index] && neighbor_v != diagonal_v && - is_vertex_diagonal(neighbor_v, diagonal_v)) { + is_vertex_diagonal(neighbor_v, diagonal_v)) + { BLI_gsqueue_push(queue, &neighbor_v); visited_verts[neighbor_vertex_index] = true; BM_elem_flag_set(neighbor_v, BM_ELEM_TAG, true); @@ -1063,8 +1064,8 @@ static void multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte BMVert *base_corner_y = BM_vert_at_index(bm_base_mesh, corner_y_index); /* If this is the correct loop in the base mesh, the original vertex and the two corners * should be in the loop's face. */ - if (BM_vert_in_face(base_corner_x, base_face) && - BM_vert_in_face(base_corner_y, base_face)) { + if (BM_vert_in_face(base_corner_x, base_face) && BM_vert_in_face(base_corner_y, base_face)) + { /* Get the index of the loop. */ const int base_mesh_loop_index = BM_ELEM_CD_GET_INT(lb, base_l_offset); const int base_mesh_face_index = BM_elem_index_get(base_face); diff --git a/source/blender/blenkernel/intern/multires_versioning.cc b/source/blender/blenkernel/intern/multires_versioning.cc index b2ad187db85..4de3a6d3b79 100644 --- a/source/blender/blenkernel/intern/multires_versioning.cc +++ b/source/blender/blenkernel/intern/multires_versioning.cc @@ -46,7 +46,8 @@ static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifi BKE_subdiv_converter_free(&converter); if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) { + subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) + { BKE_subdiv_free(subdiv); return nullptr; } @@ -66,7 +67,8 @@ void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifi Subdiv *subdiv = subdiv_for_simple_to_catmull_clark(object, mmd); MultiresReshapeContext reshape_context; if (!multires_reshape_context_create_from_subdiv( - &reshape_context, object, mmd, subdiv, mmd->totlvl)) { + &reshape_context, object, mmd, subdiv, mmd->totlvl)) + { BKE_subdiv_free(subdiv); return; } @@ -81,8 +83,8 @@ void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifi /* Calculate the new tangent displacement against the new Catmull-Clark limit surface. */ { MultiresReshapeContext reshape_context; - if (!multires_reshape_context_create_from_modifier( - &reshape_context, object, mmd, mmd->totlvl)) { + if (!multires_reshape_context_create_from_modifier(&reshape_context, object, mmd, mmd->totlvl)) + { return; } multires_reshape_object_grids_to_tangent_displacement(&reshape_context); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 0178e7c379d..0a4d5e43d18 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -398,7 +398,8 @@ void BKE_nlatrack_insert_after(ListBase *nla_tracks, if (is_liboverride && prev != NULL && (prev->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) { NlaTrack *first_local = prev->next; for (; first_local != NULL && (first_local->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0; - first_local = first_local->next) { + first_local = first_local->next) + { } prev = first_local != NULL ? first_local->prev : NULL; } @@ -1250,7 +1251,8 @@ bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip, const bool is_libove * Do not allow adding strips if this track is locked, or not a local one in liboverride case. */ if (nlt->flag & NLATRACK_PROTECTED || - (is_liboverride && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0)) { + (is_liboverride && (nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0)) + { return false; } @@ -1442,11 +1444,13 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max) * - second 2 cases cover when the strip length is greater than the bounding area */ if ((stripLen < boundsLen) && - !(IN_RANGE(strip->start, min, max) || IN_RANGE(strip->end, min, max))) { + !(IN_RANGE(strip->start, min, max) || IN_RANGE(strip->end, min, max))) + { return false; } if ((stripLen > boundsLen) && - !(IN_RANGE(min, strip->start, strip->end) || IN_RANGE(max, strip->start, strip->end))) { + !(IN_RANGE(min, strip->start, strip->end) || IN_RANGE(max, strip->start, strip->end))) + { return false; } @@ -2317,7 +2321,8 @@ void BKE_nla_tweakmode_exit(AnimData *adt) for (strip = nlt->strips.first; strip; strip = strip->next) { /* sync strip extents if this strip uses the same action */ if ((adt->actstrip) && (adt->actstrip->act == strip->act) && - (strip->flag & NLASTRIP_FLAG_SYNC_LENGTH)) { + (strip->flag & NLASTRIP_FLAG_SYNC_LENGTH)) + { BKE_nlastrip_recalculate_bounds_sync_action(strip); } diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 364b6635b0d..180b535b77b 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -65,6 +65,7 @@ #include "BKE_node.h" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" +#include "BKE_type_conversions.hh" #include "RNA_access.h" #include "RNA_define.h" @@ -522,7 +523,8 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree) if (node->storage) { if (ELEM(ntree->type, NTREE_SHADER, NTREE_GEOMETRY) && - ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB, SH_NODE_CURVE_FLOAT)) { + ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB, SH_NODE_CURVE_FLOAT)) + { BKE_curvemapping_blend_write(writer, static_cast(node->storage)); } else if (ntree->type == NTREE_SHADER && (node->type == SH_NODE_SCRIPT)) { @@ -536,11 +538,13 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree) CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, - CMP_NODE_HUECORRECT)) { + CMP_NODE_HUECORRECT)) + { BKE_curvemapping_blend_write(writer, static_cast(node->storage)); } else if ((ntree->type == NTREE_TEXTURE) && - ELEM(node->type, TEX_NODE_CURVE_RGB, TEX_NODE_CURVE_TIME)) { + ELEM(node->type, TEX_NODE_CURVE_RGB, TEX_NODE_CURVE_TIME)) + { BKE_curvemapping_blend_write(writer, static_cast(node->storage)); } else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_MOVIEDISTORTION)) { @@ -566,7 +570,8 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree) BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage); } else if ((ntree->type == NTREE_COMPOSIT) && - ELEM(node->type, CMP_NODE_CRYPTOMATTE, CMP_NODE_CRYPTOMATTE_LEGACY)) { + ELEM(node->type, CMP_NODE_CRYPTOMATTE, CMP_NODE_CRYPTOMATTE_LEGACY)) + { NodeCryptomatte *nc = static_cast(node->storage); BLO_write_string(writer, nc->matte_id); LISTBASE_FOREACH (CryptomatteEntry *, entry, &nc->entries) { @@ -1000,7 +1005,8 @@ void ntreeBlendReadExpand(BlendExpander *expander, bNodeTree *ntree) LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->id && !(node->type == CMP_NODE_R_LAYERS) && - !(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) { + !(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) + { BLO_expand(expander, node->id); } @@ -2426,6 +2432,71 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree, return node_dst; } +/** + * Type of value storage related with socket is the same. + * \param socket: Node can have multiple sockets & storages pairs. + */ +static void *node_static_value_storage_for(bNode &node, const bNodeSocket &socket) +{ + if (!socket.is_output()) { + return nullptr; + } + + switch (node.type) { + case FN_NODE_INPUT_BOOL: + return &reinterpret_cast(node.storage)->boolean; + case FN_NODE_INPUT_INT: + return &reinterpret_cast(node.storage)->integer; + case FN_NODE_INPUT_VECTOR: + return &reinterpret_cast(node.storage)->vector; + case FN_NODE_INPUT_COLOR: + return &reinterpret_cast(node.storage)->color; + case GEO_NODE_IMAGE: + return &node.id; + default: + break; + } + + return nullptr; +} + +static void *socket_value_storage(bNodeSocket &socket) +{ + switch (eNodeSocketDatatype(socket.type)) { + case SOCK_BOOLEAN: + return &socket.default_value_typed()->value; + case SOCK_INT: + return &socket.default_value_typed()->value; + case SOCK_FLOAT: + return &socket.default_value_typed()->value; + case SOCK_VECTOR: + return &socket.default_value_typed()->value; + case SOCK_RGBA: + return &socket.default_value_typed()->value; + case SOCK_IMAGE: + return &socket.default_value_typed()->value; + case SOCK_TEXTURE: + return &socket.default_value_typed()->value; + case SOCK_COLLECTION: + return &socket.default_value_typed()->value; + case SOCK_OBJECT: + return &socket.default_value_typed()->value; + case SOCK_MATERIAL: + return &socket.default_value_typed()->value; + case SOCK_STRING: + /* We don't want do this now! */ + return nullptr; + case __SOCK_MESH: + case SOCK_CUSTOM: + case SOCK_SHADER: + case SOCK_GEOMETRY: + /* Unmovable types. */ + break; + } + + return nullptr; +} + void node_socket_move_default_value(Main & /*bmain*/, bNodeTree &tree, bNodeSocket &src, @@ -2436,6 +2507,11 @@ void node_socket_move_default_value(Main & /*bmain*/, bNode &dst_node = dst.owner_node(); bNode &src_node = src.owner_node(); + const CPPType &src_type = *src.typeinfo->base_cpp_type; + const CPPType &dst_type = *dst.typeinfo->base_cpp_type; + + const bke::DataTypeConversions &convert = bke::get_implicit_type_conversions(); + if (src.is_multi_input()) { /* Multi input sockets no have value. */ return; @@ -2444,54 +2520,30 @@ void node_socket_move_default_value(Main & /*bmain*/, /* Reroute node can't have ownership of socket value directly. */ return; } - if (dst.type != src.type) { - /* It could be possible to support conversion in future. */ - return; - } - - ID **src_socket_value = nullptr; - Vector dst_values; - switch (dst.type) { - case SOCK_IMAGE: { - Image **tmp_socket_value = &src.default_value_typed()->value; - src_socket_value = reinterpret_cast(tmp_socket_value); - if (*src_socket_value == nullptr) { - break; - } - - switch (dst_node.type) { - case GEO_NODE_IMAGE: { - dst_values.append(&dst_node.id); - break; - } - default: { - break; - } - } - break; - } - case SOCK_CUSTOM: - case SOCK_SHADER: - case SOCK_GEOMETRY: { - /* Unmovable types. */ + if (&src_type != &dst_type) { + if (!convert.is_convertible(src_type, dst_type)) { return; } - default: { - break; - } } - if (dst_values.is_empty() || src_socket_value == nullptr) { + void *src_value = socket_value_storage(src); + void *dst_value = node_static_value_storage_for(dst_node, dst); + if (!dst_value || !src_value) { return; } - for (ID **dst_value : dst_values) { - *dst_value = *src_socket_value; - id_us_plus(*dst_value); - } + convert.convert_to_uninitialized(src_type, dst_type, src_value, dst_value); - id_us_min(*src_socket_value); - *src_socket_value = nullptr; + src_type.destruct(src_value); + if (ELEM(eNodeSocketDatatype(src.type), + SOCK_COLLECTION, + SOCK_IMAGE, + SOCK_MATERIAL, + SOCK_TEXTURE, + SOCK_OBJECT)) + { + src_type.value_initialize(src_value); + } } bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, const int flag, const bool use_unique) @@ -2534,7 +2586,8 @@ bNodeLink *nodeAddLink( link->tosock = tosock; } else if (eNodeSocketInOut(fromsock->in_out) == SOCK_IN && - eNodeSocketInOut(tosock->in_out) == SOCK_OUT) { + eNodeSocketInOut(tosock->in_out) == SOCK_OUT) + { /* OK but flip */ link = MEM_cnew("link"); if (ntree) { diff --git a/source/blender/blenkernel/intern/node_runtime.cc b/source/blender/blenkernel/intern/node_runtime.cc index dc24e5ddbc4..b496348db73 100644 --- a/source/blender/blenkernel/intern/node_runtime.cc +++ b/source/blender/blenkernel/intern/node_runtime.cc @@ -342,7 +342,8 @@ static void update_toposort(const bNodeTree &ntree, } if ((direction == ToposortDirection::LeftToRight) ? node->runtime->has_available_linked_outputs : - node->runtime->has_available_linked_inputs) { + node->runtime->has_available_linked_inputs) + { /* Ignore non-start nodes. */ continue; } diff --git a/source/blender/blenkernel/intern/node_tree_anonymous_attributes.cc b/source/blender/blenkernel/intern/node_tree_anonymous_attributes.cc index a3b2465428d..b3ff255602b 100644 --- a/source/blender/blenkernel/intern/node_tree_anonymous_attributes.cc +++ b/source/blender/blenkernel/intern/node_tree_anonymous_attributes.cc @@ -135,7 +135,8 @@ static void infer_propagate_relations(const bNodeTree &tree, tree, *group_output_socket, [&](const bNodeSocket &output_socket) { Vector indices; for (const aal::PropagateRelation &relation : - relations_by_node[output_socket.owner_node().index()]->propagate_relations) { + relations_by_node[output_socket.owner_node().index()]->propagate_relations) + { if (relation.to_geometry_output == output_socket.index()) { indices.append(relation.from_geometry_input); } @@ -164,7 +165,8 @@ static void infer_reference_relations(const bNodeTree &tree, tree, *group_output_socket, [&](const bNodeSocket &output_socket) { Vector indices; for (const aal::ReferenceRelation &relation : - relations_by_node[output_socket.owner_node().index()]->reference_relations) { + relations_by_node[output_socket.owner_node().index()]->reference_relations) + { if (relation.to_field_output == output_socket.index()) { indices.append(relation.from_field_input); } @@ -173,7 +175,8 @@ static void infer_reference_relations(const bNodeTree &tree, }); for (const int input_index : input_indices) { if (tree.runtime->field_inferencing_interface->inputs[input_index] != - nodes::InputSocketFieldType::None) { + nodes::InputSocketFieldType::None) + { aal::ReferenceRelation relation; relation.from_field_input = input_index; relation.to_field_output = group_output_socket->index(); @@ -434,7 +437,8 @@ static void infer_eval_relations(const bNodeTree &tree, { for (const int input_index : tree.interface_inputs().index_range()) { if (tree.runtime->field_inferencing_interface->inputs[input_index] == - nodes::InputSocketFieldType::None) { + nodes::InputSocketFieldType::None) + { continue; } const Vector geometry_input_indices = find_eval_on_inputs( diff --git a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc index 067745e0ad6..309c1c50b81 100644 --- a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc +++ b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc @@ -212,7 +212,8 @@ static OutputFieldDependency find_group_output_dependencies( const bNodeSocket *input_socket = sockets_to_check.pop(); if (!input_socket->is_directly_linked() && - !field_state_by_socket_id[input_socket->index_in_tree()].is_single) { + !field_state_by_socket_id[input_socket->index_in_tree()].is_single) + { /* This socket uses a field as input by default. */ return OutputFieldDependency::ForFieldSource(); } @@ -240,7 +241,8 @@ static OutputFieldDependency find_group_output_dependencies( /* Propagate search further to the left. */ for (const bNodeSocket *origin_input_socket : - gather_input_socket_dependencies(field_dependency, origin_node)) { + gather_input_socket_dependencies(field_dependency, origin_node)) + { if (!origin_input_socket->is_available()) { continue; } @@ -398,8 +400,8 @@ static void propagate_field_status_from_left_to_right( } state.is_single = true; if (!input_socket->is_directly_linked()) { - if (inferencing_interface.inputs[input_socket->index()] == - InputSocketFieldType::Implicit) { + if (inferencing_interface.inputs[input_socket->index()] == InputSocketFieldType::Implicit) + { state.is_single = false; } } diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index c4e25a8e97d..0da51c56564 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -487,7 +487,8 @@ class NodeTreeMainUpdater { } if (ntree.runtime->changed_flag & NTREE_CHANGED_INTERFACE || - ntree.runtime->changed_flag & NTREE_CHANGED_ANY) { + ntree.runtime->changed_flag & NTREE_CHANGED_ANY) + { result.interface_changed = true; } @@ -722,7 +723,8 @@ class NodeTreeMainUpdater { for (const StringRefNull idname : {"ShaderNodeOutputMaterial", "ShaderNodeOutputLight", "ShaderNodeOutputWorld", - "ShaderNodeOutputAOV"}) { + "ShaderNodeOutputAOV"}) + { const Span nodes = ntree.nodes_by_type(idname); if (!nodes.is_empty()) { ntree.runtime->runtime_flag |= NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT; @@ -806,7 +808,8 @@ class NodeTreeMainUpdater { /* The topology hash can only be used when only topology-changing operations have been done. */ if (tree.runtime->changed_flag == - (tree.runtime->changed_flag & (NTREE_CHANGED_LINK | NTREE_CHANGED_REMOVED_NODE))) { + (tree.runtime->changed_flag & (NTREE_CHANGED_LINK | NTREE_CHANGED_REMOVED_NODE))) + { if (old_topology_hash == new_topology_hash) { return false; } @@ -847,7 +850,8 @@ class NodeTreeMainUpdater { if (node.type == NODE_GROUP) { const bNodeTree *node_group = reinterpret_cast(node.id); if (node_group != nullptr && - node_group->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT) { + node_group->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT) + { return true; } } diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 11fbdd5add7..d4bb1112971 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1177,14 +1177,16 @@ static void object_lib_override_apply_post(ID *id_dst, ID *id_src) PTCacheID *pid_src, *pid_dst; for (pid_dst = (PTCacheID *)pidlist_dst.first, pid_src = (PTCacheID *)pidlist_src.first; pid_dst != nullptr; - pid_dst = pid_dst->next, pid_src = (pid_src != nullptr) ? pid_src->next : nullptr) { + pid_dst = pid_dst->next, pid_src = (pid_src != nullptr) ? pid_src->next : nullptr) + { /* If pid's do not match, just tag info of caches in dst as dirty and continue. */ if (pid_src == nullptr) { continue; } if (pid_dst->type != pid_src->type || pid_dst->file_type != pid_src->file_type || pid_dst->default_step != pid_src->default_step || pid_dst->max_step != pid_src->max_step || - pid_dst->data_types != pid_src->data_types || pid_dst->info_types != pid_src->info_types) { + pid_dst->data_types != pid_src->data_types || pid_dst->info_types != pid_src->info_types) + { LISTBASE_FOREACH (PointCache *, point_cache_src, pid_src->ptcaches) { point_cache_src->flag |= PTCACHE_FLAG_INFO_DIRTY; } @@ -1196,7 +1198,8 @@ static void object_lib_override_apply_post(ID *id_dst, ID *id_src) point_cache_src = (PointCache *)pid_src->ptcaches->first; point_cache_dst != nullptr; point_cache_dst = point_cache_dst->next, - point_cache_src = (point_cache_src != nullptr) ? point_cache_src->next : nullptr) { + point_cache_src = (point_cache_src != nullptr) ? point_cache_src->next : nullptr) + { /* Always force updating info about caches of applied lib-overrides. */ point_cache_dst->flag |= PTCACHE_FLAG_INFO_DIRTY; if (point_cache_src == nullptr || !STREQ(point_cache_dst->name, point_cache_src->name)) { @@ -1461,7 +1464,8 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) } if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) || - (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) { + (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) + { return false; } @@ -1638,7 +1642,8 @@ bool BKE_object_modifier_stack_copy(Object *ob_dst, } if (!BLI_listbase_is_empty(&ob_dst->modifiers) || - !BLI_listbase_is_empty(&ob_dst->greasepencil_modifiers)) { + !BLI_listbase_is_empty(&ob_dst->greasepencil_modifiers)) + { BLI_assert( !"Trying to copy a modifier stack into an object having a non-empty modifier stack."); return false; @@ -1812,7 +1817,8 @@ void BKE_object_free_derived_caches(Object *ob) object_update_from_subsurf_ccg(ob); if (ob->runtime.editmesh_eval_cage && - ob->runtime.editmesh_eval_cage != reinterpret_cast(ob->runtime.data_eval)) { + ob->runtime.editmesh_eval_cage != reinterpret_cast(ob->runtime.data_eval)) + { BKE_mesh_eval_delete(ob->runtime.editmesh_eval_cage); } ob->runtime.editmesh_eval_cage = nullptr; @@ -3211,7 +3217,8 @@ static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4]) /* vec: 4 items! */ if (BKE_where_on_path( - par, ctime, vec, nullptr, (cu->flag & CU_FOLLOW) ? quat : nullptr, &radius, nullptr)) { + par, ctime, vec, nullptr, (cu->flag & CU_FOLLOW) ? quat : nullptr, &radius, nullptr)) + { if (cu->flag & CU_FOLLOW) { quat_apply_track(quat, ob->trackflag, ob->upflag); normalize_qt(quat); @@ -4938,14 +4945,16 @@ int BKE_object_is_modified(Scene *scene, Object *ob) /* cloth */ for (md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md = md->next) { + md = md->next) + { if ((flag & eModifierMode_Render) == 0 && BKE_modifier_is_enabled(scene, md, eModifierMode_Render)) { flag |= eModifierMode_Render; } if ((flag & eModifierMode_Realtime) == 0 && - BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) { + BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) + { flag |= eModifierMode_Realtime; } } @@ -5074,7 +5083,8 @@ int BKE_object_is_deform_modified(Scene *scene, Object *ob) /* cloth */ for (md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md = md->next) { + md = md->next) + { const ModifierTypeInfo *mti = BKE_modifier_get_info((const ModifierType)md->type); bool can_deform = mti->type == eModifierTypeType_OnlyDeform || is_modifier_animated; @@ -5247,7 +5257,8 @@ LinkNode *BKE_object_relational_superset(const Scene *scene, } else { if ((objectSet == OB_SET_SELECTED && BASE_SELECTED_EDITABLE(((View3D *)nullptr), base)) || - (objectSet == OB_SET_VISIBLE && BASE_EDITABLE(((View3D *)nullptr), base))) { + (objectSet == OB_SET_VISIBLE && BASE_EDITABLE(((View3D *)nullptr), base))) + { Object *ob = base->object; if (obrel_list_test(ob)) { @@ -5282,7 +5293,8 @@ LinkNode *BKE_object_relational_superset(const Scene *scene, if (obrel_list_test(child)) { if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && BKE_object_is_child_recursive(ob, child)) || - (includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob)) { + (includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob)) + { obrel_list_add(&links, child); } } diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c index 07db35b49e7..7fce89617d3 100644 --- a/source/blender/blenkernel/intern/object_deform.c +++ b/source/blender/blenkernel/intern/object_deform.c @@ -568,7 +568,8 @@ bool *BKE_object_defgroup_validmap_get(Object *ob, const int defbase_tot) /* now loop through the armature modifiers and identify deform bones */ for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0), BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData) : - md->next) { + md->next) + { if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual))) { continue; } diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 87363380294..1c826d0ab9b 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -981,7 +981,8 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, nullptr, id, &geometry_set, - i)) { + i)) + { break; } @@ -1012,7 +1013,8 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, nullptr, id, &geometry_set, - i)) { + i)) + { make_duplis_geometry_set_impl( &sub_ctx, reference.geometry_set(), new_transform, true, false); } @@ -1383,7 +1385,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem totchild = psys->totchild; if ((for_render || part->draw_as == PART_DRAW_REND) && - ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) + { ParticleSimulationData sim = {nullptr}; sim.depsgraph = ctx->depsgraph; sim.scene = scene; @@ -1454,8 +1457,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } } else { - FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( - part->instance_collection, object, mode) { + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object, mode) + { (void)object; totcollection++; } @@ -1482,8 +1485,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else { a = 0; - FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( - part->instance_collection, object, mode) { + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object, mode) + { oblist[a] = object; a++; } @@ -1526,7 +1529,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem /* Some hair paths might be non-existent so they can't be used for duplication. */ if (hair && psys->pathcache && ((a < totpart && psys->pathcache[a]->segments < 0) || - (a >= totpart && psys->childcache[a - totpart]->segments < 0))) { + (a >= totpart && psys->childcache[a - totpart]->segments < 0))) + { continue; } @@ -1577,8 +1581,8 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { b = 0; - FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( - part->instance_collection, object, mode) { + FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object, mode) + { copy_m4_m4(tmat, oblist[b]->object_to_world); /* Apply collection instance offset. */ @@ -1705,7 +1709,8 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx) /* Should the dupli's be generated for this object? - Respect restrict flags. */ if (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER ? (visibility_flag & OB_HIDE_RENDER) : - (visibility_flag & OB_HIDE_VIEWPORT)) { + (visibility_flag & OB_HIDE_VIEWPORT)) + { return nullptr; } @@ -1789,7 +1794,8 @@ ListBase *object_duplilist_preview(Depsgraph *depsgraph, continue; } if (const geo_log::ViewerNodeLog *viewer_log = - geo_log::GeoModifierLog::find_viewer_node_log_for_path(*viewer_path)) { + geo_log::GeoModifierLog::find_viewer_node_log_for_path(*viewer_path)) + { ctx.preview_base_geometry = &viewer_log->geometry; make_duplis_geometry_set_impl( &ctx, viewer_log->geometry, ob_eval->object_to_world, true, ob_eval->type == OB_CURVES); diff --git a/source/blender/blenkernel/intern/object_facemap.c b/source/blender/blenkernel/intern/object_facemap.c index dff87469084..31404afe07c 100644 --- a/source/blender/blenkernel/intern/object_facemap.c +++ b/source/blender/blenkernel/intern/object_facemap.c @@ -150,8 +150,8 @@ static void object_fmap_remove_edit_mode(Object *ob, bFaceMap *fmap, bool do_sel BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { map = BM_ELEM_CD_GET_VOID_P(efa, cd_fmap_offset); - if (map && *map == fmap_nr && - (!do_selected || BM_elem_flag_test(efa, BM_ELEM_SELECT))) { + if (map && *map == fmap_nr && (!do_selected || BM_elem_flag_test(efa, BM_ELEM_SELECT))) + { *map = -1; } } diff --git a/source/blender/blenkernel/intern/object_update.cc b/source/blender/blenkernel/intern/object_update.cc index be2e93d7a48..61cb6aa5cff 100644 --- a/source/blender/blenkernel/intern/object_update.cc +++ b/source/blender/blenkernel/intern/object_update.cc @@ -209,7 +209,8 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o /* check use of dupli objects here */ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || use_render_params) && ((psys->part->ren_as == PART_DRAW_OB && psys->part->instance_object) || - (psys->part->ren_as == PART_DRAW_GR && psys->part->instance_collection))) { + (psys->part->ren_as == PART_DRAW_GR && psys->part->instance_collection))) + { ob->transflag |= OB_DUPLIPARTS; } @@ -265,7 +266,8 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) for (ModifierData *md = static_cast(object->modifiers.first), *md_orig = static_cast(object_orig->modifiers.first); md != nullptr && md_orig != nullptr; - md = md->next, md_orig = md_orig->next) { + md = md->next, md_orig = md_orig->next) + { BLI_assert(md->type == md_orig->type && STREQ(md->name, md_orig->name)); MEM_SAFE_FREE(md_orig->error); if (md->error != nullptr) { @@ -425,7 +427,8 @@ void BKE_object_eval_eval_base_flags(Depsgraph *depsgraph, if (object->mode == OB_MODE_PARTICLE_EDIT) { for (ParticleSystem *psys = static_cast(object->particlesystem.first); psys != nullptr; - psys = psys->next) { + psys = psys->next) + { BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL); } } diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 73619facd93..312e1357f79 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -852,7 +852,8 @@ bool BKE_ocean_init(struct Ocean *o, (o->_h0_minus = (fftw_complex *)MEM_mallocN(sizeof(fftw_complex) * (size_t)M * N, "ocean_h0_minus")) && (o->_kx = (float *)MEM_mallocN(sizeof(float) * o->_M, "ocean_kx")) && - (o->_kz = (float *)MEM_mallocN(sizeof(float) * o->_N, "ocean_kz"))) { + (o->_kz = (float *)MEM_mallocN(sizeof(float) * o->_N, "ocean_kz"))) + { /* Success. */ } else { @@ -1119,8 +1120,8 @@ void BKE_ocean_free(struct Ocean *oc) # define CACHE_TYPE_SPRAY 4 # define CACHE_TYPE_SPRAY_INVERSE 5 -static void cache_filename( - char *string, const char *path, const char *relbase, int frame, int type) +static void cache_filepath( + char *filepath, const char *dirname, const char *relbase, int frame, int type) { char cachepath[FILE_MAX]; const char *fname; @@ -1144,10 +1145,10 @@ static void cache_filename( break; } - BLI_path_join(cachepath, sizeof(cachepath), path, fname); + BLI_path_join(cachepath, sizeof(cachepath), dirname, fname); BKE_image_path_from_imtype( - string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, ""); + filepath, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, ""); } /* silly functions but useful to inline when the args do a lot of indirections */ @@ -1345,7 +1346,7 @@ struct OceanCache *BKE_ocean_init_cache(const char *bakepath, void BKE_ocean_simulate_cache(struct OceanCache *och, int frame) { - char string[FILE_MAX]; + char filepath[FILE_MAX]; int f = frame; /* ibufs array is zero based, but filenames are based on frame numbers */ @@ -1361,20 +1362,20 @@ void BKE_ocean_simulate_cache(struct OceanCache *och, int frame) /* Use default color spaces since we know for sure cache * files were saved with default settings too. */ - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); - och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); + och->ibufs_disp[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); - och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); + och->ibufs_foam[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY); - och->ibufs_spray[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY); + och->ibufs_spray[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY_INVERSE); - och->ibufs_spray_inverse[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_SPRAY_INVERSE); + och->ibufs_spray_inverse[f] = IMB_loadiffname(filepath, 0, NULL); - cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); - och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL); + cache_filepath(filepath, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); + och->ibufs_norm[f] = IMB_loadiffname(filepath, 0, NULL); } void BKE_ocean_bake(struct Ocean *o, @@ -1395,7 +1396,7 @@ void BKE_ocean_bake(struct Ocean *o, float *prev_foam; int res_x = och->resolution_x; int res_y = och->resolution_y; - char string[FILE_MAX]; + char filepath[FILE_MAX]; // RNG *rng; if (!o) { @@ -1494,34 +1495,34 @@ void BKE_ocean_bake(struct Ocean *o, } /* write the images */ - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); - if (0 == BKE_imbuf_write(ibuf_disp, string, &imf)) { - printf("Cannot save Displacement File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); + if (0 == BKE_imbuf_write(ibuf_disp, filepath, &imf)) { + printf("Cannot save Displacement File Output to %s\n", filepath); } if (o->_do_jacobian) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); - if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) { - printf("Cannot save Foam File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); + if (0 == BKE_imbuf_write(ibuf_foam, filepath, &imf)) { + printf("Cannot save Foam File Output to %s\n", filepath); } if (o->_do_spray) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY); - if (0 == BKE_imbuf_write(ibuf_spray, string, &imf)) { - printf("Cannot save Spray File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY); + if (0 == BKE_imbuf_write(ibuf_spray, filepath, &imf)) { + printf("Cannot save Spray File Output to %s\n", filepath); } - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY_INVERSE); - if (0 == BKE_imbuf_write(ibuf_spray_inverse, string, &imf)) { - printf("Cannot save Spray Inverse File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_SPRAY_INVERSE); + if (0 == BKE_imbuf_write(ibuf_spray_inverse, filepath, &imf)) { + printf("Cannot save Spray Inverse File Output to %s\n", filepath); } } } if (o->_do_normals) { - cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); - if (0 == BKE_imbuf_write(ibuf_normal, string, &imf)) { - printf("Cannot save Normal File Output to %s\n", string); + cache_filepath(filepath, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); + if (0 == BKE_imbuf_write(ibuf_normal, filepath, &imf)) { + printf("Cannot save Normal File Output to %s\n", filepath); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 53405c2f2ea..b5e0a5d4268 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -174,16 +174,16 @@ PackedFile *BKE_packedfile_new_from_memory(void *mem, int memlen) return pf; } -PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath, const char *basepath) +PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath) { PackedFile *pf = NULL; int file, filelen; - char name[FILE_MAX]; + char filepath[FILE_MAX]; void *data; /* render result has no filepath and can be ignored * any other files with no name can be ignored too */ - if (filepath[0] == '\0') { + if (filepath_rel[0] == '\0') { return pf; } @@ -191,15 +191,15 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath, const /* convert relative filenames to absolute filenames */ - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, basepath); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, basepath); /* open the file * and create a PackedFile structure */ - file = BLI_open(name, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { - BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name); + BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", filepath); } else { filelen = BLI_file_descriptor_size(file); @@ -251,8 +251,8 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose) } for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) { - if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && - BKE_vfont_is_builtin(vfont) == false) { + if (vfont->packedfile == NULL && !ID_IS_LINKED(vfont) && BKE_vfont_is_builtin(vfont) == false) + { vfont->packedfile = BKE_packedfile_new( reports, vfont->filepath, BKE_main_blendfile_path(bmain)); tot++; @@ -285,28 +285,28 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose) int BKE_packedfile_write_to_file(ReportList *reports, const char *ref_file_name, - const char *filepath, + const char *filepath_rel, PackedFile *pf, const bool guimode) { int file, number; int ret_value = RET_OK; bool remove_tmp = false; - char name[FILE_MAX]; - char tempname[FILE_MAX]; + char filepath[FILE_MAX]; + char filepath_temp[FILE_MAX]; /* void *data; */ if (guimode) { } // XXX waitcursor(1); - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, ref_file_name); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, ref_file_name); - if (BLI_exists(name)) { + if (BLI_exists(filepath)) { for (number = 1; number <= 999; number++) { - BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); - if (!BLI_exists(tempname)) { - if (BLI_copy(name, tempname) == RET_OK) { + BLI_snprintf(filepath_temp, sizeof(filepath_temp), "%s.%03d_", filepath, number); + if (!BLI_exists(filepath_temp)) { + if (BLI_copy(filepath, filepath_temp) == RET_OK) { remove_tmp = true; } break; @@ -314,21 +314,20 @@ int BKE_packedfile_write_to_file(ReportList *reports, } } - /* make sure the path to the file exists... */ - BLI_make_existing_file(name); + BLI_file_ensure_parent_dir_exists(filepath); - file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); + file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); if (file == -1) { - BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name); + BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", filepath); ret_value = RET_ERROR; } else { if (write(file, pf->data, pf->size) != pf->size) { - BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", name); + BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", filepath); ret_value = RET_ERROR; } else { - BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", name); + BKE_reportf(reports, RPT_INFO, "Saved packed file to: %s", filepath); } close(file); @@ -336,17 +335,17 @@ int BKE_packedfile_write_to_file(ReportList *reports, if (remove_tmp) { if (ret_value == RET_ERROR) { - if (BLI_rename(tempname, name) != 0) { + if (BLI_rename(filepath_temp, filepath) != 0) { BKE_reportf(reports, RPT_ERROR, "Error restoring temp file (check files '%s' '%s')", - tempname, - name); + filepath_temp, + filepath); } } else { - if (BLI_delete(tempname, false, false) != 0) { - BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", tempname); + if (BLI_delete(filepath_temp, false, false) != 0) { + BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", filepath_temp); } } } @@ -358,18 +357,18 @@ int BKE_packedfile_write_to_file(ReportList *reports, } enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, - const char *filepath, + const char *filepath_rel, PackedFile *pf) { BLI_stat_t st; enum ePF_FileCompare ret_val; char buf[4096]; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BLI_strncpy(name, filepath, sizeof(name)); - BLI_path_abs(name, ref_file_name); + BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + BLI_path_abs(filepath, ref_file_name); - if (BLI_stat(name, &st) == -1) { + if (BLI_stat(filepath, &st) == -1) { ret_val = PF_CMP_NOFILE; } else if (st.st_size != pf->size) { @@ -378,7 +377,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, else { /* we'll have to compare the two... */ - const int file = BLI_open(name, O_BINARY | O_RDONLY, 0); + const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { ret_val = PF_CMP_NOFILE; } @@ -479,7 +478,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports, return newname; } -static void unpack_generate_paths(const char *name, +static void unpack_generate_paths(const char *filepath, ID *id, char *r_abspath, char *r_relpath, @@ -487,15 +486,16 @@ static void unpack_generate_paths(const char *name, size_t relpathlen) { const short id_type = GS(id->name); - char tempname[FILE_MAX]; - char tempdir[FILE_MAXDIR]; + char temp_filename[FILE_MAX]; + char temp_dirname[FILE_MAXDIR]; - BLI_split_dirfile(name, tempdir, tempname, sizeof(tempdir), sizeof(tempname)); + BLI_path_split_dir_file( + filepath, temp_dirname, sizeof(temp_dirname), temp_filename, sizeof(temp_filename)); - if (tempname[0] == '\0') { + if (temp_filename[0] == '\0') { /* NOTE: we generally do not have any real way to re-create extension out of data. */ - const size_t len = BLI_strncpy_rlen(tempname, id->name + 2, sizeof(tempname)); - printf("%s\n", tempname); + const size_t len = BLI_strncpy_rlen(temp_filename, id->name + 2, sizeof(temp_filename)); + printf("%s\n", temp_filename); /* For images ensure that the temporary filename contains tile number information as well as * a file extension based on the file magic. */ @@ -508,22 +508,22 @@ static void unpack_generate_paths(const char *name, if (ima->source == IMA_SRC_TILED) { char tile_number[6]; BLI_snprintf(tile_number, sizeof(tile_number), ".%d", imapf->tile_number); - BLI_strncpy(tempname + len, tile_number, sizeof(tempname) - len); + BLI_strncpy(temp_filename + len, tile_number, sizeof(temp_filename) - len); } if (ftype != IMB_FTYPE_NONE) { const int imtype = BKE_ftype_to_imtype(ftype, NULL); - BKE_image_path_ensure_ext_from_imtype(tempname, imtype); + BKE_image_path_ensure_ext_from_imtype(temp_filename, imtype); } } } - BLI_filename_make_safe(tempname); - printf("%s\n", tempname); + BLI_path_make_safe_filename(temp_filename); + printf("%s\n", temp_filename); } - if (tempdir[0] == '\0') { + if (temp_dirname[0] == '\0') { /* Fallback to relative dir. */ - BLI_strncpy(tempdir, "//", sizeof(tempdir)); + BLI_strncpy(temp_dirname, "//", sizeof(temp_dirname)); } { @@ -545,13 +545,13 @@ static void unpack_generate_paths(const char *name, break; } if (dir_name) { - BLI_path_join(r_relpath, relpathlen, "//", dir_name, tempname); + BLI_path_join(r_relpath, relpathlen, "//", dir_name, temp_filename); } } { - size_t len = BLI_strncpy_rlen(r_abspath, tempdir, abspathlen); - BLI_strncpy(r_abspath + len, tempname, abspathlen - len); + size_t len = BLI_strncpy_rlen(r_abspath, temp_dirname, abspathlen); + BLI_strncpy(r_abspath + len, temp_filename, abspathlen - len); } } diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 14be0979940..4b448cfe778 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -750,8 +750,8 @@ void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_inde void BKE_palette_color_remove(Palette *palette, PaletteColor *color) { - if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) == - palette->active_color) { + if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) == palette->active_color) + { palette->active_color--; } @@ -1787,7 +1787,8 @@ static void sculpt_update_object( * that simply recompute vertex weights (which can even include Geometry Nodes). */ if (me_eval_deform->totpoly == me_eval->totpoly && me_eval_deform->totloop == me_eval->totloop && - me_eval_deform->totvert == me_eval->totvert) { + me_eval_deform->totvert == me_eval->totvert) + { BKE_sculptsession_free_deformMats(ss); BLI_assert(me_eval_deform->totvert == me->totvert); @@ -1929,7 +1930,8 @@ void BKE_sculpt_color_layer_create_if_needed(Object *object) char unique_name[MAX_CUSTOMDATA_LAYER_NAME]; BKE_id_attribute_calc_unique_name(&orig_me->id, "Color", unique_name); if (!orig_me->attributes_for_write().add( - unique_name, ATTR_DOMAIN_POINT, CD_PROP_COLOR, AttributeInitDefaultValue())) { + unique_name, ATTR_DOMAIN_POINT, CD_PROP_COLOR, AttributeInitDefaultValue())) + { return; } @@ -2857,7 +2859,8 @@ bool BKE_sculpt_attribute_destroy(Object *ob, SculptAttribute *attr) SculptAttribute *attr2 = ss->temp_attributes + i; if (STREQ(attr2->name, attr->name) && attr2->domain == attr->domain && - attr2->proptype == attr->proptype) { + attr2->proptype == attr->proptype) + { attr2->used = false; } diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c index f35755021d2..c1b0d3d8431 100644 --- a/source/blender/blenkernel/intern/paint_toolslots.c +++ b/source/blender/blenkernel/intern/paint_toolslots.c @@ -139,8 +139,8 @@ void BKE_paint_toolslots_brush_validate(Main *bmain, Paint *paint) for (int i = 0; i < paint->tool_slots_len; i++) { PaintToolSlot *tslot = &paint->tool_slots[i]; if (tslot->brush) { - if ((i != BKE_brush_tool_get(tslot->brush, paint)) || - (tslot->brush->ob_mode & ob_mode) == 0) { + if ((i != BKE_brush_tool_get(tslot->brush, paint)) || (tslot->brush->ob_mode & ob_mode) == 0) + { id_us_min(&tslot->brush->id); tslot->brush = NULL; } diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index fbc7e34f759..0320f98e349 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -662,7 +662,8 @@ short psys_get_current_num(Object *ob) } for (psys = static_cast(ob->particlesystem.first), i = 0; psys; - psys = psys->next, i++) { + psys = psys->next, i++) + { if (psys->flag & PSYS_CURRENT) { return i; } @@ -680,7 +681,8 @@ void psys_set_current_num(Object *ob, int index) } for (psys = static_cast(ob->particlesystem.first), i = 0; psys; - psys = psys->next, i++) { + psys = psys->next, i++) + { if (i == index) { psys->flag |= PSYS_CURRENT; } @@ -2137,8 +2139,8 @@ void psys_particle_on_dm(Mesh *mesh_final, const float(*orcodata)[3]; int mapindex; - if (!psys_map_index_on_dm( - mesh_final, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) { + if (!psys_map_index_on_dm(mesh_final, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) + { if (vec) { vec[0] = vec[1] = vec[2] = 0.0; } @@ -2246,7 +2248,8 @@ float psys_particle_value_from_verts(Mesh *mesh, short from, ParticleData *pa, f int mapindex; if (!psys_map_index_on_dm( - mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw)) { + mesh, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw)) + { return 0.0f; } @@ -2487,7 +2490,8 @@ bool do_guides(Depsgraph *depsgraph, guidedir, nullptr, &radius, - &weight) == 0) { + &weight) == 0) + { return 0; } } @@ -2782,7 +2786,8 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleEditSettings *pset = &scene->toolsettings->particle; if ((use_render_params == 0) && - (psys_orig_edit_get(psys) == nullptr || pset->flag & PE_DRAW_PART) == 0) { + (psys_orig_edit_get(psys) == nullptr || pset->flag & PE_DRAW_PART) == 0) + { totchild = 0; } @@ -3905,7 +3910,8 @@ static void psys_face_mat(Object *ob, Mesh *mesh, ParticleData *pa, float mat[4] CustomData_get_for_write(&mesh->fdata, i, CD_ORIGSPACE, mesh->totface)); if (orco && - (orcodata = static_cast(CustomData_get_layer(&mesh->vdata, CD_ORCO)))) { + (orcodata = static_cast(CustomData_get_layer(&mesh->vdata, CD_ORCO)))) + { copy_v3_v3(v[0], orcodata[mface->v1]); copy_v3_v3(v[1], orcodata[mface->v2]); copy_v3_v3(v[2], orcodata[mface->v3]); @@ -4078,21 +4084,24 @@ void object_remove_particle_system(Main *bmain, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYBUBBLE, - PART_FLUID_SPRAYFOAMBUBBLE)) { + PART_FLUID_SPRAYFOAMBUBBLE)) + { fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY; } if (ELEM(psys->part->type, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_FOAMBUBBLE, - PART_FLUID_SPRAYFOAMBUBBLE)) { + PART_FLUID_SPRAYFOAMBUBBLE)) + { fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM; } if (ELEM(psys->part->type, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYBUBBLE, - PART_FLUID_SPRAYFOAMBUBBLE)) { + PART_FLUID_SPRAYFOAMBUBBLE)) + { fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE; } if (psys->part->type == PART_FLUID_TRACER) { @@ -4104,7 +4113,8 @@ void object_remove_particle_system(Main *bmain, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYBUBBLE, PART_FLUID_FOAMBUBBLE, - PART_FLUID_SPRAYFOAMBUBBLE)) { + PART_FLUID_SPRAYFOAMBUBBLE)) + { fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF; } } @@ -4326,7 +4336,8 @@ static void get_cpa_texture(Mesh *mesh, if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || - part->distr == PART_DISTR_GRID)) { + part->distr == PART_DISTR_GRID)) + { texco = TEXCO_GLOB; } @@ -4347,7 +4358,8 @@ static void get_cpa_texture(Mesh *mesh, fw, mtex->uvname, texvec, - (part->from == PART_FROM_VERT))) { + (part->from == PART_FROM_VERT))) + { break; } /* no break, failed to get uv's, so let's try orco's */ @@ -4414,7 +4426,8 @@ void psys_get_texture( short texco = mtex->texco; if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || - part->distr == PART_DISTR_GRID)) { + part->distr == PART_DISTR_GRID)) + { texco = TEXCO_GLOB; } @@ -4435,7 +4448,8 @@ void psys_get_texture( pa->fuv, mtex->uvname, texvec, - (part->from == PART_FROM_VERT))) { + (part->from == PART_FROM_VERT))) + { break; } /* no break, failed to get uv's, so let's try orco's */ @@ -4946,7 +4960,8 @@ bool psys_get_particle_state(ParticleSimulationData *sim, if (!always) { if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) || - (state->time > 1.0f && !(part->flag & PART_DIED))) { + (state->time > 1.0f && !(part->flag & PART_DIED))) + { return false; } } @@ -4968,7 +4983,8 @@ bool psys_get_particle_state(ParticleSimulationData *sim, if (pa) { if (!always) { if ((cfra < pa->time && (part->flag & PART_UNBORN) == 0) || - (cfra >= pa->dietime && (part->flag & PART_DIED) == 0)) { + (cfra >= pa->dietime && (part->flag & PART_DIED) == 0)) + { return false; } } @@ -5343,7 +5359,8 @@ void BKE_particle_system_blend_write(BlendWriter *writer, ListBase *particles) } if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) && - (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) { + (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) + { BLO_write_struct_array( writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs); } diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index cac20c039ab..4d0770226b8 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -900,7 +900,8 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, } if (!BKE_mesh_is_deformed_only(final_mesh) && - !CustomData_get_layer(&final_mesh->fdata, CD_ORIGINDEX)) { + !CustomData_get_layer(&final_mesh->fdata, CD_ORIGINDEX)) + { printf( "Can't create particles with the current modifier stack, disable destructive modifiers\n"); // XXX error("Can't paint with the current modifier stack, disable destructive modifiers"); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6e5b343c3b3..baa327c0fe7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1077,7 +1077,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, bpa->gravity[0] = bpa->gravity[1] = 0.0f; bpa->gravity[2] = -1.0f; if ((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) && - (sim->scene->physics_settings.gravity[2] != 0.0f)) { + (sim->scene->physics_settings.gravity[2] != 0.0f)) + { bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; } @@ -1110,7 +1111,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->dietime = pa->time + pa->lifetime; if ((sim->psys->pointcache) && (sim->psys->pointcache->flag & PTCACHE_BAKED) && - (sim->psys->pointcache->mem_cache.first)) { + (sim->psys->pointcache->mem_cache.first)) + { float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p); pa->dietime = MIN2(pa->dietime, dietime); } @@ -1584,7 +1586,8 @@ static void sph_spring_delete(ParticleSystem *psys, int j) psys->tot_fluidsprings--; if (psys->tot_fluidsprings < psys->alloc_fluidsprings / 2 && - psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE) { + psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE) + { psys->alloc_fluidsprings /= 2; psys->fluid_springs = (ParticleSpring *)MEM_reallocN( psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring)); @@ -2279,7 +2282,8 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa /* add global acceleration (gravitation) */ if (psys_uses_gravity(sim) && /* normal gravity is too strong for hair so it's disabled by default */ - (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) { + (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) + { zero_v3(gr); madd_v3_v3fl(gr, sim->scene->physics_settings.gravity, @@ -2334,7 +2338,8 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f } if ((part->flag & PART_ROT_DYN) && - ELEM(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) { + ELEM(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) + { float angle; float len1 = len_v3(pa->prev_state.vel); float len2 = len_v3(pa->state.vel); @@ -3010,7 +3015,8 @@ static int collision_response(ParticleSimulationData *sim, /* calculate normal particle velocity */ /* special case for object hitting the particle from behind */ if (through == 0 && ((vc_dot > 0.0f && v0_dot > 0.0f && vc_dot > v0_dot) || - (vc_dot < 0.0f && v0_dot < 0.0f && vc_dot < v0_dot))) { + (vc_dot < 0.0f && v0_dot < 0.0f && vc_dot < v0_dot))) + { mul_v3_v3fl(v0_nor, pce->nor, vc_dot); } else if (v0_dot > 0.0f) { @@ -3153,7 +3159,8 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa } else if (collision_response( sim, pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN) == - 0) { + 0) + { return; } } @@ -3181,12 +3188,14 @@ static void psys_update_path_cache(ParticleSimulationData *sim, if ((psys->part->childtype && psys->totchild != psys_get_tot_child(sim->scene, psys, use_render_params)) || - psys->recalc & ID_RECALC_PSYS_RESET) { + psys->recalc & ID_RECALC_PSYS_RESET) + { alloc = 1; } if (alloc || psys->recalc & ID_RECALC_PSYS_CHILD || - (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT))) { + (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT))) + { distr = 1; } @@ -3211,11 +3220,13 @@ static void psys_update_path_cache(ParticleSimulationData *sim, } if ((part->type == PART_HAIR || psys->flag & PSYS_KEYED || - psys->pointcache->flag & PTCACHE_BAKED) == 0) { + psys->pointcache->flag & PTCACHE_BAKED) == 0) + { skip = 1; /* only hair, keyed and baked stuff can have paths */ } else if (part->ren_as != PART_DRAW_PATH && - !(part->type == PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))) { + !(part->type == PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))) + { skip = 1; /* particle visualization must be set as path */ } else if (DEG_get_mode(sim->depsgraph) != DAG_EVAL_RENDER) { @@ -3230,7 +3241,8 @@ static void psys_update_path_cache(ParticleSimulationData *sim, skip = 1; } else if (part->childtype == 0 && - (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0) { + (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0) + { skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */ } } @@ -3878,8 +3890,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) ParticleTarget *pt = psys->targets.first; psys_update_particle_bvhtree(psys, cfra); - for (; pt; - pt = pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ + /* Updating others systems particle tree for fluid-fluid interaction. */ + for (; pt; pt = pt->next) { if (pt->ob) { psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys - 1), cfra); } @@ -3922,15 +3934,16 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* Only reset unborn particles if they're shown or if the particle is born soon. */ if (pa->alive == PARS_UNBORN && - (part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) { + (part->flag & PART_UNBORN || (cfra + psys->pointcache->step > pa->time))) + { reset_particle(sim, pa, dtime, cfra); } else if (part->phystype == PART_PHYS_NO) { reset_particle(sim, pa, dtime, cfra); } - if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING) == 0 || - (pa->flag & (PARS_UNEXIST | PARS_NO_DISP))) { + if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING) == 0 || (pa->flag & (PARS_UNEXIST | PARS_NO_DISP))) + { pa->state.time = -1.0f; } } @@ -4209,7 +4222,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, (particles_has_foam(part->type) && (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) == 0) || (particles_has_tracer(part->type) && - (fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) == 0)) { + (fds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) == 0)) + { BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "particles_fluid_step::error - found particle system that is not enabled in " @@ -4222,7 +4236,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, tottypepart = totpart = manta_liquid_get_num_flip_particles(fds->fluid); } if (particles_has_spray(part->type) || particles_has_bubble(part->type) || - particles_has_foam(part->type) || particles_has_tracer(part->type)) { + particles_has_foam(part->type) || particles_has_tracer(part->type)) + { totpart = manta_liquid_get_num_snd_particles(fds->fluid); /* tottypepart is the amount of particles of a snd particle type. */ @@ -4289,7 +4304,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, velZ = manta_liquid_get_flip_particle_velocity_z_at(fds->fluid, p); } else if (particles_has_spray(part->type) || particles_has_bubble(part->type) || - particles_has_foam(part->type) || particles_has_tracer(part->type)) { + particles_has_foam(part->type) || particles_has_tracer(part->type)) + { flagActivePart = manta_liquid_get_snd_particle_flag_at(fds->fluid, p); resX = (float)manta_liquid_get_particle_res_x(fds->fluid); @@ -4726,7 +4742,8 @@ static int hair_needs_recalc(ParticleSystem *psys) { if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) && ((psys->flag & PSYS_HAIR_DONE) == 0 || psys->recalc & ID_RECALC_PSYS_RESET || - (psys->part->flag & PART_HAIR_REGROW && !psys->edit))) { + (psys->part->flag & PART_HAIR_REGROW && !psys->edit))) + { return 1; } @@ -4865,7 +4882,8 @@ void particle_system_update(struct Depsgraph *depsgraph, } else if (particles_has_flip(part->type) || particles_has_spray(part->type) || particles_has_bubble(part->type) || particles_has_foam(part->type) || - particles_has_tracer(part->type)) { + particles_has_tracer(part->type)) + { particles_fluid_step(&sim, (int)cfra, use_render_params); } else { diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index f4c26dcf7a8..cd9a96601a3 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -2411,7 +2411,8 @@ bool ray_face_intersection_quad(const float ray_start[3], if ((isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t1, t2, &depth_test, nullptr) && (depth_test < *depth)) || (isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t2, t3, &depth_test, nullptr) && - (depth_test < *depth))) { + (depth_test < *depth))) + { *depth = depth_test; return true; } @@ -2428,7 +2429,8 @@ bool ray_face_intersection_tri(const float ray_start[3], { float depth_test; if (isect_ray_tri_watertight_v3(ray_start, isect_precalc, t0, t1, t2, &depth_test, nullptr) && - (depth_test < *depth)) { + (depth_test < *depth)) + { *depth = depth_test; return true; } @@ -2474,11 +2476,13 @@ bool ray_face_nearest_quad(const float ray_start[3], float co[3], depth_test; if ((dist_sq_test = dist_squared_ray_to_tri_v3_fast( - ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq) { + ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq) + { *dist_sq = dist_sq_test; *depth = depth_test; if ((dist_sq_test = dist_squared_ray_to_tri_v3_fast( - ray_start, ray_normal, t0, t2, t3, co, &depth_test)) < *dist_sq) { + ray_start, ray_normal, t0, t2, t3, co, &depth_test)) < *dist_sq) + { *dist_sq = dist_sq_test; *depth = depth_test; } @@ -2500,7 +2504,8 @@ bool ray_face_nearest_tri(const float ray_start[3], float co[3], depth_test; if ((dist_sq_test = dist_squared_ray_to_tri_v3_fast( - ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq) { + ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq) + { *dist_sq = dist_sq_test; *depth = depth_test; return true; @@ -3795,7 +3800,8 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh) int grid_index = poly[loop_index]; if (pbvh->grid_hidden[grid_index] && - BLI_BITMAP_TEST(pbvh->grid_hidden[grid_index], key.grid_area - 1)) { + BLI_BITMAP_TEST(pbvh->grid_hidden[grid_index], key.grid_area - 1)) + { hidden = true; break; diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.cc b/source/blender/blenkernel/intern/pbvh_bmesh.cc index 50c15164f5d..a428ac63dc5 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.cc +++ b/source/blender/blenkernel/intern/pbvh_bmesh.cc @@ -828,7 +828,8 @@ static void edge_queue_insert(EdgeQueueContext *eq_ctx, BMEdge *e, float priorit if (((eq_ctx->cd_vert_mask_offset == -1) || (check_mask(eq_ctx, e->v1) || check_mask(eq_ctx, e->v2))) && !(BM_elem_flag_test_bool(e->v1, BM_ELEM_HIDDEN) || - BM_elem_flag_test_bool(e->v2, BM_ELEM_HIDDEN))) { + BM_elem_flag_test_bool(e->v2, BM_ELEM_HIDDEN))) + { BMVert **pair = static_cast(BLI_mempool_alloc(eq_ctx->pool)); pair[0] = e->v1; pair[1] = e->v2; @@ -1024,7 +1025,8 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx, /* Check leaf nodes marked for topology update */ if ((node->flag & PBVH_Leaf) && (node->flag & PBVH_UpdateTopology) && - !(node->flag & PBVH_FullyHidden)) { + !(node->flag & PBVH_FullyHidden)) + { GSetIterator gs_iter; /* Check each face */ @@ -1083,7 +1085,8 @@ static void short_edge_queue_create(EdgeQueueContext *eq_ctx, /* Check leaf nodes marked for topology update */ if ((node->flag & PBVH_Leaf) && (node->flag & PBVH_UpdateTopology) && - !(node->flag & PBVH_FullyHidden)) { + !(node->flag & PBVH_FullyHidden)) + { GSetIterator gs_iter; /* Check each face */ @@ -1253,7 +1256,8 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, * and the node has been split, thus leaving wire edges and * associated vertices. */ if ((BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE) || - (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE)) { + (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE)) + { continue; } @@ -1281,7 +1285,8 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh, /* one of the two vertices may be masked, select the correct one for deletion */ if (BM_ELEM_CD_GET_FLOAT(v1, eq_ctx->cd_vert_mask_offset) < - BM_ELEM_CD_GET_FLOAT(v2, eq_ctx->cd_vert_mask_offset)) { + BM_ELEM_CD_GET_FLOAT(v2, eq_ctx->cd_vert_mask_offset)) + { v_del = v1; v_conn = v2; } @@ -1343,8 +1348,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh, { BLI_buffer_append(deleted_faces, BMFace *, existing_face); } - else - { + else { BMVert *v_tri[3] = {v_conn, l->next->v, l->prev->v}; BLI_assert(!BM_face_exists(v_tri, 3)); @@ -1453,7 +1457,8 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, /* Check the verts still exist */ if (!(v1 = bm_vert_hash_lookup_chain(deleted_verts, v1)) || - !(v2 = bm_vert_hash_lookup_chain(deleted_verts, v2)) || (v1 == v2)) { + !(v2 = bm_vert_hash_lookup_chain(deleted_verts, v2)) || (v1 == v2)) + { continue; } @@ -1475,7 +1480,8 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, * and the node has been split, thus leaving wire edges and * associated vertices. */ if ((BM_ELEM_CD_GET_INT(e->v1, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE) || - (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE)) { + (BM_ELEM_CD_GET_INT(e->v2, eq_ctx->cd_vert_node_offset) == DYNTOPO_NODE_NONE)) + { continue; } @@ -1549,7 +1555,8 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node, BM_face_as_array_vert_tri(f, v_tri); if (ray_face_intersection_tri( - ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth)) { + ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth)) + { hit = true; if (r_face_normal) { @@ -1561,7 +1568,8 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node, madd_v3_v3v3fl(location, ray_start, ray_normal, *depth); for (int j = 0; j < 3; j++) { if (j == 0 || len_squared_v3v3(location, v_tri[j]->co) < - len_squared_v3v3(location, nearest_vertex_co)) { + len_squared_v3v3(location, nearest_vertex_co)) + { copy_v3_v3(nearest_vertex_co, v_tri[j]->co); r_active_vertex->i = intptr_t(v_tri[j]); } diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc index 1834aab06ad..4f472ddd199 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc @@ -296,7 +296,8 @@ struct Rows { tile_pixels.pixel_rows, [&](const PackedPixelRow &encoded_pixels) { for (int x = encoded_pixels.start_image_coordinate.x; x < encoded_pixels.start_image_coordinate.x + encoded_pixels.num_pixels; - x++) { + x++) + { int64_t index = encoded_pixels.start_image_coordinate.y * resolution.x + x; pixels[index].type = PixelType::Brush; pixels[index].distance = 0.0f; diff --git a/source/blender/blenkernel/intern/pbvh_uv_islands.cc b/source/blender/blenkernel/intern/pbvh_uv_islands.cc index 389cef21306..d3f0b35f1ed 100644 --- a/source/blender/blenkernel/intern/pbvh_uv_islands.cc +++ b/source/blender/blenkernel/intern/pbvh_uv_islands.cc @@ -160,7 +160,8 @@ static void extract_uv_neighbors(const MeshData &mesh_data, if (primitive_has_shared_uv_edge(mesh_data.uv_map, mesh_data.looptris[primitive_i], - mesh_data.looptris[other_primitive_i])) { + mesh_data.looptris[other_primitive_i])) + { prims_to_add.append(other_primitive_i); } } @@ -1374,8 +1375,8 @@ UVEdge *UVPrimitive::get_uv_edge(const int v1, const int v2) const bool UVPrimitive::contains_uv_vertex(const UVVertex *uv_vertex) const { for (UVEdge *edge : edges) { - if (std::find(edge->vertices.begin(), edge->vertices.end(), uv_vertex) != - edge->vertices.end()) { + if (std::find(edge->vertices.begin(), edge->vertices.end(), uv_vertex) != edge->vertices.end()) + { return true; } } @@ -1611,7 +1612,8 @@ static bool dilate_y(UVIslandsMask::Tile &islands_mask) changed = true; } else if (y < islands_mask.mask_resolution.y - 1 && - prev_mask[offset + islands_mask.mask_resolution.x] != 0xffff) { + prev_mask[offset + islands_mask.mask_resolution.x] != 0xffff) + { islands_mask.mask[offset] = prev_mask[offset + islands_mask.mask_resolution.x]; changed = true; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a211d76c9b0..35d6ecbc4ca 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -506,7 +506,8 @@ static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int UNUSE if (psys->part->phystype == PART_PHYS_FLUID && psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS && psys->tot_fluidsprings && - psys->fluid_springs) { + psys->fluid_springs) + { ptcache_add_extra_data( pm, BPHYS_EXTRA_FLUID_SPRINGS, psys->tot_fluidsprings, psys->fluid_springs); } @@ -934,7 +935,8 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p (1 << BPHYS_DATA_BOIDS); } else if (psys->part->phystype == PART_PHYS_FLUID && psys->part->fluid && - psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) { + psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) + { pid->write_extra_data = ptcache_particle_extra_write; pid->read_extra_data = ptcache_particle_extra_read; } @@ -943,7 +945,8 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p pid->data_types |= (1 << BPHYS_DATA_ROTATION); if (psys->part->rotmode != PART_ROT_VEL || psys->part->avemode == PART_AVE_RAND || - psys->part->avefac != 0.0f) { + psys->part->avefac != 0.0f) + { pid->data_types |= (1 << BPHYS_DATA_AVELOCITY); } } @@ -1220,7 +1223,8 @@ static bool foreach_object_ptcache( /* Rigid body. */ if (scene != NULL && (object == NULL || object->rigidbody_object != NULL) && - scene->rigidbody_world != NULL) { + scene->rigidbody_world != NULL) + { BKE_ptcache_id_from_rigidbody(&pid, object, scene->rigidbody_world); if (!callback(&pid, callback_user_data)) { return false; @@ -1322,7 +1326,7 @@ static int ptcache_path(PTCacheID *pid, char dirname[MAX_PTCACHE_PATH]) if ((blendfile_path[0] != '\0') || lib) { char file[MAX_PTCACHE_PATH]; /* we don't want the dir, only the file */ - BLI_split_file_part(blendfilename, file, sizeof(file)); + BLI_path_split_file_part(blendfilename, file, sizeof(file)); i = strlen(file); /* remove .blend */ @@ -1471,13 +1475,11 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) fp = BLI_fopen(filepath, "rb"); } else if (mode == PTCACHE_FILE_WRITE) { - /* Will create the dir if needs be, same as "//textures" is created. */ - BLI_make_existing_file(filepath); - + BLI_file_ensure_parent_dir_exists(filepath); fp = BLI_fopen(filepath, "wb"); } else if (mode == PTCACHE_FILE_UPDATE) { - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); fp = BLI_fopen(filepath, "rb+"); } @@ -1632,8 +1634,8 @@ static int ptcache_file_data_read(PTCacheFile *pf) int i; for (i = 0; i < BPHYS_TOT_DATA; i++) { - if ((pf->data_types & (1 << i)) && - !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) { + if ((pf->data_types & (1 << i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i])) + { return 0; } } @@ -2652,7 +2654,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, uint cfra) if (frame != -1) { if ((mode == PTCACHE_CLEAR_BEFORE && frame < cfra) || - (mode == PTCACHE_CLEAR_AFTER && frame > cfra)) { + (mode == PTCACHE_CLEAR_AFTER && frame > cfra)) + { BLI_path_join(path_full, sizeof(path_full), path, de->d_name); BLI_delete(path_full, false, false); if (pid->cache->cached_frames && frame >= sta && frame <= end) { @@ -2689,7 +2692,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, uint cfra) else { while (pm) { if ((mode == PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || - (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra)) { + (mode == PTCACHE_CLEAR_AFTER && pm->frame > cfra)) + { link = pm; if (pid->cache->cached_frames && pm->frame >= sta && pm->frame <= end) { pid->cache->cached_frames[pm->frame - sta] = 0; @@ -2946,7 +2950,8 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) else if (psys->clmd) { BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd); if (mode == PSYS_RESET_ALL || - !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) { + !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) + { reset |= BKE_ptcache_id_reset(scene, &pid, mode); } else { @@ -3241,7 +3246,8 @@ void BKE_ptcache_bake(PTCacheBaker *baker) if (pid->type == PTCACHE_TYPE_RIGIDBODY) { if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID) == 0) && - (render || bake)) { + (render || bake)) + { BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); } } @@ -3330,7 +3336,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) } /* clear baking flag */ - if (pid) { + if (pid && cache) { cache->flag &= ~(PTCACHE_BAKING | PTCACHE_REDO_NEEDED); cache->flag |= PTCACHE_SIMULATION_VALID; if (bake) { @@ -3348,7 +3354,8 @@ void BKE_ptcache_bake(PTCacheBaker *baker) for (pid = pidlist.first; pid; pid = pid->next) { /* skip hair particles */ if (pid->type == PTCACHE_TYPE_PARTICLES && - ((ParticleSystem *)pid->calldata)->part->type == PART_HAIR) { + ((ParticleSystem *)pid->calldata)->part->type == PART_HAIR) + { continue; } diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index b5509b1bfe2..69bd701bcf8 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -208,7 +208,8 @@ bool BKE_rigidbody_is_affected_by_simulation(Object *ob) RigidBodyOb *rbo = ob->rigidbody_object; if (rbo == NULL || rbo->flag & RBO_FLAG_KINEMATIC || rbo->type == RBO_TYPE_PASSIVE || - obCompoundParent) { + obCompoundParent) + { return false; } @@ -587,7 +588,8 @@ static void rigidbody_validate_sim_shape(RigidBodyWorld *rbw, Object *ob, bool r /* Also don't create a shape if this object is parent of a compound shape */ if (ob->parent != NULL && ob->parent->rigidbody_object != NULL && - ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) { + ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) + { return; } @@ -794,7 +796,8 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool } /* Don't create rigid body object if the parent is a compound shape */ if (ob->parent != NULL && ob->parent->rigidbody_object != NULL && - ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) { + ob->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) + { return; } @@ -1602,7 +1605,8 @@ static void rigidbody_update_ob_array(RigidBodyWorld *rbw) (void)object; /* Ignore if this object is the direct child of an object with a compound shape */ if (object->parent == NULL || object->parent->rigidbody_object == NULL || - object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) { + object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) + { n++; } } @@ -1617,7 +1621,8 @@ static void rigidbody_update_ob_array(RigidBodyWorld *rbw) FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) { /* Ignore if this object is the direct child of an object with a compound shape */ if (object->parent == NULL || object->parent->rigidbody_object == NULL || - object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) { + object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) + { rbw->objects[i] = object; i++; } @@ -1938,8 +1943,8 @@ static void rigidbody_update_external_forces(Depsgraph *depsgraph, /* update influence of effectors - but don't do it on an effector */ /* only dynamic bodies need effector update */ - if (rbo->type == RBO_TYPE_ACTIVE && - ((ob->pd == NULL) || (ob->pd->forcefield == PFIELD_NULL))) { + if (rbo->type == RBO_TYPE_ACTIVE && ((ob->pd == NULL) || (ob->pd->forcefield == PFIELD_NULL))) + { EffectorWeights *effector_weights = rbw->effector_weights; EffectedPoint epoint; ListBase *effectors; @@ -2008,7 +2013,8 @@ static void rigidbody_update_simulation_post_step(Depsgraph *depsgraph, RigidBod RigidBodyOb *rbo = ob->rigidbody_object; /* Reset kinematic state for transformed objects. */ if (rbo && base && (base->flag & BASE_SELECTED) && (G.moving & G_TRANSFORM_OBJ) && - rbo->shared->physics_object) { + rbo->shared->physics_object) + { RB_body_set_kinematic_state(rbo->shared->physics_object, rbo->flag & RBO_FLAG_KINEMATIC || rbo->flag & RBO_FLAG_DISABLED); RB_body_set_mass(rbo->shared->physics_object, RBO_GET_MASS(rbo)); @@ -2037,7 +2043,8 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) /* use rigid body transform after cache start frame if objects is not being transformed */ if (BKE_rigidbody_check_sim_running(rbw, ctime) && - !(ob->base_flag & BASE_SELECTED && G.moving & G_TRANSFORM_OBJ)) { + !(ob->base_flag & BASE_SELECTED && G.moving & G_TRANSFORM_OBJ)) + { float mat[4][4], size_mat[4][4], size[3]; normalize_qt(rbo->orn); /* RB_TODO investigate why quaternion isn't normalized at this point */ @@ -2152,7 +2159,8 @@ void BKE_rigidbody_rebuild_world(Depsgraph *depsgraph, Scene *scene, float ctime (void)object; /* Ignore if this object is the direct child of an object with a compound shape */ if (object->parent == NULL || object->parent->rigidbody_object == NULL || - object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) { + object->parent->rigidbody_object->shape != RB_SHAPE_COMPOUND) + { n++; } } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index a84b34e32a4..225136ebcbe 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -290,7 +290,8 @@ static void scene_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int for (ViewLayer *view_layer_src = static_cast(scene_src->view_layers.first), *view_layer_dst = static_cast(scene_dst->view_layers.first); view_layer_src; - view_layer_src = view_layer_src->next, view_layer_dst = view_layer_dst->next) { + view_layer_src = view_layer_src->next, view_layer_dst = view_layer_dst->next) + { BKE_view_layer_copy_data(scene_dst, scene_src, view_layer_dst, view_layer_src, flag_subdata); } @@ -1474,7 +1475,8 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) for (bNode *node : ntree->all_nodes()) { if (node->id == nullptr && ((node->type == CMP_NODE_R_LAYERS) || - (node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER))) { + (node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER))) + { node->id = &scene->id; } } @@ -2419,7 +2421,8 @@ const char *BKE_scene_find_marker_name(const Scene *scene, int frame) for (m1 = static_cast(markers->first), m2 = static_cast(markers->last); m1 && m2; - m1 = m1->next, m2 = m2->prev) { + m1 = m1->next, m2 = m2->prev) + { if (m1->frame == frame) { return m1->name; } @@ -2628,7 +2631,8 @@ static void prepare_mesh_for_viewport_render(Main *bmain, if (obedit) { Mesh *mesh = static_cast(obedit->data); if ((obedit->type == OB_MESH) && - ((obedit->id.recalc & ID_RECALC_ALL) || (mesh->id.recalc & ID_RECALC_ALL))) { + ((obedit->id.recalc & ID_RECALC_ALL) || (mesh->id.recalc & ID_RECALC_ALL))) + { if (check_rendered_viewport_visible(bmain)) { BMesh *bm = mesh->edit_mesh->bm; BMeshToMeshParams params{}; @@ -3358,7 +3362,8 @@ void BKE_scene_multiview_view_prefix_get(Scene *scene, if (BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { const size_t suffix_len = strlen(srv->suffix); if (basename_len >= suffix_len && - STREQLEN(name + basename_len - suffix_len, srv->suffix, suffix_len)) { + STREQLEN(name + basename_len - suffix_len, srv->suffix, suffix_len)) + { BLI_strncpy(r_prefix, name, basename_len - suffix_len + 1); break; } @@ -3502,7 +3507,8 @@ static Depsgraph **scene_get_depsgraph_p(Scene *scene, DepsgraphKey **key_ptr; if (BLI_ghash_ensure_p_ex( - scene->depsgraph_hash, &key, (void ***)&key_ptr, (void ***)&depsgraph_ptr)) { + scene->depsgraph_hash, &key, (void ***)&key_ptr, (void ***)&depsgraph_ptr)) + { return depsgraph_ptr; } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 8ccc4c57af8..5b4ffa2ef8a 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -1066,7 +1066,8 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) { /* Test area's outer screen verts, not inner `area->totrct`. */ if (xy[0] >= area->v1->vec.x && xy[0] <= area->v4->vec.x && xy[1] >= area->v1->vec.y && - xy[1] <= area->v2->vec.y) { + xy[1] <= area->v2->vec.y) + { if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) { return area; } diff --git a/source/blender/blenkernel/intern/shrinkwrap.cc b/source/blender/blenkernel/intern/shrinkwrap.cc index b7a2ddf725f..74d6f44d052 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.cc +++ b/source/blender/blenkernel/intern/shrinkwrap.cc @@ -473,7 +473,8 @@ bool BKE_shrinkwrap_project_normal(char options, /* Apply back-face. */ const float dot = dot_v3v3(dir, hit_tmp.no); if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || - ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)) { + ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)) + { return false; /* Ignore hit */ } } @@ -522,8 +523,8 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata, return; } - if (calc->vert_positions != nullptr && - calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { + if (calc->vert_positions != nullptr && calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) + { /* calc->vert_positions contains verts from evaluated mesh. */ /* These coordinates are deformed by vertexCos only for normal projection * (to get correct normals) for other cases calc->verts contains undeformed coordinates and @@ -552,7 +553,8 @@ static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata, } if (BKE_shrinkwrap_project_normal( - calc->smd->shrinkOpts, tmp_co, tmp_no, 0.0, &calc->local2target, tree, hit)) { + calc->smd->shrinkOpts, tmp_co, tmp_no, 0.0, &calc->local2target, tree, hit)) + { is_aux = false; } } @@ -638,7 +640,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) /* If the user doesn't allows to project in any direction of projection axis * then there's nothing todo. */ if ((calc->smd->shrinkOpts & - (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) { + (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) + { return; } @@ -678,7 +681,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } if (BKE_shrinkwrap_init_tree( - &aux_tree_stack, auxMesh, calc->smd->shrinkType, calc->smd->shrinkMode, false)) { + &aux_tree_stack, auxMesh, calc->smd->shrinkType, calc->smd->shrinkMode, false)) + { aux_tree = &aux_tree_stack; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 091f89d3873..d6d61001de9 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1003,7 +1003,8 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), if (ccdm) { if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) { + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) + { /* boxes don't intersect */ BLI_ghashIterator_step(ihash); continue; @@ -1075,7 +1076,8 @@ static int sb_detect_face_pointCached(const float face_v1[3], outerfacethickness = ob->pd->pdef_sboft; if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) { + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) + { /* boxes don't intersect */ BLI_ghashIterator_step(ihash); continue; @@ -1172,7 +1174,8 @@ static int sb_detect_face_collisionCached(const float face_v1[3], if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) { + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) + { /* boxes don't intersect */ BLI_ghashIterator_step(ihash); continue; @@ -1189,7 +1192,8 @@ static int sb_detect_face_collisionCached(const float face_v1[3], while (a--) { if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) || - (aabbmax[2] < mima->minz) || (aabbmin[2] > mima->maxz)) { + (aabbmax[2] < mima->minz) || (aabbmin[2] > mima->maxz)) + { mima++; vt++; continue; @@ -1220,7 +1224,8 @@ static int sb_detect_face_collisionCached(const float face_v1[3], normalize_v3(d_nvect); if (isect_line_segment_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || isect_line_segment_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || - isect_line_segment_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL)) { + isect_line_segment_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL)) + { madd_v3_v3fl(force, d_nvect, -0.5f); *damp = tune * ob->pd->pdef_sbdamp; deflected = 2; @@ -1259,7 +1264,8 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) &damp, feedback, ob, - timenow)) { + timenow)) + { madd_v3_v3fl(sb->bpoint[bf->v1].force, feedback, tune); madd_v3_v3fl(sb->bpoint[bf->v2].force, feedback, tune); madd_v3_v3fl(sb->bpoint[bf->v3].force, feedback, tune); @@ -1280,7 +1286,8 @@ static void scan_for_ext_face_forces(Object *ob, float timenow) &damp, feedback, ob, - timenow)) { + timenow)) + { madd_v3_v3fl(sb->bpoint[bf->v1].force, feedback, tune); madd_v3_v3fl(sb->bpoint[bf->v2].force, feedback, tune); madd_v3_v3fl(sb->bpoint[bf->v3].force, feedback, tune); @@ -1348,7 +1355,8 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3], if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) { + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2])) + { /* boxes don't intersect */ BLI_ghashIterator_step(ihash); continue; @@ -1365,7 +1373,8 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3], while (a--) { if ((aabbmax[0] < mima->minx) || (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || (aabbmin[1] > mima->maxy) || - (aabbmax[2] < mima->minz) || (aabbmin[2] > mima->maxz)) { + (aabbmax[2] < mima->minz) || (aabbmin[2] > mima->maxz)) + { mima++; vt++; continue; @@ -1438,7 +1447,8 @@ static void _scan_for_ext_spring_forces( /* +++ springs colliding */ if (ob->softflag & OB_SB_EDGECOLL) { if (sb_detect_edge_collisionCached( - sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos, &damp, feedback, ob, timenow)) { + sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos, &damp, feedback, ob, timenow)) + { add_v3_v3(bs->ext_force, feedback); bs->flag |= BSF_INTERSECT; // bs->cf=damp; @@ -1653,7 +1663,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], maxz = ccdm->bbmax[2]; if ((opco[0] < minx) || (opco[1] < miny) || (opco[2] < minz) || (opco[0] > maxx) || - (opco[1] > maxy) || (opco[2] > maxz)) { + (opco[1] > maxy) || (opco[2] > maxz)) + { /* Outside the padded bound-box -> collision object is too far away. */ BLI_ghashIterator_step(ihash); continue; @@ -1677,7 +1688,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], /* Use mesh. */ while (a--) { if ((opco[0] < mima->minx) || (opco[0] > mima->maxx) || (opco[1] < mima->miny) || - (opco[1] > mima->maxy) || (opco[2] < mima->minz) || (opco[2] > mima->maxz)) { + (opco[1] > mima->maxy) || (opco[2] < mima->minz) || (opco[2] > mima->maxz)) + { mima++; vt++; continue; @@ -2050,8 +2062,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, kd = sb->goalfrict * sb_fric_force_scale(ob); add_v3_v3v3(auxvect, velgoal, bp->vec); - if (forcetime > - 0.0f) { /* make sure friction does not become rocket motor on time reversal */ + /* Make sure friction does not become rocket motor on time reversal. */ + if (forcetime > 0.0f) { bp->force[0] -= kd * (auxvect[0]); bp->force[1] -= kd * (auxvect[1]); bp->force[2] -= kd * (auxvect[2]); @@ -3533,7 +3545,8 @@ void sbObjectStep(struct Depsgraph *depsgraph, /* verify if we need to create the softbody data */ if (sb->bpoint == NULL || - ((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) { + ((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) + { switch (ob->type) { case OB_MESH: @@ -3581,13 +3594,15 @@ void sbObjectStep(struct Depsgraph *depsgraph, cache_result = BKE_ptcache_read(&pid, (float)framenr + scene->r.subframe, can_simulate); if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED || - (!can_simulate && cache_result == PTCACHE_READ_OLD)) { + (!can_simulate && cache_result == PTCACHE_READ_OLD)) + { softbody_to_object(ob, vertexCos, numVerts, sb->local); BKE_ptcache_validate(cache, framenr); if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED && - can_write_cache) { + can_write_cache) + { BKE_ptcache_write(&pid, framenr); } @@ -3600,7 +3615,8 @@ void sbObjectStep(struct Depsgraph *depsgraph, } else if (/*ob->id.lib || */ /* "library linking & point-caches" has to be solved properly at some point. */ - (cache->flag & PTCACHE_BAKED)) { + (cache->flag & PTCACHE_BAKED)) + { /* If baked and nothing in cache, do nothing. */ if (can_write_cache) { BKE_ptcache_invalidate(cache); @@ -3613,8 +3629,8 @@ void sbObjectStep(struct Depsgraph *depsgraph, } /* if on second frame, write cache for first frame */ - if (cache->simframe == startframe && - (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) { + if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) + { BKE_ptcache_write(&pid, startframe); } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 73330c25179..af957824bce 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -953,7 +953,8 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene) } AUD_Handle_resume(scene->playback_handle); if (scene->sound_scrub_handle && - AUD_Handle_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) { + AUD_Handle_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) + { AUD_Handle_setPosition(scene->sound_scrub_handle, 0); } else { diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 7183fb74550..f19944b9b43 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -141,7 +141,7 @@ static void studiolight_free(struct StudioLight *sl) static struct StudioLight *studiolight_create(int flag) { struct StudioLight *sl = MEM_callocN(sizeof(*sl), __func__); - sl->path[0] = 0x00; + sl->filepath[0] = 0x00; sl->name[0] = 0x00; sl->path_irr_cache = NULL; sl->path_sh_cache = NULL; @@ -201,7 +201,7 @@ static struct StudioLight *studiolight_create(int flag) static void studiolight_load_solid_light(StudioLight *sl) { - LinkNode *lines = BLI_file_read_as_lines(sl->path); + LinkNode *lines = BLI_file_read_as_lines(sl->filepath); if (lines) { READ_VEC3("light_ambient", sl->light_ambient, lines); READ_SOLIDLIGHT(sl->light, 0, lines); @@ -238,7 +238,7 @@ static void studiolight_load_solid_light(StudioLight *sl) static void studiolight_write_solid_light(StudioLight *sl) { - FILE *fp = BLI_fopen(sl->path, "wb"); + FILE *fp = BLI_fopen(sl->filepath, "wb"); if (fp) { DynStr *str = BLI_dynstr_new(); @@ -393,7 +393,7 @@ static void studiolight_multilayer_addpass(void *base, static void studiolight_load_equirect_image(StudioLight *sl) { if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { - ImBuf *ibuf = IMB_loadiffname(sl->path, IB_multilayer, NULL); + ImBuf *ibuf = IMB_loadiffname(sl->filepath, IB_multilayer, NULL); ImBuf *specular_ibuf = NULL; ImBuf *diffuse_ibuf = NULL; const bool failed = (ibuf == NULL); @@ -570,7 +570,8 @@ static void studiolight_calculate_radiance_buffer(ImBuf *ibuf, const float zsign) { ITER_PIXELS ( - float, colbuf, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) { + float, colbuf, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) + { float direction[3]; direction[index_x] = xsign * (x - 0.5f); direction[index_y] = ysign * (y - 0.5f); @@ -683,7 +684,8 @@ static void studiolight_spherical_harmonics_calculate_coefficients(StudioLight * sl->radiance_cubemap_buffers[face]->rect_float, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, - STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) { + STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) + { float color[3], cubevec[3], weight; studiolight_calculate_cubemap_vector_weight(cubevec, &weight, face, x, y); mul_v3_v3fl(color, pixel, weight); @@ -977,7 +979,8 @@ BLI_INLINE void studiolight_evaluate_specular_radiance_buffer(ImBuf *radiance_bu radiance_buffer->rect_float, 4, STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE, - STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) { + STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE) + { float direction[3]; direction[zoffset] = zsign * 0.5f; direction[xoffset] = x - 0.5f; @@ -1130,7 +1133,8 @@ static void studiolight_calculate_irradiance_equirect_image(StudioLight *sl) colbuf, 4, STUDIOLIGHT_IRRADIANCE_EQUIRECT_WIDTH, - STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT) { + STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT) + { float dir[3]; equirect_to_direction(dir, x, y); studiolight_spherical_harmonics_eval(sl, pixel, dir); @@ -1147,23 +1151,24 @@ static void studiolight_calculate_irradiance_equirect_image(StudioLight *sl) sl->flag |= STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED; } -static StudioLight *studiolight_add_file(const char *path, int flag) +static StudioLight *studiolight_add_file(const char *filepath, int flag) { char filename[FILE_MAXFILE]; - BLI_split_file_part(path, filename, FILE_MAXFILE); + BLI_path_split_file_part(filepath, filename, FILE_MAXFILE); if ((((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) && BLI_path_extension_check(filename, ".sl")) || - BLI_path_extension_check_array(filename, imb_ext_image)) { + BLI_path_extension_check_array(filename, imb_ext_image)) + { StudioLight *sl = studiolight_create(STUDIOLIGHT_EXTERNAL_FILE | flag); - BLI_strncpy(sl->name, filename, FILE_MAXFILE); - BLI_strncpy(sl->path, path, FILE_MAXFILE); + STRNCPY(sl->name, filename); + STRNCPY(sl->filepath, filepath); if ((flag & STUDIOLIGHT_TYPE_STUDIO) != 0) { studiolight_load_solid_light(sl); } else { - sl->path_irr_cache = BLI_string_joinN(path, ".irr"); - sl->path_sh_cache = BLI_string_joinN(path, ".sh2"); + sl->path_irr_cache = BLI_string_joinN(filepath, ".irr"); + sl->path_sh_cache = BLI_string_joinN(filepath, ".sh2"); } BLI_addtail(&studiolights, sl); return sl; @@ -1573,13 +1578,13 @@ void BKE_studiolight_remove(StudioLight *sl) } } -StudioLight *BKE_studiolight_load(const char *path, int type) +StudioLight *BKE_studiolight_load(const char *filepath, int type) { - StudioLight *sl = studiolight_add_file(path, type | STUDIOLIGHT_USER_DEFINED); + StudioLight *sl = studiolight_add_file(filepath, type | STUDIOLIGHT_USER_DEFINED); return sl; } -StudioLight *BKE_studiolight_create(const char *path, +StudioLight *BKE_studiolight_create(const char *filepath, const SolidLight light[4], const float light_ambient[3]) { @@ -1588,8 +1593,8 @@ StudioLight *BKE_studiolight_create(const char *path, STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS); char filename[FILE_MAXFILE]; - BLI_split_file_part(path, filename, FILE_MAXFILE); - STRNCPY(sl->path, path); + BLI_path_split_file_part(filepath, filename, FILE_MAXFILE); + STRNCPY(sl->filepath, filepath); STRNCPY(sl->name, filename); memcpy(sl->light, light, sizeof(*light) * 4); diff --git a/source/blender/blenkernel/intern/subdiv_ccg.cc b/source/blender/blenkernel/intern/subdiv_ccg.cc index b5fba4658ac..051c1f03df4 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.cc +++ b/source/blender/blenkernel/intern/subdiv_ccg.cc @@ -595,7 +595,8 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv, /* Make sure evaluator is ready. */ BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG); if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, coarse_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) { + subdiv, coarse_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) + { if (coarse_mesh->totpoly) { return nullptr; } diff --git a/source/blender/blenkernel/intern/subdiv_deform.cc b/source/blender/blenkernel/intern/subdiv_deform.cc index d6ea887c568..e052e68118c 100644 --- a/source/blender/blenkernel/intern/subdiv_deform.cc +++ b/source/blender/blenkernel/intern/subdiv_deform.cc @@ -189,7 +189,8 @@ void BKE_subdiv_deform_coarse_vertices(Subdiv *subdiv, /* Make sure evaluator is up to date with possible new topology, and that * is refined for the new positions of coarse vertices. */ if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, coarse_mesh, vertex_cos, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) { + subdiv, coarse_mesh, vertex_cos, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) + { /* This could happen in two situations: * - OpenSubdiv is disabled. * - Something totally bad happened, and OpenSubdiv rejected our diff --git a/source/blender/blenkernel/intern/subdiv_foreach.cc b/source/blender/blenkernel/intern/subdiv_foreach.cc index 95c8ff6ea7c..72939e12cff 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.cc +++ b/source/blender/blenkernel/intern/subdiv_foreach.cc @@ -295,8 +295,8 @@ static void subdiv_foreach_corner_vertices_regular_do( const int ptex_face_index = ctx->face_ptex_offset[coarse_poly_index]; for (int corner = 0; corner < coarse_poly.size(); corner++) { const int coarse_vert = ctx->coarse_corner_verts[coarse_poly[corner]]; - if (check_usage && - BLI_BITMAP_TEST_AND_SET_ATOMIC(ctx->coarse_vertices_used_map, coarse_vert)) { + if (check_usage && BLI_BITMAP_TEST_AND_SET_ATOMIC(ctx->coarse_vertices_used_map, coarse_vert)) + { continue; } const int coarse_vertex_index = coarse_vert; @@ -334,8 +334,8 @@ static void subdiv_foreach_corner_vertices_special_do( int ptex_face_index = ctx->face_ptex_offset[coarse_poly_index]; for (int corner = 0; corner < coarse_poly.size(); corner++, ptex_face_index++) { const int coarse_vert = ctx->coarse_corner_verts[coarse_poly[corner]]; - if (check_usage && - BLI_BITMAP_TEST_AND_SET_ATOMIC(ctx->coarse_vertices_used_map, coarse_vert)) { + if (check_usage && BLI_BITMAP_TEST_AND_SET_ATOMIC(ctx->coarse_vertices_used_map, coarse_vert)) + { continue; } const int coarse_vertex_index = coarse_vert; @@ -430,7 +430,8 @@ static void subdiv_foreach_edge_vertices_regular_do(SubdivForeachTaskContext *ct int subdiv_vertex_index = ctx->vertices_edge_offset + coarse_edge_index * num_subdiv_vertices_per_coarse_edge; for (int vertex_index = 0; vertex_index < num_subdiv_vertices_per_coarse_edge; - vertex_index++, subdiv_vertex_index++) { + vertex_index++, subdiv_vertex_index++) + { float fac = (vertex_index + 1) * inv_resolution_1; if (flip) { fac = 1.0f - fac; @@ -498,7 +499,8 @@ static void subdiv_foreach_edge_vertices_special_do(SubdivForeachTaskContext *ct vertex_delta = -1; } for (int vertex_index = 1; vertex_index < num_vertices_per_ptex_edge; - vertex_index++, subdiv_vertex_index += vertex_delta) { + vertex_index++, subdiv_vertex_index += vertex_delta) + { const float u = vertex_index * inv_ptex_resolution_1; vertex_edge(ctx->foreach_context, tls, @@ -513,7 +515,8 @@ static void subdiv_foreach_edge_vertices_special_do(SubdivForeachTaskContext *ct const int next_corner = (corner + 1) % coarse_poly.size(); const int next_ptex_face_index = ptex_face_start_index + next_corner; for (int vertex_index = 1; vertex_index < num_vertices_per_ptex_edge - 1; - vertex_index++, subdiv_vertex_index += vertex_delta) { + vertex_index++, subdiv_vertex_index += vertex_delta) + { const float v = 1.0f - vertex_index * inv_ptex_resolution_1; vertex_edge(ctx->foreach_context, tls, @@ -1402,7 +1405,8 @@ static void subdiv_foreach_loops_special(SubdivForeachTaskContext *ctx, coarse_poly.size() * num_inner_edges_per_ptex_face + ptex_face_inner_resolution - 1; for (int corner = 0, prev_corner = coarse_poly.size() - 1; corner < coarse_poly.size(); - prev_corner = corner, corner++, subdiv_loop_index += 4) { + prev_corner = corner, corner++, subdiv_loop_index += 4) + { const int corner_edge_index = start_edge_index + corner * num_inner_edges_per_ptex_face; const int current_patch_end_vertex_index = start_vertex_index + corner * num_inner_vertices_per_ptex + @@ -1443,7 +1447,8 @@ static void subdiv_foreach_loops_special(SubdivForeachTaskContext *ctx, } /* Loops for faces connecting inner ptex part with boundary. */ for (int prev_corner = coarse_poly.size() - 1, corner = 0; corner < coarse_poly.size(); - prev_corner = corner, corner++) { + prev_corner = corner, corner++) + { const int coarse_vert = ctx->coarse_corner_verts[coarse_poly[corner]]; const int coarse_edge_i = ctx->coarse_corner_edges[coarse_poly[corner]]; const int coase_prev_vert = ctx->coarse_corner_verts[coarse_poly[prev_corner]]; @@ -1636,9 +1641,11 @@ static void subdiv_foreach_polys(SubdivForeachTaskContext *ctx, void *tls, int p /* Hi-poly subdivided mesh. */ int subdiv_polyon_index = start_poly_index; for (int ptex_of_poly_index = 0; ptex_of_poly_index < num_ptex_faces_per_poly; - ptex_of_poly_index++) { + ptex_of_poly_index++) + { for (int subdiv_poly_index = 0; subdiv_poly_index < num_polys_per_ptex; - subdiv_poly_index++, subdiv_polyon_index++) { + subdiv_poly_index++, subdiv_polyon_index++) + { const int loopstart = start_loop_index + (ptex_of_poly_index * num_loops_per_ptex) + (subdiv_poly_index * 4); ctx->foreach_context->poly( @@ -1810,7 +1817,8 @@ bool BKE_subdiv_foreach_subdiv_geometry(Subdiv *subdiv, ctx.num_subdiv_edges, ctx.num_subdiv_loops, ctx.num_subdiv_polygons, - ctx.subdiv_polygon_offset)) { + ctx.subdiv_polygon_offset)) + { subdiv_foreach_ctx_free(&ctx); return false; } diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index e28ba92d132..eabf6847b40 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -696,7 +696,8 @@ static void subdiv_mesh_ensure_vertex_interpolation(SubdivMeshContext *ctx, /* Check whether we've moved to another corner or polygon. */ if (tls->vertex_interpolation_initialized) { if (tls->vertex_interpolation_coarse_poly_index != coarse_poly_index || - tls->vertex_interpolation_coarse_corner != coarse_corner) { + tls->vertex_interpolation_coarse_corner != coarse_corner) + { vertex_interpolation_end(&tls->vertex_interpolation); tls->vertex_interpolation_initialized = false; } @@ -707,7 +708,8 @@ static void subdiv_mesh_ensure_vertex_interpolation(SubdivMeshContext *ctx, } /* Update it for a new corner if needed. */ if (!tls->vertex_interpolation_initialized || - tls->vertex_interpolation_coarse_corner != coarse_corner) { + tls->vertex_interpolation_coarse_corner != coarse_corner) + { vertex_interpolation_from_corner(ctx, &tls->vertex_interpolation, coarse_poly, coarse_corner); } /* Store settings used for the current state of interpolator. */ @@ -868,7 +870,8 @@ static void subdiv_mesh_ensure_loop_interpolation(SubdivMeshContext *ctx, /* Check whether we've moved to another corner or polygon. */ if (tls->loop_interpolation_initialized) { if (tls->loop_interpolation_coarse_poly_index != coarse_poly_index || - tls->loop_interpolation_coarse_corner != coarse_corner) { + tls->loop_interpolation_coarse_corner != coarse_corner) + { loop_interpolation_end(&tls->loop_interpolation); tls->loop_interpolation_initialized = false; } @@ -1151,7 +1154,8 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv, /* Make sure evaluator is up to date with possible new topology, and that * it is refined for the new positions of coarse vertices. */ if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, coarse_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) { + subdiv, coarse_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) + { /* This could happen in two situations: * - OpenSubdiv is disabled. * - Something totally bad happened, and OpenSubdiv rejected our diff --git a/source/blender/blenkernel/intern/subsurf_ccg.cc b/source/blender/blenkernel/intern/subsurf_ccg.cc index 30f3202963c..93dbc4f224b 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.cc +++ b/source/blender/blenkernel/intern/subsurf_ccg.cc @@ -102,7 +102,8 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int numLaye ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, nullptr, nullptr, nullptr); if ((oldUseAging != useAging) || - (ccgSubSurf_getSimpleSubdiv(prevSS) != !!(flags & CCG_SIMPLE_SUBDIV))) { + (ccgSubSurf_getSimpleSubdiv(prevSS) != !!(flags & CCG_SIMPLE_SUBDIV))) + { ccgSubSurf_free(prevSS); } else { @@ -390,7 +391,8 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh * CCGFace **faceMap = static_cast( MEM_mallocN(totface * sizeof(*faceMap), "facemapuv")); for (ccgSubSurf_initFaceIterator(uvss, &fi); !ccgFaceIterator_isStopped(&fi); - ccgFaceIterator_next(&fi)) { + ccgFaceIterator_next(&fi)) + { CCGFace *f = ccgFaceIterator_getCurrent(&fi); faceMap[POINTER_AS_INT(ccgSubSurf_getFaceFaceHandle(f))] = f; } @@ -597,7 +599,8 @@ static void ss_sync_ccg_from_derivedmesh(CCGSubSurf *ss, * other parts of code significantly to handle missing faces. * since this really shouldn't even be possible we just bail. */ if (ccgSubSurf_syncFace(ss, POINTER_FROM_INT(i), poly.size(), fverts.data(), &f) == - eCCGError_InvalidValue) { + eCCGError_InvalidValue) + { static int hasGivenError = 0; if (!hasGivenError) { @@ -682,7 +685,8 @@ static void UNUSED_FUNCTION(ccgDM_getMinMax)(DerivedMesh *dm, float r_min[3], fl } for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); - ccgVertIterator_next(&vi)) { + ccgVertIterator_next(&vi)) + { CCGVert *v = ccgVertIterator_getCurrent(&vi); float *co = static_cast(ccgSubSurf_getVertData(ss, v)); @@ -690,7 +694,8 @@ static void UNUSED_FUNCTION(ccgDM_getMinMax)(DerivedMesh *dm, float r_min[3], fl } for (ccgSubSurf_initEdgeIterator(ss, &ei); !ccgEdgeIterator_isStopped(&ei); - ccgEdgeIterator_next(&ei)) { + ccgEdgeIterator_next(&ei)) + { CCGEdge *e = ccgEdgeIterator_getCurrent(&ei); CCGElem *edgeData = static_cast(ccgSubSurf_getEdgeDataArray(ss, e)); @@ -700,7 +705,8 @@ static void UNUSED_FUNCTION(ccgDM_getMinMax)(DerivedMesh *dm, float r_min[3], fl } for (ccgSubSurf_initFaceIterator(ss, &fi); !ccgFaceIterator_isStopped(&fi); - ccgFaceIterator_next(&fi)) { + ccgFaceIterator_next(&fi)) + { CCGFace *f = ccgFaceIterator_getCurrent(&fi); int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); @@ -1016,7 +1022,8 @@ static void ccgDM_release(DerivedMesh *dm) if (ccgdm->multires.modified_flags) { /* Check that mmd still exists */ if (!ccgdm->multires.local_mmd && - BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0) { + BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0) + { ccgdm->multires.mmd = nullptr; } @@ -1356,7 +1363,8 @@ static void create_ccgdm_maps(CCGDerivedMesh *ccgdm, CCGSubSurf *ss) ccgdm->vertMap = static_cast( MEM_mallocN(totvert * sizeof(*ccgdm->vertMap), "vertMap")); for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); - ccgVertIterator_next(&vi)) { + ccgVertIterator_next(&vi)) + { CCGVert *v = ccgVertIterator_getCurrent(&vi); ccgdm->vertMap[POINTER_AS_INT(ccgSubSurf_getVertVertHandle(v))].vert = v; @@ -1366,7 +1374,8 @@ static void create_ccgdm_maps(CCGDerivedMesh *ccgdm, CCGSubSurf *ss) ccgdm->edgeMap = static_cast( MEM_mallocN(totedge * sizeof(*ccgdm->edgeMap), "edgeMap")); for (ccgSubSurf_initEdgeIterator(ss, &ei); !ccgEdgeIterator_isStopped(&ei); - ccgEdgeIterator_next(&ei)) { + ccgEdgeIterator_next(&ei)) + { CCGEdge *e = ccgEdgeIterator_getCurrent(&ei); ccgdm->edgeMap[POINTER_AS_INT(ccgSubSurf_getEdgeEdgeHandle(e))].edge = e; @@ -1376,7 +1385,8 @@ static void create_ccgdm_maps(CCGDerivedMesh *ccgdm, CCGSubSurf *ss) ccgdm->faceMap = static_cast( MEM_mallocN(totface * sizeof(*ccgdm->faceMap), "faceMap")); for (ccgSubSurf_initFaceIterator(ss, &fi); !ccgFaceIterator_isStopped(&fi); - ccgFaceIterator_next(&fi)) { + ccgFaceIterator_next(&fi)) + { CCGFace *f = ccgFaceIterator_getCurrent(&fi); ccgdm->faceMap[POINTER_AS_INT(ccgSubSurf_getFaceFaceHandle(f))].face = f; @@ -1866,7 +1876,8 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*r_positions)[3]) ss_sync_from_derivedmesh(ss, dm, nullptr, 0, 0); for (ccgSubSurf_initVertIterator(ss, &vi); !ccgVertIterator_isStopped(&vi); - ccgVertIterator_next(&vi)) { + ccgVertIterator_next(&vi)) + { CCGVert *v = ccgVertIterator_getCurrent(&vi); int idx = POINTER_AS_INT(ccgSubSurf_getVertVertHandle(v)); int N = ccgSubSurf_getVertNumEdges(v); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 4b770ab8989..5dc7f0e8a97 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1150,7 +1150,8 @@ static void txt_curs_swap(Text *text) static void txt_pop_first(Text *text) { if (txt_get_span(text->curl, text->sell) < 0 || - (text->curl == text->sell && text->curc > text->selc)) { + (text->curl == text->sell && text->curc > text->selc)) + { txt_curs_swap(text); } @@ -1160,7 +1161,8 @@ static void txt_pop_first(Text *text) static void txt_pop_last(Text *text) { if (txt_get_span(text->curl, text->sell) > 0 || - (text->curl == text->sell && text->curc < text->selc)) { + (text->curl == text->sell && text->curc < text->selc)) + { txt_curs_swap(text); } @@ -1185,13 +1187,15 @@ void txt_order_cursors(Text *text, const bool reverse) /* Flip so text->curl is before/after text->sell */ if (reverse == false) { if ((txt_get_span(text->curl, text->sell) < 0) || - (text->curl == text->sell && text->curc > text->selc)) { + (text->curl == text->sell && text->curc > text->selc)) + { txt_curs_swap(text); } } else { if ((txt_get_span(text->curl, text->sell) > 0) || - (text->curl == text->sell && text->curc < text->selc)) { + (text->curl == text->sell && text->curc < text->selc)) + { txt_curs_swap(text); } } diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index 7f9e4bbdc07..a42fdf906e0 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -272,7 +272,8 @@ void BKE_texture_mapping_init(TexMapping *texmap) float smat[4][4], rmat[4][4], tmat[4][4], proj[4][4], size[3]; if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && - is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { + is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) + { unit_m4(texmap->mat); texmap->flag |= TEXMAP_UNIT_MATRIX; diff --git a/source/blender/blenkernel/intern/tracking.cc b/source/blender/blenkernel/intern/tracking.cc index e10c4b8ffe3..a0ac5779d16 100644 --- a/source/blender/blenkernel/intern/tracking.cc +++ b/source/blender/blenkernel/intern/tracking.cc @@ -1678,8 +1678,8 @@ void BKE_tracking_plane_tracks_remove_point_track(MovieTracking *tracking, MovieTrackingTrack *track) { MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); - LISTBASE_FOREACH_MUTABLE ( - MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) { + LISTBASE_FOREACH_MUTABLE (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) + { if (BKE_tracking_plane_track_has_point_track(plane_track, track)) { if (!BKE_tracking_plane_track_remove_point_track(plane_track, track)) { /* Delete planes with less than 3 point tracks in it. */ @@ -2718,7 +2718,8 @@ ImBuf *BKE_tracking_get_search_imbuf(const ImBuf *ibuf, if (disable_channels) { if ((track->flag & TRACK_PREVIEW_GRAYSCALE) || (track->flag & TRACK_DISABLE_RED) || - (track->flag & TRACK_DISABLE_GREEN) || (track->flag & TRACK_DISABLE_BLUE)) { + (track->flag & TRACK_DISABLE_GREEN) || (track->flag & TRACK_DISABLE_BLUE)) + { disable_imbuf_channels(searchibuf, track, true); } } diff --git a/source/blender/blenkernel/intern/tracking_auto.cc b/source/blender/blenkernel/intern/tracking_auto.cc index a2154e475e1..c21818108a1 100644 --- a/source/blender/blenkernel/intern/tracking_auto.cc +++ b/source/blender/blenkernel/intern/tracking_auto.cc @@ -300,7 +300,8 @@ static bool tracking_check_marker_margin(const libmv_Marker *libmv_marker, if (libmv_marker->center[0] < margin_left || libmv_marker->center[0] > frame_width - margin_right || libmv_marker->center[1] < margin_bottom || - libmv_marker->center[1] > frame_height - margin_top) { + libmv_marker->center[1] > frame_height - margin_top) + { return false; } @@ -644,7 +645,8 @@ static void autotrack_context_step_cb(void *__restrict userdata, /* Check whether marker is going outside of allowed frame margin. */ if (!tracking_check_marker_margin( - libmv_current_marker, track->margin, autotrack_clip->width, autotrack_clip->height)) { + libmv_current_marker, track->margin, autotrack_clip->width, autotrack_clip->height)) + { return; } diff --git a/source/blender/blenkernel/intern/tracking_plane_tracker.cc b/source/blender/blenkernel/intern/tracking_plane_tracker.cc index de3c6835418..ebd11c1027d 100644 --- a/source/blender/blenkernel/intern/tracking_plane_tracker.cc +++ b/source/blender/blenkernel/intern/tracking_plane_tracker.cc @@ -130,7 +130,8 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac new_plane_marker.framenr = current_frame + frame_delta; if (!retrack && keyframe_plane_marker && next_plane_marker && - (plane_track->flag & PLANE_TRACK_AUTOKEY)) { + (plane_track->flag & PLANE_TRACK_AUTOKEY)) + { float fac = (float(next_plane_marker->framenr) - start_plane_marker->framenr) / (float(keyframe_plane_marker->framenr) - start_plane_marker->framenr); diff --git a/source/blender/blenkernel/intern/tracking_region_tracker.cc b/source/blender/blenkernel/intern/tracking_region_tracker.cc index fb63887810f..48a258d1bbf 100644 --- a/source/blender/blenkernel/intern/tracking_region_tracker.cc +++ b/source/blender/blenkernel/intern/tracking_region_tracker.cc @@ -278,7 +278,8 @@ static bool refine_marker_reference_frame_get(MovieTrackingTrack *track, MovieTrackingMarker *reference = backwards ? marker + 1 : marker - 1; while (reference >= first_marker && reference <= last_marker && - (reference->flag & MARKER_DISABLED) != 0) { + (reference->flag & MARKER_DISABLED) != 0) + { if (backwards) { reference++; } diff --git a/source/blender/blenkernel/intern/tracking_stabilize.cc b/source/blender/blenkernel/intern/tracking_stabilize.cc index 36db23aa0ea..a230c57b636 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.cc +++ b/source/blender/blenkernel/intern/tracking_stabilize.cc @@ -267,7 +267,8 @@ static void retrieve_next_higher_usable_frame( BLI_assert(0 <= i && i < end); while (i < end && - (markers[i].framenr < ref_frame || is_effectively_disabled(ctx, track, &markers[i]))) { + (markers[i].framenr < ref_frame || is_effectively_disabled(ctx, track, &markers[i]))) + { i++; } if (i < end && markers[i].framenr < *next_higher) { @@ -282,7 +283,8 @@ static void retrieve_next_lower_usable_frame( MovieTrackingMarker *markers = track->markers; BLI_assert(0 <= i && i < track->markersnr); while (i >= 0 && - (markers[i].framenr > ref_frame || is_effectively_disabled(ctx, track, &markers[i]))) { + (markers[i].framenr > ref_frame || is_effectively_disabled(ctx, track, &markers[i]))) + { i--; } if (0 <= i && markers[i].framenr > *next_lower) { @@ -1116,7 +1118,8 @@ static float calculate_autoscale_factor(StabContext *ctx, int size, float aspect /* Calculate maximal frame range of tracks where stabilization is active. */ LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_camera_object->tracks) { if ((track->flag & TRACK_USE_2D_STAB) || - ((stab->flag & TRACKING_STABILIZE_ROTATION) && (track->flag & TRACK_USE_2D_STAB_ROT))) { + ((stab->flag & TRACKING_STABILIZE_ROTATION) && (track->flag & TRACK_USE_2D_STAB_ROT))) + { int first_frame = track->markers[0].framenr; int last_frame = track->markers[track->markersnr - 1].framenr; sfra = min_ii(sfra, first_frame); @@ -1267,7 +1270,8 @@ void BKE_tracking_stabilization_data_get(MovieClip *clip, } if (enabled && stabilization_determine_offset_for_frame( - ctx, framenr, aspect, translation, pivot, angle, &scale_step)) { + ctx, framenr, aspect, translation, pivot, angle, &scale_step)) + { stabilization_calculate_data( ctx, framenr, size, aspect, do_compensate, scale_step, translation, pivot, scale, angle); compensate_rotation_center(size, aspect, *angle, *scale, pivot, translation); diff --git a/source/blender/blenkernel/intern/tracking_util.cc b/source/blender/blenkernel/intern/tracking_util.cc index 0a6669e2a29..7b2da85afac 100644 --- a/source/blender/blenkernel/intern/tracking_util.cc +++ b/source/blender/blenkernel/intern/tracking_util.cc @@ -349,8 +349,8 @@ void tracking_principal_point_normalized_to_pixel(const float principal_point_no const int frame_height, float r_principal_point_pixel[2]) { - const float frame_center_x = (float(frame_width)) / 2; - const float frame_center_y = (float(frame_height)) / 2; + const float frame_center_x = float(frame_width) / 2; + const float frame_center_y = float(frame_height) / 2; r_principal_point_pixel[0] = frame_center_x + principal_point_normalized[0] * frame_center_x; r_principal_point_pixel[1] = frame_center_y + principal_point_normalized[1] * frame_center_y; @@ -361,8 +361,8 @@ void tracking_principal_point_pixel_to_normalized(const float principal_point_pi const int frame_height, float r_principal_point_normalized[2]) { - const float frame_center_x = (float(frame_width)) / 2; - const float frame_center_y = (float(frame_height)) / 2; + const float frame_center_x = float(frame_width) / 2; + const float frame_center_y = float(frame_height) / 2; r_principal_point_normalized[0] = (principal_point_pixel[0] - frame_center_x) / frame_center_x; r_principal_point_normalized[1] = (principal_point_pixel[1] - frame_center_y) / frame_center_y; @@ -626,7 +626,8 @@ static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf) const size_t num_pixels = size_t(grayscale->x) * size_t(grayscale->y); grayscale->channels = 1; if ((grayscale->rect_float = MEM_cnew_array(num_pixels, "tracking grayscale image")) != - nullptr) { + nullptr) + { grayscale->mall |= IB_rectfloat; grayscale->flags |= IB_rectfloat; @@ -655,7 +656,8 @@ static ImBuf *float_image_to_ibuf(libmv_FloatImage *float_image) size_t num_total_channels = size_t(ibuf->x) * size_t(ibuf->y) * float_image->channels; ibuf->channels = float_image->channels; if ((ibuf->rect_float = MEM_cnew_array(num_total_channels, "tracking grayscale image")) != - nullptr) { + nullptr) + { ibuf->mall |= IB_rectfloat; ibuf->flags |= IB_rectfloat; diff --git a/source/blender/blenkernel/intern/undo_system.cc b/source/blender/blenkernel/intern/undo_system.cc index 4058c7b91d6..76d3f26b59b 100644 --- a/source/blender/blenkernel/intern/undo_system.cc +++ b/source/blender/blenkernel/intern/undo_system.cc @@ -767,7 +767,8 @@ bool BKE_undosys_step_load_data_ex(UndoStack *ustack, * from given reference step. */ bool is_processing_extra_skipped_steps = false; for (UndoStep *us_iter = undosys_step_iter_first(us_reference, undo_dir); us_iter != nullptr; - us_iter = (undo_dir == -1) ? us_iter->prev : us_iter->next) { + us_iter = (undo_dir == -1) ? us_iter->prev : us_iter->next) + { BLI_assert(us_iter != nullptr); const bool is_final = (us_iter == us_target_active); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index a3d46850c92..e5f64df3741 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -714,7 +714,8 @@ static const char *unit_find_str(const char *str, const char *substr, bool case_ if (str_found == str || /* Weak unicode support!, so "µm" won't match up be replaced by "m" * since non ascii utf8 values will NEVER return true */ - isalpha_or_utf8(*BLI_str_find_prev_char_utf8(str_found, str)) == 0) { + isalpha_or_utf8(*BLI_str_find_prev_char_utf8(str_found, str)) == 0) + { /* Next char cannot be alpha-numeric. */ int len_name = strlen(substr); @@ -812,7 +813,8 @@ static char *find_next_op(const char *str, char *remaining_str, int len_max) if (remaining_str != str && i != 0) { /* Check for velocity or acceleration (e.g. '/' in 'ft/s' is not an op). */ if ((remaining_str[i] == '/') && ELEM(remaining_str[i - 1], 't', 'T', 'm', 'M') && - ELEM(remaining_str[i + 1], 's', 'S')) { + ELEM(remaining_str[i + 1], 's', 'S')) + { continue; } @@ -1110,7 +1112,8 @@ bool BKE_unit_replace_string( /* Apply the default unit on the whole expression, this allows to handle nasty cases like * '2+2in'. */ if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) < - sizeof(str_tmp)) { + sizeof(str_tmp)) + { strncpy(str, str_tmp, len_max); } else { diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c index 1d55cd9d494..ef6ecfbf63d 100644 --- a/source/blender/blenkernel/intern/vfont.c +++ b/source/blender/blenkernel/intern/vfont.c @@ -327,7 +327,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) is_builtin = true; } else { - BLI_split_file_part(filepath, filename, sizeof(filename)); + BLI_path_split_file_part(filepath, filename, sizeof(filename)); pf = BKE_packedfile_new(NULL, filepath, BKE_main_blendfile_path(bmain)); is_builtin = false; @@ -1339,7 +1339,8 @@ static bool vfont_to_curve(Object *ob, if (cu->textoncurve && cu->textoncurve->type == OB_CURVES_LEGACY) { BLI_assert(cu->textoncurve->runtime.curve_cache != NULL); if (cu->textoncurve->runtime.curve_cache != NULL && - cu->textoncurve->runtime.curve_cache->anim_path_accum_length != NULL) { + cu->textoncurve->runtime.curve_cache->anim_path_accum_length != NULL) + { float distfac, imat[4][4], imat3[3][3], cmat[3][3]; float minx, maxx; float timeofs, sizefac; @@ -1474,37 +1475,9 @@ static bool vfont_to_curve(Object *ob, } } - if (cursor_params) { - cursor_params->r_string_offset = -1; - for (i = 0; i <= slen; i++, ct++) { - info = &custrinfo[i]; - ascii = mem[i]; - if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) { - ascii = towupper(ascii); - } - ct = &chartransdata[i]; - che = find_vfont_char(vfd, ascii); - float charwidth = char_width(cu, che, info); - float charhalf = (charwidth / 2.0f); - if (cursor_params->cursor_location[1] >= ct->yof - (0.25f * linedist) && - cursor_params->cursor_location[1] <= (ct->yof + (0.75f * linedist))) { - /* On this row. */ - if (cursor_params->cursor_location[0] >= (ct->xof) && - cursor_params->cursor_location[0] <= (ct->xof + charhalf)) { - /* Left half of character. */ - cursor_params->r_string_offset = i; - } - else if (cursor_params->cursor_location[0] >= (ct->xof + charhalf) && - cursor_params->cursor_location[0] <= (ct->xof + charwidth)) { - /* Right half of character. */ - cursor_params->r_string_offset = i + 1; - } - } - } - } - if (ELEM(mode, FO_CURSUP, FO_CURSDOWN, FO_PAGEUP, FO_PAGEDOWN) && - iter_data->status == VFONT_TO_CURVE_INIT) { + iter_data->status == VFONT_TO_CURVE_INIT) + { ct = &chartransdata[ef->pos]; if (ELEM(mode, FO_CURSUP, FO_PAGEUP) && ct->linenr == 0) { @@ -1617,7 +1590,8 @@ static bool vfont_to_curve(Object *ob, info = &(custrinfo[i]); if ((cu->overflow == CU_OVERFLOW_TRUNCATE) && (ob && ob->mode != OB_MODE_EDIT) && - (info->flag & CU_CHINFO_OVERFLOW)) { + (info->flag & CU_CHINFO_OVERFLOW)) + { break; } @@ -1643,7 +1617,8 @@ static bool vfont_to_curve(Object *ob, if ((i < (slen - 1)) && (mem[i + 1] != '\n') && ((mem[i + 1] != ' ') || (custrinfo[i + 1].flag & CU_CHINFO_UNDERLINE)) && - ((custrinfo[i + 1].flag & CU_CHINFO_WRAP) == 0)) { + ((custrinfo[i + 1].flag & CU_CHINFO_WRAP) == 0)) + { uloverlap = xtrax + 0.1f; } /* Find the character, the characters has to be in the memory already @@ -1751,7 +1726,8 @@ static bool vfont_to_curve(Object *ob, /* We iterated enough or got a good enough result. */ if ((!iter_data->iteraction--) || ((iter_data->bisect.max - iter_data->bisect.min) < - (cu->fsize * FONT_TO_CURVE_SCALE_THRESHOLD))) { + (cu->fsize * FONT_TO_CURVE_SCALE_THRESHOLD))) + { if (valid) { iter_data->status = VFONT_TO_CURVE_DONE; } @@ -1764,6 +1740,38 @@ static bool vfont_to_curve(Object *ob, } } + if (cursor_params) { + cursor_params->r_string_offset = -1; + for (i = 0; i <= slen; i++, ct++) { + info = &custrinfo[i]; + ascii = mem[i]; + if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) { + ascii = towupper(ascii); + } + ct = &chartransdata[i]; + che = find_vfont_char(vfd, ascii); + float charwidth = char_width(cu, che, info); + float charhalf = (charwidth / 2.0f); + if (cursor_params->cursor_location[1] >= (ct->yof - (0.25f * linedist)) * font_size && + cursor_params->cursor_location[1] <= (ct->yof + (0.75f * linedist)) * font_size) + { + /* On this row. */ + if (cursor_params->cursor_location[0] >= (ct->xof * font_size) && + cursor_params->cursor_location[0] <= ((ct->xof + charhalf) * font_size)) + { + /* Left half of character. */ + cursor_params->r_string_offset = i; + } + else if (cursor_params->cursor_location[0] >= ((ct->xof + charhalf) * font_size) && + cursor_params->cursor_location[0] <= ((ct->xof + charwidth) * font_size)) + { + /* Right half of character. */ + cursor_params->r_string_offset = i + 1; + } + } + } + } + /* Scale to fit only works for single text box layouts. */ if (ELEM(iter_data->status, VFONT_TO_CURVE_SCALE_ONCE, VFONT_TO_CURVE_BISECT)) { /* Always cleanup before going to the scale-to-fit repetition. */ diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index 9fe83ce7aa0..ee3515d2a1f 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -219,7 +219,8 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData * (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > eps_sq) && (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > max_ff(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), - len_squared_v2v2(bezt->vec[1], bezt->vec[2])))) { + len_squared_v2v2(bezt->vec[1], bezt->vec[2])))) + { bezt->h1 = bezt->h2 = HD_ALIGN; } bezt->radius = 1.0f; @@ -293,7 +294,8 @@ static FT_Face vfont_face_load_from_packed_file(FT_Library library, PackedFile * FT_UInt glyph_index = 0; FT_Get_First_Char(face, &glyph_index); if (!glyph_index || - FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) != FT_Err_Ok) { + FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) != FT_Err_Ok) + { FT_Done_Face(face); return NULL; } diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 68ec2b7957a..6a48d0d0292 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -769,7 +769,7 @@ static void volume_filepath_get(const Main *bmain, const Volume *volume, char r_ if (volume->is_sequence && BLI_path_frame_get(r_filepath, &path_frame, &path_digits)) { char ext[32]; BLI_path_frame_strip(r_filepath, ext, sizeof(ext)); - BLI_path_frame(r_filepath, volume->runtime.frame, path_digits); + BLI_path_frame(r_filepath, FILE_MAX, volume->runtime.frame, path_digits); BLI_path_extension_ensure(r_filepath, FILE_MAX, ext); } } @@ -873,7 +873,7 @@ bool BKE_volume_load(const Volume *volume, const Main *bmain) /* Test if file exists. */ if (!BLI_exists(filepath)) { char filename[FILE_MAX]; - BLI_split_file_part(filepath, filename, sizeof(filename)); + BLI_path_split_file_part(filepath, filename, sizeof(filename)); grids.error_msg = filename + std::string(" not found"); CLOG_INFO(&LOG, 1, "Volume %s: %s", volume_name, grids.error_msg.c_str()); return false; diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index 2183a3c82e1..b0524f9b5d4 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -309,7 +309,8 @@ static bool UNUSED_FUNCTION(workspaces_is_screen_used) (const Main *bmain, bScreen *screen) { for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; - workspace = static_cast(workspace->id.next)) { + workspace = static_cast(workspace->id.next)) + { if (workspace_layout_find_exec(workspace, screen)) { return true; } @@ -336,7 +337,8 @@ void BKE_workspace_remove(Main *bmain, WorkSpace *workspace) for (WorkSpaceLayout *layout = static_cast(workspace->layouts.first), *layout_next; layout; - layout = layout_next) { + layout = layout_next) + { layout_next = layout->next; BKE_workspace_layout_remove(bmain, workspace, layout); } @@ -349,7 +351,8 @@ WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const Main *bmain, con /* set an active screen-layout for each possible window/workspace combination */ for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; - workspace = static_cast(workspace->id.next)) { + workspace = static_cast(workspace->id.next)) + { BKE_workspace_active_layout_set( hook, winid, workspace, static_cast(workspace->layouts.first)); } @@ -365,12 +368,14 @@ void BKE_workspace_instance_hook_free(const Main *bmain, WorkSpaceInstanceHook * /* Free relations for this hook */ for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; - workspace = static_cast(workspace->id.next)) { + workspace = static_cast(workspace->id.next)) + { for (WorkSpaceDataRelation *relation = static_cast( workspace->hook_layout_relations.first), *relation_next; relation; - relation = relation_next) { + relation = relation_next) + { relation_next = relation->next; if (relation->parent == hook) { workspace_relation_remove(&workspace->hook_layout_relations, relation); @@ -417,7 +422,8 @@ void BKE_workspace_relations_free(ListBase *relation_list) relation = static_cast(relation_list->first), *relation_next; relation; - relation = relation_next) { + relation = relation_next) + { relation_next = relation->next; workspace_relation_remove(relation_list, relation); } @@ -457,7 +463,8 @@ WorkSpaceLayout *BKE_workspace_layout_find_global(const Main *bmain, } for (WorkSpace *workspace = static_cast(bmain->workspaces.first); workspace; - workspace = static_cast(workspace->id.next)) { + workspace = static_cast(workspace->id.next)) + { if ((layout = workspace_layout_find_exec(workspace, screen))) { if (r_workspace) { *r_workspace = workspace; @@ -519,7 +526,7 @@ void BKE_workspace_tool_id_replace_table(struct WorkSpace *workspace, int replace_table_num) { const size_t idname_prefix_len = idname_prefix_skip ? strlen(idname_prefix_skip) : 0; - const size_t idname_suffix_len = sizeof(((bToolRef *)nullptr)->idname) - idname_prefix_len; + const size_t idname_suffix_len = sizeof(bToolRef::idname) - idname_prefix_len; LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { if (!(tref->space_type == space_type && tref->mode == mode)) { diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index a1f14623cef..541f9acf9fb 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -119,7 +119,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype) R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA, - R_IMF_IMTYPE_AV1)) { + R_IMF_IMTYPE_AV1)) + { mh.start_movie = BKE_ffmpeg_start; mh.append_movie = BKE_ffmpeg_append; mh.end_movie = BKE_ffmpeg_end; @@ -139,11 +140,11 @@ bMovieHandle *BKE_movie_handle_get(const char imtype) #ifdef WITH_AVI -static void filepath_avi(char *string, const RenderData *rd, bool preview, const char *suffix) +static void filepath_avi(char *filepath, const RenderData *rd, bool preview, const char *suffix) { int sfra, efra; - if (string == NULL) { + if (filepath == NULL) { return; } @@ -156,24 +157,24 @@ static void filepath_avi(char *string, const RenderData *rd, bool preview, const efra = rd->efra; } - strcpy(string, rd->pic); - BLI_path_abs(string, BKE_main_blendfile_path_from_global()); + strcpy(filepath, rd->pic); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); - BLI_make_existing_file(string); + BLI_file_ensure_parent_dir_exists(filepath); if (rd->scemode & R_EXTENSION) { - if (!BLI_path_extension_check(string, ".avi")) { - BLI_path_frame_range(string, sfra, efra, 4); - strcat(string, ".avi"); + if (!BLI_path_extension_check(filepath, ".avi")) { + BLI_path_frame_range(filepath, sfra, efra, 4); + BLI_strncat(filepath, ".avi", FILE_MAX); } } else { - if (BLI_path_frame_check_chars(string)) { - BLI_path_frame_range(string, sfra, efra, 4); + if (BLI_path_frame_check_chars(filepath)) { + BLI_path_frame_range(filepath, sfra, efra, 4); } } - BLI_path_suffix(string, FILE_MAX, suffix, ""); + BLI_path_suffix(filepath, FILE_MAX, suffix, ""); } static int start_avi(void *context_v, @@ -296,13 +297,13 @@ static void context_free_avi(void *context_v) #endif /* WITH_AVI */ -void BKE_movie_filepath_get(char *string, const RenderData *rd, bool preview, const char *suffix) +void BKE_movie_filepath_get(char *filepath, const RenderData *rd, bool preview, const char *suffix) { bMovieHandle *mh = BKE_movie_handle_get(rd->im_format.imtype); if (mh && mh->get_movie_path) { - mh->get_movie_path(string, rd, preview, suffix); + mh->get_movie_path(filepath, rd, preview, suffix); } else { - string[0] = '\0'; + filepath[0] = '\0'; } } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ffafd926785..c107c028985 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -103,7 +103,7 @@ typedef struct FFMpegContext { static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value); static void ffmpeg_filepath_get(FFMpegContext *context, - char *string, + char string[FILE_MAX], const struct RenderData *rd, bool preview, const char *suffix); @@ -1097,7 +1097,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, /* Handle to the output file */ AVFormatContext *of; const AVOutputFormat *fmt; - char name[FILE_MAX], error[1024]; + char filepath[FILE_MAX], error[1024]; const char **exts; context->ffmpeg_type = rd->ffcodecdata.type; @@ -1115,14 +1115,14 @@ static int start_ffmpeg_impl(FFMpegContext *context, } /* Determine the correct filename */ - ffmpeg_filepath_get(context, name, rd, context->ffmpeg_preview, suffix); + ffmpeg_filepath_get(context, filepath, rd, context->ffmpeg_preview, suffix); PRINT( "Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" " gop_size=%d, autosplit=%d\n" " render width=%d, render height=%d\n", - name, + filepath, context->ffmpeg_type, context->ffmpeg_codec, context->ffmpeg_audio_codec, @@ -1155,7 +1155,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, enum AVCodecID audio_codec = context->ffmpeg_audio_codec; enum AVCodecID video_codec = context->ffmpeg_codec; - of->url = av_strdup(name); + of->url = av_strdup(filepath); /* Check if we need to force change the codec because of file type codec restrictions */ switch (context->ffmpeg_type) { case FFMPEG_OGG: @@ -1217,7 +1217,8 @@ static int start_ffmpeg_impl(FFMpegContext *context, if (context->ffmpeg_type == FFMPEG_DV) { audio_codec = AV_CODEC_ID_PCM_S16LE; if (context->ffmpeg_audio_codec != AV_CODEC_ID_NONE && - rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) { + rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) + { BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!"); goto fail; } @@ -1255,7 +1256,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, } } if (!(fmt->flags & AVFMT_NOFILE)) { - if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) { + if (avio_open(&of->pb, filepath, AVIO_FLAG_WRITE) < 0) { BKE_report(reports, RPT_ERROR, "Could not open file for writing"); PRINT("Could not open file for writing\n"); goto fail; @@ -1277,7 +1278,7 @@ static int start_ffmpeg_impl(FFMpegContext *context, } context->outfile = of; - av_dump_format(of, 0, name, 1); + av_dump_format(of, 0, filepath, 1); return 1; @@ -1356,8 +1357,11 @@ static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext *o * ********************************************************************** */ /* Get the output filename-- similar to the other output formats */ -static void ffmpeg_filepath_get( - FFMpegContext *context, char *string, const RenderData *rd, bool preview, const char *suffix) +static void ffmpeg_filepath_get(FFMpegContext *context, + char string[FILE_MAX], + const RenderData *rd, + bool preview, + const char *suffix) { char autosplit[20]; @@ -1378,10 +1382,10 @@ static void ffmpeg_filepath_get( efra = rd->efra; } - strcpy(string, rd->pic); + BLI_strncpy(string, rd->pic, FILE_MAX); BLI_path_abs(string, BKE_main_blendfile_path_from_global()); - BLI_make_existing_file(string); + BLI_file_ensure_parent_dir_exists(string); autosplit[0] = '\0'; @@ -1400,15 +1404,15 @@ static void ffmpeg_filepath_get( } if (*fe == NULL) { - strcat(string, autosplit); + BLI_strncat(string, autosplit, FILE_MAX); BLI_path_frame_range(string, sfra, efra, 4); - strcat(string, *exts); + BLI_strncat(string, *exts, FILE_MAX); } else { *(string + strlen(string) - strlen(*fe)) = '\0'; - strcat(string, autosplit); - strcat(string, *fe); + BLI_strncat(string, autosplit, FILE_MAX); + BLI_strncat(string, *fe, FILE_MAX); } } else { @@ -1416,15 +1420,18 @@ static void ffmpeg_filepath_get( BLI_path_frame_range(string, sfra, efra, 4); } - strcat(string, autosplit); + BLI_strncat(string, autosplit, FILE_MAX); } BLI_path_suffix(string, FILE_MAX, suffix, ""); } -void BKE_ffmpeg_filepath_get(char *string, const RenderData *rd, bool preview, const char *suffix) +void BKE_ffmpeg_filepath_get(char *filepath, + const RenderData *rd, + bool preview, + const char *suffix) { - ffmpeg_filepath_get(NULL, string, rd, preview, suffix); + ffmpeg_filepath_get(NULL, filepath, rd, preview, suffix); } int BKE_ffmpeg_start(void *context_v, @@ -1738,7 +1745,8 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, const ImageFormatData *imf) if (imf->imtype == R_IMF_IMTYPE_FFMPEG) { if (rd->ffcodecdata.type <= 0 || rd->ffcodecdata.codec <= 0 || - rd->ffcodecdata.audio_codec <= 0 || rd->ffcodecdata.video_bitrate <= 1) { + rd->ffcodecdata.audio_codec <= 0 || rd->ffcodecdata.video_bitrate <= 1) + { BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); rd->ffcodecdata.constant_rate_factor = FFM_CRF_MEDIUM; rd->ffcodecdata.ffmpeg_preset = FFM_PRESET_GOOD; diff --git a/source/blender/blenlib/BLI_atomic_disjoint_set.hh b/source/blender/blenlib/BLI_atomic_disjoint_set.hh index b5cb652e2bc..ab458ef3a32 100644 --- a/source/blender/blenlib/BLI_atomic_disjoint_set.hh +++ b/source/blender/blenlib/BLI_atomic_disjoint_set.hh @@ -60,7 +60,8 @@ class AtomicDisjointSet { /* Implement union by rank heuristic. */ x_item.rank > y_item.rank /* If the rank is the same, make a consistent decision. */ - || (x_item.rank == y_item.rank && x < y)) { + || (x_item.rank == y_item.rank && x < y)) + { std::swap(x_item, y_item); std::swap(x, y); } diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index a4f1eef647c..2defe7853be 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -49,14 +49,14 @@ int BLI_rename(const char *from, const char *to) ATTR_NONNULL(); * * \return zero on success (matching 'remove' behavior). */ -int BLI_delete(const char *file, bool dir, bool recursive) ATTR_NONNULL(); +int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL(); /** * Soft deletes the specified file or directory (depending on dir) by moving the files to the * recycling bin, optionally doing recursive delete of directory contents. * * \return zero on success (matching 'remove' behavior). */ -int BLI_delete_soft(const char *file, const char **error_message) ATTR_NONNULL(); +int BLI_delete_soft(const char *filepath, const char **error_message) ATTR_NONNULL(); /** * When `path` points to a directory, moves all its contents into `to`, * else rename `path` itself to `to`. @@ -276,7 +276,14 @@ bool BLI_file_is_writable(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NON * Creates the file with nothing in it, or updates its last-modified date if it already exists. * Returns true if successful (like the unix touch command). */ -bool BLI_file_touch(const char *file) ATTR_NONNULL(); +bool BLI_file_touch(const char *filepath) ATTR_NONNULL(1); +/** + * Ensures that the parent directory of `filepath` exists. + * + * \return true on success (i.e. given path now exists on file-system), false otherwise. + */ +bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1); + bool BLI_file_alias_target(const char *filepath, char *r_targetpath) ATTR_WARN_UNUSED_RESULT; bool BLI_file_magic_is_gzip(const char header[4]); diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h index 3e4acb44457..63878d5a61f 100644 --- a/source/blender/blenlib/BLI_linklist_stack.h +++ b/source/blender/blenlib/BLI_linklist_stack.h @@ -146,7 +146,8 @@ LinkNode *_##var##_iter; \ unsigned int i; \ for (_##var##_iter = _##var##_stack, i = 0; _##var##_iter; \ - _##var##_iter = _##var##_iter->next, i++) { \ + _##var##_iter = _##var##_iter->next, i++) \ + { \ (data)[i] = _BLI_SMALLSTACK_CAST(var)(_##var##_iter->link); \ } \ } \ diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 4cda904a84a..0e3240e4b29 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -37,53 +37,50 @@ void BLI_setenv_if_new(const char *env, const char *val) ATTR_NONNULL(1); */ const char *BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; -/** - * Ensures that the parent directory of `name` exists. - * - * \return true on success (i.e. given path now exists on file-system), false otherwise. - */ -bool BLI_make_existing_file(const char *name); /** * Converts `/foo/bar.txt` to `/foo/` and `bar.txt` * * - Won't change \a string. * - Won't create any directories. * - Doesn't use CWD, or deal with relative paths. - * - Only fill's in \a dir and \a file when they are non NULL. */ -void BLI_split_dirfile(const char *string, char *dir, char *file, size_t dirlen, size_t filelen); +void BLI_path_split_dir_file(const char *string, + char *dir, + size_t dirlen, + char *file, + size_t filelen) ATTR_NONNULL(1, 2, 4); /** * Copies the parent directory part of string into `dir`, max length `dirlen`. */ -void BLI_split_dir_part(const char *string, char *dir, size_t dirlen); +void BLI_path_split_dir_part(const char *string, char *dir, size_t dirlen) ATTR_NONNULL(1, 2); /** * Copies the leaf filename part of string into `file`, max length `filelen`. */ -void BLI_split_file_part(const char *string, char *file, size_t filelen); +void BLI_path_split_file_part(const char *string, char *file, size_t filelen) ATTR_NONNULL(1, 2); /** * Returns a pointer to the last extension (e.g. the position of the last period). * Returns a pointer to the nil byte when no extension is found. */ const char *BLI_path_extension_or_end(const char *filepath) - ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL; + ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL; /** * Returns a pointer to the last extension (e.g. the position of the last period). * Returns NULL if there is no extension. */ -const char *BLI_path_extension(const char *filepath) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +const char *BLI_path_extension(const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; /** * Append a filename to a dir, ensuring slash separates. * \return The new length of `dst`. */ size_t BLI_path_append(char *__restrict dst, size_t maxlen, const char *__restrict file) - ATTR_NONNULL(); + ATTR_NONNULL(1, 3); /** * A version of #BLI_path_append that ensures a trailing slash if there is space in `dst`. * \return The new length of `dst`. */ size_t BLI_path_append_dir(char *__restrict dst, size_t maxlen, const char *__restrict dir) - ATTR_NONNULL(); + ATTR_NONNULL(1, 3); /** * See #BLI_path_join doc-string. @@ -91,7 +88,7 @@ size_t BLI_path_append_dir(char *__restrict dst, size_t maxlen, const char *__re size_t BLI_path_join_array(char *__restrict dst, const size_t dst_len, const char *path_array[], - const int path_array_num); + const int path_array_num) ATTR_NONNULL(1, 3); /** * Join multiple strings into a path, ensuring only a single path separator between each, @@ -200,7 +197,7 @@ BLI_INLINE size_t _BLI_path_join_12(_BLI_PATH_JOIN_ARGS_10) * \return The pointer into \a path string immediately after last slash, * or start of \a path if none found. */ -const char *BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +const char *BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; /** * Get an element of the path at an index, eg: * `/some/path/file.txt` where an index of: @@ -216,20 +213,20 @@ const char *BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_ bool BLI_path_name_at_index(const char *__restrict path, int index, int *__restrict r_offset, - int *__restrict r_len) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; + int *__restrict r_len) ATTR_NONNULL(1, 3, 4) ATTR_WARN_UNUSED_RESULT; /** Return true only if #containee_path is contained in #container_path. */ -bool BLI_path_contains(const char *container_path, - const char *containee_path) ATTR_WARN_UNUSED_RESULT; +bool BLI_path_contains(const char *container_path, const char *containee_path) + ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; /** * \return pointer to the leftmost path separator in string (or NULL when not found). */ -const char *BLI_path_slash_find(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +const char *BLI_path_slash_find(const char *string) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; /** * \return pointer to the rightmost path separator in string (or NULL when not found). */ -const char *BLI_path_slash_rfind(const char *string) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +const char *BLI_path_slash_rfind(const char *string) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; /** * Appends a slash to string if there isn't one there already. * Returns the new length of the string. @@ -238,37 +235,38 @@ int BLI_path_slash_ensure(char *string, size_t string_maxlen) ATTR_NONNULL(1); /** * Removes the last slash and everything after it to the end of string, if there is one. */ -void BLI_path_slash_rstrip(char *string) ATTR_NONNULL(); +void BLI_path_slash_rstrip(char *string) ATTR_NONNULL(1); /** * Changes to the path separators to the native ones for this OS. */ -void BLI_path_slash_native(char *path) ATTR_NONNULL(); +void BLI_path_slash_native(char *path) ATTR_NONNULL(1); #ifdef _WIN32 -bool BLI_path_program_extensions_add_win32(char *name, size_t maxlen); +bool BLI_path_program_extensions_add_win32(char *program_name, size_t maxlen); #endif /** * Search for a binary (executable) */ -bool BLI_path_program_search(char *fullname, size_t maxlen, const char *name); +bool BLI_path_program_search(char *program_filepath, size_t maxlen, const char *program_name) + ATTR_NONNULL(1, 3); /** * \return true when `str` end with `ext` (case insensitive). */ bool BLI_path_extension_check(const char *str, const char *ext) - ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; + ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; bool BLI_path_extension_check_n(const char *str, ...) ATTR_NONNULL(1) ATTR_SENTINEL(0); /** * \return true when `str` ends with any of the suffixes in `ext_array`. */ bool BLI_path_extension_check_array(const char *str, const char **ext_array) - ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; + ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; /** * Semicolon separated wildcards, eg: `*.zip;*.py;*.exe` * does `str` match any of the semicolon-separated glob patterns in #fnmatch. */ bool BLI_path_extension_check_glob(const char *str, const char *ext_fnmatch) - ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; + ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; /** * Does basic validation of the given glob string, to prevent common issues from string * truncation. @@ -278,26 +276,27 @@ bool BLI_path_extension_check_glob(const char *str, const char *ext_fnmatch) * * \returns true if it had to modify given \a ext_fnmatch pattern. */ -bool BLI_path_extension_glob_validate(char *ext_fnmatch) ATTR_NONNULL(); +bool BLI_path_extension_glob_validate(char *ext_fnmatch) ATTR_NONNULL(1); /** * Removes any existing extension on the end of \a path and appends \a ext. * \return false if there was no room. */ -bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL(); +bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL(1, 3); /** * Remove the file extension. * \return true if a change was made to `path`. */ -bool BLI_path_extension_strip(char *path) ATTR_NONNULL(); +bool BLI_path_extension_strip(char *path) ATTR_NONNULL(1); /** * Strip's trailing '.'s and adds the extension only when needed */ -bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL(); +bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL(1, 3); /** * Ensure `filepath` has a file component, adding `filename` when it's empty or ends with a slash. * \return true if the `filename` was appended to `filepath`. */ -bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filename) ATTR_NONNULL(); +bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filename) + ATTR_NONNULL(1, 3); /** * Looks for a sequence of decimal digits in string, preceding any filename extension, * returning the integer value if found, or 0 if not. @@ -381,8 +380,8 @@ void BLI_path_normalize_dir(char *dir, size_t dir_maxlen) ATTR_NONNULL(1); * \note On Windows, it also checks for forbidden names * (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx ). */ -bool BLI_filename_make_safe_ex(char *fname, bool allow_tokens) ATTR_NONNULL(1); -bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1); +bool BLI_path_make_safe_filename_ex(char *fname, bool allow_tokens) ATTR_NONNULL(1); +bool BLI_path_make_safe_filename(char *fname) ATTR_NONNULL(1); /** * Make given path OS-safe. @@ -399,14 +398,14 @@ bool BLI_path_make_safe(char *path) ATTR_NONNULL(1); * * On success, the resulting path will always have a trailing slash. */ -bool BLI_path_parent_dir(char *path) ATTR_NONNULL(); +bool BLI_path_parent_dir(char *path) ATTR_NONNULL(1); /** * Go back until the directory is found. * * Strips off nonexistent (or non-accessible) sub-directories from the end of `dir`, * leaving the path of the lowest-level directory that does exist and we can read. */ -bool BLI_path_parent_dir_until_exists(char *path) ATTR_NONNULL(); +bool BLI_path_parent_dir_until_exists(char *path) ATTR_NONNULL(1); /** * If path begins with "//", strips that and replaces it with `basepath` directory. @@ -418,29 +417,29 @@ bool BLI_path_parent_dir_until_exists(char *path) ATTR_NONNULL(); * \param basepath: The directory to base relative paths with. * \return true if the path was relative (started with "//"). */ -bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL(); +bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL(1, 2); /** * Replaces "#" character sequence in last slash-separated component of `path` * with frame as decimal integer, with leading zeroes as necessary, to make digits. */ -bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL(); +bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) ATTR_NONNULL(1); /** * Replaces "#" character sequence in last slash-separated component of `path` * with sta and end as decimal integers, with leading zeroes as necessary, to make digits * digits each, with a hyphen in-between. */ -bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL(); +bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL(1); /** * Get the frame from a filename formatted by blender's frame scheme */ -bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(); +bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1, 2, 3); /** * Given a `path` with digits representing frame numbers, replace the digits with the '#' * character and extract the extension. * So: `/some/path_123.jpeg` * Becomes: `/some/path_###` with `r_ext` set to `.jpeg`. */ -void BLI_path_frame_strip(char *path, char *r_ext, size_t ext_maxlen) ATTR_NONNULL(); +void BLI_path_frame_strip(char *path, char *r_ext, size_t ext_maxlen) ATTR_NONNULL(1, 2); /** * Check if we have '#' chars, usable for #BLI_path_frame, #BLI_path_frame_range */ @@ -459,18 +458,18 @@ bool BLI_path_is_abs_from_cwd(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED * This is _not_ something Blender's internal paths support, instead they use the "//" prefix. * In most cases #BLI_path_abs should be used instead. */ -bool BLI_path_abs_from_cwd(char *path, size_t maxlen) ATTR_NONNULL(); +bool BLI_path_abs_from_cwd(char *path, size_t maxlen) ATTR_NONNULL(1); /** * Replaces `file` with a relative version (prefixed by "//") such that #BLI_path_abs, given * the same `relfile`, will convert it back to its original value. */ -void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL(); +void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL(1); /** * Does path begin with the special "//" prefix that Blender uses to indicate * a path relative to the .blend file. */ -bool BLI_path_is_rel(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT; +bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; /** * Return true if the path is a UNC share. */ @@ -480,7 +479,7 @@ bool BLI_path_is_unc(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; * Creates a display string from path to be used menus and the user interface. * Like `bpy.path.display_name()`. */ -void BLI_path_to_display_name(char *display_name, int maxlen, const char *name) ATTR_NONNULL(); +void BLI_path_to_display_name(char *display_name, int maxlen, const char *name) ATTR_NONNULL(1, 3); #if defined(WIN32) void BLI_path_normalize_unc_16(wchar_t *path_16); @@ -500,7 +499,7 @@ void BLI_path_normalize_unc(char *path_16, int maxlen); * \return true if succeeded */ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep) - ATTR_NONNULL(); + ATTR_NONNULL(1, 3, 4); /* Path string comparisons: case-insensitive for Windows, case-sensitive otherwise. */ #if defined(WIN32) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 87749e90e77..0a329c0686b 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -41,7 +41,7 @@ extern "C" { * \param len: The number of bytes to duplicate * \retval Returns the duplicated string */ -char *BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +char *BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /** * Duplicates the cstring \a str into a newly mallocN'd @@ -50,7 +50,7 @@ char *BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESU * \param str: The string to be duplicated * \retval Returns the duplicated string */ -char *BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC; +char *BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC; /** * Appends the two strings, and returns new mallocN'ed string @@ -60,7 +60,7 @@ char *BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MA */ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL() ATTR_MALLOC; + ATTR_NONNULL(1, 2) ATTR_MALLOC; /** * Like strncpy but ensures dst is always @@ -72,7 +72,8 @@ char *BLI_strdupcat(const char *__restrict str1, * the size of dst) * \retval Returns dst */ -char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL(); +char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) + ATTR_NONNULL(1, 2); /** * Like BLI_strncpy but ensures dst is always padded by given char, @@ -87,7 +88,7 @@ char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxnc char *BLI_strncpy_ensure_pad(char *__restrict dst, const char *__restrict src, char pad, - size_t maxncpy) ATTR_NONNULL(); + size_t maxncpy) ATTR_NONNULL(1, 2); /** * Like strncpy but ensures dst is always @@ -104,10 +105,13 @@ char *BLI_strncpy_ensure_pad(char *__restrict dst, */ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, - size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); + +char *BLI_strncat(char *__restrict dst, const char *__restrict src, size_t maxncpy) + ATTR_NONNULL(1, 2); /** * Return the range of the quoted string (excluding quotes) `str` after `prefix`. @@ -129,7 +133,7 @@ bool BLI_str_quoted_substr_range(const char *__restrict str, #if 0 /* UNUSED */ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL() ATTR_MALLOC; + ATTR_NONNULL(1, 2) ATTR_MALLOC; #endif /** * Fills \a result with text within "" that appear after some the contents of \a prefix. @@ -164,7 +168,7 @@ bool BLI_str_quoted_substr(const char *__restrict str, char *BLI_str_replaceN(const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL() ATTR_MALLOC; + ATTR_NONNULL(1, 2, 3) ATTR_MALLOC; /** * In-place replace every \a src to \a dst in \a str. @@ -173,7 +177,7 @@ char *BLI_str_replaceN(const char *__restrict str, * \param src: The character to replace. * \param dst: The character to replace with. */ -void BLI_str_replace_char(char *str, char src, char dst) ATTR_NONNULL(); +void BLI_str_replace_char(char *str, char src, char dst) ATTR_NONNULL(1); /** * Simple exact-match string replacement. @@ -241,7 +245,7 @@ int BLI_sprintf(char *__restrict str, const char *__restrict format, ...) ATTR_N * \note This is used for creating animation paths in blend files. */ size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); /** * This roughly matches C and Python's string escaping with double quotes - `"`. * @@ -259,7 +263,7 @@ size_t BLI_str_unescape_ex(char *__restrict dst, size_t src_maxncpy, /* Additional arguments. */ size_t dst_maxncpy, - bool *r_is_complete) ATTR_NONNULL(); + bool *r_is_complete) ATTR_NONNULL(1, 2, 5); /** * See #BLI_str_unescape_ex doc-string. * @@ -271,7 +275,7 @@ size_t BLI_str_unescape_ex(char *__restrict dst, * \note This is used for parsing animation paths in blend files (runs often). */ size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, size_t src_maxncpy) - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); /** * Find the first un-escaped quote in the string (to find the end of the string). @@ -281,7 +285,7 @@ size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, size_t * * \return The pointer to the first un-escaped quote. */ -const char *BLI_str_escape_find_quote(const char *str) ATTR_NONNULL(); +const char *BLI_str_escape_find_quote(const char *str) ATTR_NONNULL(1); /** * Format ints with decimal grouping. @@ -292,7 +296,7 @@ const char *BLI_str_escape_find_quote(const char *str) ATTR_NONNULL(); * \return The length of \a dst */ size_t BLI_str_format_int_grouped(char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], int num) - ATTR_NONNULL(); + ATTR_NONNULL(1); /** * Format uint64_t with decimal grouping. * 1000 -> 1,000 @@ -302,7 +306,7 @@ size_t BLI_str_format_int_grouped(char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], i * \return The length of \a dst */ size_t BLI_str_format_uint64_grouped(char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE], uint64_t num) - ATTR_NONNULL(); + ATTR_NONNULL(1); /** * Format a size in bytes using binary units. * 1000 -> 1 KB @@ -315,7 +319,7 @@ size_t BLI_str_format_uint64_grouped(char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE */ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE], long long int bytes, - bool base_10) ATTR_NONNULL(); + bool base_10) ATTR_NONNULL(1); /** * Format a count to up to 6 places (plus '\0' terminator) string using long number * names abbreviations. Used to produce a compact representation of large numbers. @@ -335,7 +339,7 @@ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE], * Length of 7 is the maximum of the resulting string, for example, `-15.5K\0`. */ void BLI_str_format_decimal_unit(char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE], - int number_to_format) ATTR_NONNULL(); + int number_to_format) ATTR_NONNULL(1); /** * Format a count to up to 3 places (plus minus sign, plus '\0' terminator) string using long * number names abbreviations. Used to produce a compact representation of large numbers as @@ -358,56 +362,57 @@ void BLI_str_format_decimal_unit(char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE * Length of 5 is the maximum of the resulting string, for example, `-15K\0`. */ void BLI_str_format_integer_unit(char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE], - int number_to_format) ATTR_NONNULL(); + int number_to_format) ATTR_NONNULL(1); /** * Compare two strings without regard to case. * * \retval True if the strings are equal, false otherwise. */ -int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); /** * Portable replacement for `strcasestr` (not available in MSVC) */ -char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); /** * Variation of #BLI_strcasestr with string length limited to \a len */ char *BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(); -int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + ATTR_NONNULL(1, 2); +int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); int BLI_strncasecmp(const char *s1, const char *s2, size_t len) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); /** * Case insensitive, *natural* string comparison, * keeping numbers in order. */ -int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 2); /** - * Like strcmp, but will ignore any heading/trailing pad char for comparison. + * Like `strcmp`, but will ignore any heading/trailing pad char for comparison. * So e.g. if pad is '*', '*world' and 'world*' will compare equal. */ int BLI_strcmp_ignore_pad(const char *str1, const char *str2, char pad) ATTR_WARN_UNUSED_RESULT - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); /** * Determine the length of a fixed-size string. */ -size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /** * String case conversion, not affected by locale. */ -void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(); -void BLI_str_toupper_ascii(char *str, size_t len) ATTR_NONNULL(); +void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(1); +void BLI_str_toupper_ascii(char *str, size_t len) ATTR_NONNULL(1); -char BLI_tolower_ascii(const char c); -char BLI_toupper_ascii(const char c); +char BLI_tolower_ascii(const char c) ATTR_WARN_UNUSED_RESULT; +char BLI_toupper_ascii(const char c) ATTR_WARN_UNUSED_RESULT; /** * Strip white-space from end of the string. */ -void BLI_str_rstrip(char *str) ATTR_NONNULL(); +void BLI_str_rstrip(char *str) ATTR_NONNULL(1); /** * Strip trailing zeros from a float, eg: * 0.0000 -> 0.0 @@ -417,7 +422,7 @@ void BLI_str_rstrip(char *str) ATTR_NONNULL(); * \param pad: * \return The number of zeros stripped. */ -int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(); +int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(1); /** * Return index of a string in a string array. @@ -429,7 +434,7 @@ int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(); */ int BLI_str_index_in_array_n(const char *__restrict str, const char **__restrict str_array, - int str_array_len) ATTR_NONNULL(); + int str_array_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /** * Return index of a string in a string array. * @@ -437,8 +442,9 @@ int BLI_str_index_in_array_n(const char *__restrict str, * \param str_array: Array of strings, (must be NULL-terminated). * \return The index of str in str_array or -1. */ -int BLI_str_index_in_array(const char *__restrict str, const char **__restrict str_array) - ATTR_NONNULL(); +int BLI_str_index_in_array(const char *__restrict str, + const char **__restrict str_array) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 2); /** * Find if a string starts with another string. @@ -447,7 +453,8 @@ int BLI_str_index_in_array(const char *__restrict str, const char **__restrict s * \param start: The string we look for at the start. * \return If str starts with start. */ -bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_NONNULL(); +bool BLI_str_startswith(const char *__restrict str, + const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); /** * Find if a string ends with another string. * @@ -455,9 +462,9 @@ bool BLI_str_startswith(const char *__restrict str, const char *__restrict start * \param end: The string we look for at the end. * \return If str ends with end. */ -bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(); +bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1, 2); bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t length) - ATTR_NONNULL(); + ATTR_NONNULL(1, 2); /** * Find the first char matching one of the chars in \a delim, from left. @@ -470,7 +477,7 @@ bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, s * \return The length of the prefix (i.e. *sep - str). */ size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf) - ATTR_NONNULL(); + ATTR_NONNULL(1, 2, 3, 4); /** * Find the first char matching one of the chars in \a delim, from right. * @@ -482,7 +489,7 @@ size_t BLI_str_partition(const char *str, const char delim[], const char **sep, * \return The length of the prefix (i.e. *sep - str). */ size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf) - ATTR_NONNULL(); + ATTR_NONNULL(1, 2, 3, 4); /** * Find the first char matching one of the chars in \a delim, either from left or right. * @@ -502,12 +509,14 @@ size_t BLI_str_partition_ex(const char *str, const char **suf, bool from_right) ATTR_NONNULL(1, 3, 4, 5); -int BLI_string_max_possible_word_count(int str_len); -bool BLI_string_has_word_prefix(const char *haystack, const char *needle, size_t needle_len); +int BLI_string_max_possible_word_count(int str_len) ATTR_WARN_UNUSED_RESULT; +bool BLI_string_has_word_prefix(const char *haystack, + const char *needle, + size_t needle_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); bool BLI_string_all_words_matched(const char *name, const char *str, int (*words)[2], - int words_len); + int words_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2, 3); /** * Find the ranges needed to split \a str into its individual words. @@ -523,7 +532,7 @@ int BLI_string_find_split_words(const char *str, size_t len, char delim, int r_words[][2], - int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 4); /* -------------------------------------------------------------------- */ /** \name String Copy/Format Macros diff --git a/source/blender/blenlib/BLI_string_utils.h b/source/blender/blenlib/BLI_string_utils.h index 7dcfbb939aa..841ea38219c 100644 --- a/source/blender/blenlib/BLI_string_utils.h +++ b/source/blender/blenlib/BLI_string_utils.h @@ -34,18 +34,21 @@ typedef bool (*UniquenameCheckCallback)(void *arg, const char *name); * \param delim: Delimiter character`. * \return Length of \a left. */ -size_t BLI_split_name_num(char *left, int *nr, const char *name, char delim); -bool BLI_string_is_decimal(const char *string) ATTR_NONNULL(); +size_t BLI_string_split_name_number(const char *name, char delim, char *r_name_left, int *r_number) + ATTR_NONNULL(1, 3, 4); +bool BLI_string_is_decimal(const char *string) ATTR_NONNULL(1); /** - * Based on `BLI_split_dirfile()` / `os.path.splitext()`, + * Based on `BLI_path_split_dir_file()` / `os.path.splitext()`, * `"a.b.c"` -> (`"a.b"`, `".c"`). */ -void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, size_t str_len); +void BLI_string_split_suffix(const char *string, size_t string_maxlen, char *r_body, char *r_suf) + ATTR_NONNULL(1, 3, 4); /** * `"a.b.c"` -> (`"a."`, `"b.c"`). */ -void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, size_t str_len); +void BLI_string_split_prefix(const char *string, size_t string_maxlen, char *r_pre, char *r_body) + ATTR_NONNULL(1, 3, 4); /** * A version of #BLI_string_join_array_by_sep_charN that takes a table array. @@ -54,7 +57,7 @@ void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, size char *BLI_string_join_array_by_sep_char_with_tableN(char sep, char *table[], const char *strings[], - uint strings_len) ATTR_NONNULL(); + uint strings_len) ATTR_NONNULL(2, 3); #define BLI_string_join_by_sep_char_with_tableN(sep, table, ...) \ BLI_string_join_array_by_sep_char_with_tableN( \ @@ -74,7 +77,7 @@ char *BLI_string_join_array_by_sep_char_with_tableN(char sep, size_t BLI_string_flip_side_name(char *r_name, const char *from_name, bool strip_number, - size_t name_len); + size_t name_len) ATTR_NONNULL(1, 2); /** * Ensures name is unique (according to criteria specified by caller in unique_check callback), @@ -93,7 +96,7 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check, const char *defname, char delim, char *name, - size_t name_len); + size_t name_len) ATTR_NONNULL(1, 3, 5); /** * Ensures that the specified block has a unique name within the containing list, * incrementing its numeric suffix as necessary. Returns true if name had to be adjusted. @@ -110,7 +113,7 @@ bool BLI_uniquename(struct ListBase *list, const char *defname, char delim, int name_offset, - size_t name_len); + size_t name_len) ATTR_NONNULL(1, 3); /* Expand array functions. */ diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index d830ca541fe..54a5ece2f2e 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -1260,7 +1260,8 @@ inline void devirtualize_varray(const VArray &varray, const Func &func, bool { if (enable) { if (call_with_devirtualized_parameters( - std::make_tuple(VArrayDevirtualizer{varray}), func)) { + std::make_tuple(VArrayDevirtualizer{varray}), func)) + { return; } } @@ -1282,7 +1283,8 @@ inline void devirtualize_varray2(const VArray &varray1, if (call_with_devirtualized_parameters( std::make_tuple(VArrayDevirtualizer{varray1}, VArrayDevirtualizer{varray2}), - func)) { + func)) + { return; } } diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c index 6240c855c99..4d489c0ae9f 100644 --- a/source/blender/blenlib/intern/BLI_filelist.c +++ b/source/blender/blenlib/intern/BLI_filelist.c @@ -127,7 +127,8 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname) dirname_with_slash, dirname, sizeof(dirname_with_slash) - 1); if ((dirname_with_slash_len > 0) && - (BLI_path_slash_is_native_compat(dirname[dirname_with_slash_len - 1]) == false)) { + (BLI_path_slash_is_native_compat(dirname[dirname_with_slash_len - 1]) == false)) + { dirname_with_slash[dirname_with_slash_len++] = SEP; dirname_with_slash[dirname_with_slash_len] = '\0'; } diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index afd036fb85d..5b6002bd461 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -467,7 +467,8 @@ static void bvhtree_print_tree(BVHTree *tree, BVHNode *node, int depth) } printf(" - %d (%ld): ", node->index, (long int)(node - tree->nodearray)); for (axis_iter = (axis_t)(2 * tree->start_axis); axis_iter < (axis_t)(2 * tree->stop_axis); - axis_iter++) { + axis_iter++) + { printf("%.3f ", node->bv[axis_iter]); } printf("\n"); @@ -582,7 +583,8 @@ static void build_implicit_tree_helper(const BVHTree *tree, BVHBuildHelper *data /* Calculate the smallest tree_type^n such that tree_type^n >= leafs_num */ for (data->leafs_per_child[0] = 1; data->leafs_per_child[0] < data->leafs_num; - data->leafs_per_child[0] *= data->tree_type) { + data->leafs_per_child[0] *= data->tree_type) + { /* pass */ } @@ -1205,7 +1207,8 @@ static bool tree_overlap_traverse_num(BVHOverlapData_Thread *data_thread, /* only difference to tree_overlap_traverse! */ if (!data->callback || - data->callback(data->userdata, node1->index, node2->index, data_thread->thread)) { + data->callback(data->userdata, node1->index, node2->index, data_thread->thread)) + { /* both leafs, insert overlap! */ if (data_thread->overlap) { overlap = BLI_stack_push_r(data_thread->overlap); @@ -1351,7 +1354,8 @@ BVHTreeOverlap *BLI_bvhtree_overlap_ex( /* check for compatibility of both trees (can't compare 14-DOP with 18-DOP) */ if (UNLIKELY((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && - (tree1->axis == 18 || tree2->axis == 18))) { + (tree1->axis == 18 || tree2->axis == 18))) + { BLI_assert(0); return NULL; } @@ -1470,8 +1474,8 @@ static bool tree_intersect_plane_test(const float *bv, const float plane[4]) const float bb_max[3] = {bv[1], bv[3], bv[5]}; float bb_near[3], bb_far[3]; aabb_get_near_far_from_plane(plane, bb_min, bb_max, bb_near, bb_far); - if ((plane_point_side_v3(plane, bb_near) > 0.0f) != - (plane_point_side_v3(plane, bb_far) > 0.0f)) { + if ((plane_point_side_v3(plane, bb_near) > 0.0f) != (plane_point_side_v3(plane, bb_far) > 0.0f)) + { return true; } @@ -1713,7 +1717,8 @@ static bool isect_aabb_v3(BVHNode *node, const float co[3]) const BVHTreeAxisRange *bv = (const BVHTreeAxisRange *)node->bv; if (co[0] > bv[0].min && co[0] < bv[0].max && co[1] > bv[1].min && co[1] < bv[1].max && - co[2] > bv[2].min && co[2] < bv[2].max) { + co[2] > bv[2].min && co[2] < bv[2].max) + { return true; } @@ -1805,7 +1810,8 @@ static float ray_nearest_hit(const BVHRayCastData *data, const float bv[6]) if (data->ray_dot_axis[i] == 0.0f) { /* axis aligned ray */ if (data->ray.origin[i] < bv[0] - data->ray.radius || - data->ray.origin[i] > bv[1] + data->ray.radius) { + data->ray.origin[i] > bv[1] + data->ray.radius) + { return FLT_MAX; } } @@ -1857,7 +1863,8 @@ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *nod if ((t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) || (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) || - (t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist)) { + (t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist)) + { return FLT_MAX; } return max_fff(t1x, t1y, t1z); @@ -2223,7 +2230,8 @@ static void bvhtree_nearest_projected_dfs_recursive(BVHNearestProjectedData *__r if (dist_squared_to_projected_aabb(&data->precalc, (float[3]){bv[0], bv[2], bv[4]}, (float[3]){bv[1], bv[3], bv[5]}, - data->closest_axis) <= data->nearest.dist_sq) { + data->closest_axis) <= data->nearest.dist_sq) + { bvhtree_nearest_projected_dfs_recursive(data, node->children[i]); } } @@ -2235,7 +2243,8 @@ static void bvhtree_nearest_projected_dfs_recursive(BVHNearestProjectedData *__r if (dist_squared_to_projected_aabb(&data->precalc, (float[3]){bv[0], bv[2], bv[4]}, (float[3]){bv[1], bv[3], bv[5]}, - data->closest_axis) <= data->nearest.dist_sq) { + data->closest_axis) <= data->nearest.dist_sq) + { bvhtree_nearest_projected_dfs_recursive(data, node->children[i]); } } @@ -2277,7 +2286,8 @@ static void bvhtree_nearest_projected_with_clipplane_test_dfs_recursive( if ((isect_type != ISECT_AABB_PLANE_BEHIND_ANY) && dist_squared_to_projected_aabb(&data->precalc, bb_min, bb_max, data->closest_axis) <= - data->nearest.dist_sq) { + data->nearest.dist_sq) + { if (isect_type == ISECT_AABB_PLANE_CROSS_ANY) { bvhtree_nearest_projected_with_clipplane_test_dfs_recursive(data, node->children[i]); } @@ -2299,7 +2309,8 @@ static void bvhtree_nearest_projected_with_clipplane_test_dfs_recursive( if (isect_type != ISECT_AABB_PLANE_BEHIND_ANY && dist_squared_to_projected_aabb(&data->precalc, bb_min, bb_max, data->closest_axis) <= - data->nearest.dist_sq) { + data->nearest.dist_sq) + { if (isect_type == ISECT_AABB_PLANE_CROSS_ANY) { bvhtree_nearest_projected_with_clipplane_test_dfs_recursive(data, node->children[i]); } @@ -2357,7 +2368,8 @@ int BLI_bvhtree_find_nearest_projected(const BVHTree *tree, if (isect_type != 0 && dist_squared_to_projected_aabb(&data.precalc, bb_min, bb_max, data.closest_axis) <= - data.nearest.dist_sq) { + data.nearest.dist_sq) + { if (isect_type == 1) { bvhtree_nearest_projected_with_clipplane_test_dfs_recursive(&data, root); } @@ -2404,10 +2416,12 @@ static bool bvhtree_walk_dfs_recursive(BVHTree_WalkData *walk_data, const BVHNod /* First pick the closest node to recurse into */ if (walk_data->walk_order_cb( - (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) { + (const BVHTreeAxisRange *)node->bv, node->main_axis, walk_data->userdata)) + { for (int i = 0; i != node->node_num; i++) { if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv, - walk_data->userdata)) { + walk_data->userdata)) + { if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) { return false; } @@ -2417,7 +2431,8 @@ static bool bvhtree_walk_dfs_recursive(BVHTree_WalkData *walk_data, const BVHNod else { for (int i = node->node_num - 1; i >= 0; i--) { if (walk_data->walk_parent_cb((const BVHTreeAxisRange *)node->children[i]->bv, - walk_data->userdata)) { + walk_data->userdata)) + { if (!bvhtree_walk_dfs_recursive(walk_data, node->children[i])) { return false; } diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 99c29bb73d2..4b17d2b24fd 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -734,7 +734,8 @@ void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *ts_iter) (iter->curchunk != NULL) && (atomic_cas_ptr((void **)ts_iter->curchunk_threaded_shared, iter->curchunk, iter->curchunk->next) != iter->curchunk); - iter->curchunk = *ts_iter->curchunk_threaded_shared) { + iter->curchunk = *ts_iter->curchunk_threaded_shared) + { /* pass. */ } if (UNLIKELY(iter->curchunk == NULL)) { diff --git a/source/blender/blenlib/intern/BLI_mmap.c b/source/blender/blenlib/intern/BLI_mmap.c index aeb0dec5ebd..576f6e70e4d 100644 --- a/source/blender/blenlib/intern/BLI_mmap.c +++ b/source/blender/blenlib/intern/BLI_mmap.c @@ -189,11 +189,13 @@ bool BLI_mmap_read(BLI_mmap_file *file, void *dest, size_t offset, size_t length memcpy(dest, file->memory + offset, length); #else /* On Windows, we use exception handling to be notified of errors. */ - __try { + __try + { memcpy(dest, file->memory + offset, length); } __except (GetExceptionCode() == EXCEPTION_IN_PAGE_ERROR ? EXCEPTION_EXECUTE_HANDLER : - EXCEPTION_CONTINUE_SEARCH) { + EXCEPTION_CONTINUE_SEARCH) + { file->io_error = true; return false; } diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c index 611e9eb0df1..62aaa737493 100644 --- a/source/blender/blenlib/intern/array_store.c +++ b/source/blender/blenlib/intern/array_store.c @@ -1166,7 +1166,8 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info, if (!BLI_listbase_is_empty(&chunk_list_reference->chunk_refs)) { const BChunkRef *cref = chunk_list_reference->chunk_refs.last; while ((cref->prev != NULL) && (cref != cref_match_first) && - (cref->link->data_len <= data_len - i_prev)) { + (cref->link->data_len <= data_len - i_prev)) + { BChunk *chunk_test = cref->link; size_t offset = data_len - chunk_test->data_len; if (bchunk_data_compare(chunk_test, data, data_len, offset)) { @@ -1237,7 +1238,8 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info, } else if ((data_len - i_prev >= info->chunk_byte_size) && (chunk_list_reference->chunk_refs_len >= chunk_list_reference_skip_len) && - (chunk_list_reference->chunk_refs.first != NULL)) { + (chunk_list_reference->chunk_refs.first != NULL)) + { /* -------------------------------------------------------------------- * Non-Aligned Chunk De-Duplication. */ @@ -1304,7 +1306,8 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info, #endif while ((cref != chunk_list_reference_last) && - (chunk_list_reference_bytes_remaining >= info->accum_read_ahead_bytes)) { + (chunk_list_reference_bytes_remaining >= info->accum_read_ahead_bytes)) + { hash_key key = key_from_chunk_ref(info, cref diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c index a401059755d..766cf5c0346 100644 --- a/source/blender/blenlib/intern/array_utils.c +++ b/source/blender/blenlib/intern/array_utils.c @@ -30,7 +30,8 @@ void _bli_array_reverse(void *arr_v, uint arr_len, size_t arr_stride) char *buf = BLI_array_alloca(buf, arr_stride); for (i = 0, i_end = (arr_len - 1) * arr_stride_uint; i < arr_half_stride; - i += arr_stride_uint, i_end -= arr_stride_uint) { + i += arr_stride_uint, i_end -= arr_stride_uint) + { memcpy(buf, &arr[i], arr_stride); memcpy(&arr[i], &arr[i_end], arr_stride); memcpy(&arr[i_end], buf, arr_stride); @@ -97,7 +98,8 @@ uint _bli_array_deduplicate_ordered(void *arr, uint arr_len, size_t arr_stride) for (uint i = 0; i < arr_len; i++) { if ((i == j) || (memcmp(POINTER_OFFSET(arr, arr_stride_uint * i), POINTER_OFFSET(arr, arr_stride_uint * j), - arr_stride) == 0)) { + arr_stride) == 0)) + { continue; } j += 1; diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c index 514bb4378e3..5ded1863337 100644 --- a/source/blender/blenlib/intern/boxpack_2d.c +++ b/source/blender/blenlib/intern/boxpack_2d.c @@ -424,7 +424,8 @@ void BLI_box_pack_2d( if (/* Constrain boxes to positive X/Y values */ box_xmin_get(box) < 0.0f || box_ymin_get(box) < 0.0f || /* check for last intersected */ - (vert->isect_cache[j] && box_isect(box, vert->isect_cache[j]))) { + (vert->isect_cache[j] && box_isect(box, vert->isect_cache[j]))) + { /* Here we check that the last intersected * box will intersect with this one using * isect_cache that can store a pointer to a diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index b714865ce57..4deb8f3ac4e 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -1361,7 +1361,8 @@ void dc_tri(CDTArrangement *cdt, while (filtered_incircle(basel_sym->vert->co, basel->vert->co, lcand->next->vert->co, - lcand->rot->next->vert->co) > 0.0) { + lcand->rot->next->vert->co) > 0.0) + { if (dbg_level > 1) { std::cout << "incircle says to remove lcand\n"; std::cout << " lcand" << lcand << "\n"; @@ -1380,7 +1381,8 @@ void dc_tri(CDTArrangement *cdt, while (filtered_incircle(basel_sym->vert->co, basel->vert->co, rcand->next->vert->co, - sym(rcand)->next->next->vert->co) > 0.0) { + sym(rcand)->next->next->vert->co) > 0.0) + { if (dbg_level > 0) { std::cout << "incircle says to remove rcand\n"; std::cout << " rcand" << rcand << "\n"; @@ -1404,10 +1406,11 @@ void dc_tri(CDTArrangement *cdt, } /* The next cross edge to be connected is to either `lcand->next->vert` or `rcand->next->vert`; * if both are valid, choose the appropriate one using the #incircle test. */ - if (!valid_lcand || (valid_rcand && filtered_incircle(lcand->next->vert->co, - lcand->vert->co, - rcand->vert->co, - rcand->next->vert->co) > 0)) { + if (!valid_lcand || + (valid_rcand && + filtered_incircle( + lcand->next->vert->co, lcand->vert->co, rcand->vert->co, rcand->next->vert->co) > 0)) + { if (dbg_level > 0) { std::cout << "connecting rcand\n"; std::cout << " se1=basel_sym" << basel_sym << "\n"; @@ -1753,7 +1756,8 @@ void fill_crossdata_for_intersect(const FatCo &curco, } case isect_result>::LINE_LINE_COLINEAR: { if (distance_squared(va->co.approx, v2->co.approx) <= - distance_squared(vb->co.approx, v2->co.approx)) { + distance_squared(vb->co.approx, v2->co.approx)) + { fill_crossdata_for_through_vert(va, se_vcva, cd, cd_next); } else { @@ -1982,7 +1986,8 @@ void add_edge_constraint( for (j = i - 1; j > 0; --j) { cd_prev = &crossings[j]; if ((cd_prev->lambda == 0.0 && cd_prev->vert != v) || - (cd_prev->lambda != 0.0 && cd_prev->in->vert != v && cd_prev->in->next->vert != v)) { + (cd_prev->lambda != 0.0 && cd_prev->in->vert != v && cd_prev->in->next->vert != v)) + { break; } cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */ @@ -2262,7 +2267,8 @@ int add_face_constraints(CDT_state *cdt_state, int id = cdt_state->need_ids ? f : 0; add_face_ids(cdt_state, face_symedge0, id, fedge_start, fedge_end); if (cdt_state->need_ids || - ELEM(output_type, CDT_CONSTRAINTS_VALID_BMESH, CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) { + ELEM(output_type, CDT_CONSTRAINTS_VALID_BMESH, CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) + { add_face_ids(cdt_state, face_symedge0, f, fedge_start, fedge_end); } } @@ -2387,12 +2393,14 @@ template void remove_non_constraint_edges_leave_valid_bmesh(CDT_stat CDTFace *fleft = se->face; CDTFace *fright = sym(se)->face; if (fleft != cdt->outer_face && fright != cdt->outer_face && - (fleft->input_ids.size() > 0 || fright->input_ids.size() > 0)) { + (fleft->input_ids.size() > 0 || fright->input_ids.size() > 0)) + { /* Is there another #SymEdge with same left and right faces? * Or is there a vertex not part of e touching the same left and right faces? */ for (SymEdge *se2 = se->next; dissolve && se2 != se; se2 = se2->next) { if (sym(se2)->face == fright || - (se2->vert != se->next->vert && vert_touches_face(se2->vert, fright))) { + (se2->vert != se->next->vert && vert_touches_face(se2->vert, fright))) + { dissolve = false; } } diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c index 1cd23ea2ca0..91f6e3f69d5 100644 --- a/source/blender/blenlib/intern/dynlib.c +++ b/source/blender/blenlib/intern/dynlib.c @@ -66,7 +66,8 @@ char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib) MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), - NULL)) { + NULL)) + { return buf; } } diff --git a/source/blender/blenlib/intern/expr_pylike_eval.c b/source/blender/blenlib/intern/expr_pylike_eval.c index 1c32336fee0..cc603246943 100644 --- a/source/blender/blenlib/intern/expr_pylike_eval.c +++ b/source/blender/blenlib/intern/expr_pylike_eval.c @@ -600,7 +600,8 @@ static bool parse_add_func(ExprParseState *state, eOpCode code, int args, void * CHECK_ERROR(args == 3); if (jmp_gap >= 3 && prev_ops[-3].opcode == OPCODE_CONST && - prev_ops[-2].opcode == OPCODE_CONST && prev_ops[-1].opcode == OPCODE_CONST) { + prev_ops[-2].opcode == OPCODE_CONST && prev_ops[-1].opcode == OPCODE_CONST) + { TernaryOpFunc func = funcptr; /* volatile because some compilers overly aggressive optimize this call out. @@ -1013,7 +1014,8 @@ static bool parse_expr(ExprParseState *state) /* Parse condition. */ if (!parse_next_token(state) || !parse_or(state) || state->token != TOKEN_ELSE || - !parse_next_token(state)) { + !parse_next_token(state)) + { MEM_freeN(body); return false; } diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index b804eacfbe7..a6d494bf5a9 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -103,7 +103,8 @@ bool BLI_file_external_operation_execute(const char *filepath, FileExternalOpera #ifdef WIN32 char *opstring = windows_operation_string(operation); if (BLI_windows_external_operation_supported(filepath, opstring) && - BLI_windows_external_operation_execute(filepath, opstring)) { + BLI_windows_external_operation_execute(filepath, opstring)) + { return true; } return false; @@ -245,7 +246,7 @@ bool BLI_file_is_writable(const char *filepath) else { /* file doesn't exist -- check I can create it in parent directory */ char parent[FILE_MAX]; - BLI_split_dirfile(filepath, parent, NULL, sizeof(parent), 0); + BLI_path_split_dir_part(filepath, parent, sizeof(parent)); #ifdef WIN32 /* windows does not have X_OK */ writable = BLI_access(parent, W_OK) == 0; @@ -256,9 +257,9 @@ bool BLI_file_is_writable(const char *filepath) return writable; } -bool BLI_file_touch(const char *file) +bool BLI_file_touch(const char *filepath) { - FILE *f = BLI_fopen(file, "r+b"); + FILE *f = BLI_fopen(filepath, "r+b"); if (f != NULL) { int c = getc(f); @@ -266,7 +267,7 @@ bool BLI_file_touch(const char *file) if (c == EOF) { /* Empty file, reopen in truncate write mode... */ fclose(f); - f = BLI_fopen(file, "w+b"); + f = BLI_fopen(filepath, "w+b"); } else { /* Otherwise, rewrite first byte. */ @@ -275,7 +276,7 @@ bool BLI_file_touch(const char *file) } } else { - f = BLI_fopen(file, "wb"); + f = BLI_fopen(filepath, "wb"); } if (f) { fclose(f); @@ -284,6 +285,15 @@ bool BLI_file_touch(const char *file) return false; } +bool BLI_file_ensure_parent_dir_exists(const char *filepath) +{ + char di[FILE_MAX]; + BLI_path_split_dir_part(filepath, di, sizeof(di)); + + /* Make if the dir doesn't exist. */ + return BLI_dir_create_recursive(di); +} + #ifdef WIN32 static void callLocalErrorCallBack(const char *err) @@ -458,9 +468,9 @@ static bool delete_recursive(const char *dir) i = filelist_num = BLI_filelist_dir_contents(dir, &filelist); fl = filelist; while (i--) { - const char *file = BLI_path_basename(fl->path); + const char *filename = BLI_path_basename(fl->path); - if (FILENAME_IS_CURRPAR(file)) { + if (FILENAME_IS_CURRPAR(filename)) { /* Skip! */ } else if (S_ISDIR(fl->type)) { @@ -491,17 +501,17 @@ static bool delete_recursive(const char *dir) return err; } -int BLI_delete(const char *file, bool dir, bool recursive) +int BLI_delete(const char *path, bool dir, bool recursive) { int err; - BLI_assert(!BLI_path_is_rel(file)); + BLI_assert(!BLI_path_is_rel(path)); if (recursive) { - err = delete_recursive(file); + err = delete_recursive(path); } else { - err = delete_unique(file, dir); + err = delete_unique(path, dir); } return err; @@ -923,7 +933,8 @@ static int delete_soft(const char *file, const char **error_message) char *xdg_session_desktop = getenv("XDG_SESSION_DESKTOP"); if ((xdg_current_desktop != NULL && STREQ(xdg_current_desktop, "KDE")) || - (xdg_session_desktop != NULL && STREQ(xdg_session_desktop, "KDE"))) { + (xdg_session_desktop != NULL && STREQ(xdg_session_desktop, "KDE"))) + { args[0] = "kioclient5"; args[1] = "move"; args[2] = file; @@ -995,17 +1006,17 @@ int BLI_access(const char *filepath, int mode) return access(filepath, mode); } -int BLI_delete(const char *file, bool dir, bool recursive) +int BLI_delete(const char *path, bool dir, bool recursive) { - BLI_assert(!BLI_path_is_rel(file)); + BLI_assert(!BLI_path_is_rel(path)); if (recursive) { - return recursive_operation(file, NULL, NULL, delete_single_file, delete_callback_post); + return recursive_operation(path, NULL, NULL, delete_single_file, delete_callback_post); } if (dir) { - return rmdir(file); + return rmdir(path); } - return remove(file); + return remove(path); } int BLI_delete_soft(const char *file, const char **error_message) diff --git a/source/blender/blenlib/intern/filereader_zstd.c b/source/blender/blenlib/intern/filereader_zstd.c index 9ec865a4a06..17f3900cb1d 100644 --- a/source/blender/blenlib/intern/filereader_zstd.c +++ b/source/blender/blenlib/intern/filereader_zstd.c @@ -172,7 +172,8 @@ static const char *zstd_ensure_cache(ZstdReader *zstd, int frame) char *uncompressed_data = MEM_mallocN(uncompressed_size, __func__); char *compressed_data = MEM_mallocN(compressed_size, __func__); if (zstd->base->seek(zstd->base, zstd->seek.compressed_ofs[frame], SEEK_SET) < 0 || - zstd->base->read(zstd->base, compressed_data, compressed_size) < compressed_size) { + zstd->base->read(zstd->base, compressed_data, compressed_size) < compressed_size) + { MEM_freeN(compressed_data); MEM_freeN(uncompressed_data); return NULL; diff --git a/source/blender/blenlib/intern/implicit_sharing.cc b/source/blender/blenlib/intern/implicit_sharing.cc index 3625e7babae..a5943af9344 100644 --- a/source/blender/blenlib/intern/implicit_sharing.cc +++ b/source/blender/blenlib/intern/implicit_sharing.cc @@ -83,7 +83,8 @@ void *resize_trivial_array_impl(void *old_data, BLI_assert(old_size != 0); if ((*sharing_info)->is_mutable()) { if (auto *info = const_cast( - dynamic_cast(*sharing_info))) { + dynamic_cast(*sharing_info))) + { /* If the array was allocated with the MEM allocator, we can use realloc directly, which * could theoretically give better performance if the data can be reused in place. */ void *new_data = static_cast(MEM_reallocN(old_data, new_size)); diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h index 53a3ea90285..f43e32ced76 100644 --- a/source/blender/blenlib/intern/kdtree_impl.h +++ b/source/blender/blenlib/intern/kdtree_impl.h @@ -32,6 +32,7 @@ struct KDTree { KDTreeNode *nodes; uint nodes_len; uint root; + int max_node_index; #ifdef DEBUG bool is_balanced; /* ensure we call balance first */ uint nodes_len_capacity; /* max size of the tree */ @@ -90,6 +91,7 @@ KDTree *BLI_kdtree_nd_(new)(uint nodes_len_capacity) tree->nodes = MEM_mallocN(sizeof(KDTreeNode) * nodes_len_capacity, "KDTreeNode"); tree->nodes_len = 0; tree->root = KD_NODE_ROOT_IS_INIT; + tree->max_node_index = -1; #ifdef DEBUG tree->is_balanced = false; @@ -125,6 +127,7 @@ void BLI_kdtree_nd_(insert)(KDTree *tree, int index, const float co[KD_DIMS]) copy_vn_vn(node->co, co); node->index = index; node->d = 0; + tree->max_node_index = MAX2(tree->max_node_index, index); #ifdef DEBUG tree->is_balanced = false; @@ -796,12 +799,14 @@ finally: * Use when we want to loop over nodes ordered by index. * Requires indices to be aligned with nodes. */ -static uint *kdtree_order(const KDTree *tree) +static int *kdtree_order(const KDTree *tree) { const KDTreeNode *nodes = tree->nodes; - uint *order = MEM_mallocN(sizeof(uint) * tree->nodes_len, __func__); + const size_t bytes_num = sizeof(int) * (size_t)(tree->max_node_index + 1); + int *order = MEM_mallocN(bytes_num, __func__); + memset(order, -1, bytes_num); for (uint i = 0; i < tree->nodes_len; i++) { - order[nodes[i].index] = i; + order[nodes[i].index] = (int)i; } return order; } @@ -885,10 +890,13 @@ int BLI_kdtree_nd_(calc_duplicates_fast)(const KDTree *tree, }; if (use_index_order) { - uint *order = kdtree_order(tree); - for (uint i = 0; i < tree->nodes_len; i++) { - const uint node_index = order[i]; - const int index = (int)i; + int *order = kdtree_order(tree); + for (int i = 0; i < tree->max_node_index + 1; i++) { + const int node_index = order[i]; + if (node_index == -1) { + continue; + } + const int index = i; if (ELEM(duplicates[index], -1, index)) { p.search = index; copy_vn_vn(p.search_co, tree->nodes[node_index].co); diff --git a/source/blender/blenlib/intern/listbase.cc b/source/blender/blenlib/intern/listbase.cc index 3b549cf68c4..a72ed23d13b 100644 --- a/source/blender/blenlib/intern/listbase.cc +++ b/source/blender/blenlib/intern/listbase.cc @@ -511,8 +511,8 @@ int BLI_listbase_count_at_most(const ListBase *listbase, const int count_max) Link *link; int count = 0; - for (link = static_cast(listbase->first); link && count != count_max; - link = link->next) { + for (link = static_cast(listbase->first); link && count != count_max; link = link->next) + { count++; } @@ -754,7 +754,8 @@ void *BLI_listbase_string_or_index_find(const ListBase *listbase, int index_iter; for (link = static_cast(listbase->first), index_iter = 0; link; - link = link->next, index_iter++) { + link = link->next, index_iter++) + { if (string != nullptr && string[0] != '\0') { const char *string_iter = ((const char *)link) + string_offset; diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc index bb6136022c5..3445e44dd3f 100644 --- a/source/blender/blenlib/intern/math_boolean.cc +++ b/source/blender/blenlib/intern/math_boolean.cc @@ -890,7 +890,8 @@ static double orient3dadapt( if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0) && (adztail == 0.0) && (bdztail == 0.0) && - (cdztail == 0.0)) { + (cdztail == 0.0)) + { return det; } @@ -1418,7 +1419,8 @@ static double incircleadapt( Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail); Two_Diff_Tail(pc[1], pd[1], cdy, cdytail); if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && (adytail == 0.0) && - (bdytail == 0.0) && (cdytail == 0.0)) { + (bdytail == 0.0) && (cdytail == 0.0)) + { return det; } @@ -2321,7 +2323,8 @@ static double insphereadapt(const double *pa, Two_Diff_Tail(pd[2], pe[2], dez, deztail); if ((aextail == 0.0) && (aeytail == 0.0) && (aeztail == 0.0) && (bextail == 0.0) && (beytail == 0.0) && (beztail == 0.0) && (cextail == 0.0) && (ceytail == 0.0) && - (ceztail == 0.0) && (dextail == 0.0) && (deytail == 0.0) && (deztail == 0.0)) { + (ceztail == 0.0) && (dextail == 0.0) && (deytail == 0.0) && (deztail == 0.0)) + { return det; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index c21b07573e8..f6feffc6865 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1469,7 +1469,8 @@ bool isect_point_poly_v2(const float pt[2], if (((verts[i][1] > pt[1]) != (verts[j][1] > pt[1])) && (pt[0] < (verts[j][0] - verts[i][0]) * (pt[1] - verts[i][1]) / (verts[j][1] - verts[i][1]) + - verts[i][0])) { + verts[i][0])) + { isect = !isect; } } @@ -1488,7 +1489,8 @@ bool isect_point_poly_v2_int(const int pt[2], if (((verts[i][1] > pt[1]) != (verts[j][1] > pt[1])) && (pt[0] < (verts[j][0] - verts[i][0]) * (pt[1] - verts[i][1]) / (verts[j][1] - verts[i][1]) + - verts[i][0])) { + verts[i][0])) + { isect = !isect; } } @@ -1869,7 +1871,8 @@ bool isect_ray_tri_watertight_v3(const float ray_origin[3], #if 0 || (sign_T > *r_lambda * xor_signmask(det, sign_mask)) #endif - ) { + ) + { return false; } @@ -2259,7 +2262,8 @@ bool isect_tri_tri_v3_ex(const float tri_a[3][3], } if ((side[1][0] && side[1][1] && side[1][2]) && (side[1][0] < 0.0f) == (side[1][1] < 0.0f) && - (side[1][0] < 0.0f) == (side[1][2] < 0.0f)) { + (side[1][0] < 0.0f) == (side[1][2] < 0.0f)) + { /* All vertices of the 2nd triangle are positioned on the same side to the * plane defined by the 1st triangle. */ return false; @@ -2274,7 +2278,8 @@ bool isect_tri_tri_v3_ex(const float tri_a[3][3], side[0][2] = (float)(dot_v3db_v3fl(plane_b, tri_a[2]) + plane_b[3]); if ((side[0][0] && side[0][1] && side[0][2]) && (side[0][0] < 0.0f) == (side[0][1] < 0.0f) && - (side[0][0] < 0.0f) == (side[0][2] < 0.0f)) { + (side[0][0] < 0.0f) == (side[0][2] < 0.0f)) + { /* All vertices of the 1st triangle are positioned on the same side to the * plane defined by the 2nd triangle. */ return false; @@ -3666,7 +3671,8 @@ int barycentric_inside_triangle_v2(const float w[3]) return 1; } if (IN_RANGE_INCL(w[0], 0.0f, 1.0f) && IN_RANGE_INCL(w[1], 0.0f, 1.0f) && - IN_RANGE_INCL(w[2], 0.0f, 1.0f)) { + IN_RANGE_INCL(w[2], 0.0f, 1.0f)) + { return 2; } diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 1b1ae9a8a53..40e47f7dda1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1840,7 +1840,8 @@ bool is_uniform_scaled_m3(const float m[3][3]) l6 = len_squared_v3(t[2]); if (fabsf(l2 - l1) <= eps && fabsf(l3 - l1) <= eps && fabsf(l4 - l1) <= eps && - fabsf(l5 - l1) <= eps && fabsf(l6 - l1) <= eps) { + fabsf(l5 - l1) <= eps && fabsf(l6 - l1) <= eps) + { return true; } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 49e6b61fad5..835dfd8ec0f 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1405,7 +1405,8 @@ void mat3_normalized_to_eul(float eul[3], const float mat[3][3]) /* return best, which is just the one with lowest values it in */ if (fabsf(eul1[0]) + fabsf(eul1[1]) + fabsf(eul1[2]) > - fabsf(eul2[0]) + fabsf(eul2[1]) + fabsf(eul2[2])) { + fabsf(eul2[0]) + fabsf(eul2[1]) + fabsf(eul2[2])) + { copy_v3_v3(eul, eul2); } else { @@ -1964,7 +1965,8 @@ void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4 copy_m3_m4(mat3, mat); if (!is_orthonormal_m3(mat3) || (determinant_m4(mat) < 0.0f) || - len_squared_v3(dscale) > square_f(1e-4f)) { + len_squared_v3(dscale) > square_f(1e-4f)) + { /* Extract R and S. */ float tmp[4][4]; @@ -2361,7 +2363,8 @@ bool mat3_from_axis_conversion( } if ((_axis_signed(src_forward) == _axis_signed(src_up)) || - (_axis_signed(dst_forward) == _axis_signed(dst_up))) { + (_axis_signed(dst_forward) == _axis_signed(dst_up))) + { /* we could assert here! */ unit_m3(r_mat); return false; diff --git a/source/blender/blenlib/intern/math_vec.cc b/source/blender/blenlib/intern/math_vec.cc index fcc726316bb..18a3633e1a9 100644 --- a/source/blender/blenlib/intern/math_vec.cc +++ b/source/blender/blenlib/intern/math_vec.cc @@ -87,7 +87,8 @@ isect_result isect_seg_seg(const mpq2 &v1, const mpq2 &v2, const mpq2 &v3, /* Avoid dividing mu by div: it is expensive in multi-precision. */ mpq_class mudiv = ((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])); if (ans.lambda >= 0 && ans.lambda <= 1 && - ((div > 0 && mudiv >= 0 && mudiv <= div) || (div < 0 && mudiv <= 0 && mudiv >= div))) { + ((div > 0 && mudiv >= 0 && mudiv <= div) || (div < 0 && mudiv <= 0 && mudiv >= div))) + { if (ans.lambda == 0 || ans.lambda == 1 || mudiv == 0 || mudiv == div) { ans.kind = isect_result::LINE_LINE_EXACT; } diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc index 5c15975f393..387990c9c31 100644 --- a/source/blender/blenlib/intern/mesh_boolean.cc +++ b/source/blender/blenlib/intern/mesh_boolean.cc @@ -2554,7 +2554,8 @@ static void inside_shape_callback(void *userdata, std::cout << " fv2=(" << fv2[0] << "," << fv2[1] << "," << fv2[2] << ")\n"; } if (isect_ray_tri_epsilon_v3( - ray->origin, ray->direction, fv0, fv1, fv2, &dist, nullptr, FLT_EPSILON)) { + ray->origin, ray->direction, fv0, fv1, fv2, &dist, nullptr, FLT_EPSILON)) + { /* Count parity as +1 if ray is in the same direction as tri's normal, * and -1 if the directions are opposite. */ double3 o_db{double(ray->origin[0]), double(ray->origin[1]), double(ray->origin[2])}; @@ -3116,7 +3117,8 @@ static bool dissolve_leaves_valid_bmesh(FaceMergeState *fms, bool ok = true; /* Is there another edge, not me, in A's face, whose right face is B's left? */ for (int a_e_index = (a_edge_start + 1) % alen; ok && a_e_index != a_edge_start; - a_e_index = (a_e_index + 1) % alen) { + a_e_index = (a_e_index + 1) % alen) + { const MergeEdge &a_me_cur = fms->edge[mf_left.edge[a_e_index]]; if (a_me_cur.right_face == b_left_face) { ok = false; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 66b7dfd8827..f07cb901fa8 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -42,7 +42,7 @@ static int BLI_path_unc_prefix_len(const char *path); #ifdef WIN32 -static bool BLI_path_is_abs_win32(const char *name); +static bool BLI_path_is_abs_win32(const char *path); #endif /* WIN32 */ // #define DEBUG_STRSIZE @@ -267,7 +267,8 @@ void BLI_path_normalize(char *path) (start_temp = ((start <= &path[path_len - 3]) && STREQ(&path[path_len - 3], SEP_STR "..")) ? &path[path_len - 3] : - NULL))) { + NULL))) + { start = start_temp + 1; /* Skip the `/`. */ BLI_assert(start_base != start); @@ -364,7 +365,7 @@ void BLI_path_normalize_dir(char *dir, size_t dir_maxlen) BLI_path_slash_ensure(dir, dir_maxlen); } -bool BLI_filename_make_safe_ex(char *fname, bool allow_tokens) +bool BLI_path_make_safe_filename_ex(char *fname, bool allow_tokens) { #define INVALID_CHARS \ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \ @@ -440,14 +441,14 @@ bool BLI_filename_make_safe_ex(char *fname, bool allow_tokens) return changed; } -bool BLI_filename_make_safe(char *fname) +bool BLI_path_make_safe_filename(char *fname) { - return BLI_filename_make_safe_ex(fname, false); + return BLI_path_make_safe_filename_ex(fname, false); } bool BLI_path_make_safe(char *path) { - /* Simply apply #BLI_filename_make_safe() over each component of the path. + /* Simply apply #BLI_path_make_safe_filename() over each component of the path. * Luckily enough, same *safe* rules applies to file & directory names. */ char *curr_slash, *curr_path = path; bool changed = false; @@ -461,17 +462,18 @@ bool BLI_path_make_safe(char *path) #endif for (curr_slash = (char *)BLI_path_slash_find(curr_path); curr_slash; - curr_slash = (char *)BLI_path_slash_find(curr_path)) { + curr_slash = (char *)BLI_path_slash_find(curr_path)) + { const char backup = *curr_slash; *curr_slash = '\0'; - if (!skip_first && (*curr_path != '\0') && BLI_filename_make_safe(curr_path)) { + if (!skip_first && (*curr_path != '\0') && BLI_path_make_safe_filename(curr_path)) { changed = true; } skip_first = false; curr_path = curr_slash + 1; *curr_slash = backup; } - if (BLI_filename_make_safe(curr_path)) { + if (BLI_path_make_safe_filename(curr_path)) { changed = true; } @@ -483,9 +485,9 @@ bool BLI_path_is_rel(const char *path) return path[0] == '/' && path[1] == '/'; } -bool BLI_path_is_unc(const char *name) +bool BLI_path_is_unc(const char *path) { - return name[0] == '\\' && name[1] == '\\'; + return path[0] == '\\' && path[1] == '\\'; } /** @@ -518,9 +520,9 @@ static int BLI_path_unc_prefix_len(const char *path) * \note Not to be confused with the opposite of #BLI_path_is_rel which checks for the * Blender specific convention of using `//` prefix for blend-file relative paths. */ -static bool BLI_path_is_abs_win32(const char *name) +static bool BLI_path_is_abs_win32(const char *path) { - return (name[1] == ':' && ELEM(name[2], '\\', '/')) || BLI_path_is_unc(name); + return (path[1] == ':' && ELEM(path[2], '\\', '/')) || BLI_path_is_unc(path); } static wchar_t *next_slash(wchar_t *path) @@ -556,7 +558,8 @@ static void BLI_path_unc_to_short(wchar_t *unc) * - `\\?\C:\folder\...` to `C:\folder\...` */ if ((len > 3) && (unc[0] == L'\\') && (unc[1] == L'\\') && (unc[2] == L'?') && - ELEM(unc[3], L'\\', L'/')) { + ELEM(unc[3], L'\\', L'/')) + { if ((len > 5) && (unc[5] == L':')) { wcsncpy(tmp, unc + 4, len - 4); tmp[len - 4] = L'\0'; @@ -849,7 +852,7 @@ static void ensure_digits(char *path, int digits) } } -bool BLI_path_frame(char *path, int frame, int digits) +bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) { int ch_sta, ch_end; @@ -861,7 +864,7 @@ bool BLI_path_frame(char *path, int frame, int digits) char tmp[FILE_MAX]; BLI_snprintf( tmp, sizeof(tmp), "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end); - BLI_strncpy(path, tmp, FILE_MAX); + BLI_strncpy(path, tmp, path_maxncpy); return true; } return false; @@ -1137,7 +1140,7 @@ bool BLI_path_abs_from_cwd(char *path, const size_t maxlen) * environment variable (Windows-only) onto `name` in turn until such a file is found. * Returns success/failure. */ -bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen) +bool BLI_path_program_extensions_add_win32(char *program_name, const size_t maxlen) { bool retval = false; int type; @@ -1184,10 +1187,10 @@ bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen) } #endif /* WIN32 */ -bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *name) +bool BLI_path_program_search(char *program_filepath, const size_t maxlen, const char *program_name) { #ifdef DEBUG_STRSIZE - memset(fullname, 0xff, sizeof(*fullname) * maxlen); + memset(program_filepath, 0xff, sizeof(*program_filepath) * maxlen); #endif const char *path; bool retval = false; @@ -1214,15 +1217,16 @@ bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *na BLI_strncpy(filepath_test, path, sizeof(filepath_test)); } - BLI_path_append(filepath_test, maxlen, name); + BLI_path_append(filepath_test, maxlen, program_name); if ( #ifdef _WIN32 BLI_path_program_extensions_add_win32(filepath_test, maxlen) #else BLI_exists(filepath_test) #endif - ) { - BLI_strncpy(fullname, filepath_test, maxlen); + ) + { + BLI_strncpy(program_filepath, filepath_test, maxlen); retval = true; break; } @@ -1230,7 +1234,7 @@ bool BLI_path_program_search(char *fullname, const size_t maxlen, const char *na } if (retval == false) { - *fullname = '\0'; + *program_filepath = '\0'; } return retval; @@ -1288,15 +1292,6 @@ const char *BLI_getenv(const char *env) #endif } -bool BLI_make_existing_file(const char *name) -{ - char di[FILE_MAX]; - BLI_split_dir_part(name, di, sizeof(di)); - - /* Make if the dir doesn't exist. */ - return BLI_dir_create_recursive(di); -} - static bool path_extension_check_ex(const char *str, const size_t str_len, const char *ext, @@ -1475,39 +1470,51 @@ bool BLI_path_filename_ensure(char *filepath, size_t maxlen, const char *filenam return false; } -void BLI_split_dirfile( - const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen) +static size_t path_split_dir_file_offset(const char *string) +{ + const char *lslash_str = BLI_path_slash_rfind(string); + const size_t lslash = lslash_str ? (size_t)(lslash_str - string) + 1 : 0; + return lslash; +} + +void BLI_path_split_dir_file( + const char *string, char *dir, const size_t dirlen, char *file, const size_t filelen) { #ifdef DEBUG_STRSIZE memset(dir, 0xff, sizeof(*dir) * dirlen); memset(file, 0xff, sizeof(*file) * filelen); #endif - const char *lslash_str = BLI_path_slash_rfind(string); - const size_t lslash = lslash_str ? (size_t)(lslash_str - string) + 1 : 0; - - if (dir) { - if (lslash) { - /* +1 to include the slash and the last char. */ - BLI_strncpy(dir, string, MIN2(dirlen, lslash + 1)); - } - else { - dir[0] = '\0'; - } + const size_t lslash = path_split_dir_file_offset(string); + if (lslash) { /* +1 to include the slash and the last char. */ + BLI_strncpy(dir, string, MIN2(dirlen, lslash + 1)); } + else { + dir[0] = '\0'; + } + BLI_strncpy(file, string + lslash, filelen); +} - if (file) { - BLI_strncpy(file, string + lslash, filelen); +void BLI_path_split_dir_part(const char *string, char *dir, const size_t dirlen) +{ +#ifdef DEBUG_STRSIZE + memset(dir, 0xff, sizeof(*dir) * dirlen); +#endif + const size_t lslash = path_split_dir_file_offset(string); + if (lslash) { /* +1 to include the slash and the last char. */ + BLI_strncpy(dir, string, MIN2(dirlen, lslash + 1)); + } + else { + dir[0] = '\0'; } } -void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen) +void BLI_path_split_file_part(const char *string, char *file, const size_t filelen) { - BLI_split_dirfile(string, dir, NULL, dirlen, 0); -} - -void BLI_split_file_part(const char *string, char *file, const size_t filelen) -{ - BLI_split_dirfile(string, NULL, file, 0, filelen); +#ifdef DEBUG_STRSIZE + memset(file, 0xff, sizeof(*file) * filelen); +#endif + const size_t lslash = path_split_dir_file_offset(string); + BLI_strncpy(file, string + lslash, filelen); } const char *BLI_path_extension_or_end(const char *filepath) diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c index c5a877a9539..5962f33ff1f 100644 --- a/source/blender/blenlib/intern/polyfill_2d.c +++ b/source/blender/blenlib/intern/polyfill_2d.c @@ -329,7 +329,8 @@ static void kdtree2d_node_remove(struct KDTree2D *tree, uint32_t index) node->flag |= KDNODE_FLAG_REMOVED; while ((node->neg == KDNODE_UNSET) && (node->pos == KDNODE_UNSET) && - (node->parent != KDNODE_UNSET)) { + (node->parent != KDNODE_UNSET)) + { KDTreeNode2D *node_parent = &tree->nodes[node->parent]; BLI_assert((uint32_t)(node - tree->nodes) == node_index); @@ -364,10 +365,12 @@ static bool kdtree2d_isect_tri_recursive(const struct KDTree2D *tree, if ((node->flag & KDNODE_FLAG_REMOVED) == 0) { /* bounding box test first */ if ((co[0] >= bounds[0].min) && (co[0] <= bounds[0].max) && (co[1] >= bounds[1].min) && - (co[1] <= bounds[1].max)) { + (co[1] <= bounds[1].max)) + { if ((span_tri_v2_sign(tri_coords[0], tri_coords[1], co) != CONCAVE) && (span_tri_v2_sign(tri_coords[1], tri_coords[2], co) != CONCAVE) && - (span_tri_v2_sign(tri_coords[2], tri_coords[0], co) != CONCAVE)) { + (span_tri_v2_sign(tri_coords[2], tri_coords[0], co) != CONCAVE)) + { if (!ELEM(node->index, tri_index[0], tri_index[1], tri_index[2])) { return true; } @@ -738,7 +741,8 @@ static bool pf_ear_tip_check(PolyFill *pf, PolyIndex *pi_ear_tip, const eSign si * It's logical - the chance is low that points exist on the * same side as the ear we're clipping off. */ if ((span_tri_v2_sign(v3, v1, v) != CONCAVE) && (span_tri_v2_sign(v1, v2, v) != CONCAVE) && - (span_tri_v2_sign(v2, v3, v) != CONCAVE)) { + (span_tri_v2_sign(v2, v3, v) != CONCAVE)) + { return false; } diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 04e6ed4a7bb..d3a10211096 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -382,8 +382,8 @@ static void testvertexnearedge(ScanFillContext *sf_ctx) /* find the edge which has vertex eve, * NOTE: we _know_ this will crash if 'ed1' becomes NULL * but this will never happen. */ - for (ed1 = sf_ctx->filledgebase.first; !(ed1->v1 == eve || ed1->v2 == eve); - ed1 = ed1->next) { + for (ed1 = sf_ctx->filledgebase.first; !(ed1->v1 == eve || ed1->v2 == eve); ed1 = ed1->next) + { /* do nothing */ } @@ -911,7 +911,8 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n toggle++; for (eed = (toggle & 1) ? sf_ctx->filledgebase.first : sf_ctx->filledgebase.last; eed; - eed = (toggle & 1) ? eed->next : eed->prev) { + eed = (toggle & 1) ? eed->next : eed->prev) + { if (eed->v1->poly_nr == SF_POLY_UNSET && eed->v2->poly_nr == poly) { eed->v1->poly_nr = poly; eed->poly_nr = poly; @@ -983,7 +984,8 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n toggle++; for (eed = (toggle & 1) ? sf_ctx->filledgebase.first : sf_ctx->filledgebase.last; eed; - eed = eed_next) { + eed = eed_next) + { eed_next = (toggle & 1) ? eed->next : eed->prev; if (eed->v1->edge_count == 1) { eed->v2->edge_count--; diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c index 28b89a79fb0..15fa4420934 100644 --- a/source/blender/blenlib/intern/scanfill_utils.c +++ b/source/blender/blenlib/intern/scanfill_utils.c @@ -173,15 +173,18 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx, ScanFillEdge *eed_other; for (eed_other = eed->next; eed_other; - eed_other = (eed_other == pi->edge_last) ? NULL : eed_other->next) { + eed_other = (eed_other == pi->edge_last) ? NULL : eed_other->next) + { if (!ELEM(eed->v1, eed_other->v1, eed_other->v2) && - !ELEM(eed->v2, eed_other->v1, eed_other->v2) && (eed != eed_other)) { + !ELEM(eed->v2, eed_other->v1, eed_other->v2) && (eed != eed_other)) + { /* check isect */ float pt[2]; BLI_assert(eed != eed_other); if (isect_seg_seg_v2_point( - eed->v1->co, eed->v2->co, eed_other->v1->co, eed_other->v2->co, pt) == 1) { + eed->v1->co, eed->v2->co, eed_other->v1->co, eed_other->v2->co, pt) == 1) + { ScanFillIsect *isect; if (UNLIKELY(isect_hash == NULL)) { @@ -388,7 +391,8 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx, BLI_assert(eed->poly_nr == eed->v2->poly_nr); if ((poly_info[poly_nr].edge_last != NULL) && - (poly_info[poly_nr].edge_last->poly_nr != eed->poly_nr)) { + (poly_info[poly_nr].edge_last->poly_nr != eed->poly_nr)) + { poly_nr++; } diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c index 4da07ad9e4c..64e9f0183ed 100644 --- a/source/blender/blenlib/intern/smallhash.c +++ b/source/blender/blenlib/intern/smallhash.c @@ -111,7 +111,8 @@ BLI_INLINE SmallHashEntry *smallhash_lookup(const SmallHash *sh, const uintptr_t /* NOTE: there are always more buckets than entries, * so we know there will always be a free bucket if the key isn't found. */ for (e = &sh->buckets[h % sh->nbuckets]; e->val != SMHASH_CELL_FREE; - h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) { + h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) + { if (e->key == key) { /* should never happen because unused keys are zero'd */ BLI_assert(e->val != SMHASH_CELL_UNUSED); @@ -129,7 +130,8 @@ BLI_INLINE SmallHashEntry *smallhash_lookup_first_free(SmallHash *sh, const uint uint hoff = 1; for (e = &sh->buckets[h % sh->nbuckets]; smallhash_val_is_used(e->val); - h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) { + h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) + { /* pass */ } @@ -381,7 +383,8 @@ double BLI_smallhash_calc_quality(SmallHash *sh) uint hoff = 1; for (e = &sh->buckets[h % sh->nbuckets]; e != e_final; - h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) { + h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) + { count += 1; } diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index f796d6adca5..7b2f0d049bb 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -136,7 +136,7 @@ double BLI_dir_free_space(const char *dir) struct statfs disk; # endif - char name[FILE_MAXDIR], *slash; + char dirname[FILE_MAXDIR], *slash; int len = strlen(dir); if (len >= FILE_MAXDIR) { @@ -144,28 +144,28 @@ double BLI_dir_free_space(const char *dir) return -1; } - strcpy(name, dir); + strcpy(dirname, dir); if (len) { - slash = strrchr(name, '/'); + slash = strrchr(dirname, '/'); if (slash) { slash[1] = 0; } } else { - strcpy(name, "/"); + strcpy(dirname, "/"); } # if defined(USE_STATFS_STATVFS) - if (statvfs(name, &disk)) { + if (statvfs(dirname, &disk)) { return -1; } # elif defined(USE_STATFS_4ARGS) - if (statfs(name, &disk, sizeof(struct statfs), 0)) { + if (statfs(dirname, &disk, sizeof(struct statfs), 0)) { return -1; } # else - if (statfs(name, &disk)) { + if (statfs(dirname, &disk)) { return -1; } # endif @@ -268,7 +268,8 @@ eFileAttributes BLI_file_attributes(const char *path) ret |= FILE_ATTR_SPARSE_FILE; } if (attr & FILE_ATTRIBUTE_OFFLINE || attr & FILE_ATTRIBUTE_RECALL_ON_OPEN || - attr & FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) { + attr & FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) + { ret |= FILE_ATTR_OFFLINE; } if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index afb1a92c02a..1c492524b3f 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -138,6 +138,19 @@ size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) return srclen; } +/* -------------------------------------------------------------------- */ +/** \name String Append + * \{ */ + +char *BLI_strncat(char *__restrict dst, const char *__restrict src, const size_t maxncpy) +{ + size_t len = BLI_strnlen(dst, maxncpy); + if (len < maxncpy) { + BLI_strncpy(dst + len, src, maxncpy - len); + } + return dst; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 0f32db4a79e..d1db44e5884 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -415,7 +415,8 @@ char32_t BLI_str_utf32_char_to_upper(const char32_t wc) if ((wc <= U'z' && wc >= U'a') || (wc <= U'\xF6' && wc >= U'\xE0') || /* Correct but the first case is know, only check the second */ // (wc <= U'\xFE' && wc >= U'\xF8') - (wc >= U'\xF8')) { + (wc >= U'\xF8')) + { return wc - 32; } return wc; @@ -438,7 +439,8 @@ char32_t BLI_str_utf32_char_to_upper(const char32_t wc) /* There are only three remaining ranges that contain capitalization. */ if (!(wc <= U'\x0292' && wc >= U'\x00FF') && !(wc <= U'\x04F9' && wc >= U'\x03AC') && - !(wc <= U'\x1FE1' && wc >= U'\x1E01')) { + !(wc <= U'\x1FE1' && wc >= U'\x1E01')) + { return wc; } @@ -543,7 +545,8 @@ char32_t BLI_str_utf32_char_to_lower(const char32_t wc) /* There are only three remaining ranges that contain capitalization. */ if (!(wc <= U'\x0216' && wc >= U'\x00D8') && !(wc <= U'\x04F8' && wc >= U'\x0386') && - !(wc <= U'\x1FE9' && wc >= U'\x1E00')) { + !(wc <= U'\x1FE9' && wc >= U'\x1E00')) + { return wc; } @@ -962,7 +965,8 @@ size_t BLI_str_partition_ex_utf8(const char *str, for (char *sep = (char *)(from_right ? BLI_str_find_prev_char_utf8(end, str) : str); from_right ? (sep > str) : ((sep < end) && (*sep != '\0')); sep = (char *)(from_right ? (str != sep ? BLI_str_find_prev_char_utf8(sep, str) : NULL) : - str + index)) { + str + index)) + { size_t index_ofs = 0; const uint c = BLI_str_utf8_as_unicode_step_or_error(sep, (size_t)(end - sep), &index_ofs); if (UNLIKELY(c == BLI_UTF8_ERR)) { diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c index bbcc7fb1bf8..a02e83fcb92 100644 --- a/source/blender/blenlib/intern/string_utils.c +++ b/source/blender/blenlib/intern/string_utils.c @@ -22,23 +22,26 @@ # pragma GCC diagnostic error "-Wsign-conversion" #endif -size_t BLI_split_name_num(char *left, int *nr, const char *name, const char delim) +size_t BLI_string_split_name_number(const char *name, + const char delim, + char *r_name_left, + int *r_number) { const size_t name_len = strlen(name); - *nr = 0; - memcpy(left, name, (name_len + 1) * sizeof(char)); + *r_number = 0; + memcpy(r_name_left, name, (name_len + 1) * sizeof(char)); /* name doesn't end with a delimiter "foo." */ if ((name_len > 1 && name[name_len - 1] == delim) == 0) { size_t a = name_len; while (a--) { if (name[a] == delim) { - left[a] = '\0'; /* truncate left part here */ - *nr = atol(name + a + 1); + r_name_left[a] = '\0'; /* truncate left part here */ + *r_number = atol(name + a + 1); /* casting down to an int, can overflow for large numbers */ - if (*nr < 0) { - *nr = 0; + if (*r_number < 0) { + *r_number = 0; } return a; } @@ -72,9 +75,12 @@ static bool is_char_sep(const char c) return ELEM(c, '.', ' ', '-', '_'); } -void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, const size_t str_len) +void BLI_string_split_suffix(const char *string, + const size_t string_maxlen, + char *r_body, + char *r_suf) { - size_t len = BLI_strnlen(string, str_len); + size_t len = BLI_strnlen(string, string_maxlen); size_t i; r_body[0] = r_suf[0] = '\0'; @@ -90,9 +96,12 @@ void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, cons memcpy(r_body, string, len + 1); } -void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, const size_t str_len) +void BLI_string_split_prefix(const char *string, + const size_t string_maxlen, + char *r_pre, + char *r_body) { - size_t len = BLI_strnlen(string, str_len); + size_t len = BLI_strnlen(string, string_maxlen); size_t i; r_body[0] = r_pre[0] = '\0'; @@ -246,7 +255,7 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check, char *tempname = alloca(name_len); char *left = alloca(name_len); int number; - size_t len = BLI_split_name_num(left, &number, name, delim); + size_t len = BLI_string_split_name_number(name, delim, left, &number); do { /* add 1 to account for \0 */ const size_t numlen = BLI_snprintf(numstr, sizeof(numstr), "%c%03d", delim, ++number) + 1; @@ -321,7 +330,7 @@ bool BLI_uniquename( BLI_assert(name_len > 1); /* See if we are given an empty string */ - if (ELEM(NULL, vlink, defname)) { + if (ELEM(NULL, vlink)) { return false; } diff --git a/source/blender/blenlib/intern/system_win32.c b/source/blender/blenlib/intern/system_win32.c index f5c678abbc7..5a08f77d20a 100644 --- a/source/blender/blenlib/intern/system_win32.c +++ b/source/blender/blenlib/intern/system_win32.c @@ -158,7 +158,8 @@ static bool BLI_windows_system_backtrace_run_trace(FILE *fp, HANDLE hThread, PCO NULL, SymFunctionTableAccess64, SymGetModuleBase64, - 0)) { + 0)) + { if (frame.AddrPC.Offset) { char module[MAX_PATH]; @@ -170,7 +171,8 @@ static bool BLI_windows_system_backtrace_run_trace(FILE *fp, HANDLE hThread, PCO lineinfo.SizeOfStruct = sizeof(lineinfo); DWORD displacement = 0; if (SymGetLineFromAddr( - GetCurrentProcess(), (DWORD64)(frame.AddrPC.Offset), &displacement, &lineinfo)) { + GetCurrentProcess(), (DWORD64)(frame.AddrPC.Offset), &displacement, &lineinfo)) + { fprintf(fp, " %s:%d", lineinfo.FileName, lineinfo.LineNumber); } fprintf(fp, "\n"); diff --git a/source/blender/blenlib/intern/voronoi_2d.c b/source/blender/blenlib/intern/voronoi_2d.c index 489043a76f5..2ed8f02dfbb 100644 --- a/source/blender/blenlib/intern/voronoi_2d.c +++ b/source/blender/blenlib/intern/voronoi_2d.c @@ -578,13 +578,15 @@ static int voronoi_getNextSideCoord( float co[2], cur_distance; if (fabsf(edge->start[other_dim] - coord[other_dim]) < VORONOI_EPS && - len_squared_v2v2(coord, edge->start) > VORONOI_EPS) { + len_squared_v2v2(coord, edge->start) > VORONOI_EPS) + { copy_v2_v2(co, edge->start); ok = true; } if (fabsf(edge->end[other_dim] - coord[other_dim]) < VORONOI_EPS && - len_squared_v2v2(coord, edge->end) > VORONOI_EPS) { + len_squared_v2v2(coord, edge->end) > VORONOI_EPS) + { copy_v2_v2(co, edge->end); ok = true; } diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index d424b2c20c4..a2d63861b77 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -33,7 +33,7 @@ int BLI_windows_get_executable_dir(char *str) int a; /* Change to utf support. */ GetModuleFileName(NULL, str, FILE_MAX); - BLI_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */ + BLI_path_split_dir_part(str, dir, sizeof(dir)); /* shouldn't be relative */ a = strlen(dir); if (dir[a - 1] == '\\') { dir[a - 1] = 0; diff --git a/source/blender/blenlib/intern/winstuff_dir.c b/source/blender/blenlib/intern/winstuff_dir.c index d5bc84c4c4f..74f1e1f78a0 100644 --- a/source/blender/blenlib/intern/winstuff_dir.c +++ b/source/blender/blenlib/intern/winstuff_dir.c @@ -54,7 +54,8 @@ DIR *opendir(const char *path) DIR *newd = NULL; if ((GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) && - ((path_len = strlen(path)) < (sizeof(newd->path) - PATH_SUFFIX_LEN))) { + ((path_len = strlen(path)) < (sizeof(newd->path) - PATH_SUFFIX_LEN))) + { newd = MEM_mallocN(sizeof(DIR), "opendir"); newd->handle = INVALID_HANDLE_VALUE; memcpy(newd->path, path, path_len); diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc index 5fbb063463b..0717e88a19e 100644 --- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc @@ -165,7 +165,8 @@ int get_output_edge_index(const CDT_result &out, int out_index_1, int out_ind int ne = int(out.edge.size()); for (int i = 0; i < ne; ++i) { if ((out.edge[i].first == out_index_1 && out.edge[i].second == out_index_2) || - (out.edge[i].first == out_index_2 && out.edge[i].second == out_index_1)) { + (out.edge[i].first == out_index_2 && out.edge[i].second == out_index_1)) + { return i; } } diff --git a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc index 0c2b4ee52cc..a0af053758d 100644 --- a/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc +++ b/source/blender/blenlib/tests/BLI_linklist_lockfree_test.cc @@ -46,7 +46,8 @@ TEST(LockfreeLinkList, InsertMultiple) /* Check rest of the nodes. */ int node_index = 0; for (LockfreeLinkNode *node = BLI_linklist_lockfree_begin(&list); node != nullptr; - node = node->next, ++node_index) { + node = node->next, ++node_index) + { EXPECT_EQ(node, &nodes[node_index]); if (node_index != nodes_num - 1) { EXPECT_EQ(node->next, &nodes[node_index + 1]); @@ -93,7 +94,8 @@ TEST(LockfreeLinkList, InsertMultipleConcurrent) bool *visited_nodes = (bool *)MEM_callocN(sizeof(bool) * nodes_num, "visited nodes"); /* First, we make sure that none of the nodes are added twice. */ for (LockfreeLinkNode *node_v = BLI_linklist_lockfree_begin(&list); node_v != nullptr; - node_v = node_v->next) { + node_v = node_v->next) + { IndexedNode *node = (IndexedNode *)node_v; EXPECT_GE(node->index, 0); EXPECT_LT(node->index, nodes_num); diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc index afe70c85200..6f879c62e6b 100644 --- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc +++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc @@ -298,7 +298,8 @@ TEST(mesh_intersect, TriTri) EXPECT_TRUE(v0 != nullptr && v1 != nullptr && v2 != nullptr); EXPECT_TRUE(v3 != nullptr && v4 != nullptr && v5 != nullptr); if (v0 != nullptr && v1 != nullptr && v2 != nullptr && v3 != nullptr && v4 != nullptr && - v5 != nullptr) { + v5 != nullptr) + { EXPECT_EQ(v0->orig, 0); EXPECT_EQ(v1->orig, 1); const Face *f0 = find_tri_with_verts(out, v4, v1, v5); @@ -369,7 +370,8 @@ TEST(mesh_intersect, TriTriReversed) EXPECT_TRUE(v0 != nullptr && v1 != nullptr && v2 != nullptr); EXPECT_TRUE(v3 != nullptr && v4 != nullptr && v5 != nullptr); if (v0 != nullptr && v1 != nullptr && v2 != nullptr && v3 != nullptr && v4 != nullptr && - v5 != nullptr) { + v5 != nullptr) + { EXPECT_EQ(v0->orig, 0); EXPECT_EQ(v1->orig, 1); const Face *f0 = find_tri_with_verts(out, v4, v5, v1); diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc index 616105d5adf..81b9628d592 100644 --- a/source/blender/blenlib/tests/BLI_path_util_test.cc +++ b/source/blender/blenlib/tests/BLI_path_util_test.cc @@ -570,42 +570,42 @@ TEST(path_util, Frame) { char path[FILE_MAX] = ""; - ret = BLI_path_frame(path, 123, 1); + ret = BLI_path_frame(path, sizeof(path), 123, 1); EXPECT_TRUE(ret); EXPECT_STREQ(path, "123"); } { char path[FILE_MAX] = ""; - ret = BLI_path_frame(path, 123, 12); + ret = BLI_path_frame(path, sizeof(path), 123, 12); EXPECT_TRUE(ret); EXPECT_STREQ(path, "000000000123"); } { char path[FILE_MAX] = "test_"; - ret = BLI_path_frame(path, 123, 1); + ret = BLI_path_frame(path, sizeof(path), 123, 1); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_123"); } { char path[FILE_MAX] = "test_"; - ret = BLI_path_frame(path, 1, 12); + ret = BLI_path_frame(path, sizeof(path), 1, 12); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_000000000001"); } { char path[FILE_MAX] = "test_############"; - ret = BLI_path_frame(path, 1, 0); + ret = BLI_path_frame(path, sizeof(path), 1, 0); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_000000000001"); } { char path[FILE_MAX] = "test_#_#_middle"; - ret = BLI_path_frame(path, 123, 0); + ret = BLI_path_frame(path, sizeof(path), 123, 0); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_#_123_middle"); } @@ -613,14 +613,14 @@ TEST(path_util, Frame) /* intentionally fail */ { char path[FILE_MAX] = ""; - ret = BLI_path_frame(path, 123, 0); + ret = BLI_path_frame(path, sizeof(path), 123, 0); EXPECT_FALSE(ret); EXPECT_STREQ(path, ""); } { char path[FILE_MAX] = "test_middle"; - ret = BLI_path_frame(path, 123, 0); + ret = BLI_path_frame(path, sizeof(path), 123, 0); EXPECT_FALSE(ret); EXPECT_STREQ(path, "test_middle"); } @@ -628,13 +628,13 @@ TEST(path_util, Frame) /* negative frame numbers */ { char path[FILE_MAX] = "test_####"; - ret = BLI_path_frame(path, -1, 4); + ret = BLI_path_frame(path, sizeof(path), -1, 4); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_-0001"); } { char path[FILE_MAX] = "test_####"; - ret = BLI_path_frame(path, -100, 4); + ret = BLI_path_frame(path, sizeof(path), -100, 4); EXPECT_TRUE(ret); EXPECT_STREQ(path, "test_-0100"); } @@ -643,7 +643,7 @@ TEST(path_util, Frame) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Tests for: #BLI_split_dirfile +/** \name Tests for: #BLI_path_split_dir_file * \{ */ TEST(path_util, SplitDirfile) @@ -651,7 +651,7 @@ TEST(path_util, SplitDirfile) { const char *path = ""; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, ""); EXPECT_STREQ(file, ""); } @@ -659,7 +659,7 @@ TEST(path_util, SplitDirfile) { const char *path = "/"; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, "/"); EXPECT_STREQ(file, ""); } @@ -667,7 +667,7 @@ TEST(path_util, SplitDirfile) { const char *path = "fileonly"; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, ""); EXPECT_STREQ(file, "fileonly"); } @@ -675,7 +675,7 @@ TEST(path_util, SplitDirfile) { const char *path = "dironly/"; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, "dironly/"); EXPECT_STREQ(file, ""); } @@ -683,7 +683,7 @@ TEST(path_util, SplitDirfile) { const char *path = "/a/b"; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, "/a/"); EXPECT_STREQ(file, "b"); } @@ -691,11 +691,11 @@ TEST(path_util, SplitDirfile) { const char *path = "/dirtoobig/filetoobig"; char dir[5], file[5]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); EXPECT_STREQ(dir, "/dir"); EXPECT_STREQ(file, "file"); - BLI_split_dirfile(path, dir, file, 1, 1); + BLI_path_split_dir_file(path, dir, 1, file, 1); EXPECT_STREQ(dir, ""); EXPECT_STREQ(file, ""); } diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc index 547300a098e..1f87f2229fe 100644 --- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc @@ -118,7 +118,8 @@ static void test_polyfill_topology(const float /*poly*/[][2], } for (ehi = BLI_edgehashIterator_new(edgehash), i = 0; BLI_edgehashIterator_isDone(ehi) == false; - BLI_edgehashIterator_step(ehi), i++) { + BLI_edgehashIterator_step(ehi), i++) + { void **p = BLI_edgehashIterator_getValue_p(ehi); EXPECT_TRUE(ELEM(intptr_t(*p), 1, 2)); } diff --git a/source/blender/blenlib/tests/BLI_task_test.cc b/source/blender/blenlib/tests/BLI_task_test.cc index b7ee6962aec..385d3d912b5 100644 --- a/source/blender/blenlib/tests/BLI_task_test.cc +++ b/source/blender/blenlib/tests/BLI_task_test.cc @@ -271,7 +271,8 @@ TEST(task, ListBaseIter) EXPECT_EQ(items_num, 0); LinkData *item; for (i = 0, item = (LinkData *)list.first; i < ITEMS_NUM && item != nullptr; - i++, item = item->next) { + i++, item = item->next) + { EXPECT_EQ(POINTER_AS_INT(item->data), i); } EXPECT_EQ(ITEMS_NUM, i); diff --git a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc index 68fdf4031ab..5d6ef85874c 100644 --- a/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc +++ b/source/blender/blenlib/tests/performance/BLI_task_performance_test.cc @@ -120,7 +120,8 @@ static void task_listbase_test_do(ListBase *list, LinkData *item; int j; for (j = 0, item = (LinkData *)list->first; j < items_num && item != nullptr; - j++, item = item->next) { + j++, item = item->next) + { EXPECT_EQ(POINTER_AS_INT(item->data), j); item->data = POINTER_FROM_INT(0); } diff --git a/source/blender/blenloader/intern/blend_validate.cc b/source/blender/blenloader/intern/blend_validate.cc index 7ac0a4fe1af..b8ab1dd2c4c 100644 --- a/source/blender/blenloader/intern/blend_validate.cc +++ b/source/blender/blenloader/intern/blend_validate.cc @@ -46,7 +46,8 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) int i = set_listbasepointers(bmain, lbarray); while (i--) { for (ID *id = static_cast(lbarray[i]->first); id != nullptr; - id = static_cast(id->next)) { + id = static_cast(id->next)) + { if (ID_IS_LINKED(id)) { is_valid = false; BKE_reportf(reports, diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc index d5b810f6a98..4de3874b3e9 100644 --- a/source/blender/blenloader/intern/readblenentry.cc +++ b/source/blender/blenloader/intern/readblenentry.cc @@ -191,7 +191,8 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, bool has_preview = false; /* See if we can find a preview in the data of this ID. */ for (BHead *data_bhead = blo_bhead_next(fd, id_bhead); data_bhead->code == BLO_CODE_DATA; - data_bhead = blo_bhead_next(fd, data_bhead)) { + data_bhead = blo_bhead_next(fd, data_bhead)) + { if (data_bhead->SDNAnr == sdna_nr_preview_image) { has_preview = true; break; @@ -229,7 +230,8 @@ static BHead *blo_blendhandle_read_preview_rects(FileData *fd, { for (int preview_index = 0; preview_index < NUM_ICON_SIZES; preview_index++) { if (preview_from_file->rect[preview_index] && preview_from_file->w[preview_index] && - preview_from_file->h[preview_index]) { + preview_from_file->h[preview_index]) + { bhead = blo_bhead_next(fd, bhead); BLI_assert((preview_from_file->w[preview_index] * preview_from_file->h[preview_index] * sizeof(uint)) == bhead->len); diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 87446026c44..040efa2c214 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -366,7 +366,8 @@ static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint li if (id->lib) { if ((uint(id->lib->temp_index) < lib_main_array_len) && /* this check should never fail, just in case 'id->lib' is a dangling pointer. */ - (lib_main_array[id->lib->temp_index]->curlib == id->lib)) { + (lib_main_array[id->lib->temp_index]->curlib == id->lib)) + { Main *mainvar = lib_main_array[id->lib->temp_index]; ListBase *lb_dst = which_libbase(mainvar, GS(id->name)); BLI_remlink(lb_src, id); @@ -401,7 +402,8 @@ void blo_split_main(ListBase *mainlist, Main *main) int i = 0; for (Library *lib = static_cast(main->libraries.first); lib; - lib = static_cast(lib->id.next), i++) { + lib = static_cast(lib->id.next), i++) + { Main *libmain = BKE_main_new(); libmain->curlib = lib; libmain->versionfile = lib->versionfile; @@ -513,20 +515,20 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab ListBase *mainlist = fd->mainlist; Main *m; Library *lib; - char name1[FILE_MAX]; + char filepath_abs[FILE_MAX]; - BLI_strncpy(name1, filepath, sizeof(name1)); - BLI_path_abs(name1, relabase); - BLI_path_normalize(name1); + BLI_strncpy(filepath_abs, filepath, sizeof(filepath_abs)); + BLI_path_abs(filepath_abs, relabase); + BLI_path_normalize(filepath_abs); // printf("blo_find_main: relabase %s\n", relabase); // printf("blo_find_main: original in %s\n", filepath); - // printf("blo_find_main: converted to %s\n", name1); + // printf("blo_find_main: converted to %s\n", filepath_abs); for (m = static_cast
(mainlist->first); m; m = m->next) { const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->filepath; - if (BLI_path_cmp(name1, libname) == 0) { + if (BLI_path_cmp(filepath_abs, libname) == 0) { if (G.debug & G_DEBUG) { CLOG_INFO(&LOG, 3, "Found library %s", libname); } @@ -549,7 +551,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab id_us_ensure_real(&lib->id); BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); - BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs)); + BLI_strncpy(lib->filepath_abs, filepath_abs, sizeof(lib->filepath_abs)); m->curlib = lib; @@ -926,7 +928,8 @@ static void decode_blender_header(FileData *fd) if (readsize == sizeof(header) && STREQLEN(header, "BLENDER", 7) && ELEM(header[7], '_', '-') && ELEM(header[8], 'v', 'V') && - (isdigit(header[9]) && isdigit(header[10]) && isdigit(header[11]))) { + (isdigit(header[9]) && isdigit(header[10]) && isdigit(header[11]))) + { fd->flags |= FD_FLAGS_FILE_OK; /* what size are pointers in the file ? */ @@ -2294,8 +2297,8 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View /* Local-view can become invalid during undo/redo steps, * so we exit it when no could be found. */ - for (base = static_cast(view_layer->object_bases.first); base; - base = base->next) { + for (base = static_cast(view_layer->object_bases.first); base; base = base->next) + { if (base->local_view_bits & v3d->local_view_uuid) { break; } @@ -3583,7 +3586,8 @@ static void lib_link_all(FileData *fd, Main *bmain) } if ((fd->flags & FD_FLAGS_IS_MEMFILE) && do_partial_undo && - (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) != 0) { + (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) != 0) + { /* This ID has been re-used from 'old' bmain. Since it was therefore unchanged across * current undo step, and old IDs re-use their old memory address, we do not need to liblink * it at all. */ diff --git a/source/blender/blenloader/intern/undofile.cc b/source/blender/blenloader/intern/undofile.cc index 43643f25eb2..ad109117fd5 100644 --- a/source/blender/blenloader/intern/undofile.cc +++ b/source/blender/blenloader/intern/undofile.cc @@ -60,7 +60,8 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) /* First, detect all memchunks in second memfile that are not owned by it. */ for (MemFileChunk *sc = static_cast(second->chunks.first); sc != nullptr; - sc = static_cast(sc->next)) { + sc = static_cast(sc->next)) + { if (sc->is_identical) { BLI_ghash_insert(buffer_to_second_memchunk, (void *)sc->buf, sc); } @@ -69,7 +70,8 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) /* Now, check all chunks from first memfile (the one we are removing), and if a memchunk owned by * it is also used by the second memfile, transfer the ownership. */ for (MemFileChunk *fc = static_cast(first->chunks.first); fc != nullptr; - fc = static_cast(fc->next)) { + fc = static_cast(fc->next)) + { if (!fc->is_identical) { MemFileChunk *sc = static_cast( BLI_ghash_lookup(buffer_to_second_memchunk, fc->buf)); @@ -121,7 +123,8 @@ void BLO_memfile_write_init(MemFileWriteData *mem_data, void **entry; if (!BLI_ghash_ensure_p(mem_data->id_session_uuid_mapping, POINTER_FROM_UINT(current_session_uuid), - &entry)) { + &entry)) + { *entry = mem_chunk; } else { @@ -231,7 +234,8 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath) } for (chunk = static_cast(memfile->chunks.first); chunk; - chunk = static_cast(chunk->next)) { + chunk = static_cast(chunk->next)) + { #ifdef _WIN32 if (size_t(write(file, chunk->buf, uint(chunk->size))) != chunk->size) #else diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index d05de03f4bb..c94022153a7 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -908,7 +908,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* Add default gravity to scenes */ for (sce = bmain->scenes.first; sce; sce = sce->id.next) { if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && - is_zero_v3(sce->physics_settings.gravity)) { + is_zero_v3(sce->physics_settings.gravity)) + { sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY; @@ -1406,7 +1407,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* initialize to sane default so toggling on border shows something */ for (sce = bmain->scenes.first; sce; sce = sce->id.next) { if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && sce->r.border.xmax == 0.0f && - sce->r.border.ymax == 0.0f) { + sce->r.border.ymax == 0.0f) + { sce->r.border.xmin = 0.0f; sce->r.border.ymin = 0.0f; sce->r.border.xmax = 1.0f; diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 06f3628cf21..1a3cc7570f3 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -271,7 +271,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo char basepath[FILE_MAXDIR]; /* split off filename from the old path, to be used as socket sub-path */ - BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename)); + BLI_path_split_dir_file( + old_data->name, basepath, sizeof(basepath), filename, sizeof(filename)); BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path)); nimf->format = old_data->im_format; @@ -455,7 +456,8 @@ static void do_versions_affine_tracker_track(MovieTrackingTrack *track) MovieTrackingMarker *marker = &track->markers[i]; if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) && - is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3])) { + is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3])) + { marker->pattern_corners[0][0] = track->pat_min_legacy[0]; marker->pattern_corners[0][1] = track->pat_min_legacy[1]; @@ -1623,7 +1625,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) MovieTrackingObject *tracking_object; for (tracking_object = tracking->objects.first; tracking_object; - tracking_object = tracking_object->next) { + tracking_object = tracking_object->next) + { if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) { tracking_object->keyframe1 = tracking->settings.keyframe1_legacy; tracking_object->keyframe2 = tracking->settings.keyframe2_legacy; @@ -1684,7 +1687,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f && - v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f) { + v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f) + { v3d->render_border.xmax = 1.0f; v3d->render_border.ymax = 1.0f; } @@ -2045,7 +2049,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (ELEM(srl->freestyleConfig.raycasting_algorithm, FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE, - FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL)) { + FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL)) + { srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */ srl->freestyleConfig.flags |= FREESTYLE_CULLING; } @@ -2328,11 +2333,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) if (sl->spacetype == SPACE_OUTLINER) { SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - if (!ELEM(space_outliner->outlinevis, - SO_SCENES, - SO_LIBRARIES, - SO_SEQUENCE, - SO_DATA_API)) { + if (!ELEM( + space_outliner->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) + { space_outliner->outlinevis = SO_SCENES; } } @@ -2453,7 +2456,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) for (clip = bmain->movieclips.first; clip; clip = clip->id.next) { MovieTrackingPlaneTrack *plane_track; for (plane_track = clip->tracking.plane_tracks_legacy.first; plane_track; - plane_track = plane_track->next) { + plane_track = plane_track->next) + { plane_track->image_opacity = 1.0f; } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 0b93f193bff..c915c36ed40 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -320,7 +320,8 @@ static void do_versions_compositor_render_passes_storage(bNode *node) int pass_index = 0; const char *sockname; for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; - sock = sock->next, pass_index++) { + sock = sock->next, pass_index++) + { if (sock->storage == NULL) { NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); sock->storage = sockdata; @@ -690,7 +691,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) Brush *br; for (br = bmain->brushes.first; br; br = br->id.next) { if ((br->ob_mode & OB_MODE_SCULPT) && - ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK)) { + ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK)) + { br->alpha = 1.0f; } } @@ -1402,8 +1404,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find( - fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) { + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) + { MovieClip *clip; for (clip = bmain->movieclips.first; clip != NULL; clip = clip->id.next) { if (clip->tracking.stabilization.rot_track_legacy) { @@ -1539,8 +1541,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (MaskLayer *, mlayer, &mask->masklayers) { LISTBASE_FOREACH (MaskSpline *, mspline, &mlayer->splines) { int i = 0; - for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; - mspoint++, i++) { + for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) + { if (mspoint->parent.id_type == 0) { BKE_mask_parent_init(&mspoint->parent); } @@ -1685,7 +1687,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!DNA_struct_elem_find( - fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) { + fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) + { for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_ParticleInstance) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index be03b32850e..335cf087517 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -568,7 +568,8 @@ static void do_version_collection_propagate_lib_to_children(Collection *collecti { if (ID_IS_LINKED(collection)) { for (CollectionChild *collection_child = collection->children.first; collection_child != NULL; - collection_child = collection_child->next) { + collection_child = collection_child->next) + { if (!ID_IS_LINKED(collection_child->collection)) { collection_child->collection->id.lib = collection->id.lib; } @@ -694,8 +695,8 @@ static bool replace_bbone_scale_rnapath(char **p_old_path) return false; } - if (BLI_str_endswith(old_path, "bbone_scalein") || - BLI_str_endswith(old_path, "bbone_scaleout")) { + if (BLI_str_endswith(old_path, "bbone_scalein") || BLI_str_endswith(old_path, "bbone_scaleout")) + { *p_old_path = BLI_strdupcat(old_path, "x"); MEM_freeN(old_path); @@ -978,7 +979,8 @@ static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMa CMP_NODE_TIME, CMP_NODE_HUECORRECT, TEX_NODE_CURVE_RGB, - TEX_NODE_CURVE_TIME)) { + TEX_NODE_CURVE_TIME)) + { callback((CurveMapping *)node->storage); } } @@ -1179,7 +1181,8 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain) /* Convert group layer visibility flags to hidden nested collection. */ for (Collection *collection = bmain->collections.first; collection; - collection = collection->id.next) { + collection = collection->id.next) + { /* Add fake user for all existing groups. */ id_fake_user_set(&collection->id); @@ -1228,7 +1231,8 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain) * which is FORBIDDEN! NOTE: we need this to be recursive, since a child collection may be * sorted before its parent in bmain. */ for (Collection *collection = bmain->collections.first; collection != NULL; - collection = collection->id.next) { + collection = collection->id.next) + { do_version_collection_propagate_lib_to_children(collection); } @@ -1493,7 +1497,8 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain) /* If the settings in the Bone are not set, copy. */ if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO && pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO && - pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL) { + pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL) + { pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE; @@ -1798,7 +1803,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { /* If we have UVs, so this file will have MTexPoly layers too! */ if (CustomData_has_layer(&me->ldata, CD_MLOOPUV) || - CustomData_has_layer(&me->ldata, CD_PROP_FLOAT2)) { + CustomData_has_layer(&me->ldata, CD_PROP_FLOAT2)) + { CustomData_update_typemap(&me->pdata); CustomData_free_layers(&me->pdata, CD_MTEXPOLY, me->totpoly); } @@ -1848,7 +1854,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (ntree->type == NTREE_SHADER) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && - STREQ(node->idname, "ShaderNodeOutputMetallic")) { + STREQ(node->idname, "ShaderNodeOutputMetallic")) + { BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); error |= NTREE_DOVERSION_NEED_OUTPUT; } @@ -1860,13 +1867,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && - STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) { + STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) + { node->type = SH_NODE_OUTPUT_MATERIAL; BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); } else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && - STREQ(node->idname, "ShaderNodeEeveeMetallic")) { + STREQ(node->idname, "ShaderNodeEeveeMetallic")) + { node->type = SH_NODE_BSDF_PRINCIPLED; BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); node->custom1 = SHD_GLOSSY_MULTI_GGX; @@ -1900,7 +1909,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (use_collection_compat_28 && (DNA_struct_elem_find(fd->filesdna, "ViewLayer", "FreestyleConfig", "freestyle_config") == false) && - DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) { + DNA_struct_elem_find(fd->filesdna, "Scene", "ListBase", "view_layers")) + { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { ViewLayer *view_layer; for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { @@ -1930,8 +1940,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* Grease pencil multi-frame falloff curve. */ - if (!DNA_struct_elem_find( - fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff")) { + if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_falloff")) + { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { /* sculpt brushes */ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; @@ -2020,7 +2030,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API, - SO_ID_ORPHANS)) { + SO_ID_ORPHANS)) + { space_outliner->outlinevis = SO_VIEW_LAYER; } } @@ -2651,8 +2662,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find( - fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) { + if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) + { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { RigidBodyWorld *rbw = scene->rigidbody_world; @@ -3349,8 +3360,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* Grease pencil primitive curve */ - if (!DNA_struct_elem_find( - fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) { + if (!DNA_struct_elem_find(fd->filesdna, "GP_Sculpt_Settings", "CurveMapping", "cur_primitive")) + { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_primitive == NULL)) { @@ -3668,8 +3679,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) { /* All tool names changed, reset to defaults. */ - for (WorkSpace *workspace = bmain->workspaces.first; workspace; - workspace = workspace->id.next) { + for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) + { while (!BLI_listbase_is_empty(&workspace->tools)) { BKE_workspace_tool_remove(workspace, workspace->tools.first); } @@ -3868,7 +3879,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) ARegion *region = NULL; if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ) && ((region = do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER)) == - NULL)) { + NULL)) + { /* Add tool header. */ region = do_versions_add_region(RGN_TYPE_TOOL_HEADER, "tool header"); region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; @@ -3905,8 +3917,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find( - fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) { + if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) + { for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { @@ -4283,8 +4295,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!DNA_struct_elem_find( - fd->filesdna, "LayerCollection", "short", "local_collections_bits")) { + if (!DNA_struct_elem_find(fd->filesdna, "LayerCollection", "short", "local_collections_bits")) + { LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) { @@ -4715,8 +4727,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) case eGpencilModifierType_Array: { ArrayGpencilModifierData *mmd = (ArrayGpencilModifierData *)md; mmd->seed = 1; - if ((mmd->offset[0] != 0.0f) || (mmd->offset[1] != 0.0f) || - (mmd->offset[2] != 0.0f)) { + if ((mmd->offset[0] != 0.0f) || (mmd->offset[1] != 0.0f) || (mmd->offset[2] != 0.0f)) + { mmd->flag |= GP_ARRAY_USE_OFFSET; } if ((mmd->shift[0] != 0.0f) || (mmd->shift[1] != 0.0f) || (mmd->shift[2] != 0.0f)) { @@ -4878,7 +4890,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Boundary Edges Auto-masking. */ if (!DNA_struct_elem_find( - fd->filesdna, "Brush", "int", "automasking_boundary_edges_propagation_steps")) { + fd->filesdna, "Brush", "int", "automasking_boundary_edges_propagation_steps")) + { for (Brush *br = bmain->brushes.first; br; br = br->id.next) { br->automasking_boundary_edges_propagation_steps = 1; } diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index 08b60bf919e..4b620d97851 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -872,8 +872,8 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) /* Init Grease Pencil new random curves. */ if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "random_hue")) { LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { - if ((brush->gpencil_settings) && - (brush->gpencil_settings->curve_rand_pressure == nullptr)) { + if ((brush->gpencil_settings) && (brush->gpencil_settings->curve_rand_pressure == nullptr)) + { brush->gpencil_settings->curve_rand_pressure = BKE_curvemapping_add( 1, 0.0f, 0.0f, 1.0f, 1.0f); brush->gpencil_settings->curve_rand_strength = BKE_curvemapping_add( @@ -1054,8 +1054,8 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) } /* Initialize additional velocity parameter for #CacheFile's. */ - if (!DNA_struct_elem_find( - fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale")) { + if (!DNA_struct_elem_find(fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale")) + { LISTBASE_FOREACH (Object *, object, &bmain->objects) { LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_MeshSequenceCache) { @@ -1303,8 +1303,8 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) /* Ensure that particle systems generated by fluid modifier have correct phystype. */ LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) { - if (ELEM( - part->type, PART_FLUID_FLIP, PART_FLUID_SPRAY, PART_FLUID_BUBBLE, PART_FLUID_FOAM)) { + if (ELEM(part->type, PART_FLUID_FLIP, PART_FLUID_SPRAY, PART_FLUID_BUBBLE, PART_FLUID_FOAM)) + { part->phystype = PART_PHYS_NO; } } @@ -1614,7 +1614,8 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 292, 14) || - ((bmain->versionfile == 293) && !MAIN_VERSION_ATLEAST(bmain, 293, 1))) { + ((bmain->versionfile == 293) && !MAIN_VERSION_ATLEAST(bmain, 293, 1))) + { FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type != NTREE_GEOMETRY) { continue; @@ -1750,7 +1751,8 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) SEQ_RENDER_SIZE_PROXY_100, SEQ_RENDER_SIZE_PROXY_75, SEQ_RENDER_SIZE_PROXY_50, - SEQ_RENDER_SIZE_PROXY_25)) { + SEQ_RENDER_SIZE_PROXY_25)) + { sseq->flag |= SEQ_USE_PROXIES; } if (sseq->render_size == SEQ_RENDER_SIZE_FULL) { diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 4c9b557dadf..3371924be7d 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -204,8 +204,8 @@ static void version_idproperty_move_data_string(IDPropertyUIDataString *ui_data, static void version_idproperty_ui_data(IDProperty *idprop_group) { - if (idprop_group == - nullptr) { /* nullptr check here to reduce verbosity of calls to this function. */ + /* `nullptr` check here to reduce verbosity of calls to this function. */ + if (idprop_group == nullptr) { return; } @@ -555,7 +555,8 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree) GEO_NODE_TRIM_CURVE, GEO_NODE_REPLACE_MATERIAL, GEO_NODE_SUBDIVIDE_MESH, - GEO_NODE_TRIANGULATE)) { + GEO_NODE_TRIANGULATE)) + { bNodeSocket *geometry_socket = static_cast(node->inputs.first); add_realize_instances_before_socket(ntree, node, geometry_socket); } @@ -864,7 +865,8 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree) GEO_NODE_MESH_PRIMITIVE_CYLINDER, GEO_NODE_MESH_PRIMITIVE_GRID, GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE, - GEO_NODE_MESH_PRIMITIVE_UV_SPHERE)) { + GEO_NODE_MESH_PRIMITIVE_UV_SPHERE)) + { continue; } bNodeSocket *primitive_output_socket = nullptr; @@ -956,7 +958,8 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree) continue; } if (static_cast(node->storage)->mode != - GEO_NODE_EXTRUDE_MESH_EDGES) { + GEO_NODE_EXTRUDE_MESH_EDGES) + { continue; } bNodeSocket *geometry_in_socket = nodeFindSocket(node, SOCK_IN, "Mesh"); @@ -982,8 +985,8 @@ static void version_geometry_nodes_extrude_smooth_propagation(bNodeTree &ntree) bNode *capture_node = geometry_in_link->fromnode; const NodeGeometryAttributeCapture &capture_storage = *static_cast(capture_node->storage); - if (capture_storage.data_type != CD_PROP_BOOL || - capture_storage.domain != ATTR_DOMAIN_FACE) { + if (capture_storage.data_type != CD_PROP_BOOL || capture_storage.domain != ATTR_DOMAIN_FACE) + { return false; } bNodeSocket *capture_in_socket = nodeFindSocket(capture_node, SOCK_IN, "Value_003"); @@ -1116,22 +1119,26 @@ void do_versions_after_linking_300(FileData * /*fd*/, Main *bmain) ToolSettings *tool_settings = scene->toolsettings; ImagePaintSettings *imapaint = &tool_settings->imapaint; if (imapaint->canvas != nullptr && - ELEM(imapaint->canvas->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + ELEM(imapaint->canvas->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) + { imapaint->canvas = nullptr; } if (imapaint->stencil != nullptr && - ELEM(imapaint->stencil->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + ELEM(imapaint->stencil->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) + { imapaint->stencil = nullptr; } if (imapaint->clone != nullptr && - ELEM(imapaint->clone->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + ELEM(imapaint->clone->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) + { imapaint->clone = nullptr; } } LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { if (brush->clone.image != nullptr && - ELEM(brush->clone.image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + ELEM(brush->clone.image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) + { brush->clone.image = nullptr; } } @@ -1391,8 +1398,8 @@ static void version_switch_node_input_prefix(Main *bmain) /* Replace "A" and "B", but keep the unique number suffix at the end. */ char number_suffix[8]; BLI_strncpy(number_suffix, socket->identifier + 1, sizeof(number_suffix)); - strcpy(socket->identifier, socket->name); - strcat(socket->identifier, number_suffix); + BLI_string_join( + socket->identifier, sizeof(socket->identifier), socket->name, number_suffix); } } } @@ -1412,7 +1419,8 @@ static bool replace_bbone_len_scale_rnapath(char **p_old_path, int *p_index) int len = strlen(old_path); if (BLI_str_endswith(old_path, ".bbone_curveiny") || - BLI_str_endswith(old_path, ".bbone_curveouty")) { + BLI_str_endswith(old_path, ".bbone_curveouty")) + { old_path[len - 1] = 'z'; return true; } @@ -1420,7 +1428,8 @@ static bool replace_bbone_len_scale_rnapath(char **p_old_path, int *p_index) if (BLI_str_endswith(old_path, ".bbone_scaleinx") || BLI_str_endswith(old_path, ".bbone_scaleiny") || BLI_str_endswith(old_path, ".bbone_scaleoutx") || - BLI_str_endswith(old_path, ".bbone_scaleouty")) { + BLI_str_endswith(old_path, ".bbone_scaleouty")) + { int index = (old_path[len - 1] == 'y' ? 2 : 0); old_path[len - 1] = 0; @@ -1778,7 +1787,8 @@ static bool version_set_seq_single_frame_content(Sequence *seq, void * /*user_da { if ((seq->len == 1) && (seq->type == SEQ_TYPE_IMAGE || - ((seq->type & SEQ_TYPE_EFFECT) && SEQ_effect_get_num_inputs(seq->type) == 0))) { + ((seq->type & SEQ_TYPE_EFFECT) && SEQ_effect_get_num_inputs(seq->type) == 0))) + { seq->flag |= SEQ_SINGLE_FRAME_CONTENT; } return true; @@ -1798,7 +1808,7 @@ static void version_liboverride_rnacollections_insertion_object_constraints( ListBase *constraints, IDOverrideLibraryProperty *op) { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->operation != IDOVERRIDE_LIBRARY_OP_INSERT_AFTER) { + if (opop->operation != LIBOVERRIDE_OP_INSERT_AFTER) { continue; } bConstraint *constraint_anchor = static_cast( @@ -1832,7 +1842,7 @@ static void version_liboverride_rnacollections_insertion_object(Object *object) op = BKE_lib_override_library_property_find(liboverride, "modifiers"); if (op != nullptr) { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->operation != IDOVERRIDE_LIBRARY_OP_INSERT_AFTER) { + if (opop->operation != LIBOVERRIDE_OP_INSERT_AFTER) { continue; } ModifierData *mod_anchor = static_cast( @@ -1861,7 +1871,7 @@ static void version_liboverride_rnacollections_insertion_object(Object *object) op = BKE_lib_override_library_property_find(liboverride, "grease_pencil_modifiers"); if (op != nullptr) { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->operation != IDOVERRIDE_LIBRARY_OP_INSERT_AFTER) { + if (opop->operation != LIBOVERRIDE_OP_INSERT_AFTER) { continue; } GpencilModifierData *gp_mod_anchor = static_cast( @@ -1920,7 +1930,7 @@ static void version_liboverride_rnacollections_insertion_animdata(ID *id) op = BKE_lib_override_library_property_find(liboverride, "animation_data.nla_tracks"); if (op != nullptr) { LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->operation != IDOVERRIDE_LIBRARY_OP_INSERT_AFTER) { + if (opop->operation != LIBOVERRIDE_OP_INSERT_AFTER) { continue; } /* NLA tracks are only referenced by index, which limits possibilities, basically they are @@ -2209,7 +2219,8 @@ static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format) LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { if (format != &scene->r.im_format && ELEM(format->view_settings.curve_mapping, scene->view_settings.curve_mapping, - scene->r.im_format.view_settings.curve_mapping)) { + scene->r.im_format.view_settings.curve_mapping)) + { format->view_settings.curve_mapping = BKE_curvemapping_copy( format->view_settings.curve_mapping); break; @@ -2236,13 +2247,15 @@ static void version_ensure_missing_regions(ScrArea *area, SpaceLink *sl) switch (sl->spacetype) { case SPACE_FILE: { if (ARegion *ui_region = do_versions_add_region_if_not_found( - regionbase, RGN_TYPE_UI, "versioning: UI region for file", RGN_TYPE_TOOLS)) { + regionbase, RGN_TYPE_UI, "versioning: UI region for file", RGN_TYPE_TOOLS)) + { ui_region->alignment = RGN_ALIGN_TOP; ui_region->flag |= RGN_FLAG_DYNAMIC_SIZE; } if (ARegion *exec_region = do_versions_add_region_if_not_found( - regionbase, RGN_TYPE_EXECUTE, "versioning: execute region for file", RGN_TYPE_UI)) { + regionbase, RGN_TYPE_EXECUTE, "versioning: execute region for file", RGN_TYPE_UI)) + { exec_region->alignment = RGN_ALIGN_BOTTOM; exec_region->flag = RGN_FLAG_DYNAMIC_SIZE; } @@ -2251,7 +2264,8 @@ static void version_ensure_missing_regions(ScrArea *area, SpaceLink *sl) regionbase, RGN_TYPE_TOOL_PROPS, "versioning: tool props region for file", - RGN_TYPE_EXECUTE)) { + RGN_TYPE_EXECUTE)) + { tool_props_region->alignment = RGN_ALIGN_RIGHT; tool_props_region->flag = RGN_FLAG_HIDDEN; } @@ -2540,8 +2554,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 300, 13)) { /* Convert Surface Deform to sparse-capable bind structure. */ - if (!DNA_struct_elem_find( - fd->filesdna, "SurfaceDeformModifierData", "int", "num_mesh_verts")) { + if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "int", "num_mesh_verts")) + { LISTBASE_FOREACH (Object *, ob, &bmain->objects) { LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { if (md->type == eModifierType_SurfaceDeform) { @@ -2567,15 +2581,16 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } - if (!DNA_struct_elem_find( - fd->filesdna, "WorkSpace", "AssetLibraryReference", "asset_library")) { + if (!DNA_struct_elem_find(fd->filesdna, "WorkSpace", "AssetLibraryReference", "asset_library")) + { LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) { BKE_asset_library_reference_init_default(&workspace->asset_library_ref); } } if (!DNA_struct_elem_find( - fd->filesdna, "FileAssetSelectParams", "AssetLibraryReference", "asset_library_ref")) { + fd->filesdna, "FileAssetSelectParams", "AssetLibraryReference", "asset_library_ref")) + { LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) { @@ -2661,7 +2676,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } if (!DNA_struct_elem_find( - fd->filesdna, "FileAssetSelectParams", "AssetLibraryReference", "asset_library_ref")) { + fd->filesdna, "FileAssetSelectParams", "AssetLibraryReference", "asset_library_ref")) + { LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) { @@ -2748,7 +2764,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 300, 22)) { if (!DNA_struct_elem_find( - fd->filesdna, "LineartGpencilModifierData", "bool", "use_crease_on_smooth")) { + fd->filesdna, "LineartGpencilModifierData", "bool", "use_crease_on_smooth")) + { LISTBASE_FOREACH (Object *, ob, &bmain->objects) { if (ob->type == OB_GPENCIL_LEGACY) { LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) { @@ -3173,7 +3190,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) /* Special case to handle older in-development 3.1 files, before change from 3.0 branch gets * merged in master. */ if (!MAIN_VERSION_ATLEAST(bmain, 300, 42) || - (bmain->versionfile == 301 && !MAIN_VERSION_ATLEAST(bmain, 301, 3))) { + (bmain->versionfile == 301 && !MAIN_VERSION_ATLEAST(bmain, 301, 3))) + { /* Update LibOverride operations regarding insertions in RNA collections (i.e. modifiers, * constraints and NLA tracks). */ ID *id_iter; @@ -3320,7 +3338,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 301, 7) || - (bmain->versionfile == 302 && !MAIN_VERSION_ATLEAST(bmain, 302, 4))) { + (bmain->versionfile == 302 && !MAIN_VERSION_ATLEAST(bmain, 302, 4))) + { /* Duplicate value for two flags that mistakenly had the same numeric value. */ LISTBASE_FOREACH (Object *, ob, &bmain->objects) { LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { @@ -3483,7 +3502,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) /* Do not 'lock' an ID already edited by the user. */ continue; } - id->override_library->flag |= IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id->override_library->flag |= LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } FOREACH_MAIN_ID_END; @@ -4092,7 +4111,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) /* Grease Pencil Build modifier: * Set default value for new natural draw-speed factor and maximum gap. */ if (!DNA_struct_elem_find(fd->filesdna, "BuildGpencilModifierData", "float", "speed_fac") || - !DNA_struct_elem_find(fd->filesdna, "BuildGpencilModifierData", "float", "speed_maxgap")) { + !DNA_struct_elem_find(fd->filesdna, "BuildGpencilModifierData", "float", "speed_maxgap")) + { LISTBASE_FOREACH (Object *, ob, &bmain->objects) { LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) { if (md->type == eGpencilModifierType_Build) { @@ -4311,6 +4331,19 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) do_versions_rename_id(bmain, ID_BR, "Draw Weight", "Weight Draw"); } + /* fcm->name was never used to store modifier name so it has always been an empty string. Now + * this property supports name editing. So assign value to name variable of Fmodifier otherwise + * modifier interface would show an empty name field. Also ensure uniqueness when opening old + * files. */ + if (!MAIN_VERSION_ATLEAST(bmain, 306, 7)) { + LISTBASE_FOREACH (bAction *, act, &bmain->actions) { + LISTBASE_FOREACH (FCurve *, fcu, &act->curves) { + LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) { + BKE_fmodifier_name_set(fcm, ""); + } + } + } + } /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 31e8c7620dc..9468b978716 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -207,7 +207,8 @@ void version_node_socket_index_animdata(Main *bmain, * keyframe data. Not sure what causes that, so I (Sybren) moved the code here from * versioning_290.cc as-is (structure-wise). */ for (int input_index = total_number_of_sockets - 1; input_index >= socket_index_orig; - input_index--) { + input_index--) + { FOREACH_NODETREE_BEGIN (bmain, ntree, owner_id) { if (ntree->type != node_tree_type) { continue; diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 67772140466..3a4454ef7e3 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -130,7 +130,8 @@ static void displacement_node_insert(bNodeTree *ntree) bNodeSocket *tosock = link->tosock; if (!(tonode->type == SH_NODE_OUTPUT_MATERIAL && fromnode->type != SH_NODE_DISPLACEMENT && - STREQ(tosock->identifier, "Displacement"))) { + STREQ(tosock->identifier, "Displacement"))) + { continue; } @@ -442,7 +443,8 @@ static void update_math_node_single_operand_operators(bNodeTree *ntree) NODE_MATH_ABSOLUTE, NODE_MATH_FRACTION, NODE_MATH_ARCCOSINE, - NODE_MATH_ARCTANGENT)) { + NODE_MATH_ARCTANGENT)) + { bNodeSocket *sockA = BLI_findlink(&node->inputs, 0); bNodeSocket *sockB = BLI_findlink(&node->inputs, 1); if (!sockA->link && sockB->link) { @@ -481,7 +483,8 @@ static void update_vector_math_node_add_and_subtract_operators(bNodeTree *ntree) if (node->type == SH_NODE_VECTOR_MATH) { bNodeSocket *sockOutValue = nodeFindSocket(node, SOCK_OUT, "Value"); if (socket_is_used(sockOutValue) && - ELEM(node->custom1, NODE_VECTOR_MATH_ADD, NODE_VECTOR_MATH_SUBTRACT)) { + ELEM(node->custom1, NODE_VECTOR_MATH_ADD, NODE_VECTOR_MATH_SUBTRACT)) + { bNode *absNode = nodeAddStaticNode(NULL, ntree, SH_NODE_VECTOR_MATH); absNode->custom1 = NODE_VECTOR_MATH_ABSOLUTE; @@ -819,7 +822,8 @@ static void update_mapping_node_fcurve_rna_path_callback(ID *UNUSED(id), { MappingNodeFCurveCallbackData *data = (MappingNodeFCurveCallbackData *)_data; if (!STRPREFIX(fcurve->rna_path, data->nodePath) || - BLI_str_endswith(fcurve->rna_path, "default_value")) { + BLI_str_endswith(fcurve->rna_path, "default_value")) + { return; } char *old_fcurve_rna_path = fcurve->rna_path; @@ -1194,7 +1198,8 @@ static void update_voronoi_node_square_distance(bNodeTree *ntree) NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage; bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance"); if (tex->distance == SHD_VORONOI_EUCLIDEAN && - ELEM(tex->feature, SHD_VORONOI_F1, SHD_VORONOI_F2) && socket_is_used(sockDistance)) { + ELEM(tex->feature, SHD_VORONOI_F1, SHD_VORONOI_F2) && socket_is_used(sockDistance)) + { bNode *multiplyNode = nodeAddStaticNode(NULL, ntree, SH_NODE_MATH); multiplyNode->custom1 = NODE_MATH_MULTIPLY; multiplyNode->locx = node->locx + node->width + 20.0f; @@ -1389,7 +1394,8 @@ void do_versions_after_linking_cycles(Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 279, 2) || - (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 4))) { + (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 4))) + { displacement_node_insert(ntree); } @@ -1400,7 +1406,8 @@ void do_versions_after_linking_cycles(Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 279, 4) || - (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 5))) { + (MAIN_VERSION_ATLEAST(bmain, 280, 0) && !MAIN_VERSION_ATLEAST(bmain, 280, 5))) + { /* Switch to squared roughness convention */ square_roughness_node_insert(ntree); } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 562e89866d0..153a49f167a 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1395,8 +1395,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } } - if ((ob->softflag & OB_SB_ENABLE) && - !BKE_modifiers_findby_type(ob, eModifierType_Softbody)) { + if ((ob->softflag & OB_SB_ENABLE) && !BKE_modifiers_findby_type(ob, eModifierType_Softbody)) + { if (ob->softflag & OB_SB_POSTDEF) { md = ob->modifiers.first; @@ -1932,8 +1932,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) /* unless the file was created 2.44.3 but not 2.45, update the constraints */ if (!(bmain->versionfile == 244 && bmain->subversionfile == 3) && - ((bmain->versionfile < 245) || - (bmain->versionfile == 245 && bmain->subversionfile == 0))) { + ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile == 0))) + { for (ob = bmain->objects.first; ob; ob = ob->id.next) { ListBase *list; list = &ob->constraints; diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 230f9647835..3c74f5faec7 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -624,7 +624,8 @@ static void mywrite_id_begin(WriteData *wd, ID *id) if (wd->mem.id_session_uuid_mapping != nullptr && (curr_memchunk == nullptr || curr_memchunk->id_session_uuid != id->session_uuid || (prev_memchunk != nullptr && - (prev_memchunk->id_session_uuid == curr_memchunk->id_session_uuid)))) { + (prev_memchunk->id_session_uuid == curr_memchunk->id_session_uuid)))) + { void *ref = BLI_ghash_lookup(wd->mem.id_session_uuid_mapping, POINTER_FROM_UINT(id->session_uuid)); if (ref != nullptr) { @@ -959,9 +960,9 @@ static void write_libraries(WriteData *wd, Main *main) found_one = false; while (!found_one && tot--) { for (id = static_cast(lbarray[tot]->first); id; id = static_cast(id->next)) { - if (id->us > 0 && - ((id->tag & LIB_TAG_EXTERN) || - ((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) { + if (id->us > 0 && ((id->tag & LIB_TAG_EXTERN) || ((id->tag & LIB_TAG_INDIRECT) && + (id->flag & LIB_INDIRECT_WEAK_LINK)))) + { found_one = true; break; } @@ -995,9 +996,9 @@ static void write_libraries(WriteData *wd, Main *main) /* Write link placeholders for all direct linked IDs. */ while (a--) { for (id = static_cast(lbarray[a]->first); id; id = static_cast(id->next)) { - if (id->us > 0 && - ((id->tag & LIB_TAG_EXTERN) || - ((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) { + if (id->us > 0 && ((id->tag & LIB_TAG_EXTERN) || ((id->tag & LIB_TAG_INDIRECT) && + (id->flag & LIB_INDIRECT_WEAK_LINK)))) + { if (!BKE_idtype_idcode_is_linkable(GS(id->name))) { CLOG_ERROR(&LOG, "Data-block '%s' from lib '%s' is not linkable, but is flagged as " @@ -1473,13 +1474,13 @@ bool BLO_write_file(Main *mainvar, /* Normalize the paths in case there is some subtle difference (so they can be compared). */ if (relbase_valid) { - BLI_split_dir_part(mainvar->filepath, dir_src, sizeof(dir_src)); + BLI_path_split_dir_part(mainvar->filepath, dir_src, sizeof(dir_src)); BLI_path_normalize(dir_src); } else { dir_src[0] = '\0'; } - BLI_split_dir_part(filepath, dir_dst, sizeof(dir_dst)); + BLI_path_split_dir_part(filepath, dir_dst, sizeof(dir_dst)); BLI_path_normalize(dir_dst); /* Only for relative, not relative-all, as this means making existing paths relative. */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 5fbbd087d7e..37e0163503c 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -540,7 +540,8 @@ int bmesh_elem_check(void *element, const char htype) case BM_EDGE: { BMEdge *e = element; if (e->v1_disk_link.prev == NULL || e->v2_disk_link.prev == NULL || - e->v1_disk_link.next == NULL || e->v2_disk_link.next == NULL) { + e->v1_disk_link.next == NULL || e->v2_disk_link.next == NULL) + { err |= IS_EDGE_NULL_DISK_LINK; } @@ -1909,7 +1910,8 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd /* validate that for each face, each vertex has another edge in its disk cycle that is * not e, and not shared. */ if (BM_edge_in_face(l_f1->next->e, f2) || BM_edge_in_face(l_f1->prev->e, f2) || - BM_edge_in_face(l_f2->next->e, f1) || BM_edge_in_face(l_f2->prev->e, f1)) { + BM_edge_in_face(l_f2->next->e, f1) || BM_edge_in_face(l_f2->prev->e, f1)) + { return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c index 4391a6a92d7..079c75e890b 100644 --- a/source/blender/bmesh/intern/bmesh_edgeloop.c +++ b/source/blender/bmesh/intern/bmesh_edgeloop.c @@ -146,7 +146,8 @@ int BM_mesh_edgeloops_find(BMesh *bm, /* add both directions */ if (bm_loop_build(el_store, e->v1, e->v2, 1) && bm_loop_build(el_store, e->v2, e->v1, -1) && - el_store->len > 1) { + el_store->len > 1) + { BLI_addtail(r_eloops, el_store); count++; } diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 234fd8079b3..56b6ca23ad0 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -1132,7 +1132,8 @@ static void bm_loop_walk_data(struct LoopWalkCtx *lwc, BMLoop *l_walk) BLI_assert(l_other->v == l_walk->v); if (BM_elem_flag_test(l_other, BM_ELEM_INTERNAL_TAG)) { if (CustomData_data_equals( - lwc->type, lwc->data_ref, BM_ELEM_CD_GET_VOID_P(l_other, lwc->cd_layer_offset))) { + lwc->type, lwc->data_ref, BM_ELEM_CD_GET_VOID_P(l_other, lwc->cd_layer_offset))) + { bm_loop_walk_data(lwc, l_other); } } diff --git a/source/blender/bmesh/intern/bmesh_iterators.cc b/source/blender/bmesh/intern/bmesh_iterators.cc index c27d02b9a04..ba8e71f934a 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.cc +++ b/source/blender/bmesh/intern/bmesh_iterators.cc @@ -112,7 +112,8 @@ int BMO_iter_as_array(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], void *ele; for (ele = BMO_iter_new(&oiter, slot_args, slot_name, restrictmask); ele; - ele = BMO_iter_step(&oiter)) { + ele = BMO_iter_step(&oiter)) + { array[i] = ele; i++; if (i == len) { @@ -185,7 +186,8 @@ void *BMO_iter_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], BLI_assert(stack_array_size == 0 || (stack_array_size && stack_array)); if ((ele = static_cast(BMO_iter_new(&iter, slot_args, slot_name, restrictmask))) && - slot_len > 0) { + slot_len > 0) + { BMElem **array = slot_len > stack_array_size ? static_cast(MEM_mallocN(sizeof(ele) * slot_len, __func__)) : reinterpret_cast(stack_array); diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index a81e70b4e67..9c85131b1cc 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -319,7 +319,8 @@ static void bm_mesh_select_mode_flush_vert_to_edge_iter_fn(void *UNUSED(userdata const bool is_selected = BM_elem_flag_test(e, BM_ELEM_SELECT); const bool is_hidden = BM_elem_flag_test(e, BM_ELEM_HIDDEN); if (!is_hidden && - (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT))) { + (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT))) + { BM_elem_flag_enable(e, BM_ELEM_SELECT); chunk_data->delta_selection_len += is_selected ? 0 : 1; } @@ -442,8 +443,8 @@ void BM_mesh_deselect_flush(BMesh *bm) BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { - if (!BM_elem_flag_test(e->v1, BM_ELEM_SELECT) || - !BM_elem_flag_test(e->v2, BM_ELEM_SELECT)) { + if (!BM_elem_flag_test(e->v1, BM_ELEM_SELECT) || !BM_elem_flag_test(e->v2, BM_ELEM_SELECT)) + { BM_elem_flag_disable(e, BM_ELEM_SELECT); } } @@ -480,7 +481,8 @@ void BM_mesh_select_flush(BMesh *bm) BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + { BM_elem_flag_enable(e, BM_ELEM_SELECT); } } @@ -1233,7 +1235,8 @@ void BM_mesh_elem_hflag_disable_test(BMesh *bm, } if ((htype == (BM_VERT | BM_EDGE | BM_FACE)) && (hflag == BM_ELEM_SELECT) && - (respecthide == false) && (hflag_test == 0)) { + (respecthide == false) && (hflag_test == 0)) + { /* fast path for deselect all, avoid topology loops * since we know all will be de-selected anyway. */ for (i = 0; i < 3; i++) { diff --git a/source/blender/bmesh/intern/bmesh_mesh.cc b/source/blender/bmesh/intern/bmesh_mesh.cc index db70182fa27..1dadf2eb08c 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.cc +++ b/source/blender/bmesh/intern/bmesh_mesh.cc @@ -278,8 +278,8 @@ void bmesh_edit_begin(BMesh * /*bm*/, BMOpTypeFlag /*type_flag*/) * until this is shown to be better for certain types of mesh edits. */ #ifdef BMOP_UNTAN_MULTIRES_ENABLED /* switch multires data out of tangent space */ - if ((type_flag & BMO_OPTYPE_FLAG_UNTAN_MULTIRES) && - CustomData_has_layer(&bm->ldata, CD_MDISPS)) { + if ((type_flag & BMO_OPTYPE_FLAG_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) + { bmesh_mdisps_space_set(bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE); /* ensure correct normals, if possible */ @@ -378,7 +378,8 @@ void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4 if (htype & (BM_FACE | BM_LOOP)) { if ((bm->elem_index_dirty & (BM_FACE | BM_LOOP)) || - (elem_offset && (elem_offset[2] || elem_offset[3]))) { + (elem_offset && (elem_offset[2] || elem_offset[3]))) + { BMIter iter; BMElem *ele; diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 3515b3a48d6..81f193ef1e1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -378,7 +378,8 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar int i; KeyBlock *block; for (i = 0, block = static_cast(me->key->block.first); i < tot_shape_keys; - block = block->next, i++) { + block = block->next, i++) + { if (is_new) { CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY, CD_SET_DEFAULT, 0, block->name); int j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i); @@ -620,7 +621,8 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, const int old_verts_num) /* Not fool-proof, but chances are if we have many verts with the same index, * we will want to use the first one, * since the second is more likely to be a duplicate. */ - (vertMap[keyi] == nullptr)) { + (vertMap[keyi] == nullptr)) + { vertMap[keyi] = eve; } } @@ -799,7 +801,8 @@ static void bm_to_mesh_shape(BMesh *bm, /* Original key-indices are only used to check the vertex existed when entering edit-mode. */ (cd_shape_keyindex_offset != -1) && /* Offsets are only needed if the current shape is a basis for others. */ - BKE_keyblock_is_basis(key, bm->shapenr - 1)) { + BKE_keyblock_is_basis(key, bm->shapenr - 1)) + { BLI_assert(actkey != nullptr); /* Assured by `actkey_has_layer` check. */ const int actkey_uuid = bm_to_mesh_shape_layer_index_from_kb(bm, actkey); @@ -927,7 +930,8 @@ static void bm_to_mesh_shape(BMesh *bm, if ((currkey->data != nullptr) && (cd_shape_keyindex_offset != -1) && ((keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset)) != ORIGINDEX_NONE) && - (keyi < currkey->totelem)) { + (keyi < currkey->totelem)) + { /* Reconstruct keys via vertices original key indices. * WARNING(@ideasman42): `currkey->data` is known to be unreliable as the edit-mesh * coordinates may be flushed back to the shape-key when exporting or rendering. diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.cc b/source/blender/bmesh/intern/bmesh_mesh_normals.cc index 761b5f6c277..06bef52a86e 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.cc @@ -501,10 +501,12 @@ static int bm_mesh_loops_calc_normals_for_loop(BMesh *bm, * BM_vert_step_fan_loop() is quite cheap in term of CPU cycles, * so really think it's not worth it. */ if (BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) && - (BM_elem_flag_test(l_curr, BM_ELEM_TAG) || !BM_loop_check_cyclic_smooth_fan(l_curr))) { + (BM_elem_flag_test(l_curr, BM_ELEM_TAG) || !BM_loop_check_cyclic_smooth_fan(l_curr))) + { } else if (!BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) && - !BM_elem_flag_test(l_curr->prev->e, BM_ELEM_TAG)) { + !BM_elem_flag_test(l_curr->prev->e, BM_ELEM_TAG)) + { /* Simple case (both edges around that vertex are sharp in related polygon), * this vertex just takes its poly normal. */ @@ -701,6 +703,7 @@ static int bm_mesh_loops_calc_normals_for_loop(BMesh *bm, } BKE_lnor_space_define(lnor_space, lnor, vec_org, vec_next, *edge_vectors); + edge_vectors->clear(); if (has_clnors) { if (clnors_invalid) { @@ -913,7 +916,8 @@ static void bm_mesh_loops_calc_normals_for_vert_with_clnors( continue; } if (do_rebuild && !BM_ELEM_API_FLAG_TEST(l_curr, BM_LNORSPACE_UPDATE) && - !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) { + !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) + { continue; } BM_elem_flag_disable(l_curr, BM_ELEM_TAG); @@ -1036,7 +1040,8 @@ static void bm_mesh_loops_calc_normals_for_vert_without_clnors( continue; } if (do_rebuild && !BM_ELEM_API_FLAG_TEST(l_curr, BM_LNORSPACE_UPDATE) && - !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) { + !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) + { continue; } bm_mesh_loops_calc_normals_for_loop(bm, @@ -1130,7 +1135,8 @@ static void bm_mesh_loops_calc_normals__single_threaded(BMesh *bm, l_curr = l_first = BM_FACE_FIRST_LOOP(f_curr); do { if (do_rebuild && !BM_ELEM_API_FLAG_TEST(l_curr, BM_LNORSPACE_UPDATE) && - !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) { + !(bm->spacearr_dirty & BM_SPACEARR_DIRTY_ALL)) + { continue; } bm_mesh_loops_calc_normals_for_loop(bm, @@ -1785,7 +1791,8 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all) /* Note that we only handle unselected neighbor vertices here, main loop will take care of * selected ones. */ if (!BM_elem_flag_test(l->prev->v, BM_ELEM_SELECT) && - !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->prev->v))) { + !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->prev->v))) + { BMLoop *l_prev; BMIter liter_prev; @@ -1796,7 +1803,8 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all) } if (!BM_elem_flag_test(l->next->v, BM_ELEM_SELECT) && - !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->next->v))) { + !BLI_BITMAP_TEST(done_verts, BM_elem_index_get(l->next->v))) + { BMLoop *l_next; BMIter liter_next; @@ -2256,7 +2264,8 @@ bool BM_custom_loop_normals_to_vector_layer(BMesh *bm) void BM_custom_loop_normals_from_vector_layer(BMesh *bm, bool add_sharp_edges) { if (!CustomData_has_layer(&bm->ldata, CD_CUSTOMLOOPNORMAL) || - !CustomData_has_layer(&bm->ldata, CD_NORMAL)) { + !CustomData_has_layer(&bm->ldata, CD_NORMAL)) + { return; } diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c index d18680e8839..cbdfd948142 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c @@ -82,7 +82,8 @@ BLI_INLINE void bmesh_calc_tessellation_for_face_impl(BMLoop *(*looptris)[3], } if (UNLIKELY(is_quad_flip_v3_first_third_fast( - l_ptr_a[0]->v->co, l_ptr_a[1]->v->co, l_ptr_a[2]->v->co, l_ptr_b[2]->v->co))) { + l_ptr_a[0]->v->co, l_ptr_a[1]->v->co, l_ptr_a[2]->v->co, l_ptr_b[2]->v->co))) + { /* Flip out of degenerate 0-2 state. */ l_ptr_a[2] = l_ptr_b[2]; l_ptr_b[0] = l_ptr_a[1]; diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index 4abde609558..7d10b00cea4 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -55,8 +55,8 @@ bool BM_mesh_validate(BMesh *bm) BM_mesh_elem_index_ensure(bm, BM_ALL); BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(v, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == - (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(v, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) + { ERRMSG("vert %d: is hidden and selected", i); } @@ -88,8 +88,8 @@ bool BM_mesh_validate(BMesh *bm) /* edge radial structure */ BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { - if (BM_elem_flag_test(e, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == - (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(e, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) + { ERRMSG("edge %d: is hidden and selected", i); } @@ -124,8 +124,8 @@ bool BM_mesh_validate(BMesh *bm) BMLoop *l_iter; BMLoop *l_first; - if (BM_elem_flag_test(f, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == - (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) + { ERRMSG("face %d: is hidden and selected", i); } diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index c383237c1ae..96de00753b5 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -767,7 +767,8 @@ bool BM_edge_rotate_check_degenerate(BMEdge *e, BMLoop *l1, BMLoop *l2) /* result is zero area corner */ if ((dot_v3v3(ed_dir_new, ed_dir_v1_new) > 0.999f) || - (dot_v3v3(ed_dir_new_flip, ed_dir_v2_new) > 0.999f)) { + (dot_v3v3(ed_dir_new_flip, ed_dir_v2_new) > 0.999f)) + { return false; } @@ -860,7 +861,8 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f * the #BM_edge_rotate_check will ensure this, but its possibly corrupt state or future edits * break this */ if ((l1 = BM_face_vert_share_loop(f, v1)) && (l2 = BM_face_vert_share_loop(f, v2)) && - BM_face_split(bm, f, l1, l2, NULL, NULL, true)) { + BM_face_split(bm, f, l1, l2, NULL, NULL, true)) + { /* we should really be able to know the faces some other way, * rather than fetching them back from the edge, but this is predictable * where using the return values from face split isn't. - campbell */ diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index ddecab23ed4..2a704f9b1c9 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -599,7 +599,8 @@ void BMO_mesh_selected_remap(BMesh *bm, ese->ele = BMO_slot_map_elem_get(slot_elem_map, ese->ele); if (UNLIKELY((ese->ele == NULL) || - (check_select && (BM_elem_flag_test(ese->ele, BM_ELEM_SELECT) == false)))) { + (check_select && (BM_elem_flag_test(ese->ele, BM_ELEM_SELECT) == false)))) + { BLI_remlink(&bm->selected, ese); MEM_freeN(ese); } @@ -823,7 +824,8 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, if (htype & BM_VERT) { BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && - BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) + { output->data.buf[i] = ele; i++; } @@ -833,7 +835,8 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, if (htype & BM_EDGE) { BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && - BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) + { output->data.buf[i] = ele; i++; } @@ -843,7 +846,8 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, if (htype & BM_FACE) { BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { if ((!respecthide || !BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) && - BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) + { output->data.buf[i] = ele; i++; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 13fde0e8cf4..77fbfe9a335 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -1274,7 +1274,8 @@ void BM_face_splits_check_optimal(BMFace *f, BMLoop *(*loops)[2], int len) for (i = 0; i < len; i++) { BMLoop *l_a_dummy, *l_b_dummy; if (f != BM_vert_pair_share_face_by_angle( - loops[i][0]->v, loops[i][1]->v, &l_a_dummy, &l_b_dummy, false)) { + loops[i][0]->v, loops[i][1]->v, &l_a_dummy, &l_b_dummy, false)) + { loops[i][0] = NULL; } } diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index de1ab723b9c..8e3dfe99fd9 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -325,8 +325,8 @@ static bool bm_face_split_edgenet_find_loop_walk(BMVert *v_init, /* in rare cases there may be edges with a single connecting vertex */ if (e_next != e_first) { do { - if (BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET) && - (bm_edge_flagged_radial_count(e_next) < 2)) { + if (BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET) && (bm_edge_flagged_radial_count(e_next) < 2)) + { BMVert *v_next; v_next = BM_edge_other_vert(e_next, v); @@ -525,13 +525,9 @@ bool BM_face_split_edgenet(BMesh *bm, while ((v = STACK_POP(vert_queue))) { BM_ELEM_API_FLAG_DISABLE(v, VERT_IN_QUEUE); - if (bm_face_split_edgenet_find_loop(v, - f->no, - face_normal_matrix, - edge_order, - edge_order_len, - face_verts, - &face_verts_len)) { + if (bm_face_split_edgenet_find_loop( + v, f->no, face_normal_matrix, edge_order, edge_order_len, face_verts, &face_verts_len)) + { BMFace *f_new; f_new = BM_face_create_verts(bm, face_verts, face_verts_len, f, BM_CREATE_NOP, false); @@ -559,7 +555,8 @@ bool BM_face_split_edgenet(BMesh *bm, do { /* Avoid adding to queue multiple times (not common but happens). */ if (!BM_ELEM_API_FLAG_TEST(l_iter->v, VERT_IN_QUEUE) && - bm_face_split_edgenet_find_loop_pair_exists(l_iter->v)) { + bm_face_split_edgenet_find_loop_pair_exists(l_iter->v)) + { STACK_PUSH(vert_queue, l_iter->v); BM_ELEM_API_FLAG_ENABLE(l_iter->v, VERT_IN_QUEUE); } @@ -823,8 +820,8 @@ static void bvhtree_test_edges_isect_2d_ray_cb(void *user_data, /* direction is normalized, so this will be the distance */ float dist_new; - if (isect_ray_seg_v2( - data->v_origin->co, ray->direction, e->v1->co, e->v2->co, &dist_new, NULL)) { + if (isect_ray_seg_v2(data->v_origin->co, ray->direction, e->v1->co, e->v2->co, &dist_new, NULL)) + { /* avoid float precision issues, possible this is greater, * check above zero to allow some overlap * (and needed for partial-connect which will overlap vertices) */ @@ -895,8 +892,8 @@ static BMEdge *test_edges_isect_2d_vert(const struct EdgeGroup_FindConnection_Ar float t_best = 1.0f; for (uint i = 0; i < args->edge_arr_new_len; i++) { float co_isect[2]; - if (UNLIKELY( - edge_isect_verts_point_2d(args->edge_arr_new[i], v_origin, v_other, co_isect))) { + if (UNLIKELY(edge_isect_verts_point_2d(args->edge_arr_new[i], v_origin, v_other, co_isect))) + { const float t_test = line_point_factor_v2(co_isect, v_origin->co, v_other->co); if (t_test < t_best) { t_best = t_test; @@ -1009,7 +1006,8 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn BMVert *v_iter = v_pair[j]; if (BM_elem_flag_test(v_iter, VERT_IS_VALID)) { if (direction_sign ? (v_iter->co[SORT_AXIS] > v_origin->co[SORT_AXIS]) : - (v_iter->co[SORT_AXIS] < v_origin->co[SORT_AXIS])) { + (v_iter->co[SORT_AXIS] < v_origin->co[SORT_AXIS])) + { BLI_SMALLSTACK_PUSH(vert_search, v_iter); BLI_SMALLSTACK_PUSH(vert_blacklist, v_iter); BM_elem_flag_disable(v_iter, VERT_IS_VALID); @@ -1378,7 +1376,8 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm, struct EdgeGroupIsland **group_arr_p = &group_arr[group_arr_len]; for (struct EdgeGroupIsland *g = (void *)group_head; g; - g = (struct EdgeGroupIsland *)g->edge_links.next) { + g = (struct EdgeGroupIsland *)g->edge_links.next) + { LinkNode *edge_links = g->edge_links.link; /* init with *any* different verts */ diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index e471d4804be..ed779a45620 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -223,7 +223,8 @@ static float bm_face_calc_split_dot(BMLoop *l_a, BMLoop *l_b) float no[2][3]; if ((BM_face_calc_normal_subset(l_a, l_b, no[0]) != 0.0f) && - (BM_face_calc_normal_subset(l_b, l_a, no[1]) != 0.0f)) { + (BM_face_calc_normal_subset(l_b, l_a, no[1]) != 0.0f)) + { return dot_v3v3(no[0], no[1]); } return -1.0f; @@ -904,7 +905,8 @@ bool BM_edge_is_contiguous_loop_cd(const BMEdge *e, l_iter_cd_v2 = BM_ELEM_CD_GET_VOID_P(l_iter_v2, cd_loop_offset); if ((CustomData_data_equals(cd_loop_type, l_base_cd_v1, l_iter_cd_v1) == 0) || - (CustomData_data_equals(cd_loop_type, l_base_cd_v2, l_iter_cd_v2) == 0)) { + (CustomData_data_equals(cd_loop_type, l_base_cd_v2, l_iter_cd_v2) == 0)) + { return false; } @@ -1403,7 +1405,8 @@ float BM_vert_calc_edge_angle_ex(const BMVert *v, const float fallback) if ((e1 = v->e) && (e2 = bmesh_disk_edge_next(e1, v)) && (e1 != e2) && /* make sure we come full circle and only have 2 connected edges */ - (e1 == bmesh_disk_edge_next(e2, v))) { + (e1 == bmesh_disk_edge_next(e2, v))) + { BMVert *v1 = BM_edge_other_vert(e1, v); BMVert *v2 = BM_edge_other_vert(e2, v); @@ -1768,7 +1771,8 @@ bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG) == false && /* ...using boundary verts */ BM_elem_flag_test(e->v1, BM_ELEM_INTERNAL_TAG) && - BM_elem_flag_test(e->v2, BM_ELEM_INTERNAL_TAG)) { + BM_elem_flag_test(e->v2, BM_ELEM_INTERNAL_TAG)) + { int tot_face_tag = 0; BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) { if (BM_elem_flag_test(f, BM_ELEM_INTERNAL_TAG)) { diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index a112e69fbfa..3ccd7ade8f3 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -932,7 +932,8 @@ static void bmw_EdgeLoopWalker_begin(BMWalker *walker, void *data) /* Without checking the face count, the 3 edges could be this edge * plus two boundary edges (which would not be stepped over), see #84906. */ ((vert_edge_count[0] == 3 && vert_face_count[0] == 3) || - (vert_edge_count[1] == 3 && vert_face_count[1] == 3))) { + (vert_edge_count[1] == 3 && vert_face_count[1] == 3))) + { BMIter iter; BMFace *f_iter; BMFace *f_best = NULL; @@ -1005,7 +1006,8 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) if (bmw_mask_check_edge(walker, nexte) && !BLI_gset_haskey(walker->visit_set, nexte) && /* Never step onto a boundary edge, this gives odd-results. */ - (BM_edge_is_boundary(nexte) == false)) { + (BM_edge_is_boundary(nexte) == false)) + { lwalk = BMW_state_add(walker); lwalk->cur = nexte; lwalk->lastv = v; @@ -1027,7 +1029,8 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) BM_ITER_ELEM (nexte, &eiter, v, BM_EDGES_OF_VERT) { if ((nexte->l == NULL) && bmw_mask_check_edge(walker, nexte) && - !BLI_gset_haskey(walker->visit_set, nexte)) { + !BLI_gset_haskey(walker->visit_set, nexte)) + { lwalk = BMW_state_add(walker); lwalk->cur = nexte; lwalk->lastv = v; @@ -1097,7 +1100,8 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) /* Initial edge was a boundary, so is this edge and vertex is only a part of this face * this lets us walk over the boundary of an ngon which is handy. */ - (owalk.is_single == true && vert_edge_tot == 2 && BM_edge_is_boundary(e))) { + (owalk.is_single == true && vert_edge_tot == 2 && BM_edge_is_boundary(e))) + { /* Find next boundary edge in the fan. */ do { l = BM_loop_other_edge_loop(l, v); diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c index e21fb5a1f7e..450f6c06d65 100644 --- a/source/blender/bmesh/operators/bmo_beautify.c +++ b/source/blender/bmesh/operators/bmo_beautify.c @@ -53,7 +53,8 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) if (BM_edge_rotate_check(e) && /* faces are tagged */ BMO_face_flag_test(bm, e->l->f, FACE_MARK) && - BMO_face_flag_test(bm, e->l->radial_next->f, FACE_MARK)) { + BMO_face_flag_test(bm, e->l->radial_next->f, FACE_MARK)) + { edge_array[edge_array_len] = e; edge_array_len++; } diff --git a/source/blender/bmesh/operators/bmo_bisect_plane.c b/source/blender/bmesh/operators/bmo_bisect_plane.c index e7e130165db..7c4b445b456 100644 --- a/source/blender/bmesh/operators/bmo_bisect_plane.c +++ b/source/blender/bmesh/operators/bmo_bisect_plane.c @@ -72,7 +72,8 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op) BMO_ITER (v, &siter, op->slots_in, "geom", BM_VERT) { if ((clear_outer && plane_point_side_v3(plane_outer, v->co) > 0.0f) || - (clear_inner && plane_point_side_v3(plane_inner, v->co) < 0.0f)) { + (clear_inner && plane_point_side_v3(plane_inner, v->co) < 0.0f)) + { STACK_PUSH(vert_arr, v); } } diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 6c784758d85..b9c013a650c 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -46,7 +46,8 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f, const bool check_degenera if (BMO_vert_flag_test(bm, l_iter->v, VERT_INPUT) && /* Ensure this vertex isn't part of a contiguous group. */ ((BMO_vert_flag_test(bm, l_iter->prev->v, VERT_INPUT) == 0) || - (BMO_vert_flag_test(bm, l_iter->next->v, VERT_INPUT) == 0))) { + (BMO_vert_flag_test(bm, l_iter->next->v, VERT_INPUT) == 0))) + { if (!l_tag_prev) { l_tag_prev = l_tag_first = l_iter; continue; @@ -72,7 +73,8 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f, const bool check_degenera if (!BM_loop_is_adjacent(l_tag_first, l_tag_prev) && /* ensure we don't add the same pair twice */ - (((loops_split[0][0] == l_tag_first) && (loops_split[0][1] == l_tag_prev)) == 0)) { + (((loops_split[0][0] == l_tag_first) && (loops_split[0][1] == l_tag_prev)) == 0)) + { BMLoop **l_pair = STACK_PUSH_RET(loops_split); l_pair[0] = l_tag_first; l_pair[1] = l_tag_prev; @@ -107,7 +109,8 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f, const bool check_degenera /* Note that duplicate edges in this case is very unlikely but it can happen, see #70287. */ bool edge_exists = (BM_edge_exists(verts_pair[i][0], verts_pair[i][1]) != NULL); if ((l_pair[0] = BM_face_vert_share_loop(f, verts_pair[i][0])) && - (l_pair[1] = BM_face_vert_share_loop(f, verts_pair[i][1]))) { + (l_pair[1] = BM_face_vert_share_loop(f, verts_pair[i][1]))) + { f_new = BM_face_split(bm, f, l_pair[0], l_pair[1], &l_new, NULL, edge_exists); /* Check if duplicate faces have been created, store the loops for removal in this case. diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c index 8112844fc8a..31016ca31b7 100644 --- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c +++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c @@ -73,7 +73,8 @@ static bool bm_face_split_find(BMesh *bm, BMFace *f, BMLoop *l_pair[2], float *r float no_a[3], no_b[3]; if (BM_face_calc_normal_subset(l_a, l_b, no_a) != 0.0f && - BM_face_calc_normal_subset(l_b, l_a, no_b) != 0.0f) { + BM_face_calc_normal_subset(l_b, l_a, no_b) != 0.0f) + { const float err_a = bm_face_subset_calc_planar(l_a, l_b, no_a); const float err_b = bm_face_subset_calc_planar(l_b, l_a, no_b); const float err_test = err_a + err_b; diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index ab468200e8d..bf279e09f6d 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -85,7 +85,8 @@ static void bm_face_split(BMesh *bm, const short oflag, bool use_edge_delete) BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { if (l->f->len > 3) { if (BMO_vert_flag_test(bm, l->next->v, oflag) == 0 && - BMO_vert_flag_test(bm, l->prev->v, oflag) == 0) { + BMO_vert_flag_test(bm, l->prev->v, oflag) == 0) + { BM_face_split(bm, l->f, l->next, l->prev, NULL, NULL, true); } } @@ -556,7 +557,8 @@ void bmo_dissolve_degenerate_exec(BMesh *bm, BMOperator *op) /* check edges are not already going to be collapsed */ !BMO_edge_flag_test(bm, l_iter->e, EDGE_COLLAPSE) && - !BMO_edge_flag_test(bm, l_iter->prev->e, EDGE_COLLAPSE))) { + !BMO_edge_flag_test(bm, l_iter->prev->e, EDGE_COLLAPSE))) + { /* test if the faces loop (ear) is degenerate */ float dir_prev[3], len_prev; float dir_next[3], len_next; @@ -580,8 +582,8 @@ void bmo_dissolve_degenerate_exec(BMesh *bm, BMOperator *op) else { /* add a joining edge and tag for removal */ BMLoop *l_split; - if (BM_face_split( - bm, l_iter->f, l_iter->prev, l_iter->next, &l_split, NULL, true)) { + if (BM_face_split(bm, l_iter->f, l_iter->prev, l_iter->next, &l_split, NULL, true)) + { BMO_edge_flag_enable(bm, l_split->e, EDGE_COLLAPSE); found = true; reset = true; diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c index 11095edac02..9fbe4770957 100644 --- a/source/blender/bmesh/operators/bmo_edgenet.c +++ b/source/blender/bmesh/operators/bmo_edgenet.c @@ -80,7 +80,8 @@ static BMEdge *edge_next(BMesh *bm, BMEdge *e) for (i = 0; i < 2; i++) { BM_ITER_ELEM (e2, &iter, i ? e->v2 : e->v1, BM_EDGES_OF_VERT) { if (BMO_edge_flag_test(bm, e2, EDGE_MARK) && - (BMO_edge_flag_test(bm, e2, EDGE_VIS) == false) && (e2 != e)) { + (BMO_edge_flag_test(bm, e2, EDGE_VIS) == false) && (e2 != e)) + { return e2; } } @@ -129,7 +130,8 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op) BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) { if (!BMO_edge_flag_test(bm, e, EDGE_VIS)) { if (BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, e->v1, EDGE_MARK, true) == 1 || - BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, e->v2, EDGE_MARK, true) == 1) { + BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, e->v2, EDGE_MARK, true) == 1) + { break; } } @@ -173,9 +175,11 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op) } if (edges1 && BLI_array_len(edges1) > 2 && - BM_edge_share_vert_check(edges1[0], edges1[BLI_array_len(edges1) - 1])) { + BM_edge_share_vert_check(edges1[0], edges1[BLI_array_len(edges1) - 1])) + { if (edges2 && BLI_array_len(edges2) > 2 && - BM_edge_share_vert_check(edges2[0], edges2[BLI_array_len(edges2) - 1])) { + BM_edge_share_vert_check(edges2[0], edges2[BLI_array_len(edges2) - 1])) + { BLI_array_free(edges1); BLI_array_free(edges2); return; @@ -185,7 +189,8 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op) } if (edges2 && BLI_array_len(edges2) > 2 && - BM_edge_share_vert_check(edges2[0], edges2[BLI_array_len(edges2) - 1])) { + BM_edge_share_vert_check(edges2[0], edges2[BLI_array_len(edges2) - 1])) + { edges2 = NULL; } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 21b32d48711..076383fc57e 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -191,7 +191,8 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) } for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundary_map.out", 0); e; - e = BMO_iter_step(&siter)) { + e = BMO_iter_step(&siter)) + { BMVert *f_verts[4]; e_new = BMO_iter_map_value_ptr(&siter); @@ -455,7 +456,8 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) slot_edges_exclude = BMO_slot_get(op->slots_in, "edges_exclude"); for (e = BMO_iter_new(&siter, dupeop.slots_out, "boundary_map.out", 0); e; - e = BMO_iter_step(&siter)) { + e = BMO_iter_step(&siter)) + { BMVert *f_verts[4]; #ifdef USE_EDGE_REGION_FLAGS BMEdge *f_edges[4]; @@ -581,7 +583,8 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) /* link isolated vert */ for (v = BMO_iter_new(&siter, dupeop.slots_out, "isovert_map.out", 0); v; - v = BMO_iter_step(&siter)) { + v = BMO_iter_step(&siter)) + { BMVert *v2 = BMO_iter_map_value_ptr(&siter); /* not essential, but ensures face normals from extruded edges are contiguous */ diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c index 9a2d297e36c..01f251da9b1 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.c +++ b/source/blender/bmesh/operators/bmo_fill_grid.c @@ -633,8 +633,8 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op) if (BM_mesh_edgeloops_find_path( bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_first, v_b_first) && - BM_mesh_edgeloops_find_path( - bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_last, v_b_last)) { + BM_mesh_edgeloops_find_path(bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_last, v_b_last)) + { estore_rail_a = eloops_rail.first; estore_rail_b = eloops_rail.last; } @@ -644,7 +644,8 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op) if (BM_mesh_edgeloops_find_path( bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_first, v_b_last) && BM_mesh_edgeloops_find_path( - bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_last, v_b_first)) { + bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_last, v_b_first)) + { estore_rail_a = eloops_rail.first; estore_rail_b = eloops_rail.last; BM_edgeloop_flip(bm, estore_b); diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 2e58b49a9d3..e49fa01b0b1 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -71,7 +71,8 @@ static BMFace *hull_find_example_face(BMesh *bm, BMEdge *e) BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) { if (BMO_face_flag_test(bm, f, HULL_FLAG_INPUT) || - BMO_face_flag_test(bm, f, HULL_FLAG_OUTPUT_GEOM) == false) { + BMO_face_flag_test(bm, f, HULL_FLAG_OUTPUT_GEOM) == false) + { return f; } } diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index a9e8174f556..26156ff8867 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -185,7 +185,8 @@ static void bm_loop_customdata_merge(BMesh *bm, BM_ELEM_CD_GET_VOID_P(l_a_inner, offset), BM_ELEM_CD_GET_VOID_P(l_b_inner, offset)) == false) # endif - ) { + ) + { /* no need to allocate a temp block: * a = (a + b); * a *= 0.5f; @@ -207,7 +208,8 @@ static void bm_loop_customdata_merge(BMesh *bm, /* check if the 2 faces share an edge */ if (is_flip ? (l_b_inner_inset->e == l_a_inner_inset->prev->e) : - (l_a_inner_inset->e == l_b_inner_inset->prev->e)) { + (l_a_inner_inset->e == l_b_inner_inset->prev->e)) + { /* simple case, we have all loops already */ } else { @@ -222,7 +224,8 @@ static void bm_loop_customdata_merge(BMesh *bm, void *data_dst = BM_ELEM_CD_GET_VOID_P(l_iter, offset); if (CustomData_data_equals(type, data_dst, data_cmp_a) || - CustomData_data_equals(type, data_dst, data_cmp_b)) { + CustomData_data_equals(type, data_dst, data_cmp_b)) + { CustomData_data_copy_value(type, data_src, data_dst); } } @@ -721,7 +724,8 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) (use_boundary && BM_edge_is_boundary(e) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) || /* tag if edge is an interior edge in between a tagged and untagged face */ - bm_edge_is_mixed_face_tag(e->l)) { + bm_edge_is_mixed_face_tag(e->l)) + { /* tag */ BM_elem_flag_enable(e->v1, BM_ELEM_TAG); BM_elem_flag_enable(e->v2, BM_ELEM_TAG); diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 3a2216d78a0..e2d267baae0 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -137,7 +137,8 @@ static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, { int cd_offset; for (cd_offset = delimit_data->cd_offset; cd_offset < delimit_data->cd_offset_end; - cd_offset += delimit_data->cd_size) { + cd_offset += delimit_data->cd_size) + { if (BM_edge_is_contiguous_loop_cd(e, delimit_data->cd_type, cd_offset) == false) { return false; } @@ -212,7 +213,8 @@ static float bm_edge_is_delimit(const BMEdge *e, const struct DelimitData *delim (fabsf(angle_normalized_v3v3(edge_vecs[2], edge_vecs[3]) - (float)M_PI_2) > delimit_data->angle_shape) || (fabsf(angle_normalized_v3v3(edge_vecs[3], edge_vecs[0]) - (float)M_PI_2) > - delimit_data->angle_shape)) { + delimit_data->angle_shape)) + { goto fail; } } @@ -278,14 +280,16 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) if (BMO_slot_bool_get(op->slots_in, "cmp_uvs") && bm_edge_delimit_cdata( - &bm->ldata, CD_PROP_FLOAT2, &delimit_data.cdata[delimit_data.cdata_len])) { + &bm->ldata, CD_PROP_FLOAT2, &delimit_data.cdata[delimit_data.cdata_len])) + { delimit_data.cdata_len += 1; } delimit_data.cdata[delimit_data.cdata_len].cd_offset = -1; if (BMO_slot_bool_get(op->slots_in, "cmp_vcols") && bm_edge_delimit_cdata( - &bm->ldata, CD_PROP_BYTE_COLOR, &delimit_data.cdata[delimit_data.cdata_len])) { + &bm->ldata, CD_PROP_BYTE_COLOR, &delimit_data.cdata[delimit_data.cdata_len])) + { delimit_data.cdata_len += 1; } @@ -300,7 +304,8 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { BMFace *f_a, *f_b; if (BM_edge_face_pair(e, &f_a, &f_b) && - (BMO_face_flag_test(bm, f_a, FACE_INPUT) && BMO_face_flag_test(bm, f_b, FACE_INPUT))) { + (BMO_face_flag_test(bm, f_a, FACE_INPUT) && BMO_face_flag_test(bm, f_b, FACE_INPUT))) + { if (!bm_edge_is_delimit(e, &delimit_data)) { BMO_edge_flag_enable(bm, e, EDGE_MARK); totedge_tag++; diff --git a/source/blender/bmesh/operators/bmo_offset_edgeloops.c b/source/blender/bmesh/operators/bmo_offset_edgeloops.c index b545cd9067a..7c2921020ee 100644 --- a/source/blender/bmesh/operators/bmo_offset_edgeloops.c +++ b/source/blender/bmesh/operators/bmo_offset_edgeloops.c @@ -40,7 +40,8 @@ static BMFace *bm_face_split_walk_back(BMesh *bm, BMLoop *l_src, BMLoop **r_l) int num, i; for (l_dst = l_src->prev, num = 0; BM_elem_index_get(l_dst->prev->v) != -1; - l_dst = l_dst->prev, num++) { + l_dst = l_dst->prev, num++) + { /* pass */ } diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c index d19530edae6..a5c0ea2e0d7 100644 --- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c +++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c @@ -379,7 +379,8 @@ static void validate_solution( leni = len_v3v3(vi1, vi2); lene = len_v3v3(ve1, ve2); if (lene > leni * SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE || - lene < leni * SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE) { + lene < leni * SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE) + { sys->zerola[idv1] = true; sys->zerola[idv2] = true; } @@ -463,7 +464,8 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) if ((sys->zerola[i] == false) && /* Non zero check is to account for vertices that aren't connected to a selected face. * Without this wire edges become `nan`, see #89214. */ - (sys->ring_areas[i] != 0.0f)) { + (sys->ring_areas[i] != 0.0f)) + { w = sys->vweights[i] * sys->ring_areas[i]; sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda_factor / (4.0f * w); w = sys->vlengths[i]; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 72509dd4f6c..fe7c81a660b 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -1175,7 +1175,8 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) /* find the boundary of one of the split edges */ for (a = 0; a < vlen; a++) { if (!BMO_vert_flag_test(bm, loops[a ? (a - 1) : (vlen - 1)]->v, ELE_INNER) && - BMO_vert_flag_test(bm, loops[a]->v, ELE_INNER)) { + BMO_vert_flag_test(bm, loops[a]->v, ELE_INNER)) + { break; } } @@ -1190,7 +1191,8 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) for (j = 0; j < vlen; j++) { b = (j + a + numcuts + 1) % vlen; if (!BMO_vert_flag_test(bm, loops[b == 0 ? vlen - 1 : b - 1]->v, ELE_INNER) && - BMO_vert_flag_test(bm, loops[b]->v, ELE_INNER)) { + BMO_vert_flag_test(bm, loops[b]->v, ELE_INNER)) + { break; } } diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c index 474b8ad6263..59ddb6d6d93 100644 --- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c +++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c @@ -624,7 +624,8 @@ static void bm_edgering_pair_interpolate(BMesh *bm, } for (el_store_ring = eloops_ring->first; el_store_ring; - el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) { + el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) + { ListBase *lb_ring = BM_edgeloop_verts_get(el_store_ring); LinkData *v_iter; @@ -709,7 +710,8 @@ static void bm_edgering_pair_interpolate(BMesh *bm, tri_end = tri_array[resolu - 1]; for (el_store_ring = eloops_ring->first; el_store_ring; - el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) { + el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) + { ListBase *lb_ring = BM_edgeloop_verts_get(el_store_ring); LinkData *v_iter; @@ -718,7 +720,8 @@ static void bm_edgering_pair_interpolate(BMesh *bm, /* skip first and last */ for (v_iter = ((LinkData *)lb_ring->first)->next, i = 1; v_iter != lb_ring->last; - v_iter = v_iter->next, i++) { + v_iter = v_iter->next, i++) + { float co_a[3], co_b[3]; tri_tmp = tri_array[i]; @@ -740,7 +743,8 @@ static void bm_edgering_pair_interpolate(BMesh *bm, /* calculate a bezier handle per edge ring */ for (el_store_ring = eloops_ring->first; el_store_ring; - el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) { + el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) + { ListBase *lb_ring = BM_edgeloop_verts_get(el_store_ring); LinkData *v_iter; @@ -790,7 +794,8 @@ static void bm_edgering_pair_interpolate(BMesh *bm, /* skip first and last */ for (v_iter = ((LinkData *)lb_ring->first)->next, i = 1; v_iter != lb_ring->last; - v_iter = v_iter->next, i++) { + v_iter = v_iter->next, i++) + { if (i > 0 && i < resolu - 1) { copy_v3_v3(((BMVert *)v_iter->data)->co, coord_array[i]); @@ -1030,7 +1035,8 @@ static void bm_edgering_pair_subdiv(BMesh *bm, /* Clear tags so subdiv verts don't get tagged too. */ for (el_store_ring = eloops_ring->first; el_store_ring; - el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) { + el_store_ring = BM_EDGELOOP_NEXT(el_store_ring)) + { bm_edgeloop_vert_tag(el_store_ring, false); } diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 9109a8eda42..bedba53b4e8 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -229,8 +229,8 @@ static void bmo_region_extend_expand(BMesh *bm, BMEdge *e; BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { if (BM_edge_is_wire(e)) { - if (!BMO_edge_flag_test(bm, e, SEL_FLAG) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { + if (!BMO_edge_flag_test(bm, e, SEL_FLAG) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + { BMO_edge_flag_enable(bm, e, SEL_FLAG); BMO_vert_flag_enable(bm, BM_edge_other_vert(e, v), SEL_FLAG); } @@ -255,7 +255,8 @@ static void bmo_region_extend_expand(BMesh *bm, BM_ITER_ELEM (f_other, &fiter, l->e, BM_FACES_OF_EDGE) { if (!BMO_face_flag_test(bm, f_other, SEL_ORIG | SEL_FLAG) && - !BM_elem_flag_test(f_other, BM_ELEM_HIDDEN)) { + !BM_elem_flag_test(f_other, BM_ELEM_HIDDEN)) + { BMO_face_flag_enable(bm, f_other, SEL_FLAG); } } @@ -266,7 +267,8 @@ static void bmo_region_extend_expand(BMesh *bm, BM_ITER_ELEM (f_other, &fiter, l->v, BM_FACES_OF_VERT) { if (!BMO_face_flag_test(bm, f_other, SEL_ORIG | SEL_FLAG) && - !BM_elem_flag_test(f_other, BM_ELEM_HIDDEN)) { + !BM_elem_flag_test(f_other, BM_ELEM_HIDDEN)) + { BMO_face_flag_enable(bm, f_other, SEL_FLAG); } } diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c index 3cb5d3513e3..8dc074cc885 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.c +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -182,7 +182,8 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3], * so the rotation calculation is scale independent. */ if (!(signum_i_ex(cross_tri_v2(v2_xy, v3_xy, v4_xy) / no_scale, eps) + - signum_i_ex(cross_tri_v2(v2_xy, v4_xy, v1_xy) / no_scale, eps))) { + signum_i_ex(cross_tri_v2(v2_xy, v4_xy, v1_xy) / no_scale, eps))) + { break; } } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 5118eb792d5..04aa678b6a6 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -775,7 +775,8 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f for (int i = 0; i < bm->ldata.totlayer; i++) { if (CustomData_layer_has_math(&bm->ldata, i)) { if (!contig_ldata_across_loops(bm, lv1f1, lv1f2, i) || - !contig_ldata_across_loops(bm, lv2f1, lv2f2, i)) { + !contig_ldata_across_loops(bm, lv2f1, lv2f2, i)) + { return false; } } @@ -1843,7 +1844,8 @@ static void move_profile_plane(BoundVert *bndv, BMVert *bmvert) cross_v3_v3v3(no3, d2, pro->proj_dir); if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG && - normalize_v3(no3) > BEVEL_EPSILON_BIG) { + normalize_v3(no3) > BEVEL_EPSILON_BIG) + { float dot2 = dot_v3v3(no, no2); float dot3 = dot_v3v3(no, no3); if (fabsf(dot2) < (1 - BEVEL_EPSILON_BIG) && fabsf(dot3) < (1 - BEVEL_EPSILON_BIG)) { @@ -2273,7 +2275,8 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) /* First edge with seam or sharp edge data. */ while ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || - (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) { + (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) + { e = e->next; if (e == efirst) { break; @@ -2295,14 +2298,16 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) while (((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(ne, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(ne, flag))) && - ne != efirst) { + ne != efirst) + { if (ne->is_bev) { flag_count++; } ne = ne->next; } if (ne == e || (ne == efirst && ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag)) || - (neg && BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag))))) { + (neg && BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag))))) + { break; } /* Set seam_len / sharp_len of starting edge. */ @@ -3087,7 +3092,8 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) * and emiter will be set to the first edge of such an edge. * A miter kind of BEVEL_MITER_SHARP means no special miter */ if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == ANGLE_LARGER) || - (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) { + (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) + { if (ang_kind == ANGLE_LARGER) { emiter = e; } @@ -3160,7 +3166,8 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) else { /* construct == false. */ AngleKind ang_kind = edges_angle_kind(e, e2, bv->v); if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == ANGLE_LARGER) || - (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) { + (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) + { if (ang_kind == ANGLE_LARGER) { emiter = e; } @@ -4494,7 +4501,8 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv) } float angdiff = fabsf(fabsf(totang) - 3.0f * (float)M_PI_2); if ((bp->pro_super_r == PRO_SQUARE_R && angdiff > (float)M_PI / 16.0f) || - (angdiff > (float)M_PI_4)) { + (angdiff > (float)M_PI_4)) + { return -1; } if (bv->edgecount != 3 || bv->selcount != 3) { @@ -5358,7 +5366,8 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert VMesh *vm1; if (bp->pro_super_r == PRO_SQUARE_R && bv->selcount >= 3 && !odd && - bp->profile_type != BEVEL_PROFILE_CUSTOM) { + bp->profile_type != BEVEL_PROFILE_CUSTOM) + { vm1 = square_out_adj_vmesh(bp, bv); } else if (vpipe) { @@ -6112,7 +6121,8 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i) BM_BEVEL_EDGE_TAG_ENABLE(nextbme); int tryj = bevel_edge_order_extend(bm, bv, j + 1); if (tryj > bestj || - (tryj == bestj && edges_face_connected_at_vert(bv->edges[tryj].e, bv->edges[0].e))) { + (tryj == bestj && edges_face_connected_at_vert(bv->edges[tryj].e, bv->edges[0].e))) + { bestj = tryj; BLI_array_clear(save_path); for (int k = j + 1; k <= bestj; k++) { @@ -6171,7 +6181,8 @@ static bool fast_bevel_edge_order(BevVert *bv) } } if (nsucs == 0 || (nsucs == 2 && j != 1) || nsucs > 2 || - (j == bv->edgecount - 1 && !edges_face_connected_at_vert(bmenext, bv->edges[0].e))) { + (j == bv->edgecount - 1 && !edges_face_connected_at_vert(bmenext, bv->edges[0].e))) + { for (int k = 1; k < j; k++) { BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[k].e); bv->edges[k].e = NULL; @@ -6351,7 +6362,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } if ((nsel == 0 && bp->affect_type != BEVEL_AFFECT_VERTICES) || - (tot_edges < 2 && bp->affect_type == BEVEL_AFFECT_VERTICES)) { + (tot_edges < 2 && bp->affect_type == BEVEL_AFFECT_VERTICES)) + { /* Signal this vert isn't being beveled. */ BM_elem_flag_disable(v, BM_ELEM_TAG); return NULL; @@ -6749,8 +6761,8 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) /* Want to undo seam and smooth for corner segments * if those attrs aren't contiguous around face. */ if (k < n - 1 && ee[k] == ee[k + 1]) { - if (BM_elem_flag_test(ee[k], BM_ELEM_SEAM) && - !BM_elem_flag_test(bme_prev, BM_ELEM_SEAM)) { + if (BM_elem_flag_test(ee[k], BM_ELEM_SEAM) && !BM_elem_flag_test(bme_prev, BM_ELEM_SEAM)) + { BM_elem_flag_disable(bme_new, BM_ELEM_SEAM); } /* Actually want "sharp" to be contiguous, so reverse the test. */ @@ -7806,7 +7818,8 @@ void BM_mesh_bevel(BMesh *bm, /* Get separate non-custom profile samples for the miter profiles if they are needed */ if (bp.profile_type == BEVEL_PROFILE_CUSTOM && - (bp.miter_inner != BEVEL_MITER_SHARP || bp.miter_outer != BEVEL_MITER_SHARP)) { + (bp.miter_inner != BEVEL_MITER_SHARP || bp.miter_outer != BEVEL_MITER_SHARP)) + { set_profile_spacing(&bp, &bp.pro_spacing_miter, false); } diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 444f45277ca..52e8a42391f 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -348,7 +348,8 @@ static void bm_face_bisect_verts( /* It would be nice to avoid loop lookup here, * but we need to know which face the verts are in. */ if ((l_a = BM_face_vert_share_loop(face_split_arr[j], v_a)) && - (l_b = BM_face_vert_share_loop(face_split_arr[j], v_b))) { + (l_b = BM_face_vert_share_loop(face_split_arr[j], v_b))) + { found = true; break; } diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index e09b8130f40..5caf47c7235 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -112,7 +112,8 @@ static bool bmvert_attached_to_hidden_face(BMVert *bmv) BMIter iter; for (BMFace *bmf = static_cast(BM_iter_new(&iter, nullptr, BM_FACES_OF_VERT, bmv)); bmf; - bmf = static_cast(BM_iter_step(&iter))) { + bmf = static_cast(BM_iter_step(&iter))) + { if (BM_elem_flag_test(bmf, BM_ELEM_HIDDEN)) { return true; } @@ -155,7 +156,8 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden BMVert *bmv = BM_vert_at_index(bm, v); if ((keep_hidden && (BM_elem_flag_test(bmv, BM_ELEM_HIDDEN) || bmvert_attached_to_hidden_face(bmv))) || - bmvert_attached_to_wire(bmv)) { + bmvert_attached_to_wire(bmv)) + { BM_elem_flag_enable(bmv, KEEP_FLAG); } else { diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index 082c5821404..c5d4defa887 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -181,7 +181,8 @@ static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_ /* avoid normalize */ if (dot_v3v3(cross_exist, cross_optim) <= - (len_squared_v3(cross_exist) + len_squared_v3(cross_optim)) * 0.01f) { + (len_squared_v3(cross_exist) + len_squared_v3(cross_optim)) * 0.01f) + { return true; } #else @@ -232,7 +233,8 @@ static void bm_decim_build_edge_cost_single(BMEdge *e, float cost; if (UNLIKELY(vweights && ((vweights[BM_elem_index_get(e->v1)] == 0.0f) || - (vweights[BM_elem_index_get(e->v2)] == 0.0f)))) { + (vweights[BM_elem_index_get(e->v2)] == 0.0f)))) + { goto clear; } @@ -300,7 +302,8 @@ static void bm_decim_build_edge_cost_single(BMEdge *e, } else #endif - if (vweights) { + if (vweights) + { const float e_weight = 2.0f - (vweights[BM_elem_index_get(e->v1)] + vweights[BM_elem_index_get(e->v2)]); if (e_weight) { @@ -372,13 +375,15 @@ static bool bm_edge_symmetry_check_cb(void *user_data, if (dot_v3v3(e_other_dir, sym_data->e_dir) > 0.0f) { if ((len_squared_v3v3(sym_data->e_v1_co, e_other->v1->co) > sym_data->limit_sq) || - (len_squared_v3v3(sym_data->e_v2_co, e_other->v2->co) > sym_data->limit_sq)) { + (len_squared_v3v3(sym_data->e_v2_co, e_other->v2->co) > sym_data->limit_sq)) + { return true; } } else { if ((len_squared_v3v3(sym_data->e_v1_co, e_other->v2->co) > sym_data->limit_sq) || - (len_squared_v3v3(sym_data->e_v2_co, e_other->v1->co) > sym_data->limit_sq)) { + (len_squared_v3v3(sym_data->e_v2_co, e_other->v1->co) > sym_data->limit_sq)) + { return true; } } @@ -620,7 +625,8 @@ static void bm_decim_triangulate_end(BMesh *bm, const int edges_tri_tot) if ((l_a->f->len == 3 && l_b->f->len == 3) && !CAN_LOOP_MERGE(l_a->next) && !CAN_LOOP_MERGE(l_a->prev) && !CAN_LOOP_MERGE(l_b->next) && - !CAN_LOOP_MERGE(l_b->prev)) { + !CAN_LOOP_MERGE(l_b->prev)) + { BMVert *vquad[4] = { e->v1, BM_vert_in_edge(e, l_a->next->v) ? l_a->prev->v : l_a->next->v, @@ -989,7 +995,8 @@ static bool bm_edge_collapse(BMesh *bm, #endif /* not totally common but we want to avoid */ if (ELEM(e_a_other[0], e_b_other[0], e_b_other[1]) || - ELEM(e_a_other[1], e_b_other[0], e_b_other[1])) { + ELEM(e_a_other[1], e_b_other[0], e_b_other[1])) + { return false; } @@ -1173,7 +1180,8 @@ static bool bm_decim_edge_collapse(BMesh *bm, edge_symmetry_map, #endif customdata_flag, - customdata_fac)) { + customdata_fac)) + { /* update collapse info */ int i; @@ -1335,7 +1343,8 @@ void BM_mesh_decimate_collapse(BMesh *bm, { /* simple non-mirror case */ while ((bm->totface > face_tot_target) && (BLI_heap_is_empty(eheap) == false) && - (BLI_heap_top_value(eheap) != COST_INVALID)) { + (BLI_heap_top_value(eheap) != COST_INVALID)) + { // const float value = BLI_heap_node_value(BLI_heap_top(eheap)); BMEdge *e = BLI_heap_pop_min(eheap); float optimize_co[3]; @@ -1364,7 +1373,8 @@ void BM_mesh_decimate_collapse(BMesh *bm, #ifdef USE_SYMMETRY else { while ((bm->totface > face_tot_target) && (BLI_heap_is_empty(eheap) == false) && - (BLI_heap_top_value(eheap) != COST_INVALID)) { + (BLI_heap_top_value(eheap) != COST_INVALID)) + { /** * \note * - `eheap_table[e_index_mirr]` is only removed from the heap at the last moment @@ -1442,7 +1452,8 @@ void BM_mesh_decimate_collapse(BMesh *bm, edge_symmetry_map, customdata_flag, optimize_co, - false)) { + false)) + { if (e_mirr && (eheap_table[e_index_mirr])) { BLI_assert(e_index_mirr != e_index); BLI_heap_remove(eheap, eheap_table[e_index_mirr]); diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index 11adeaf5c10..e118496f0c2 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -73,7 +73,8 @@ static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, int cd_loop_offset; for (cd_loop_offset = delimit_data->cd_loop_offset; cd_loop_offset < delimit_data->cd_loop_offset_end; - cd_loop_offset += delimit_data->cd_loop_size) { + cd_loop_offset += delimit_data->cd_loop_size) + { if (BM_edge_is_contiguous_loop_cd(e, delimit_data->cd_loop_type, cd_loop_offset) == false) { return false; } @@ -199,7 +200,8 @@ static bool bm_loop_collapse_is_degenerate(BMLoop *l_ear) if (!BM_vert_is_edge_pair(l_ear->prev->v)) { mul_v2_m3v3_center(adjacent_2d, axis_mat, l_ear->prev->prev->v->co, center); if (signum_i(cross_tri_v2(adjacent_2d, tri_2d[0], tri_2d[1])) != - signum_i(cross_tri_v2(adjacent_2d, tri_2d[0], tri_2d[2]))) { + signum_i(cross_tri_v2(adjacent_2d, tri_2d[0], tri_2d[2]))) + { return true; } } @@ -207,7 +209,8 @@ static bool bm_loop_collapse_is_degenerate(BMLoop *l_ear) if (!BM_vert_is_edge_pair(l_ear->next->v)) { mul_v2_m3v3_center(adjacent_2d, axis_mat, l_ear->next->next->v->co, center); if (signum_i(cross_tri_v2(adjacent_2d, tri_2d[2], tri_2d[1])) != - signum_i(cross_tri_v2(adjacent_2d, tri_2d[2], tri_2d[0]))) { + signum_i(cross_tri_v2(adjacent_2d, tri_2d[2], tri_2d[0]))) + { return true; } } @@ -330,7 +333,8 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, } while ((BLI_heap_is_empty(eheap) == false) && - (BLI_heap_node_value(enode_top = BLI_heap_top(eheap)) < angle_limit_cos_neg)) { + (BLI_heap_node_value(enode_top = BLI_heap_top(eheap)) < angle_limit_cos_neg)) + { BMFace *f_new = NULL; BMEdge *e; @@ -451,7 +455,8 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, } while ((BLI_heap_is_empty(vheap) == false) && - (BLI_heap_node_value(vnode_top = BLI_heap_top(vheap)) < angle_limit)) { + (BLI_heap_node_value(vnode_top = BLI_heap_top(vheap)) < angle_limit)) + { BMEdge *e_new = NULL; BMVert *v; @@ -464,7 +469,8 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, #else BM_vert_is_edge_pair(v) #endif - ) { + ) + { e_new = BM_vert_collapse_edge(bm, v->e, v, true, true, true); /* join edges */ if (e_new) { diff --git a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c index 02f0a25ea06..4b874d6d218 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c +++ b/source/blender/bmesh/tools/bmesh_decimate_unsubdivide.c @@ -50,7 +50,8 @@ static bool bm_vert_dissolve_fan_test(BMVert *v) if (((tot_edge == 4) && (tot_edge_boundary == 0) && (tot_edge_manifold == 4)) || ((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) || - ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1))) { + ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1))) + { if (!BM_face_exists(varr, tot_edge)) { return true; } diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c b/source/blender/bmesh/tools/bmesh_edgenet.c index 020f2613f7d..9226af36974 100644 --- a/source/blender/bmesh/tools/bmesh_edgenet.c +++ b/source/blender/bmesh/tools/bmesh_edgenet.c @@ -213,7 +213,8 @@ begin: /* flush flag down the path */ vn_next->flag &= ~VNINFO_FLAG_IS_MIXFACE; if ((vn_curr->flag & VNINFO_FLAG_IS_MIXFACE) || (vn_next->face == -1) || - (vn_next->face != vn_curr->face)) { + (vn_next->face != vn_curr->face)) + { vn_next->flag |= VNINFO_FLAG_IS_MIXFACE; } diff --git a/source/blender/bmesh/tools/bmesh_edgesplit.c b/source/blender/bmesh/tools/bmesh_edgesplit.c index 03ff6b39d0e..bec5df5dd4b 100644 --- a/source/blender/bmesh/tools/bmesh_edgesplit.c +++ b/source/blender/bmesh/tools/bmesh_edgesplit.c @@ -52,7 +52,8 @@ void BM_mesh_edgesplit(BMesh *bm, BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { if (UNLIKELY((BM_elem_flag_test(e->v1, BM_ELEM_TAG) == false) && - (BM_elem_flag_test(e->v2, BM_ELEM_TAG) == false))) { + (BM_elem_flag_test(e->v2, BM_ELEM_TAG) == false))) + { BM_elem_flag_enable(e->v1, BM_ELEM_TAG); BM_elem_flag_enable(e->v2, BM_ELEM_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c index 0a668342ab4..ce1ed86e7fc 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.c +++ b/source/blender/bmesh/tools/bmesh_intersect.c @@ -234,7 +234,8 @@ static void face_edges_split(BMesh *bm, use_partial_connect, mem_arena_edgenet, &edge_arr_holes, - &edge_arr_holes_len)) { + &edge_arr_holes_len)) + { edge_arr_len = edge_arr_holes_len; edge_arr = edge_arr_holes; /* owned by the arena */ } @@ -294,8 +295,8 @@ static enum ISectType intersect_line_tri(const float p0[3], copy_v3_v3(ix_pair[1], ix_pair[0]); } - if ((ix_pair_type == 1) || - (len_squared_v3v3(ix_pair[0], ix_pair[1]) <= e->eps_margin_sq)) { + if ((ix_pair_type == 1) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) <= e->eps_margin_sq)) + { fac = line_point_factor_v3(ix_pair[1], t_cos[i_t0], t_cos[i_t1]); if ((fac >= e->eps_margin) && (fac <= 1.0f - e->eps_margin)) { fac = line_point_factor_v3(ix_pair[0], p0, p1); @@ -311,13 +312,14 @@ static enum ISectType intersect_line_tri(const float p0[3], /* check ray isn't planar with tri */ if (fabsf(dot_v3v3(p_dir, t_nor)) >= e->eps) { - if (isect_line_segment_tri_epsilon_v3( - p0, p1, t_cos[0], t_cos[1], t_cos[2], &fac, NULL, 0.0f)) { + if (isect_line_segment_tri_epsilon_v3(p0, p1, t_cos[0], t_cos[1], t_cos[2], &fac, NULL, 0.0f)) + { if ((fac >= e->eps_margin) && (fac <= 1.0f - e->eps_margin)) { interp_v3_v3v3(r_ix, p0, p1, fac); if (min_fff(len_squared_v3v3(t_cos[0], r_ix), len_squared_v3v3(t_cos[1], r_ix), - len_squared_v3v3(t_cos[2], r_ix)) >= e->eps_margin_sq) { + len_squared_v3v3(t_cos[2], r_ix)) >= e->eps_margin_sq) + { return IX_EDGE_TRI; } } @@ -513,7 +515,8 @@ static void bm_isect_tri_tri( if (no_shared) { if (UNLIKELY(ELEM(fv_a[0], UNPACK3(fv_b)) || ELEM(fv_a[1], UNPACK3(fv_b)) || - ELEM(fv_a[2], UNPACK3(fv_b)))) { + ELEM(fv_a[2], UNPACK3(fv_b)))) + { return; } } @@ -580,7 +583,8 @@ static void bm_isect_tri_tri( uint i_b_e1 = (i_b_e0 + 1) % 3; if (BM_ELEM_API_FLAG_TEST(fv_b[i_b_e0], VERT_VISIT_B) || - BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) { + BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) + { continue; } @@ -622,7 +626,8 @@ static void bm_isect_tri_tri( uint i_a_e1 = (i_a_e0 + 1) % 3; if (BM_ELEM_API_FLAG_TEST(fv_a[i_a_e0], VERT_VISIT_A) || - BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) { + BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) + { continue; } @@ -732,7 +737,8 @@ static void bm_isect_tri_tri( BMVert *iv; if (BM_ELEM_API_FLAG_TEST(fv_a[i_a_e0], VERT_VISIT_A) || - BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) { + BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) + { continue; } @@ -753,7 +759,8 @@ static void bm_isect_tri_tri( BMVert *iv; if (BM_ELEM_API_FLAG_TEST(fv_b[i_b_e0], VERT_VISIT_B) || - BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) { + BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) + { continue; } @@ -855,7 +862,8 @@ static void raycast_callback(void *userdata, # else isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON) # endif - ) { + ) + { if (dist >= 0.0f) { # ifdef USE_DUMP printf("%s:\n", __func__); @@ -1194,7 +1202,8 @@ bool BM_mesh_intersect(BMesh *bm, BLI_assert(BM_vert_in_edge(e, v_end)); if (!BM_edge_exists(v_prev, vi) && !BM_vert_splice_check_double(v_prev, vi) && - !BM_vert_pair_share_face_check(v_prev, vi)) { + !BM_vert_pair_share_face_check(v_prev, vi)) + { BM_vert_splice(bm, vi, v_prev); } else { @@ -1409,7 +1418,8 @@ bool BM_mesh_intersect(BMesh *bm, uint i; for (i = 0; i < STACK_SIZE(splice_ls); i++) { if (!BLI_gset_haskey(verts_invalid, splice_ls[i][0]) && - !BLI_gset_haskey(verts_invalid, splice_ls[i][1])) { + !BLI_gset_haskey(verts_invalid, splice_ls[i][1])) + { if (!BM_edge_exists(UNPACK2(splice_ls[i])) && !BM_vert_splice_check_double(UNPACK2(splice_ls[i]))) { BM_vert_splice(bm, splice_ls[i][1], splice_ls[i][0]); diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.c b/source/blender/bmesh/tools/bmesh_intersect_edges.c index fbd27bda766..b1ade4fab6c 100644 --- a/source/blender/bmesh/tools/bmesh_intersect_edges.c +++ b/source/blender/bmesh/tools/bmesh_intersect_edges.c @@ -408,7 +408,8 @@ static bool bm_edgexedge_isect_cb(void *userdata, int index_a, int index_b, int if (isect_ray_ray_epsilon_v3(co_a, dir_a, co_b, dir_b, data->dist_sq_sq, &lambda_a, &lambda_b)) { struct EDBMSplitElem pair_tmp[2]; if (bm_edgexedge_isect_impl( - data, e_a, e_b, co_a, dir_a, co_b, dir_b, lambda_a, lambda_b, pair_tmp)) { + data, e_a, e_b, co_a, dir_a, co_b, dir_b, lambda_a, lambda_b, pair_tmp)) + { struct EDBMSplitElem *pair = BLI_stack_push_r(data->pair_stack[thread]); pair[0] = pair_tmp[0]; pair[1] = pair_tmp[1]; @@ -569,8 +570,8 @@ bool BM_mesh_intersect_edges( /* Tag and count the edges. */ int edges_act_len = 0, edges_remain_len = 0; BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) || - (len_squared_v3v3(e->v1->co, e->v2->co) < dist_sq)) { + if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) || (len_squared_v3v3(e->v1->co, e->v2->co) < dist_sq)) + { /* Don't test hidden edges or smaller than the minimum distance. * These have already been handled in the vertices overlap. */ BM_elem_index_set(e, 0); diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c index 5b86b06aa50..c089577a3bc 100644 --- a/source/blender/bmesh/tools/bmesh_path_region.c +++ b/source/blender/bmesh/tools/bmesh_path_region.c @@ -80,7 +80,8 @@ static bool bm_vert_region_test_chain(BMVert *v, int *const depths[2], const int } if (BM_vert_is_edge_pair_manifold(v) && bm_vert_pair_ends(v, v_end_pair) && bm_vert_region_test(v_end_pair[0], depths, pass) && - bm_vert_region_test(v_end_pair[1], depths, pass)) { + bm_vert_region_test(v_end_pair[1], depths, pass)) + { return true; } diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.c b/source/blender/bmesh/tools/bmesh_path_region_uv.c index 25637fae949..b5a1eca77c2 100644 --- a/source/blender/bmesh/tools/bmesh_path_region_uv.c +++ b/source/blender/bmesh/tools/bmesh_path_region_uv.c @@ -78,7 +78,8 @@ static bool bm_loop_region_test_chain(BMLoop *l, int *const depths[2], const int } if (BM_vert_is_edge_pair_manifold(l->v) && bm_loop_pair_ends(l, l_end_pair) && bm_loop_region_test(l_end_pair[0], depths, pass) && - bm_loop_region_test(l_end_pair[1], depths, pass)) { + bm_loop_region_test(l_end_pair[1], depths, pass)) + { return true; } @@ -249,7 +250,8 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, while (BM_vert_is_edge_pair_manifold(l_b->v) && ((depths[side][l_b_index] == -1) && /* Don't walk back to the beginning */ - (l_b != (j ? l_iter->prev : l_iter->next)))) { + (l_b != (j ? l_iter->prev : l_iter->next)))) + { depths[side][l_b_index] = pass; l_b = j ? l_b->next : l_b->prev; diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index fe16c098c21..119dbc4d04d 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -499,7 +499,8 @@ static void bm_uuidwalk_pass_add(UUIDWalk *uuidwalk, void **val_p; if (!BLI_ghash_haskey(uuidwalk->verts_uuid, l_iter->v) && !BLI_ghash_ensure_p(verts_uuid_pass, l_iter->v, &val_p) && - (bm_vert_is_uuid_connect(uuidwalk, l_iter->v) == true)) { + (bm_vert_is_uuid_connect(uuidwalk, l_iter->v) == true)) + { const UUID_Int uuid = bm_uuidwalk_calc_vert_uuid(uuidwalk, l_iter->v); *val_p = (void *)uuid; } @@ -510,7 +511,8 @@ static void bm_uuidwalk_pass_add(UUIDWalk *uuidwalk, do { if (!BLI_ghash_haskey(uuidwalk->faces_uuid, l_iter_radial->f) && !BLI_gset_haskey(faces_step_next, l_iter_radial->f) && - bm_uuidwalk_face_test(uuidwalk, l_iter_radial->f)) { + bm_uuidwalk_face_test(uuidwalk, l_iter_radial->f)) + { BLI_gset_insert(faces_step_next, l_iter_radial->f); /* add to fstep */ @@ -771,13 +773,15 @@ static BMFace **bm_mesh_region_match_pair( UUIDFaceStepItem *fstep_item_dst; for (fstep_item_src = fstep_src->items.first, fstep_item_dst = fstep_dst->items.first; fstep_item_src && fstep_item_dst; - fstep_item_src = fstep_item_src->next, fstep_item_dst = fstep_item_dst->next) { + fstep_item_src = fstep_item_src->next, fstep_item_dst = fstep_item_dst->next) + { while ((fstep_item_dst != NULL) && (fstep_item_dst->uuid < fstep_item_src->uuid)) { fstep_item_dst = fstep_item_dst->next; } if ((fstep_item_dst == NULL) || (fstep_item_src->uuid != fstep_item_dst->uuid) || - (fstep_item_src->list_len > fstep_item_dst->list_len)) { + (fstep_item_src->list_len > fstep_item_dst->list_len)) + { /* if the target walker has less than the source * then the islands don't match, bail early */ ok = false; @@ -935,7 +939,8 @@ static void bm_face_region_pivot_edge_use_best(GHash *gh, if ((*r_e_pivot_best == NULL) || ((e_pivot_best_id[0] != e_pivot_test_id[0]) ? (e_pivot_best_id[0] < e_pivot_test_id[0]) : - (e_pivot_best_id[1] < e_pivot_test_id[1]))) { + (e_pivot_best_id[1] < e_pivot_test_id[1]))) + { e_pivot_best_id[0] = e_pivot_test_id[0]; e_pivot_best_id[1] = e_pivot_test_id[1]; diff --git a/source/blender/compositor/intern/COM_ConstantFolder.cc b/source/blender/compositor/intern/COM_ConstantFolder.cc index 5cbacd5376f..8cda97a13bc 100644 --- a/source/blender/compositor/intern/COM_ConstantFolder.cc +++ b/source/blender/compositor/intern/COM_ConstantFolder.cc @@ -26,7 +26,8 @@ static bool is_constant_foldable(NodeOperation *operation) for (int i = 0; i < operation->get_number_of_input_sockets(); i++) { NodeOperation *input = operation->get_input_operation(i); if (!input->get_flags().is_constant_operation || - !static_cast(input)->can_get_constant_elem()) { + !static_cast(input)->can_get_constant_elem()) + { return false; } } diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index a670af5eaca..ebe9b7fe2ea 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -457,9 +457,9 @@ void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render) const std::string file_name = operation_class_name(op) + "_" + std::to_string(op->get_id()) + ".png"; - const std::string path = get_operations_export_dir() + file_name; - BLI_make_existing_file(path.c_str()); - IMB_saveiff(ibuf, path.c_str(), ibuf->flags); + const std::string filepath = get_operations_export_dir() + file_name; + BLI_file_ensure_parent_dir_exists(filepath.c_str()); + IMB_saveiff(ibuf, filepath.c_str(), ibuf->flags); IMB_freeImBuf(ibuf); } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index 7ec204bf862..ae24770a317 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -103,7 +103,8 @@ bool ExecutionGroup::add_operation(NodeOperation *operation) } if (!operation->get_flags().is_read_buffer_operation && - !operation->get_flags().is_write_buffer_operation) { + !operation->get_flags().is_write_buffer_operation) + { flags_.complex = operation->get_flags().complex; flags_.open_cl = operation->get_flags().open_cl; flags_.single_threaded = operation->get_flags().single_threaded; @@ -117,8 +118,8 @@ bool ExecutionGroup::add_operation(NodeOperation *operation) NodeOperation *ExecutionGroup::get_output_operation() const { - return this - ->operations_[0]; /* the first operation of the group is always the output operation. */ + /* The first operation of the group is always the output operation. */ + return this->operations_[0]; } void ExecutionGroup::init_work_packages() @@ -323,7 +324,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) int number_evaluated = 0; for (int index = start_index; index < chunks_len_ && number_evaluated < max_number_evaluated; - index++) { + index++) + { chunk_index = chunk_order[index]; int y_chunk = chunk_index / x_chunks_len_; int x_chunk = chunk_index - (y_chunk * x_chunks_len_); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 539e1179bc8..edff127c6c0 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -208,7 +208,8 @@ void MemoryBuffer::copy_from(const MemoryBuffer *src, copy_single_elem_from(src, channel_offset, elem_size, to_channel_offset); } else if (!src->is_a_single_elem() && elem_size == src->get_num_channels() && - elem_size == this->get_num_channels()) { + elem_size == this->get_num_channels()) + { BLI_assert(to_channel_offset == 0); BLI_assert(channel_offset == 0); copy_rows_from(src, area, to_x, to_y); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 701ef9679c9..19c403ab105 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -535,7 +535,8 @@ class MemoryBuffer { float v = y; this->wrap_pixel(u, v, extend_x, extend_y); if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= get_width())) || - (extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= get_height()))) { + (extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= get_height()))) + { copy_vn_fl(result, num_channels_, 0.0f); return; } diff --git a/source/blender/compositor/intern/COM_NodeGraph.cc b/source/blender/compositor/intern/COM_NodeGraph.cc index c4f840cde4e..008a5a8dbec 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.cc +++ b/source/blender/compositor/intern/COM_NodeGraph.cc @@ -151,7 +151,8 @@ void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink return; } if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL) || - (b_nodelink->flag & NODE_LINK_MUTED)) { + (b_nodelink->flag & NODE_LINK_MUTED)) + { return; } @@ -219,7 +220,8 @@ void NodeGraph::add_proxies_group_inputs(bNode *b_node, bNode *b_node_io) bool is_active_group = false; for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io; - b_sock_io = b_sock_io->next) { + b_sock_io = b_sock_io->next) + { bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier); if (b_sock_group) { SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io, true); @@ -240,11 +242,13 @@ void NodeGraph::add_proxies_group_outputs(const CompositorContext &context, bool is_active_group = false; for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->inputs.first; b_sock_io; - b_sock_io = b_sock_io->next) { + b_sock_io = b_sock_io->next) + { bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier); if (b_sock_group) { if (context.is_groupnode_buffer_enabled() && - context.get_execution_model() == eExecutionModel::Tiled) { + context.get_execution_model() == eExecutionModel::Tiled) + { SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group); add_node(buffer, b_group_tree, key, is_active_group); } diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc index ab9b5ad1ad6..39e8bf8fe80 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cc +++ b/source/blender/compositor/intern/COM_NodeOperation.cc @@ -225,8 +225,9 @@ bool NodeOperation::determine_depending_area_of_interest(rcti *input, bool first = true; for (int i = 0; i < get_number_of_input_sockets(); i++) { NodeOperation *input_operation = this->get_input_operation(i); - if (input_operation && input_operation->determine_depending_area_of_interest( - input, read_operation, &temp_output)) { + if (input_operation && + input_operation->determine_depending_area_of_interest(input, read_operation, &temp_output)) + { if (first) { output->xmin = temp_output.xmin; output->ymin = temp_output.ymin; diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index 9a98e191d4f..e33794f2a01 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -385,7 +385,8 @@ void NodeOperationBuilder::resolve_proxies() for (const Link &link : links_) { /* don't replace links from proxy to proxy, since we may need them for replacing others! */ if (link.from()->get_operation().get_flags().is_proxy_operation && - !link.to()->get_operation().get_flags().is_proxy_operation) { + !link.to()->get_operation().get_flags().is_proxy_operation) + { proxy_links.append(link); } } @@ -413,8 +414,8 @@ void NodeOperationBuilder::determine_canvases() /* Determine all canvas areas of the operations. */ const rcti &preferred_area = COM_AREA_NONE; for (NodeOperation *op : operations_) { - if (op->is_output_operation(context_->is_rendering()) && - !op->get_flags().is_preview_operation) { + if (op->is_output_operation(context_->is_rendering()) && !op->get_flags().is_preview_operation) + { rcti canvas = COM_AREA_NONE; op->determine_canvas(preferred_area, canvas); op->set_canvas(canvas); @@ -422,8 +423,8 @@ void NodeOperationBuilder::determine_canvases() } for (NodeOperation *op : operations_) { - if (op->is_output_operation(context_->is_rendering()) && - op->get_flags().is_preview_operation) { + if (op->is_output_operation(context_->is_rendering()) && op->get_flags().is_preview_operation) + { rcti canvas = COM_AREA_NONE; op->determine_canvas(preferred_area, canvas); op->set_canvas(canvas); diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cc b/source/blender/compositor/intern/COM_WorkScheduler.cc index 539d23ff6b5..56ac192724e 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cc +++ b/source/blender/compositor/intern/COM_WorkScheduler.cc @@ -129,7 +129,8 @@ static void opencl_start(const CompositorContext &context) static bool opencl_schedule(WorkPackage *package) { if (package->type == eWorkPackageType::Tile && package->execution_group->get_flags().open_cl && - g_work_scheduler.opencl.active) { + g_work_scheduler.opencl.active) + { BLI_thread_queue_push(g_work_scheduler.opencl.queue, package); return true; } diff --git a/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc b/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc index d26b649e30b..a0f6d946770 100644 --- a/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc +++ b/source/blender/compositor/nodes/COM_ConvertColorSpaceNode.cc @@ -71,7 +71,8 @@ bool ConvertColorSpaceNode::performs_conversion(NodeConvertColorSpace &settings) } if (STREQLEN( - settings.from_color_space, settings.to_color_space, sizeof(settings.from_color_space))) { + settings.from_color_space, settings.to_color_space, sizeof(settings.from_color_space))) + { CLOG_INFO(&LOG, 2, "Color space conversion bypassed for node: %s. To and from are the same: %s.", diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cc b/source/blender/compositor/nodes/COM_CryptomatteNode.cc index ee31fce0ea8..74b709099ed 100644 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cc +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cc @@ -171,7 +171,8 @@ void CryptomatteNode::input_operations_from_image_source( int layer_index; LISTBASE_FOREACH_INDEX (RenderLayer *, render_layer, &image->rr->layers, layer_index) { if (!blender::StringRef(prefix).startswith(blender::StringRef( - render_layer->name, BLI_strnlen(render_layer->name, sizeof(render_layer->name))))) { + render_layer->name, BLI_strnlen(render_layer->name, sizeof(render_layer->name))))) + { continue; } LISTBASE_FOREACH (RenderPass *, render_pass, &render_layer->passes) { diff --git a/source/blender/compositor/nodes/COM_MaskNode.cc b/source/blender/compositor/nodes/COM_MaskNode.cc index 4f2434a7402..647d4cabaee 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cc +++ b/source/blender/compositor/nodes/COM_MaskNode.cc @@ -27,11 +27,11 @@ void MaskNode::convert_to_operations(NodeConverter &converter, /* Always connect the output image. */ MaskOperation *operation = new MaskOperation(); - if (editor_node->custom1 & CMP_NODEFLAG_MASK_FIXED) { + if (editor_node->custom1 & CMP_NODE_MASK_FLAG_SIZE_FIXED) { operation->set_mask_width(data->size_x); operation->set_mask_height(data->size_y); } - else if (editor_node->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) { + else if (editor_node->custom1 & CMP_NODE_MASK_FLAG_SIZE_FIXED_SCENE) { operation->set_mask_width(data->size_x * render_size_factor); operation->set_mask_height(data->size_y * render_size_factor); } @@ -42,10 +42,11 @@ void MaskNode::convert_to_operations(NodeConverter &converter, operation->set_mask(mask); operation->set_framenumber(context.get_framenumber()); - operation->set_feather(bool(editor_node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + operation->set_feather(bool(editor_node->custom1 & CMP_NODE_MASK_FLAG_NO_FEATHER) == 0); - if ((editor_node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editor_node->custom2 > 1) && - (editor_node->custom3 > FLT_EPSILON)) { + if ((editor_node->custom1 & CMP_NODE_MASK_FLAG_MOTION_BLUR) && (editor_node->custom2 > 1) && + (editor_node->custom3 > FLT_EPSILON)) + { operation->set_motion_blur_samples(editor_node->custom2); operation->set_motion_blur_shutter(editor_node->custom3); } diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc index 360e9e0bce3..5a109bf1f47 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc @@ -21,7 +21,7 @@ void Stabilize2dNode::convert_to_operations(NodeConverter &converter, const bNode *editor_node = this->get_bnode(); NodeInput *image_input = this->get_input_socket(0); MovieClip *clip = (MovieClip *)editor_node->id; - bool invert = (editor_node->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0; + bool invert = (editor_node->custom2 & CMP_NODE_STABILIZE_FLAG_INVERSE) != 0; const PixelSampler sampler = (PixelSampler)editor_node->custom1; MovieClipAttributeOperation *scale_attribute = new MovieClipAttributeOperation(); diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cc b/source/blender/compositor/operations/COM_AntiAliasOperation.cc index e0083b702e1..ffee95146d5 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cc +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cc @@ -140,7 +140,8 @@ void AntiAliasOperation::execute_pixel(float output[4], int x, int y, void *data &row_curr[x + 1], &row_next[x - 1], &row_next[x], - &row_next[x + 1])) { + &row_next[x + 1])) + { /* Some rounding magic to so make weighting correct with the * original coefficients. */ @@ -207,9 +208,11 @@ void AntiAliasOperation::update_memory_buffer_partial(MemoryBuffer *output, const float *row_next = row_curr + input->row_stride; int x_offset = 0; for (int x = area.xmin; x < area.xmax; - x++, out += output->elem_stride, x_offset += input->elem_stride) { + x++, out += output->elem_stride, x_offset += input->elem_stride) + { if (x == input_area.xmin || x == input_area.xmax - 1 || y == input_area.xmin || - y == input_area.ymax - 1) { + y == input_area.ymax - 1) + { out[0] = row_curr[x_offset]; continue; } @@ -231,7 +234,8 @@ void AntiAliasOperation::update_memory_buffer_partial(MemoryBuffer *output, &row_curr[x_offset + input->elem_stride], &row_next[x_offset - input->elem_stride], &row_next[x_offset], - &row_next[x_offset + input->elem_stride])) { + &row_next[x_offset + input->elem_stride])) + { /* Some rounding magic to make weighting correct with the * original coefficients. */ uchar result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] + 5 * ninepix[3] + diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cc b/source/blender/compositor/operations/COM_BokehImageOperation.cc index b74ac9dac64..e4cecb5901f 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cc +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cc @@ -56,12 +56,14 @@ float BokehImageOperation::is_inside_bokeh(float distance, float x, float y) const float catadioptric_distance_to_center = distance_rounding_to_center * data_->catadioptric; if (distance_rounding_to_center >= distance_to_center && - catadioptric_distance_to_center <= distance_to_center) { + catadioptric_distance_to_center <= distance_to_center) + { if (distance_rounding_to_center - distance_to_center < 1.0f) { inside_bokeh = (distance_rounding_to_center - distance_to_center); } else if (data_->catadioptric != 0.0f && - distance_to_center - catadioptric_distance_to_center < 1.0f) { + distance_to_center - catadioptric_distance_to_center < 1.0f) + { inside_bokeh = (distance_to_center - catadioptric_distance_to_center); } else { diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cc b/source/blender/compositor/operations/COM_ColorMatteOperation.cc index 41bf91634cd..a203a5541f5 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cc +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cc @@ -59,7 +59,8 @@ void ColorMatteOperation::execute_pixel_sampled(float output[4], * otherwise 0.5 would key all hue's */ /* hue */ - ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue)) { + ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue)) + { output[0] = 0.0f; /* make transparent */ } @@ -94,7 +95,8 @@ void ColorMatteOperation::update_memory_buffer_partial(MemoryBuffer *output, * otherwise 0.5 would key all hue's. */ /* #hue */ - ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue)) { + ((h_wrap = 2.0f * fabsf(in_color[0] - in_key[0])) < hue || (2.0f - h_wrap) < hue)) + { it.out[0] = 0.0f; /* Make transparent. */ } diff --git a/source/blender/compositor/operations/COM_ConvertColorSpaceOperation.cc b/source/blender/compositor/operations/COM_ConvertColorSpaceOperation.cc index 3d19f13c8b0..c21dd6f27cf 100644 --- a/source/blender/compositor/operations/COM_ConvertColorSpaceOperation.cc +++ b/source/blender/compositor/operations/COM_ConvertColorSpaceOperation.cc @@ -21,7 +21,8 @@ void ConvertColorSpaceOperation::set_settings(NodeConvertColorSpace *node_color_ void ConvertColorSpaceOperation::init_execution() { if (BLI_strnlen(settings_->from_color_space, sizeof(settings_->from_color_space)) == 0 || - BLI_strnlen(settings_->to_color_space, sizeof(settings_->to_color_space)) == 0) { + BLI_strnlen(settings_->to_color_space, sizeof(settings_->to_color_space)) == 0) + { return; } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc index 14b92bdcbd1..877bb19af09 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cc @@ -50,8 +50,8 @@ void ConvertDepthToRadiusOperation::init_execution() (this->get_width() / float(this->get_height())); aperture_ = 0.5f * (cam_lens_ / (aspect_ * cam_sensor)) / f_stop_; const float minsz = MIN2(get_width(), get_height()); - dof_sp_ = minsz / ((cam_sensor / 2.0f) / - cam_lens_); /* <- == `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)` */ + /* Equal to: `aspect * MIN2(img->x, img->y) / tan(0.5f * fov)`. */ + dof_sp_ = minsz / ((cam_sensor / 2.0f) / cam_lens_); if (blur_post_operation_) { blur_post_operation_->set_sigma(MIN2(aperture_ * 128.0f, max_radius_)); diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cc b/source/blender/compositor/operations/COM_DespeckleOperation.cc index a0c82ad531c..1609132e4f5 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cc +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cc @@ -103,7 +103,8 @@ void DespeckleOperation::execute_pixel(float output[4], int x, int y, void * /*d // mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) && - color_diff(color_mid, color_org, threshold_)) { + color_diff(color_mid, color_org, threshold_)) + { mul_v4_fl(color_mid_ok, 1.0f / w); interp_v4_v4v4(output, color_org, color_mid_ok, value[0]); } @@ -218,7 +219,8 @@ void DespeckleOperation::update_memory_buffer_partial(MemoryBuffer *output, // mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && ((w / WTOT) > (threshold_neighbor_)) && - color_diff(color_mid, color_org, threshold_)) { + color_diff(color_mid, color_org, threshold_)) + { const float factor = *it.in(FACTOR_INPUT_INDEX); mul_v4_fl(color_mid_ok, 1.0f / w); interp_v4_v4v4(it.out, color_org, color_mid_ok, factor); diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc index cb872f61941..63fba8e07dc 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cc @@ -138,7 +138,8 @@ void DisplaceSimpleOperation::update_memory_buffer_partial(MemoryBuffer *output, const float height = this->get_height(); const MemoryBuffer *input_color = inputs[0]; for (BuffersIterator it = output->iterate_with(inputs.drop_front(1), area); !it.is_end(); - ++it) { + ++it) + { float scale_x = *it.in(1); float scale_y = *it.in(2); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc index e120dd5f41a..7fc9fb977dc 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc @@ -29,10 +29,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Upper right corner. */ x = t; @@ -47,10 +47,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower left corner. */ x = 0; @@ -65,10 +65,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower right corner. */ x = rw - 1; @@ -83,10 +83,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ @@ -102,10 +102,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -122,10 +122,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ @@ -141,10 +141,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -161,10 +161,10 @@ static void do_adjacentKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -194,12 +194,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x - rw] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -219,12 +219,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the left. */ + if (!lomask[x - rw] || !lomask[x - 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -244,12 +244,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || - !lomask[x + 1]) { /* Test if outer mask is empty above or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the right. */ + if (!lomask[x + rw] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -269,12 +269,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || - !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the left. */ + if (!lomask[x + rw] || !lomask[x - 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -294,12 +294,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || - !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -321,12 +321,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || - !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -347,12 +347,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -374,12 +374,12 @@ static void do_adjacentBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -413,10 +413,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Upper right corner. */ x = t; @@ -430,10 +430,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower left corner. */ x = 0; @@ -447,10 +447,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Lower right corner. */ x = rw - 1; @@ -464,10 +464,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ @@ -482,10 +482,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -501,10 +501,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ @@ -519,10 +519,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -538,10 +538,10 @@ static void do_allKeepBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } @@ -570,12 +570,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x - rw] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -594,12 +594,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty above or to the left. */ + if (!lomask[x - rw] || !lomask[x - 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -618,12 +618,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || - !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the right. */ + if (!lomask[x + rw] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -642,12 +642,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x + rw] || - !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or to the left. */ + if (!lomask[x + rw] || !lomask[x - 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -666,12 +666,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || - !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -692,12 +692,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - 1] || - !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty to the left or to the right. */ + if (!lomask[x - 1] || !lomask[x + 1]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -717,12 +717,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -743,12 +743,12 @@ static void do_allBleedBorders( else { res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } - } - else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ - if (!lomask[x - rw] || - !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ - osz++; /* Increment outer edge size. */ - lres[x] = 3; /* Flag pixel as outer edge. */ + } /* Inner mask was empty, test if outer mask is filled. */ + else if (lomask[x]) { + /* Test if outer mask is empty underneath or above. */ + if (!lomask[x - rw] || !lomask[x + rw]) { + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { gsz++; /* Increment the gradient pixel count. */ @@ -800,7 +800,8 @@ static void do_allEdgeDetection(uint t, if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || - (!lomask[pix_prevRow] && !limask[pix_prevRow])) { + (!lomask[pix_prevRow] && !limask[pix_prevRow])) + { in_osz++; /* Increment the outer boundary pixel count. */ lres[a] = 3; /* Flag pixel as part of outer edge. */ } @@ -870,7 +871,8 @@ static void do_adjacentEdgeDetection(uint t, if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || - (!lomask[pix_prevRow] && !limask[pix_prevRow])) { + (!lomask[pix_prevRow] && !limask[pix_prevRow])) + { in_osz++; /* Increment the outer boundary pixel count. */ lres[a] = 3; /* Flag pixel as part of outer edge. */ } @@ -884,7 +886,8 @@ static void do_adjacentEdgeDetection(uint t, if ((!limask[pix_nextCol] && lomask[pix_nextCol]) || (!limask[pix_prevCol] && lomask[pix_prevCol]) || (!limask[pix_nextRow] && lomask[pix_nextRow]) || - (!limask[pix_prevRow] && lomask[pix_prevRow])) { + (!limask[pix_prevRow] && lomask[pix_prevRow])) + { in_isz++; /* Increment the inner boundary pixel count. */ lres[a] = 4; /* Flag pixel as part of inner edge. */ } @@ -1120,8 +1123,8 @@ static void do_fillGradientBuffer(uint rw, t = gbuf[gradient_fill_offset]; /* Calculate column of pixel indexed by `gbuf[x]`. */ fsz = gbuf[gradient_fill_offset + 1]; /* Calculate row of pixel indexed by `gbuf[x]`. */ dmin = 0xffffffff; /* Reset min distance to edge pixel. */ - for (a = outer_edge_offset + osz - 1; a >= outer_edge_offset; - a--) { /* Loop through all outer edge buffer pixels. */ + /* Loop through all outer edge buffer pixels. */ + for (a = outer_edge_offset + osz - 1; a >= outer_edge_offset; a--) { ud = a << 1; dy = t - gbuf[ud]; /* Set dx to gradient pixel column - outer edge pixel row. */ dx = fsz - gbuf[ud + 1]; /* Set dy to gradient pixel row - outer edge pixel column. */ @@ -1138,14 +1141,14 @@ static void do_fillGradientBuffer(uint rw, odist = odist * (rsopf - (rsf * odist * odist)); /* -- This line can be iterated for more accuracy. -- */ dmin = 0xffffffff; /* Reset min distance to edge pixel. */ - for (a = inner_edge_offset + isz - 1; a >= inner_edge_offset; - a--) { /* Loop through all inside edge pixels. */ + /* Loop through all inside edge pixels. */ + for (a = inner_edge_offset + isz - 1; a >= inner_edge_offset; a--) { ud = a << 1; dy = t - gbuf[ud]; /* Compute delta in Y from gradient pixel to inside edge pixel. */ dx = fsz - gbuf[ud + 1]; /* Compute delta in X from gradient pixel to inside edge pixel. */ ud = dx * dx + dy * dy; /* Compute sum of squares. */ - if (ud < - dmin) { /* If our new sum of squares is less than the current minimum we've found. */ + /* If our new sum of squares is less than the current minimum we've found. */ + if (ud < dmin) { dmin = ud; /* Set a new minimum equal to the new lower value. */ } } @@ -1196,10 +1199,9 @@ void DoubleEdgeMaskOperation::do_double_edge_mask(float *imask, float *omask, fl rw = this->get_width(); /* Width of a row of pixels. */ t = (rw * this->get_height()) - 1; /* Determine size of the frame. */ - memset(res, - 0, - sizeof(float) * - (t + 1)); /* Clear output buffer (not all pixels will be written later). */ + + /* Clear output buffer (not all pixels will be written later). */ + memset(res, 0, sizeof(float) * (t + 1)); lres = (uint *)res; /* Pointer to output buffer (for bit level ops).. */ limask = (uint *)imask; /* Pointer to input mask (for bit level ops).. */ diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc index 7557d1bc4bd..362a1f67302 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc @@ -361,7 +361,8 @@ void *FastGaussianBlurValueOperation::initialize_tile_data(rcti *rect) float *src = new_buf->get_buffer(); float *dst = copy->get_buffer(); for (int i = copy->get_width() * copy->get_height(); i != 0; - i--, src += COM_DATA_TYPE_VALUE_CHANNELS, dst += COM_DATA_TYPE_VALUE_CHANNELS) { + i--, src += COM_DATA_TYPE_VALUE_CHANNELS, dst += COM_DATA_TYPE_VALUE_CHANNELS) + { if (*src < *dst) { *dst = *src; } @@ -371,7 +372,8 @@ void *FastGaussianBlurValueOperation::initialize_tile_data(rcti *rect) float *src = new_buf->get_buffer(); float *dst = copy->get_buffer(); for (int i = copy->get_width() * copy->get_height(); i != 0; - i--, src += COM_DATA_TYPE_VALUE_CHANNELS, dst += COM_DATA_TYPE_VALUE_CHANNELS) { + i--, src += COM_DATA_TYPE_VALUE_CHANNELS, dst += COM_DATA_TYPE_VALUE_CHANNELS) + { if (*src > *dst) { *dst = *src; } diff --git a/source/blender/compositor/operations/COM_MaskOperation.cc b/source/blender/compositor/operations/COM_MaskOperation.cc index 53f59f831db..c726a750aa0 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cc +++ b/source/blender/compositor/operations/COM_MaskOperation.cc @@ -45,8 +45,8 @@ void MaskOperation::init_execution() MaskLayer *masklay; MaskLayerShape *masklay_shape; - for (masklay = (MaskLayer *)mask_temp->masklayers.first; masklay; - masklay = masklay->next) { + for (masklay = (MaskLayer *)mask_temp->masklayers.first; masklay; masklay = masklay->next) + { masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame_number_); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); } diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc index 7650746e3ed..f427b194f08 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc @@ -3,6 +3,8 @@ #include "COM_OutputFileMultiViewOperation.h" +#include "BLI_fileops.h" + #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.h" @@ -30,7 +32,7 @@ OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOpe { } -void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filename) +void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filepath) { size_t width = this->get_width(); size_t height = this->get_height(); @@ -39,7 +41,7 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam if (width != 0 && height != 0) { void *exrhandle; - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -56,11 +58,11 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam add_exr_channels(exrhandle, nullptr, datatype_, srv->name, width, false, nullptr); } - BLI_make_existing_file(filename); + BLI_file_ensure_parent_dir_exists(filepath); /* prepare the file with all the channels */ - if (!IMB_exr_begin_write(exrhandle, filename, width, height, format_.exr_codec, nullptr)) { + if (!IMB_exr_begin_write(exrhandle, filepath, width, height, format_.exr_codec, nullptr)) { printf("Error Writing Singlelayer Multiview Openexr\n"); IMB_exr_close(exrhandle); } @@ -79,9 +81,9 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution() if (width != 0 && height != 0) { void *exrhandle; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -90,7 +92,7 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution() true, nullptr); - exrhandle = this->get_handle(filename); + exrhandle = this->get_handle(filepath); add_exr_channels(exrhandle, nullptr, datatype_, @@ -130,7 +132,7 @@ OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOpera { } -void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename) +void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filepath) { uint width = this->get_width(); uint height = this->get_height(); @@ -141,7 +143,7 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename SceneRenderView *srv; /* get a new global handle */ - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -169,11 +171,11 @@ void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename } } - BLI_make_existing_file(filename); + BLI_file_ensure_parent_dir_exists(filepath); /* prepare the file with all the channels for the header */ StampData *stamp_data = create_stamp_data(); - if (!IMB_exr_begin_write(exrhandle, filename, width, height, exr_codec_, stamp_data)) { + if (!IMB_exr_begin_write(exrhandle, filepath, width, height, exr_codec_, stamp_data)) { printf("Error Writing Multilayer Multiview Openexr\n"); IMB_exr_close(exrhandle); BKE_stamp_data_free(stamp_data); @@ -194,9 +196,9 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution() if (width != 0 && height != 0) { void *exrhandle; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -205,7 +207,7 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution() true, nullptr); - exrhandle = this->get_handle(filename); + exrhandle = this->get_handle(filepath); for (uint i = 0; i < layers_.size(); i++) { add_exr_channels(exrhandle, @@ -245,17 +247,17 @@ OutputStereoOperation::OutputStereoOperation(const Scene *scene, DataType datatype, const ImageFormatData *format, const char *path, - const char *name, + const char *pass_name, const char *view_name, const bool save_as_render) : OutputSingleLayerOperation( scene, rd, tree, datatype, format, path, view_name, save_as_render) { - BLI_strncpy(name_, name, sizeof(name_)); + BLI_strncpy(pass_name_, pass_name, sizeof(pass_name_)); channels_ = get_datatype_size(datatype); } -void *OutputStereoOperation::get_handle(const char *filename) +void *OutputStereoOperation::get_handle(const char *filepath) { size_t width = this->get_width(); size_t height = this->get_height(); @@ -265,7 +267,7 @@ void *OutputStereoOperation::get_handle(const char *filename) if (width != 0 && height != 0) { void *exrhandle; - exrhandle = IMB_exr_get_handle_name(filename); + exrhandle = IMB_exr_get_handle_name(filepath); if (!BKE_scene_multiview_is_render_view_first(rd_, view_name_)) { return exrhandle; @@ -296,7 +298,7 @@ void OutputStereoOperation::deinit_execution() /* populate single EXR channel with view data */ IMB_exr_add_channel(exrhandle, nullptr, - name_, + pass_name_, view_name_, 1, channels_ * width * height, @@ -310,12 +312,12 @@ void OutputStereoOperation::deinit_execution() if (BKE_scene_multiview_is_render_view_last(rd_, view_name_)) { ImBuf *ibuf[3] = {nullptr}; const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; int i; /* get rectf from EXR */ for (i = 0; i < 2; i++) { - float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, name_, names[i]); + float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, pass_name_, names[i]); ibuf[i] = IMB_allocImBuf(width, height, format_.planes, 0); ibuf[i]->channels = channels_; @@ -330,7 +332,7 @@ void OutputStereoOperation::deinit_execution() /* create stereo buffer */ ibuf[2] = IMB_stereo3d_ImBuf(&format_, ibuf[0], ibuf[1]); - BKE_image_path_from_imformat(filename, + BKE_image_path_from_imformat(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -339,7 +341,7 @@ void OutputStereoOperation::deinit_execution() true, nullptr); - BKE_imbuf_write(ibuf[2], filename, &format_); + BKE_imbuf_write(ibuf[2], filepath, &format_); /* imbuf knows which rects are not part of ibuf */ for (i = 0; i < 3; i++) { diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h index 70773c1a559..4fe225f319b 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h @@ -27,7 +27,7 @@ class OutputOpenExrSingleLayerMultiViewOperation : public OutputSingleLayerOpera const char *view_name, bool save_as_render); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; @@ -43,13 +43,14 @@ class OutputOpenExrMultiLayerMultiViewOperation : public OutputOpenExrMultiLayer bool exr_half_float, const char *view_name); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; class OutputStereoOperation : public OutputSingleLayerOperation { private: - char name_[FILE_MAX]; + /* NOTE: Using FILE_MAX here is misleading, this is not a file path. */ + char pass_name_[FILE_MAX]; size_t channels_; public: @@ -59,10 +60,10 @@ class OutputStereoOperation : public OutputSingleLayerOperation { DataType datatype, const struct ImageFormatData *format, const char *path, - const char *name, + const char *pass_name, const char *view_name, bool save_as_render); - void *get_handle(const char *filename); + void *get_handle(const char *filepath); void deinit_execution() override; }; diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc index c0ad745613f..22a8ef7381b 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc @@ -3,8 +3,8 @@ #include "COM_OutputFileOperation.h" +#include "BLI_fileops.h" #include "BLI_listbase.h" -#include "BLI_path_util.h" #include "BLI_string.h" #include "BKE_image.h" @@ -253,7 +253,7 @@ void OutputSingleLayerOperation::deinit_execution() int size = get_datatype_size(datatype_); ImBuf *ibuf = IMB_allocImBuf(this->get_width(), this->get_height(), format_.planes, 0); - char filename[FILE_MAX]; + char filepath[FILE_MAX]; const char *suffix; ibuf->channels = size; @@ -265,7 +265,7 @@ void OutputSingleLayerOperation::deinit_execution() suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_); - BKE_image_path_from_imformat(filename, + BKE_image_path_from_imformat(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -274,11 +274,11 @@ void OutputSingleLayerOperation::deinit_execution() true, suffix); - if (0 == BKE_imbuf_write(ibuf, filename, &format_)) { - printf("Cannot save Node File Output to %s\n", filename); + if (0 == BKE_imbuf_write(ibuf, filepath, &format_)) { + printf("Cannot save Node File Output to %s\n", filepath); } else { - printf("Saved: %s\n", filename); + printf("Saved: %s\n", filepath); } IMB_freeImBuf(ibuf); @@ -395,12 +395,12 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() uint width = this->get_width(); uint height = this->get_height(); if (width != 0 && height != 0) { - char filename[FILE_MAX]; + char filepath[FILE_MAX]; const char *suffix; void *exrhandle = IMB_exr_get_handle(); suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_); - BKE_image_path_from_imtype(filename, + BKE_image_path_from_imtype(filepath, path_, BKE_main_blendfile_path_from_global(), rd_->cfra, @@ -408,7 +408,7 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() (rd_->scemode & R_EXTENSION) != 0, true, suffix); - BLI_make_existing_file(filename); + BLI_file_ensure_parent_dir_exists(filepath); for (uint i = 0; i < layers_.size(); i++) { OutputOpenExrLayer &layer = layers_[i]; @@ -425,9 +425,9 @@ void OutputOpenExrMultiLayerOperation::deinit_execution() layers_[i].output_buffer); } - /* when the filename has no permissions, this can fail */ + /* When the filepath has no permissions, this can fail. */ StampData *stamp_data = create_stamp_data(); - if (IMB_exr_begin_write(exrhandle, filename, width, height, exr_codec_, stamp_data)) { + if (IMB_exr_begin_write(exrhandle, filepath, width, height, exr_codec_, stamp_data)) { IMB_exr_write_channels(exrhandle); } else { diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc index fcd37f2a179..7ec93d57c84 100644 --- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc +++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc @@ -269,7 +269,8 @@ bool PlaneCornerPinWarpImageOperation::determine_depending_area_of_interest( { for (int i = 0; i < 4; i++) { if (get_input_operation(i + 1)->determine_depending_area_of_interest( - input, read_operation, output)) { + input, read_operation, output)) + { return true; } } diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc index 59e924311e3..55760a19bc3 100644 --- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc +++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc @@ -254,7 +254,8 @@ void PlaneDistortMaskOperation::execute_pixel_sampled(float output[4], isect_point_tri_v2(point, sample_data->frame_space_corners[0], sample_data->frame_space_corners[2], - sample_data->frame_space_corners[3])) { + sample_data->frame_space_corners[3])) + { inside_counter++; } } @@ -273,7 +274,8 @@ void PlaneDistortMaskOperation::execute_pixel_sampled(float output[4], isect_point_tri_v2(point, sample_data->frame_space_corners[0], sample_data->frame_space_corners[2], - sample_data->frame_space_corners[3])) { + sample_data->frame_space_corners[3])) + { inside_counter++; } } @@ -312,7 +314,8 @@ int PlaneDistortMaskOperation::get_jitter_samples_inside_count(int x, isect_point_tri_v2(point, sample_data.frame_space_corners[0], sample_data.frame_space_corners[2], - sample_data.frame_space_corners[3])) { + sample_data.frame_space_corners[3])) + { inside_count++; } } diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc index fb6c3944d60..5f491647118 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc @@ -79,7 +79,8 @@ bool ProjectorLensDistortionOperation::determine_depending_area_of_interest( rcti disp_input; BLI_rcti_init(&disp_input, 0, 5, 0, 5); if (this->get_input_operation(1)->determine_depending_area_of_interest( - &disp_input, read_operation, output)) { + &disp_input, read_operation, output)) + { return true; } new_input.xmin = input->xmin - 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */ @@ -88,7 +89,8 @@ bool ProjectorLensDistortionOperation::determine_depending_area_of_interest( new_input.xmax = input->xmax + 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */ } if (this->get_input_operation(0)->determine_depending_area_of_interest( - &new_input, read_operation, output)) { + &new_input, read_operation, output)) + { return true; } return false; diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cc b/source/blender/compositor/operations/COM_RenderLayersProg.cc index d95ee2a5e1a..ae3d092508c 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cc +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cc @@ -324,7 +324,8 @@ void RenderLayersDepthProg::execute_pixel_sampled(float output[4], float *input_buffer = this->get_input_buffer(); if (input_buffer == nullptr || ix < 0 || iy < 0 || ix >= int(this->get_width()) || - iy >= int(this->get_height())) { + iy >= int(this->get_height())) + { output[0] = 10e10f; } else { diff --git a/source/blender/compositor/operations/COM_SMAAOperation.cc b/source/blender/compositor/operations/COM_SMAAOperation.cc index 8f4ed844b9f..2de5e6bdd5a 100644 --- a/source/blender/compositor/operations/COM_SMAAOperation.cc +++ b/source/blender/compositor/operations/COM_SMAAOperation.cc @@ -861,7 +861,8 @@ int SMAABlendingWeightCalculationOperation::search_xright(int x, int y) x++; sample_image_fn_(x, y, e); if (e[1] == 0.0f || /* Is the edge not activated? */ - e[0] != 0.0f) { /* Or is there a crossing edge that breaks the line? */ + e[0] != 0.0f) /* Or is there a crossing edge that breaks the line? */ + { break; } sample_image_fn_(x, y - 1, e); @@ -905,7 +906,8 @@ int SMAABlendingWeightCalculationOperation::search_ydown(int x, int y) y++; sample_image_fn_(x, y, e); if (e[0] == 0.0f || /* Is the edge not activated? */ - e[1] != 0.0f) { /* Or is there a crossing edge that breaks the line? */ + e[1] != 0.0f) /* Or is there a crossing edge that breaks the line? */ + { break; } sample_image_fn_(x - 1, y, e); diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc index aa0a27503c5..9ea9731047b 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cc +++ b/source/blender/compositor/operations/COM_TextureOperation.cc @@ -50,7 +50,8 @@ void TextureBaseOperation::deinit_execution() BKE_image_pool_free(pool_); pool_ = nullptr; if (texture_ != nullptr && texture_->use_nodes && texture_->nodetree != nullptr && - texture_->nodetree->runtime->execdata != nullptr) { + texture_->nodetree->runtime->execdata != nullptr) + { ntreeTexEndExecTree(texture_->nodetree->runtime->execdata); } NodeOperation::deinit_execution(); diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc index bf6ee64c73f..c906b9d0bc5 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc @@ -338,12 +338,14 @@ static void blur_pixel(int x, int y, PixelData &p) const float *row_color = p.image_input->get_elem(minx, miny); const float *row_size = p.size_input->get_elem(minx, miny); for (int ny = miny; ny < maxy; - ny += p.step, row_size += size_row_stride, row_color += color_row_stride) { + ny += p.step, row_size += size_row_stride, row_color += color_row_stride) + { const float dy = ny - y; const float *size_elem = row_size; const float *color = row_color; for (int nx = minx; nx < maxx; - nx += p.step, size_elem += size_elem_stride, color += color_elem_stride) { + nx += p.step, size_elem += size_elem_stride, color += color_elem_stride) + { if (nx == x && ny == y) { continue; } @@ -395,7 +397,8 @@ void VariableSizeBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer * for (BuffersIterator it = output->iterate_with({p.image_input, p.size_input}, area); !it.is_end(); - ++it) { + ++it) + { const float *color = it.in(0); const float size = *it.in(1); copy_v4_v4(p.color_accum, color); diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cc b/source/blender/compositor/operations/COM_VectorBlurOperation.cc index 39b190c8c8e..3a6c9127a40 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cc @@ -825,7 +825,8 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, for (fy = -0.5f + jit[step & 255][0], y = 0; y < ysize; y++, fy += 1.0f) { for (fx = -0.5f + jit[step & 255][1], x = 0; x < xsize; - x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) { + x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) + { if (*dm > 1) { float jfx = fx + 0.5f; float jfy = fy + 0.5f; diff --git a/source/blender/compositor/realtime_compositor/CMakeLists.txt b/source/blender/compositor/realtime_compositor/CMakeLists.txt index f3a94610d1e..bc457ad92a4 100644 --- a/source/blender/compositor/realtime_compositor/CMakeLists.txt +++ b/source/blender/compositor/realtime_compositor/CMakeLists.txt @@ -70,12 +70,14 @@ set(SRC algorithms/COM_algorithm_smaa.hh algorithms/COM_algorithm_symmetric_separable_blur.hh + cached_resources/intern/cached_mask.cc cached_resources/intern/cached_texture.cc cached_resources/intern/morphological_distance_feather_weights.cc cached_resources/intern/smaa_precomputed_textures.cc cached_resources/intern/symmetric_blur_weights.cc cached_resources/intern/symmetric_separable_blur_weights.cc + cached_resources/COM_cached_mask.hh cached_resources/COM_cached_resource.hh cached_resources/COM_cached_texture.hh cached_resources/COM_morphological_distance_feather_weights.hh diff --git a/source/blender/compositor/realtime_compositor/COM_context.hh b/source/blender/compositor/realtime_compositor/COM_context.hh index 58a422416d6..014ae9d2252 100644 --- a/source/blender/compositor/realtime_compositor/COM_context.hh +++ b/source/blender/compositor/realtime_compositor/COM_context.hh @@ -82,6 +82,9 @@ class Context { /* Get the size of the compositing region. See get_compositing_region(). */ int2 get_compositing_region_size() const; + /* Get the normalized render percentage of the active scene. */ + float get_render_percentage() const; + /* Get the current frame number of the active scene. */ int get_frame_number() const; diff --git a/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh b/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh index 1f776d96c9e..f0781b5e425 100644 --- a/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh +++ b/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh @@ -2,6 +2,7 @@ #pragma once +#include "COM_cached_mask.hh" #include "COM_cached_texture.hh" #include "COM_morphological_distance_feather_weights.hh" #include "COM_smaa_precomputed_textures.hh" @@ -37,8 +38,9 @@ class StaticCacheManager { SymmetricBlurWeightsContainer symmetric_blur_weights; SymmetricSeparableBlurWeightsContainer symmetric_separable_blur_weights; MorphologicalDistanceFeatherWeightsContainer morphological_distance_feather_weights; - SMAAPrecomputedTexturesContainer smaa_precomputed_textures; CachedTextureContainer cached_textures; + CachedMaskContainer cached_masks; + SMAAPrecomputedTexturesContainer smaa_precomputed_textures; /* Reset the cache manager by deleting the cached resources that are no longer needed because * they weren't used in the last evaluation and prepare the remaining cached resources to track diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_mask.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_mask.hh new file mode 100644 index 00000000000..48070a4e0b1 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_mask.hh @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +#include +#include +#include + +#include "BLI_map.hh" +#include "BLI_math_vector_types.hh" + +#include "GPU_texture.h" + +#include "DNA_mask_types.h" +#include "DNA_scene_types.h" + +#include "COM_cached_resource.hh" + +namespace blender::realtime_compositor { + +class Context; + +/* ------------------------------------------------------------------------------------------------ + * Cached Mask Key. + */ +class CachedMaskKey { + public: + int2 size; + bool use_feather; + int motion_blur_samples; + float motion_blur_shutter; + + CachedMaskKey(int2 size, bool use_feather, int motion_blur_samples, float motion_blur_shutter); + + uint64_t hash() const; +}; + +bool operator==(const CachedMaskKey &a, const CachedMaskKey &b); + +/* ------------------------------------------------------------------------------------------------- + * Cached Mask. + * + * A cached resource that computes and caches a GPU texture containing the result of evaluating the + * given mask ID on a space that spans the given size, parametrized by the given parameters. */ +class CachedMask : public CachedResource { + private: + GPUTexture *texture_ = nullptr; + + public: + CachedMask(Mask *mask, + int2 size, + int frame, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter); + + ~CachedMask(); + + GPUTexture *texture(); +}; + +/* ------------------------------------------------------------------------------------------------ + * Cached Mask Container. + */ +class CachedMaskContainer : CachedResourceContainer { + private: + Map>> map_; + + public: + void reset() override; + + /* Check if the given mask ID has changed since the last time it was retrieved through its + * recalculate flag, and if so, invalidate its corresponding cached mask and reset the + * recalculate flag to ready it to track the next change. Then, check if there is an available + * CachedMask cached resource with the given parameters in the container, if one exists, return + * it, otherwise, return a newly created one and add it to the container. In both cases, tag the + * cached resource as needed to keep it cached for the next evaluation. */ + CachedMask &get(Context &context, + Mask *mask, + int2 size, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter); +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_texture.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_texture.hh index f17a3ef88fc..bd9c27fff8a 100644 --- a/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_texture.hh +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_texture.hh @@ -39,9 +39,8 @@ bool operator==(const CachedTextureKey &a, const CachedTextureKey &b); /* ------------------------------------------------------------------------------------------------- * Cached Texture. * - * A cached resource that computes and caches a GPU texture containing the the result of evaluating - * the given texture ID on a space that spans the given size, modified by the given offset and - * scale. */ + * A cached resource that computes and caches a GPU texture containing the result of evaluating the + * given texture ID on a space that spans the given size, parametrized by the given parameters. */ class CachedTexture : public CachedResource { private: GPUTexture *color_texture_ = nullptr; diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc new file mode 100644 index 00000000000..813153780ba --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc @@ -0,0 +1,199 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include + +#include "BLI_array.hh" +#include "BLI_hash.hh" +#include "BLI_index_range.hh" +#include "BLI_listbase.h" +#include "BLI_math_vector_types.hh" +#include "BLI_task.hh" + +#include "GPU_texture.h" + +#include "BKE_lib_id.h" +#include "BKE_mask.h" + +#include "DNA_ID.h" +#include "DNA_mask_types.h" + +#include "COM_cached_mask.hh" +#include "COM_context.hh" + +namespace blender::realtime_compositor { + +/* -------------------------------------------------------------------- + * Cached Mask Key. + */ + +CachedMaskKey::CachedMaskKey(int2 size, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter) + : size(size), + use_feather(use_feather), + motion_blur_samples(motion_blur_samples), + motion_blur_shutter(motion_blur_shutter) +{ +} + +uint64_t CachedMaskKey::hash() const +{ + return get_default_hash_4(size, use_feather, motion_blur_samples, motion_blur_shutter); +} + +bool operator==(const CachedMaskKey &a, const CachedMaskKey &b) +{ + return a.size == b.size && a.use_feather == b.use_feather && + a.motion_blur_samples == b.motion_blur_samples && + a.motion_blur_shutter == b.motion_blur_shutter; +} + +/* -------------------------------------------------------------------- + * Cached Mask. + */ + +static Vector get_mask_raster_handles(Mask *mask, + int2 size, + int current_frame, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter) +{ + Vector handles; + + if (!mask) { + return handles; + } + + /* If motion blur samples are 1, that means motion blur is disabled, in that case, just return + * the currently evaluated raster handle. */ + if (motion_blur_samples == 1) { + MaskRasterHandle *handle = BKE_maskrasterize_handle_new(); + BKE_maskrasterize_handle_init(handle, mask, size.x, size.y, true, true, use_feather); + handles.append(handle); + return handles; + } + + /* Otherwise, we have a number of motion blur samples, so make a copy of the Mask ID and evaluate + * it at the different motion blur frames to get the needed raster handles. */ + Mask *evaluation_mask = reinterpret_cast( + BKE_id_copy_ex(nullptr, &mask->id, nullptr, LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA)); + + /* We evaluate at the frames in the range [current_frame - shutter, current_frame + shutter]. */ + const float start_frame = current_frame - motion_blur_shutter; + const float frame_step = (motion_blur_shutter * 2.0f) / motion_blur_samples; + for (int i = 0; i < motion_blur_samples; i++) { + MaskRasterHandle *handle = BKE_maskrasterize_handle_new(); + BKE_mask_evaluate(evaluation_mask, start_frame + frame_step * i, true); + BKE_maskrasterize_handle_init( + handle, evaluation_mask, size.x, size.y, true, true, use_feather); + handles.append(handle); + } + + BKE_id_free(nullptr, &evaluation_mask->id); + + return handles; +} + +CachedMask::CachedMask(Mask *mask, + int2 size, + int frame, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter) +{ + Vector handles = get_mask_raster_handles( + mask, size, frame, use_feather, motion_blur_samples, motion_blur_shutter); + + Array evaluated_mask(size.x * size.y); + threading::parallel_for(IndexRange(size.y), 1, [&](const IndexRange sub_y_range) { + for (const int64_t y : sub_y_range) { + for (const int64_t x : IndexRange(size.x)) { + /* Compute the coordinates in the [0, 1] range and add 0.5 to evaluate the mask at the + * center of pixels. */ + const float2 coordinates = (float2(x, y) + 0.5f) / float2(size); + float mask_value = 0.0f; + for (MaskRasterHandle *handle : handles) { + mask_value += BKE_maskrasterize_handle_sample(handle, coordinates); + } + evaluated_mask[y * size.x + x] = mask_value / handles.size(); + } + } + }); + + for (MaskRasterHandle *handle : handles) { + BKE_maskrasterize_handle_free(handle); + } + + texture_ = GPU_texture_create_2d("Cached Mask", + size.x, + size.y, + 1, + GPU_R16F, + GPU_TEXTURE_USAGE_SHADER_READ, + evaluated_mask.data()); +} + +CachedMask::~CachedMask() +{ + GPU_texture_free(texture_); +} + +GPUTexture *CachedMask::texture() +{ + return texture_; +} + +/* -------------------------------------------------------------------- + * Cached Mask Container. + */ + +void CachedMaskContainer::reset() +{ + /* First, delete all cached masks that are no longer needed. */ + for (auto &cached_masks_for_id : map_.values()) { + cached_masks_for_id.remove_if([](auto item) { return !item.value->needed; }); + } + map_.remove_if([](auto item) { return item.value.is_empty(); }); + + /* Second, reset the needed status of the remaining cached masks to false to ready them to track + * their needed status for the next evaluation. */ + for (auto &cached_masks_for_id : map_.values()) { + for (auto &value : cached_masks_for_id.values()) { + value->needed = false; + } + } +} + +CachedMask &CachedMaskContainer::get(Context &context, + Mask *mask, + int2 size, + bool use_feather, + int motion_blur_samples, + float motion_blur_shutter) +{ + const CachedMaskKey key(size, use_feather, motion_blur_samples, motion_blur_shutter); + + auto &cached_masks_for_id = map_.lookup_or_add_default(mask->id.name); + + /* Invalidate the cache for that mask ID if it was changed and reset the recalculate flag. */ + if (context.query_id_recalc_flag(reinterpret_cast(mask)) & ID_RECALC_ALL) { + cached_masks_for_id.clear(); + } + + auto &cached_mask = *cached_masks_for_id.lookup_or_add_cb(key, [&]() { + return std::make_unique(mask, + size, + context.get_frame_number(), + use_feather, + motion_blur_samples, + motion_blur_shutter); + }); + + cached_mask.needed = true; + return cached_mask; +} + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_texture.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_texture.cc index d1728779458..4a970beba9c 100644 --- a/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_texture.cc +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_texture.cc @@ -59,7 +59,7 @@ CachedTexture::CachedTexture( threading::parallel_for(IndexRange(size.y), 1, [&](const IndexRange sub_y_range) { for (const int64_t y : sub_y_range) { for (const int64_t x : IndexRange(size.x)) { - /* Compute the coordinates in the [0, 1] range and add 0.5 to evaluate the texture at the + /* Compute the coordinates in the [-1, 1] range and add 0.5 to evaluate the texture at the * center of pixels in case it was interpolated. */ float2 coordinates = ((float2(x, y) + 0.5f) / float2(size)) * 2.0f - 1.0f; /* Note that it is expected that the offset is scaled by the scale. */ diff --git a/source/blender/compositor/realtime_compositor/intern/compile_state.cc b/source/blender/compositor/realtime_compositor/intern/compile_state.cc index d5fb91ddae2..46bbc758243 100644 --- a/source/blender/compositor/realtime_compositor/intern/compile_state.cc +++ b/source/blender/compositor/realtime_compositor/intern/compile_state.cc @@ -93,7 +93,8 @@ bool CompileState::should_compile_shader_compile_unit(DNode node) * complete and should be compiled. Identity domains are an exception as they are always * compatible because they represents single values. */ if (shader_compile_unit_domain_ != Domain::identity() && - shader_compile_unit_domain_ != compute_shader_node_domain(node)) { + shader_compile_unit_domain_ != compute_shader_node_domain(node)) + { return true; } diff --git a/source/blender/compositor/realtime_compositor/intern/context.cc b/source/blender/compositor/realtime_compositor/intern/context.cc index 3b2f2b221cb..d3150dcc3f7 100644 --- a/source/blender/compositor/realtime_compositor/intern/context.cc +++ b/source/blender/compositor/realtime_compositor/intern/context.cc @@ -19,6 +19,11 @@ int2 Context::get_compositing_region_size() const return int2(BLI_rcti_size_x(&compositing_region), BLI_rcti_size_y(&compositing_region)); } +float Context::get_render_percentage() const +{ + return get_scene()->r.size / 100.0f; +} + int Context::get_frame_number() const { return get_scene()->r.cfra; diff --git a/source/blender/compositor/realtime_compositor/intern/scheduler.cc b/source/blender/compositor/realtime_compositor/intern/scheduler.cc index 171a0c21cc1..c1ec75057eb 100644 --- a/source/blender/compositor/realtime_compositor/intern/scheduler.cc +++ b/source/blender/compositor/realtime_compositor/intern/scheduler.cc @@ -267,8 +267,8 @@ static NeededBuffers compute_number_of_needed_buffers(DNode output_node) /* If any of the links is not between two shader nodes, it means that the node outputs * a buffer through this output and so we increment the number of output buffers. */ - if (!is_output_linked_to_node_conditioned(doutput, is_shader_node) || - !is_shader_node(node)) { + if (!is_output_linked_to_node_conditioned(doutput, is_shader_node) || !is_shader_node(node)) + { number_of_output_buffers++; } } diff --git a/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc b/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc index 7fe3fa5dca9..fedae4430f9 100644 --- a/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc +++ b/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc @@ -10,6 +10,7 @@ void StaticCacheManager::reset() symmetric_separable_blur_weights.reset(); morphological_distance_feather_weights.reset(); cached_textures.reset(); + cached_masks.reset(); smaa_precomputed_textures.reset(); } diff --git a/source/blender/datatoc/datatoc_icon.c b/source/blender/datatoc/datatoc_icon.c index 2a87cf62d3a..b249773d908 100644 --- a/source/blender/datatoc/datatoc_icon.c +++ b/source/blender/datatoc/datatoc_icon.c @@ -219,8 +219,8 @@ static struct IconInfo *icon_merge_context_info_for_icon_head(struct IconMergeCo for (int i = 0; i < context->num_read_icons; i++) { struct IconInfo *read_icon_info = &context->read_icons[i]; const struct IconHead *read_icon_head = &read_icon_info->head; - if (read_icon_head->orig_x == icon_head->orig_x && - read_icon_head->orig_y == icon_head->orig_y) { + if (read_icon_head->orig_x == icon_head->orig_x && read_icon_head->orig_y == icon_head->orig_y) + { return read_icon_info; } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index c0ee0b29137..dfde4294db1 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -378,7 +378,8 @@ void DepsgraphNodeBuilder::begin_build() * possibly deleted memory. */ IDInfo *id_info = (IDInfo *)MEM_mallocN(sizeof(IDInfo), "depsgraph id info"); if (deg_copy_on_write_is_needed(id_node->id_type) && - deg_copy_on_write_is_expanded(id_node->id_cow) && id_node->id_orig != id_node->id_cow) { + deg_copy_on_write_is_expanded(id_node->id_cow) && id_node->id_orig != id_node->id_cow) + { id_info->id_cow = id_node->id_cow; } else { @@ -681,7 +682,8 @@ void DepsgraphNodeBuilder::build_collection(LayerCollection *from_layer_collecti if (built_map_.checkIsBuiltAndTag(collection)) { id_node = find_id_node(&collection->id); if (is_collection_visible && id_node->is_visible_on_build == false && - id_node->is_collection_fully_expanded == true) { + id_node->is_collection_fully_expanded == true) + { /* Collection became visible, make sure nested collections and * objects are poked with the new visibility flag, since they * might become visible too. */ @@ -815,7 +817,8 @@ void DepsgraphNodeBuilder::build_object(int base_index, } /* Force field Texture. */ if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) && - (object->pd->tex != nullptr)) { + (object->pd->tex != nullptr)) + { build_texture(object->pd->tex); } /* Object dupligroup. */ @@ -1144,8 +1147,8 @@ void DepsgraphNodeBuilder::build_animation_images(ID *id) bool has_image_animation = false; if (ELEM(GS(id->name), ID_MA, ID_WO)) { bNodeTree *ntree = *BKE_ntree_ptr_from_id(id); - if (ntree != nullptr && - ntree->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) { + if (ntree != nullptr && ntree->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) + { has_image_animation = true; } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index 6fd3aaf282a..0429fea6426 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -74,7 +74,8 @@ void DepsgraphNodeBuilder::build_ik_pose(Object *object, bPoseChannel *pchan, bC } if (has_operation_node( - &object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_IK_SOLVER)) { + &object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_IK_SOLVER)) + { return; } @@ -103,10 +104,9 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object, /* Find the chain's root. */ bPoseChannel *rootchan = BKE_armature_splineik_solver_find_root(pchan, data); - if (has_operation_node(&object->id, - NodeType::EVAL_POSE, - rootchan->name, - OperationCode::POSE_SPLINE_IK_SOLVER)) { + if (has_operation_node( + &object->id, NodeType::EVAL_POSE, rootchan->name, OperationCode::POSE_SPLINE_IK_SOLVER)) + { return; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 8398f5888f4..1d1e805552c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -120,7 +120,8 @@ namespace { bool driver_target_depends_on_time(const DriverTarget *target) { if (target->idtype == ID_SCE && - (target->rna_path != nullptr && STREQ(target->rna_path, "frame_current"))) { + (target->rna_path != nullptr && STREQ(target->rna_path, "frame_current"))) + { return true; } return false; @@ -313,8 +314,8 @@ void DepsgraphRelationBuilder::add_depends_on_transform_relation(const DepsNodeH void DepsgraphRelationBuilder::add_customdata_mask(Object *object, const DEGCustomDataMeshMasks &customdata_masks) { - if (customdata_masks != DEGCustomDataMeshMasks() && object != nullptr && - object->type == OB_MESH) { + if (customdata_masks != DEGCustomDataMeshMasks() && object != nullptr && object->type == OB_MESH) + { IDNode *id_node = graph_->find_id_node(&object->id); if (id_node == nullptr) { @@ -428,14 +429,16 @@ void DepsgraphRelationBuilder::add_particle_forcefield_relations(const Operation add_relation(eff_key, key, name); if (ELEM(relation->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) || - relation->pd->forcefield == PFIELD_GUIDE) { + relation->pd->forcefield == PFIELD_GUIDE) + { ComponentKey mod_key(&relation->ob->id, NodeType::GEOMETRY); add_relation(mod_key, key, name); } /* Force field Texture. */ if ((relation->pd != nullptr) && (relation->pd->forcefield == PFIELD_TEXTURE) && - (relation->pd->tex != nullptr)) { + (relation->pd->tex != nullptr)) + { ComponentKey tex_key(&relation->pd->tex->id, NodeType::GENERIC_DATABLOCK); add_relation(tex_key, key, "Force field Texture"); } @@ -788,7 +791,8 @@ void DepsgraphRelationBuilder::build_object(Object *object) /* Force field Texture. */ if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) && - (object->pd->tex != nullptr)) { + (object->pd->tex != nullptr)) + { build_texture(object->pd->tex); } @@ -1236,7 +1240,8 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, if (ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, - CONSTRAINT_TYPE_OBJECTSOLVER)) { + CONSTRAINT_TYPE_OBJECTSOLVER)) + { bool depends_on_camera = false; if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) { bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data; @@ -1300,7 +1305,8 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, } /* if needs bbone shape, reference the segment computation */ if (BKE_constraint_target_uses_bbone(con, ct) && - check_pchan_has_bbone_segments(ct->tar, ct->subtarget)) { + check_pchan_has_bbone_segments(ct->tar, ct->subtarget)) + { opcode = OperationCode::BONE_SEGMENTS; } OperationKey target_key(&ct->tar->id, NodeType::BONE, ct->subtarget, opcode); @@ -1376,7 +1382,8 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, CONSTRAINT_TYPE_ROTLIKE, CONSTRAINT_TYPE_SIZELIKE, CONSTRAINT_TYPE_LOCLIKE, - CONSTRAINT_TYPE_TRANSLIKE)) { + CONSTRAINT_TYPE_TRANSLIKE)) + { /* TODO(sergey): Add used space check. */ ComponentKey target_transform_key(&ct->tar->id, NodeType::TRANSFORM); add_relation(target_transform_key, constraint_op_key, cti->name); @@ -1540,8 +1547,8 @@ void DepsgraphRelationBuilder::build_animation_images(ID *id) bool has_image_animation = false; if (ELEM(GS(id->name), ID_MA, ID_WO)) { bNodeTree *ntree = *BKE_ntree_ptr_from_id(id); - if (ntree != nullptr && - ntree->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) { + if (ntree != nullptr && ntree->runtime->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) + { has_image_animation = true; } } @@ -1782,7 +1789,8 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) } /* Special handling for directly-named bones. */ if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (object && object->type == OB_ARMATURE) && - (dtar->pchan_name[0])) { + (dtar->pchan_name[0])) + { bPoseChannel *target_pchan = BKE_pose_channel_find_name(object->pose, dtar->pchan_name); if (target_pchan == nullptr) { continue; @@ -1811,7 +1819,8 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu) continue; } if (is_same_bone_dependency(variable_exit_key, self_key) || - is_same_nodetree_node_dependency(variable_exit_key, self_key)) { + is_same_nodetree_node_dependency(variable_exit_key, self_key)) + { continue; } add_relation(variable_exit_key, driver_key, "RNA Target -> Driver"); @@ -1994,7 +2003,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) add_relation(effector_geometry_key, rb_init_key, "RigidBody Field"); } if ((effector_relation->pd->forcefield == PFIELD_TEXTURE) && - (effector_relation->pd->tex != nullptr)) { + (effector_relation->pd->tex != nullptr)) + { ComponentKey tex_key(&effector_relation->pd->tex->id, NodeType::GENERIC_DATABLOCK); add_relation(tex_key, rb_init_key, "Force field Texture"); } @@ -2012,7 +2022,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) } if (object->parent != nullptr && object->parent->rigidbody_object != nullptr && - object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) { + object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) + { /* If we are a child of a compound shape object, the transforms and sim evaluation will be * handled by the parent compound shape object. Do not add any evaluation triggers * for the child objects. @@ -2105,7 +2116,8 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) psys_key, object, part->collision_group, "Particle Collision"); } else if ((psys->flag & PSYS_HAIR_DYNAMICS) && psys->clmd != nullptr && - psys->clmd->coll_parms != nullptr) { + psys->clmd->coll_parms != nullptr) + { add_particle_collision_relations( psys_key, object, psys->clmd->coll_parms->group, "Hair Collision"); } @@ -3212,7 +3224,8 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node) } int rel_flag = (RELATION_FLAG_NO_FLUSH | RELATION_FLAG_GODMODE); if ((ELEM(id_type, ID_ME, ID_CV, ID_PT, ID_VO) && comp_node->type == NodeType::GEOMETRY) || - (id_type == ID_CF && comp_node->type == NodeType::CACHE)) { + (id_type == ID_CF && comp_node->type == NodeType::CACHE)) + { rel_flag &= ~RELATION_FLAG_NO_FLUSH; } /* TODO(sergey): Needs better solution for this. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h index 83d12bea6a1..8f6e780371c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h @@ -166,8 +166,8 @@ bool DepsgraphRelationBuilder::is_same_bone_dependency(const KeyFrom &key_from, return false; } /* We are only interested in relations like BONE_DONE -> BONE_LOCAL... */ - if (!(op_from->opcode == OperationCode::BONE_DONE && - op_to->opcode == OperationCode::BONE_LOCAL)) { + if (!(op_from->opcode == OperationCode::BONE_DONE && op_to->opcode == OperationCode::BONE_LOCAL)) + { return false; } /* ... BUT, we also need to check if it's same bone. */ @@ -202,7 +202,8 @@ bool DepsgraphRelationBuilder::is_same_nodetree_node_dependency(const KeyFrom &k } /* We are only interested in relations like BONE_DONE -> BONE_LOCAL... */ if (!(op_from->opcode == OperationCode::PARAMETERS_EVAL && - op_to->opcode == OperationCode::PARAMETERS_EVAL)) { + op_to->opcode == OperationCode::PARAMETERS_EVAL)) + { return false; } return true; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index 2de07998ba9..799b0fc06da 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -239,7 +239,8 @@ void DepsgraphRelationBuilder::build_splineik_pose(Object *object, /* Walk to the chain's root/ */ int segcount = 1; for (bPoseChannel *parchan = pchan->parent; parchan != nullptr && segcount < data->chainlen; - parchan = parchan->parent, segcount++) { + parchan = parchan->parent, segcount++) + { /* Make Spline IK solver dependent on this bone's result, since it can * only run after the standard results of the bone are know. Validate * links step on the bone will ensure that users of this bone only grab @@ -430,7 +431,8 @@ void DepsgraphRelationBuilder::build_rig(Object *object) OperationCode opcode = OperationCode::BONE_DONE; /* Inheriting parent roll requires access to prev handle's B-Bone properties. */ if ((pchan->bone->bbone_flag & BBONE_ADD_PARENT_END_ROLL) != 0 && - check_pchan_has_bbone_segments(object, prev)) { + check_pchan_has_bbone_segments(object, prev)) + { opcode = OperationCode::BONE_SEGMENTS; } OperationKey prev_key(&object->id, NodeType::BONE, prev->name, opcode); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index c6273b66d90..a50053acf68 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -268,7 +268,8 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, } else if (RNA_struct_is_a(ptr->type, &RNA_Modifier) && (contains(prop_identifier, "show_viewport") || - contains(prop_identifier, "show_render"))) { + contains(prop_identifier, "show_render"))) + { node_identifier.type = NodeType::GEOMETRY; node_identifier.operation_code = OperationCode::VISIBILITY; return node_identifier; @@ -281,7 +282,8 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, RNA_struct_is_a(ptr->type, &RNA_MeshUVLoop) || RNA_struct_is_a(ptr->type, &RNA_MeshLoopColor) || RNA_struct_is_a(ptr->type, &RNA_VertexGroupElement) || - RNA_struct_is_a(ptr->type, &RNA_ShaderFx)) { + RNA_struct_is_a(ptr->type, &RNA_ShaderFx)) + { /* When modifier is used as FROM operation this is likely referencing to * the property (for example, modifier's influence). * But when it's used as TO operation, this is geometry component. */ @@ -313,7 +315,8 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, contains(prop_identifier, "delta_location") || contains(prop_identifier, "delta_rotation_euler") || contains(prop_identifier, "delta_rotation_quaternion") || - contains(prop_identifier, "delta_scale")) { + contains(prop_identifier, "delta_scale")) + { node_identifier.type = NodeType::TRANSFORM; return node_identifier; } diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc index 1b90a55bf66..70823da0a73 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.cc +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -104,7 +104,8 @@ void DEG_add_collision_relations(DepsNodeHandle *handle, continue; } if (filter_function == nullptr || - filter_function(ob1, BKE_modifiers_findby_type(ob1, (ModifierType)modifier_type))) { + filter_function(ob1, BKE_modifiers_findby_type(ob1, (ModifierType)modifier_type))) + { DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name); DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name); } @@ -134,7 +135,8 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle, DEG_add_object_pointcache_relation(handle, relation->ob, DEG_OB_COMP_TRANSFORM, name); if (relation->psys || ELEM(relation->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) || - relation->pd->forcefield == PFIELD_GUIDE) { + relation->pd->forcefield == PFIELD_GUIDE) + { /* TODO(sergey): Consider going more granular with more dedicated * particle system operation. */ DEG_add_object_pointcache_relation(handle, relation->ob, DEG_OB_COMP_GEOMETRY, name); diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc index 3fdff6b1302..a95b29764b8 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc @@ -68,7 +68,8 @@ void deg_foreach_dependent_operation(const Depsgraph * /*graph*/, } if (source_component_type != DEG_OB_COMP_ANY && - nodeTypeToObjectComponent(comp_node->type) != source_component_type) { + nodeTypeToObjectComponent(comp_node->type) != source_component_type) + { continue; } for (OperationNode *op_node : comp_node->operations) { diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index ccfb184ec73..27e194230e0 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -271,7 +271,8 @@ bool deg_iterator_objects_step(DEGObjectIterData *data) if (ob_visibility & OB_VISIBLE_INSTANCES) { if ((data->flag & DEG_ITER_OBJECT_FLAG_DUPLI) && - ((object->transflag & OB_DUPLI) || object->runtime.geometry_set_eval != nullptr)) { + ((object->transflag & OB_DUPLI) || object->runtime.geometry_set_eval != nullptr)) + { ListBase *duplis = object_duplilist(data->graph, data->scene, object); deg_iterator_duplis_init(data, object, duplis); } diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index e0397dad038..fcb3b6308db 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -359,7 +359,8 @@ void depsgraph_ensure_view_layer(Depsgraph *graph) * This allows us to have proper view layer pointer. */ Scene *scene_cow = graph->scene_cow; if (deg_copy_on_write_is_expanded(&scene_cow->id) && - (scene_cow->id.recalc & ID_RECALC_COPY_ON_WRITE) == 0) { + (scene_cow->id.recalc & ID_RECALC_COPY_ON_WRITE) == 0) + { return; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 6675fd150d0..ff0b64a20ce 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -381,7 +381,8 @@ void scene_minimize_unused_view_layers(const Depsgraph *depsgraph, for (ViewLayer *view_layer_cow = reinterpret_cast(scene_cow->view_layers.first), *view_layer_next; view_layer_cow != nullptr; - view_layer_cow = view_layer_next) { + view_layer_cow = view_layer_next) + { view_layer_next = view_layer_cow->next; if (view_layer_input != nullptr && STREQ(view_layer_input->name, view_layer_cow->name)) { view_layer_eval = view_layer_cow; @@ -887,7 +888,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode /* In case we don't need to do a copy-on-write, we can use the update cache of the grease * pencil data to do an update-on-write. */ if (id_type == ID_GD_LEGACY && BKE_gpencil_can_avoid_full_copy_on_write( - (const ::Depsgraph *)depsgraph, (bGPdata *)id_orig)) { + (const ::Depsgraph *)depsgraph, (bGPdata *)id_orig)) + { BKE_gpencil_update_on_write((bGPdata *)id_orig, (bGPdata *)id_cow); return id_cow; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 31048a81028..40f9c7288a5 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -178,7 +178,8 @@ inline OperationNode *flush_schedule_children(OperationNode *op_node, FlushQueue /* Relation only allows flushes on user changes, but the node was not * affected by user. */ if ((rel->flag & RELATION_FLAG_FLUSH_USER_EDIT_ONLY) && - (op_node->flag & DEPSOP_FLAG_USER_MODIFIED) == 0) { + (op_node->flag & DEPSOP_FLAG_USER_MODIFIED) == 0) + { continue; } OperationNode *to_node = (OperationNode *)rel->to; @@ -251,12 +252,12 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd * changed. CoW IDs indirectly modified because of changes in other IDs should never * require a lib-override diffing. */ if (ID_IS_OVERRIDE_LIBRARY_REAL(id_orig)) { - id_orig->tag |= LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + id_orig->tag |= LIB_TAG_LIBOVERRIDE_AUTOREFRESH; } else if (ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id_orig)) { switch (GS(id_orig->name)) { case ID_KE: - ((Key *)id_orig)->from->tag |= LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + ((Key *)id_orig)->from->tag |= LIB_TAG_LIBOVERRIDE_AUTOREFRESH; break; case ID_GR: BLI_assert(id_orig->flag & LIB_EMBEDDED_DATA); diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc index 7688ffda26f..4f6af6fa0ef 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc @@ -44,7 +44,8 @@ void animated_property_store_cb(ID *id, FCurve *fcurve, void *data_v) /* Resolve path to the property. */ PathResolvedRNA resolved_rna; if (!BKE_animsys_rna_path_resolve( - &data->id_pointer_rna, fcurve->rna_path, fcurve->array_index, &resolved_rna)) { + &data->id_pointer_rna, fcurve->rna_path, fcurve->array_index, &resolved_rna)) + { return; } @@ -104,7 +105,8 @@ void AnimationBackup::restore_to_id(ID *id) if (!BKE_animsys_rna_path_resolve(&id_pointer_rna, value_backup.rna_path.c_str(), value_backup.array_index, - &resolved_rna)) { + &resolved_rna)) + { return; } diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index cc2feeec42b..9702a2d6a26 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -106,7 +106,8 @@ OperationNode *ComponentNode::find_operation(OperationIDKey key) const else { for (OperationNode *op_node : operations) { if (op_node->opcode == key.opcode && op_node->name_tag == key.name_tag && - STREQ(op_node->name.c_str(), key.name)) { + STREQ(op_node->name.c_str(), key.name)) + { node = op_node; break; } diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 7dcf05651f9..01c4d4c7757 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -173,7 +173,8 @@ static void basic_cache_populate(void *vedata, Object *ob) /* Make flat object selectable in ortho view if wireframe is enabled. */ if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) || - (draw_ctx->v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)) { + (draw_ctx->v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)) + { int flat_axis = 0; bool is_flat_object_viewed_from_side = ((draw_ctx->rv3d->persp == RV3D_ORTHO) && DRW_object_is_flat(ob, &flat_axis) && diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index d805a039e8f..df5c761a73e 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -500,7 +500,8 @@ static void eevee_cryptomatte_postprocess_weights(EEVEE_Data *vedata) int accum_pixel_stride = eevee_cryptomatte_pixel_stride(view_layer); for (int pixel_index = 0; pixel_index < buffer_size; - pixel_index++, accum_pixel_index += accum_pixel_stride) { + pixel_index++, accum_pixel_index += accum_pixel_stride) + { float coverage = 1.0f; if (volumetric_transmittance_buffer != NULL) { coverage = (volumetric_transmittance_buffer[pixel_index * 4] + diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index 29e0c0665ed..08a598772d7 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -345,7 +345,8 @@ static void dof_bokeh_pass_init(EEVEE_FramebufferList *fbl, EEVEE_EffectsInfo *fx) { if ((fx->dof_bokeh_aniso[0] == 1.0f) && (fx->dof_bokeh_aniso[1] == 1.0f) && - (fx->dof_bokeh_blades == 0.0)) { + (fx->dof_bokeh_blades == 0.0)) + { fx->dof_bokeh_gather_lut_tx = NULL; fx->dof_bokeh_scatter_lut_tx = NULL; fx->dof_bokeh_resolve_lut_tx = NULL; @@ -631,7 +632,8 @@ static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl, /* TODO(@fclem): In the future, we need to check if mip_count did not change. * For now it's ok as we always define all mip level. */ if (res[0] != GPU_texture_width(txl->dof_reduced_color) || - res[1] != GPU_texture_width(txl->dof_reduced_color)) { + res[1] != GPU_texture_width(txl->dof_reduced_color)) + { DRW_TEXTURE_FREE_SAFE(txl->dof_reduced_color); DRW_TEXTURE_FREE_SAFE(txl->dof_reduced_coc); } diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 2b4ea6bf848..6540414bde0 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -390,7 +390,8 @@ void EEVEE_create_minmax_buffer(EEVEE_Data *vedata, GPUTexture *depth_src, int l GPU_framebuffer_bind(fbl->main_fb); if (GPU_mip_render_workaround() || - GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY)) { + GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY)) + { /* Fix dot corruption on intel HD5XX/HD6XX series. */ GPU_flush(); } @@ -503,7 +504,8 @@ void EEVEE_draw_effects(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) if (!stl->g_data->valid_double_buffer && ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) && - (DRW_state_is_image_render() == false)) { + (DRW_state_is_image_render() == false)) + { /* If history buffer is not valid request another frame. * This fix black reflections on area resize. */ DRW_viewport_request_redraw(); diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 9a3215eeb97..3afbc361dfd 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -230,7 +230,8 @@ static void eevee_draw_scene(void *vedata) bool taa_use_reprojection = (stl->effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0; if (DRW_state_is_image_render() || taa_use_reprojection || - ((stl->effects->enabled_effects & EFFECT_TAA) != 0)) { + ((stl->effects->enabled_effects & EFFECT_TAA) != 0)) + { int samp = taa_use_reprojection ? stl->effects->taa_reproject_sample + 1 : stl->effects->taa_current_sample; BLI_halton_3d(primes, offset, samp, r); @@ -256,14 +257,16 @@ static void eevee_draw_scene(void *vedata) if (((stl->effects->enabled_effects & EFFECT_TAA) != 0) && (stl->effects->taa_current_sample > 1) && !DRW_state_is_image_render() && - !taa_use_reprojection) { + !taa_use_reprojection) + { DRW_view_set_active(stl->effects->taa_view); } /* when doing viewport rendering the overrides needs to be recalculated for * every loop as this normally happens once inside * `EEVEE_temporal_sampling_init` */ else if (((stl->effects->enabled_effects & EFFECT_TAA) != 0) && - (stl->effects->taa_current_sample > 1) && DRW_state_is_image_render()) { + (stl->effects->taa_current_sample > 1) && DRW_state_is_image_render()) + { EEVEE_temporal_sampling_update_matrices(vedata); } @@ -342,7 +345,8 @@ static void eevee_draw_scene(void *vedata) DRW_view_set_active(NULL); if (DRW_state_is_image_render() && (stl->effects->enabled_effects & EFFECT_SSR) && - !stl->effects->ssr_was_valid_double_buffer) { + !stl->effects->ssr_was_valid_double_buffer) + { /* SSR needs one iteration to start properly. */ loop_len++; /* Reset sampling (and accumulation) after the first sample to avoid diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 83a978ccff6..03597f1bb0d 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -309,11 +309,13 @@ static bool EEVEE_lightcache_validate(const LightCache *light_cache, /* See if we need the same amount of texture space. */ if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) && (irr_size[1] == light_cache->grid_tx.tex_size[1]) && - (irr_size[2] == light_cache->grid_tx.tex_size[2]) && (grid_len == light_cache->grid_len)) { + (irr_size[2] == light_cache->grid_tx.tex_size[2]) && (grid_len == light_cache->grid_len)) + { int mip_len = log2_floor_u(cube_res) - MIN_CUBE_LOD_LEVEL; if ((cube_res == light_cache->cube_tx.tex_size[0]) && (cube_len == light_cache->cube_tx.tex_size[2] / 6) && - (cube_len == light_cache->cube_len) && (mip_len == light_cache->mips_len)) { + (cube_len == light_cache->cube_len) && (mip_len == light_cache->mips_len)) + { return true; } } @@ -386,7 +388,8 @@ static bool eevee_lightcache_static_load(LightCache *lcache) { /* We use fallback if a texture is not setup and there is no data to restore it. */ if ((!lcache->grid_tx.tex && !lcache->grid_tx.data) || !lcache->grid_data || - (!lcache->cube_tx.tex && !lcache->cube_tx.data) || !lcache->cube_data) { + (!lcache->cube_tx.tex && !lcache->cube_tx.data) || !lcache->cube_data) + { return false; } /* If cache is too big for this GPU. */ @@ -731,7 +734,8 @@ static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake) /* TODO: validate irradiance and reflection cache independently... */ if (!EEVEE_lightcache_validate( - lbake->lcache, lbake->cube_len, lbake->ref_cube_res, lbake->grid_len, lbake->irr_size)) { + lbake->lcache, lbake->cube_len, lbake->ref_cube_res, lbake->grid_len, lbake->irr_size)) + { eevee->light_cache_data = lbake->lcache = NULL; } @@ -1104,10 +1108,12 @@ static void compute_cell_id(EEVEE_LightGrid *egrid, *r_final_idx = i; cell_id_to_grid_loc(egrid, *r_final_idx, r_local_cell); if (((r_local_cell[0] % *r_stride) == 0) && ((r_local_cell[1] % *r_stride) == 0) && - ((r_local_cell[2] % *r_stride) == 0)) { + ((r_local_cell[2] % *r_stride) == 0)) + { if (!(((r_local_cell[0] % prev_stride) == 0) && ((r_local_cell[1] % prev_stride) == 0) && ((r_local_cell[2] % prev_stride) == 0)) || - ((i == 0) && (lvl == max_lvl))) { + ((i == 0) && (lvl == max_lvl))) + { if (visited_cells == cell_idx) { return; } @@ -1209,7 +1215,8 @@ static void eevee_lightbake_render_grid_sample(void *ved, void *user_data) /* If it is the last sample grid sample (and last bounce). */ if ((lbake->bounce_curr == lbake->bounce_len - 1) && (lbake->grid_curr == lbake->grid_len - 1) && - (lbake->grid_sample == lbake->grid_sample_len - 1)) { + (lbake->grid_sample == lbake->grid_sample_len - 1)) + { lcache->flag &= ~LIGHTCACHE_UPDATE_GRID; } } @@ -1458,7 +1465,8 @@ void EEVEE_lightbake_job(void *custom_data, bool *stop, bool *do_update, float * lbake->probe = lbake->grid_prb + 1; lbake->grid = lcache->grid_data + 1; for (lbake->grid_curr = 1; lbake->grid_curr < lbake->grid_len; - lbake->grid_curr++, lbake->probe++, lbake->grid++) { + lbake->grid_curr++, lbake->probe++, lbake->grid++) + { LightProbe *prb = *lbake->probe; lbake->grid_sample_len = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; @@ -1476,7 +1484,8 @@ void EEVEE_lightbake_job(void *custom_data, bool *stop, bool *do_update, float * lbake->probe = lbake->cube_prb + 1; lbake->cube = lcache->cube_data + 1; for (lbake->cube_offset = 1; lbake->cube_offset < lbake->cube_len; - lbake->cube_offset++, lbake->probe++, lbake->cube++) { + lbake->cube_offset++, lbake->probe++, lbake->cube++) + { lightbake_do_sample(lbake, eevee_lightbake_render_probe_sample); } } diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 20f5d53378f..cba80ebbd3f 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -94,7 +94,8 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref) /* Fix case were the pool was allocated width the dummy size (1,1,1). */ if (txl->planar_pool && (num_planar_ref > 0) && (GPU_texture_width(txl->planar_pool) != width || - GPU_texture_height(txl->planar_pool) != height)) { + GPU_texture_height(txl->planar_pool) != height)) + { DRW_TEXTURE_FREE_SAFE(txl->planar_pool); DRW_TEXTURE_FREE_SAFE(txl->planar_depth); } @@ -148,7 +149,8 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } else { if (scene_eval->eevee.light_cache_data && - (scene_eval->eevee.light_cache_data->flag & LIGHTCACHE_NOT_USABLE)) { + (scene_eval->eevee.light_cache_data->flag & LIGHTCACHE_NOT_USABLE)) + { /* Error message info. */ BLI_snprintf( vedata->info, sizeof(vedata->info), "Error: LightCache cannot be loaded on this GPU"); @@ -437,7 +439,8 @@ void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= EEVEE_PROBE_MAX) || (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= EEVEE_PROBE_MAX) || - (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_planar >= MAX_PLANAR)) { + (probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_planar >= MAX_PLANAR)) + { printf("Too many probes in the view !!!\n"); return; } @@ -708,7 +711,8 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved /* If light-cache auto-update is enable we tag the relevant part * of the cache to update and fire up a baking job. */ if (!DRW_state_is_image_render() && !DRW_state_is_opengl_render() && - (pinfo->do_grid_update || pinfo->do_cube_update)) { + (pinfo->do_grid_update || pinfo->do_cube_update)) + { BLI_assert(draw_ctx->evil_C); if (draw_ctx->scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) { @@ -1249,8 +1253,8 @@ void EEVEE_lightprobes_refresh(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); LightCache *light_cache = vedata->stl->g_data->light_cache; - if ((light_cache->flag & LIGHTCACHE_UPDATE_WORLD) && - (light_cache->flag & LIGHTCACHE_BAKED) == 0) { + if ((light_cache->flag & LIGHTCACHE_UPDATE_WORLD) && (light_cache->flag & LIGHTCACHE_BAKED) == 0) + { EEVEE_lightbake_update_world_quick(sldata, vedata, scene_eval); } } diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 85ea69b97f5..78ecd9a2fe4 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -111,7 +111,8 @@ void EEVEE_lookdev_init(EEVEE_Data *vedata) const int sphere_size = U.lookdev_sphere_size * UI_SCALE_FAC * viewport_scale; if (sphere_size != effects->sphere_size || rect->xmax != effects->anchor[0] || - rect->ymin != effects->anchor[1]) { + rect->ymin != effects->anchor[1]) + { /* Make sphere resolution adaptive to viewport_scale, DPI and #U.lookdev_sphere_size. */ float res_scale = clamp_f( (U.lookdev_sphere_size / 400.0f) * viewport_scale * UI_SCALE_FAC, 0.1f, 1.0f); @@ -176,7 +177,8 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, /* If one of the component is missing we start from scratch. */ if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) || (txl->lookdev_grid_tx == NULL) || (txl->lookdev_cube_tx == NULL) || - (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) { + (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) + { eevee_lookdev_lightcache_delete(vedata); } @@ -257,7 +259,8 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, g_data->studiolight_intensity != shading->studiolight_intensity || g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution || g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp || - g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) { + g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) + { stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD; g_data->studiolight_index = sl->index; copy_m3_m3(g_data->studiolight_matrix, studiolight_matrix); diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 704e932a46c..71455357afa 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -388,7 +388,8 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), /* Avoid drawing object that has no motions since object_moves is always true. */ if (!mb_geom->use_deform && /* Object deformation can happen without transform. */ equals_m4m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]) && - equals_m4m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR])) { + equals_m4m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR])) + { return; } @@ -452,7 +453,8 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) for (BLI_ghashIterator_init(&ghi, effects->motion_blur.object); BLI_ghashIterator_done(&ghi) == false; - BLI_ghashIterator_step(&ghi)) { + BLI_ghashIterator_step(&ghi)) + { EEVEE_ObjectMotionData *mb_data = BLI_ghashIterator_getValue(&ghi); EEVEE_HairMotionData *mb_hair = mb_data->hair_data; EEVEE_GeometryMotionData *mb_geom = mb_data->geometry_data; @@ -470,7 +472,8 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) EEVEE_HairMotionStepData **step_data_cache_ptr; if (!BLI_ghash_ensure_p(effects->motion_blur.hair_motion_step_cache[mb_step], vbo, - (void ***)&step_data_cache_ptr)) { + (void ***)&step_data_cache_ptr)) + { EEVEE_HairMotionStepData *new_step_data = MEM_callocN(sizeof(EEVEE_HairMotionStepData), __func__); /* Duplicate the vbo, otherwise it would be lost when evaluating another frame. */ @@ -519,9 +522,9 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) GPU_vertbuf_use(vbo); /* Perform a copy to avoid losing it after RE_engine_frame_set(). */ GPUVertBuf **vbo_cache_ptr; - if (!BLI_ghash_ensure_p(effects->motion_blur.position_vbo_cache[mb_step], - vbo, - (void ***)&vbo_cache_ptr)) { + if (!BLI_ghash_ensure_p( + effects->motion_blur.position_vbo_cache[mb_step], vbo, (void ***)&vbo_cache_ptr)) + { /* Duplicate the vbo, otherwise it would be lost when evaluating another frame. */ GPUVertBuf *duplicated_vbo = GPU_vertbuf_duplicate(vbo); *vbo_cache_ptr = duplicated_vbo; @@ -576,7 +579,8 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata) /* Rename attributes in #position_vbo_cache. */ for (BLI_ghashIterator_init(&ghi, effects->motion_blur.position_vbo_cache[MB_PREV]); !BLI_ghashIterator_done(&ghi); - BLI_ghashIterator_step(&ghi)) { + BLI_ghashIterator_step(&ghi)) + { GPUVertBuf *vbo = BLI_ghashIterator_getValue(&ghi); GPUVertFormat *format = (GPUVertFormat *)GPU_vertbuf_get_format(vbo); int attrib_id = GPU_vertformat_attr_id_get(format, "nxt"); @@ -585,7 +589,8 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata) /* Object Data. */ for (BLI_ghashIterator_init(&ghi, effects->motion_blur.object); !BLI_ghashIterator_done(&ghi); - BLI_ghashIterator_step(&ghi)) { + BLI_ghashIterator_step(&ghi)) + { EEVEE_ObjectMotionData *mb_data = BLI_ghashIterator_getValue(&ghi); EEVEE_GeometryMotionData *mb_geom = mb_data->geometry_data; EEVEE_HairMotionData *mb_hair = mb_data->hair_data; diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index 85e19927011..78f790e7742 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -43,7 +43,8 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } if (scene_eval->eevee.flag & SCE_EEVEE_GTAO_ENABLED || - stl->g_data->render_passes & EEVEE_RENDER_PASS_AO) { + stl->g_data->render_passes & EEVEE_RENDER_PASS_AO) + { const float *viewport_size = DRW_viewport_size_get(); const int fs_size[2] = {(int)viewport_size[0], (int)viewport_size[1]}; @@ -203,8 +204,8 @@ void EEVEE_occlusion_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) } if (GPU_mip_render_workaround() || - GPU_type_matches_ex( - GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { + GPU_type_matches_ex(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) + { /* Fix dot corruption on intel HD5XX/HD6XX series. */ GPU_flush(); } diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 1be0901085e..4e34b5a5efe 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -561,7 +561,8 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl double r[3]; if ((stl->effects->enabled_effects & EFFECT_SSR) && (render_samples == 1) && - !stl->effects->ssr_was_valid_double_buffer) { + !stl->effects->ssr_was_valid_double_buffer) + { /* SSR needs one iteration to start properly. * This iteration was done, reset to the original target sample count. */ render_samples--; diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c index 237c830d547..5099d021f2d 100644 --- a/source/blender/draw/engines/eevee/eevee_renderpasses.c +++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c @@ -138,7 +138,8 @@ BLI_INLINE bool eevee_renderpasses_volumetric_active(const EEVEE_EffectsInfo *ef { if (effects->enabled_effects & EFFECT_VOLUMETRIC) { if (g_data->render_passes & - (EEVEE_RENDER_PASS_VOLUME_LIGHT | EEVEE_RENDERPASSES_USES_TRANSMITTANCE)) { + (EEVEE_RENDER_PASS_VOLUME_LIGHT | EEVEE_RENDERPASSES_USES_TRANSMITTANCE)) + { return true; } } @@ -183,7 +184,8 @@ void EEVEE_renderpasses_output_init(EEVEE_ViewLayerData *sldata, } if ((g_data->render_passes & EEVEE_RENDER_PASS_BLOOM) != 0 && - (effects->enabled_effects & EFFECT_BLOOM) != 0) { + (effects->enabled_effects & EFFECT_BLOOM) != 0) + { EEVEE_bloom_output_init(sldata, vedata, tot_samples); } @@ -433,7 +435,8 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const int current_sample = stl->effects->taa_current_sample; const int total_samples = stl->effects->taa_total_sample; if ((render_pass & EEVEE_RENDERPASSES_POST_PROCESS_ON_FIRST_SAMPLE) && - (current_sample > 1 && total_samples != 1)) { + (current_sample > 1 && total_samples != 1)) + { return; } diff --git a/source/blender/draw/engines/eevee/eevee_shaders_extra.cc b/source/blender/draw/engines/eevee/eevee_shaders_extra.cc index 07838d7cd76..0b821efc93c 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders_extra.cc +++ b/source/blender/draw/engines/eevee/eevee_shaders_extra.cc @@ -59,7 +59,8 @@ void eevee_shader_material_create_info_amend(GPUMaterial *gpumat, info.define("USE_SHADER_TO_RGBA"); } if (GPU_material_flag_get(gpumat, GPU_MATFLAG_BARYCENTRIC) && !is_volume && !is_hair && - !is_point_cloud && !is_background) { + !is_point_cloud && !is_background) + { info.define("USE_BARYCENTRICS"); info.builtins(BuiltinBits::BARYCENTRIC_COORD); } diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c index 1282f8312cb..b602a68f586 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.c +++ b/source/blender/draw/engines/eevee/eevee_shadows.c @@ -67,7 +67,8 @@ void EEVEE_shadows_init(EEVEE_ViewLayerData *sldata) } if ((linfo->shadow_cascade_size != sh_cascade_size) || - (linfo->shadow_high_bitdepth != sh_high_bitdepth)) { + (linfo->shadow_high_bitdepth != sh_high_bitdepth)) + { BLI_assert((sh_cascade_size > 0) && (sh_cascade_size <= 4096)); DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_pool); CLAMP(sh_cascade_size, 1, 4096); diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index f7544f503c7..fcdde05a6f0 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -295,7 +295,8 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data if (((effects->taa_total_sample == 0) || (effects->taa_current_sample < effects->taa_total_sample)) || - (!view_is_valid) || DRW_state_is_image_render()) { + (!view_is_valid) || DRW_state_is_image_render()) + { if (view_is_valid) { /* Viewport rendering updates the matrices in `eevee_draw_scene` */ if (!DRW_state_is_image_render()) { @@ -392,7 +393,8 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata) /* Do reprojection for noise reduction */ /* TODO: do AA jitter if in only render view. */ if (!DRW_state_is_image_render() && (effects->enabled_effects & EFFECT_TAA_REPROJECT) != 0 && - stl->g_data->valid_taa_history) { + stl->g_data->valid_taa_history) + { GPU_framebuffer_bind(effects->target_buffer); DRW_draw_pass(psl->taa_resolve); SWAP_BUFFERS_TAA(); @@ -411,9 +413,9 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata) effects->taa_current_sample += 1; } else { - if (!DRW_state_is_playback() && - ((effects->taa_total_sample == 0) || - (effects->taa_current_sample < effects->taa_total_sample))) { + if (!DRW_state_is_playback() && ((effects->taa_total_sample == 0) || + (effects->taa_current_sample < effects->taa_total_sample))) + { DRW_viewport_request_redraw(); } } diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 859713e7c93..823631c126b 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -98,7 +98,8 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) /* TODO: compute snap to maxZBuffer for clustered rendering. */ if ((common_data->vol_tex_size[0] != tex_size[0]) || (common_data->vol_tex_size[1] != tex_size[1]) || - (common_data->vol_tex_size[2] != tex_size[2])) { + (common_data->vol_tex_size[2] != tex_size[2])) + { DRW_TEXTURE_FREE_SAFE(txl->volume_prop_scattering); DRW_TEXTURE_FREE_SAFE(txl->volume_prop_extinction); DRW_TEXTURE_FREE_SAFE(txl->volume_prop_emission); @@ -243,8 +244,8 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) /* World Volumetric */ struct World *wo = scene->world; - if (wo != NULL && wo->use_nodes && wo->nodetree && - !LOOK_DEV_STUDIO_LIGHT_ENABLED(draw_ctx->v3d)) { + if (wo != NULL && wo->use_nodes && wo->nodetree && !LOOK_DEV_STUDIO_LIGHT_ENABLED(draw_ctx->v3d)) + { struct GPUMaterial *mat = EEVEE_material_get(vedata, scene, NULL, wo, VAR_MAT_VOLUME); if (mat && GPU_material_has_volume_output(mat)) { diff --git a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl index 3f07f80571a..83bf29c813d 100644 --- a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl @@ -82,8 +82,8 @@ } \ \ /* Starts at 1 because 0 is world irradiance. */ \ - for (int i = 1; cl_common.diffuse_accum > 0.0 && i < prbNumRenderGrid && i < MAX_GRID; \ - i++) { \ + for (int i = 1; cl_common.diffuse_accum > 0.0 && i < prbNumRenderGrid && i < MAX_GRID; i++) \ + { \ ClosureGridData grid = closure_grid_eval_init(i, cl_common); \ if (grid.attenuation > 1e-8) { \ CLOSURE_META_SUBROUTINE_DATA(grid_eval, grid, t0, t1, t2, t3); \ diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl index 03837b97cb6..2de14ab89b7 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl @@ -160,7 +160,8 @@ void dof_gather_accumulator(float base_radius, first_ring = false; if (do_density_change && (ring == change_density_at_ring) && - (density_change < gather_max_density_change)) { + (density_change < gather_max_density_change)) + { if (dof_do_density_change(base_radius, min_intersectable_radius)) { base_radius *= radius_downscale_factor; ring += gather_density_change_ring; diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl index dc382e68d22..fa454dc5412 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl @@ -312,7 +312,8 @@ float dof_coc_max_slight_focus(float coc1, float coc2) /* Do not consider values below 0.5 for expansion as they are "encoded". * See setup pass shader for more infos. */ if ((coc1 == DOF_TILE_DEFOCUS && coc2 == DOF_TILE_FOCUS) || - (coc1 == DOF_TILE_FOCUS && coc2 == DOF_TILE_DEFOCUS)) { + (coc1 == DOF_TILE_FOCUS && coc2 == DOF_TILE_DEFOCUS)) + { /* Tile where completely out of focus and in focus are both present. * Consider as very slightly out of focus. */ return DOF_TILE_MIXED; diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl index f17c9b2bb51..6b95a6e4c67 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl @@ -59,7 +59,8 @@ void main() vec3 prev_volume = ndc_to_volume(prev_ndc * 0.5 + 0.5); if ((volHistoryAlpha > 0.0) && all(greaterThan(prev_volume, vec3(0.0))) && - all(lessThan(prev_volume, vec3(1.0)))) { + all(lessThan(prev_volume, vec3(1.0)))) + { vec4 h_Scattering = texture(historyScattering, prev_volume); vec4 h_Transmittance = texture(historyTransmittance, prev_volume); outScattering = mix(outScattering, h_Scattering, volHistoryAlpha); diff --git a/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc b/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc index db888df1973..9e5c9267981 100644 --- a/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc +++ b/source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc @@ -43,7 +43,8 @@ void Cryptomatte::begin_sync() } if (!(enabled_passes & - (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET))) { + (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET))) + { cryptomatte_object_buf.resize(16); } } @@ -52,7 +53,8 @@ void Cryptomatte::sync_object(Object *ob, ResourceHandle res_handle) { const eViewLayerEEVEEPassType enabled_passes = inst_.film.enabled_passes_get(); if (!(enabled_passes & - (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET))) { + (EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT | EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET))) + { return; } diff --git a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc index 92eeb31ad4d..1c2b9bafd66 100644 --- a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc +++ b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc @@ -126,7 +126,8 @@ void DepthOfField::sync() /* Balance blur radius between fx dof and jitter dof. */ if (do_jitter_ && (inst_.sampling.dof_ring_count_get() > 0) && !camera.is_panoramic() && - !inst_.is_viewport()) { + !inst_.is_viewport()) + { /* Compute a minimal overblur radius to fill the gaps between the samples. * This is just the simplified form of dividing the area of the bokeh by * the number of samples. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index b0a40d27982..95bcf92d32c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -286,7 +286,8 @@ void Instance::render_read_result(RenderLayer *render_layer, const char *view_na /* The vector pass is initialized to weird values. Set it to neutral value if not rendered. */ if ((pass_bits & EEVEE_RENDER_PASS_VECTOR) == 0) { for (std::string vector_pass_name : - Film::pass_to_render_pass_names(EEVEE_RENDER_PASS_VECTOR, view_layer)) { + Film::pass_to_render_pass_names(EEVEE_RENDER_PASS_VECTOR, view_layer)) + { RenderPass *vector_rp = RE_pass_find_by_name( render_layer, vector_pass_name.c_str(), view_name); if (vector_rp) { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index a210681517a..321af18b933 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -197,7 +197,8 @@ MaterialPass MaterialModule::material_pass_get(Object *ob, MAT_PIPE_FORWARD, MAT_PIPE_FORWARD_PREPASS, MAT_PIPE_FORWARD_PREPASS_VELOCITY) && - GPU_material_flag_get(matpass.gpumat, GPU_MATFLAG_TRANSPARENT)) { + GPU_material_flag_get(matpass.gpumat, GPU_MATFLAG_TRANSPARENT)) + { /* Transparent pass is generated later. */ matpass.sub_pass = nullptr; } diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.cc b/source/blender/draw/engines/eevee_next/eevee_shader.cc index 116d6004642..26d9642a525 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shader.cc @@ -257,7 +257,8 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu } if (GPU_material_flag_get(gpumat, GPU_MATFLAG_TRANSPARENT) == false && - pipeline_type == MAT_PIPE_FORWARD) { + pipeline_type == MAT_PIPE_FORWARD) + { /* Opaque forward do support AOVs and render pass if not using transparency. */ info.additional_info("eevee_aov_out"); info.additional_info("eevee_render_pass_out"); diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index 81e84d12961..80c82819a5a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -69,7 +69,8 @@ void ShadowTileMap::sync_cubeface( const float4x4 &object_mat_, float near_, float far_, eCubeFace face, float lod_bias_) { if (projection_type != SHADOW_PROJECTION_CUBEFACE || (cubeface != face) || (near != near_) || - (far != far_)) { + (far != far_)) + { set_dirty(); } projection_type = SHADOW_PROJECTION_CUBEFACE; @@ -1018,7 +1019,8 @@ void ShadowModule::debug_end_sync() eDebugMode::DEBUG_SHADOW_TILEMAPS, eDebugMode::DEBUG_SHADOW_VALUES, eDebugMode::DEBUG_SHADOW_TILE_RANDOM_COLOR, - eDebugMode::DEBUG_SHADOW_TILEMAP_RANDOM_COLOR)) { + eDebugMode::DEBUG_SHADOW_TILEMAP_RANDOM_COLOR)) + { return; } @@ -1156,7 +1158,8 @@ void ShadowModule::debug_draw(View &view, GPUFrameBuffer *view_fb) eDebugMode::DEBUG_SHADOW_TILEMAPS, eDebugMode::DEBUG_SHADOW_VALUES, eDebugMode::DEBUG_SHADOW_TILE_RANDOM_COLOR, - eDebugMode::DEBUG_SHADOW_TILEMAP_RANDOM_COLOR)) { + eDebugMode::DEBUG_SHADOW_TILEMAP_RANDOM_COLOR)) + { return; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl index 957c9b01a2a..8305bd4252e 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl @@ -524,7 +524,8 @@ void dof_gather_accumulator(sampler2D color_tx, first_ring = false; if (do_density_change && (ring == change_density_at_ring) && - (density_change < gather_max_density_change)) { + (density_change < gather_max_density_change)) + { if (dof_do_density_change(base_radius, min_intersectable_radius)) { base_radius *= radius_downscale_factor; ring += gather_density_change_ring; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl index 8ecaa0688a1..960097a2e2b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl @@ -315,7 +315,8 @@ float dof_history_blend_factor( blend = mix(blend, 1.0, coc_diff_ratio); /* Discard out of view history. */ if (any(lessThan(texel, vec2(0))) || - any(greaterThanEqual(texel, vec2(imageSize(out_history_img))))) { + any(greaterThanEqual(texel, vec2(imageSize(out_history_img))))) + { blend = 1.0; } /* Discard history if invalid. */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_debug_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_debug_frag.glsl index 1e3884bfcfb..67d06ef78a8 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_debug_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_debug_frag.glsl @@ -104,8 +104,8 @@ bool debug_tilemaps(vec3 P, LightData light) int tile_index = shadow_tile_offset(px % SHADOW_TILEMAP_RES, tilemap.tiles_index, 0); ShadowTileData tile = shadow_tile_unpack(tiles_buf[tile_index]); /* Leave 1 px border between tilemaps. */ - if (!any( - equal(ivec2(gl_FragCoord.xy) % (SHADOW_TILEMAP_RES * debug_tile_size_px), ivec2(0)))) { + if (!any(equal(ivec2(gl_FragCoord.xy) % (SHADOW_TILEMAP_RES * debug_tile_size_px), ivec2(0)))) + { gl_FragDepth = 0.0; out_color_add = vec4(debug_tile_state_color(tile), 0.0); out_color_mul = vec4(0.0); diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 11f147d5e36..2f540df235b 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -191,7 +191,8 @@ static void external_cache_populate(void *vedata, Object *ob) } if (!(DRW_object_is_renderable(ob) && - DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) { + DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) + { return; } diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index ec67c8cfbe4..4616fc48473 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -49,7 +49,8 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) for (int i = 0; i < tot_materials; i++) { MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, i + 1); if (((gp_style != NULL) && (gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT)) || - (gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT)) { + (gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT)) + { tgp_ob->do_mat_holdout = true; break; } @@ -299,7 +300,8 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl->mask_layers) { bGPDlayer *gpl_mask = BKE_gpencil_layer_named_get(gpd, mask->name); if (gpl_mask && (gpl_mask != gpl) && ((gpl_mask->flag & GP_LAYER_HIDE) == 0) && - ((mask->flag & GP_MASK_HIDE) == 0)) { + ((mask->flag & GP_MASK_HIDE) == 0)) + { int index = BLI_findindex(&gpd->layers, gpl_mask); if (index < GP_MAX_MASKBITS) { const bool invert = (mask->flag & GP_MASK_INVERT) != 0; diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 09667ff95ad..03c4c05b5b5 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -112,7 +112,8 @@ void GPENCIL_engine_init(void *ved) stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1; /* Special case: If Vertex Paint mode, use always Vertex mode. */ if (v3d->shading.type == OB_SOLID && ctx->obact && ctx->obact->type == OB_GPENCIL_LEGACY && - ctx->obact->mode == OB_MODE_VERTEX_GPENCIL) { + ctx->obact->mode == OB_MODE_VERTEX_GPENCIL) + { stl->pd->v3d_color_type = V3D_SHADING_VERTEX_COLOR; } @@ -473,8 +474,8 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, iter->pd->use_multiedit_lines_only; bool is_onion = gpl && gpf && gpf->runtime.onion_id != 0; bool hide_onion = is_onion && ((gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN) != 0); - if ((hide_material) || (!show_stroke && !show_fill) || (only_lines && !is_onion) || - (hide_onion)) { + if ((hide_material) || (!show_stroke && !show_fill) || (only_lines && !is_onion) || (hide_onion)) + { return; } @@ -917,7 +918,8 @@ void GPENCIL_draw_scene(void *ved) /* Fade 3D objects. */ if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != NULL) && - (pd->obact->type == OB_GPENCIL_LEGACY)) { + (pd->obact->type == OB_GPENCIL_LEGACY)) + { float background_color[3]; ED_view3d_background_color_get(pd->scene, pd->v3d, background_color); /* Blend color. */ diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index 2f2620e2a63..67b53384336 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -37,7 +37,8 @@ static bool effect_is_active(bGPdata *gpd, ShaderFxData *fx, bool is_viewport) } if (((fx->mode & eShaderFxMode_Realtime) && (is_viewport == true)) || - ((fx->mode & eShaderFxMode_Render) && (is_viewport == false))) { + ((fx->mode & eShaderFxMode_Render) && (is_viewport == false))) + { return true; } diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index e1499cf2711..afed17118d0 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -208,7 +208,8 @@ template class ScreenTileTextures : public BaseTextureMethod { bool assigned = false; for (TextureInfoBounds &info_bound : info_bounds) { if (info_bound.info == nullptr && - BLI_rctf_compare(&info_bound.uv_bounds, &info.clipping_uv_bounds, 0.001)) { + BLI_rctf_compare(&info_bound.uv_bounds, &info.clipping_uv_bounds, 0.001)) + { info_bound.info = &info; info.tile_id = info_bound.tile_id; assigned = true; @@ -490,8 +491,8 @@ template class ScreenSpaceDrawingMode : public AbstractD &extracted_buffer, texture_region_width, texture_region_height, 32, IB_rectfloat); int offset = 0; - for (int y = gpu_texture_region_to_update.ymin; y < gpu_texture_region_to_update.ymax; - y++) { + for (int y = gpu_texture_region_to_update.ymin; y < gpu_texture_region_to_update.ymax; y++) + { float yf = y / (float)texture_height; float v = info.clipping_uv_bounds.ymax * yf + info.clipping_uv_bounds.ymin * (1.0 - yf) - tile_offset_y; diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 20a9cde5310..4b71934ece7 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -98,7 +98,8 @@ bool OVERLAY_armature_is_pose_mode(Object *ob, const DRWContextState *draw_ctx) /* Pose armature is handled by pose mode engine. */ if (((ob == active_ob) || (ob->mode & OB_MODE_POSE)) && - ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) { + ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) + { return true; } @@ -1096,7 +1097,8 @@ static const float *get_bone_solid_with_consts_color(const ArmatureDrawContext * static float consts_color[4]; if ((arm->flag & ARM_POSEMODE) && !(boneflag & BONE_DRAW_LOCKED_WEIGHT) && - set_pchan_color(ctx, PCHAN_COLOR_CONSTS, boneflag, constflag, consts_color)) { + set_pchan_color(ctx, PCHAN_COLOR_CONSTS, boneflag, constflag, consts_color)) + { interp_v3_v3v3(consts_color, col, consts_color, 0.5f); } else { @@ -1551,7 +1553,8 @@ static void draw_points(ArmatureDrawContext *ctx, /* Draw root point if we are not connected to our parent */ if (!(eBone ? (eBone->parent && (boneflag & BONE_CONNECTED)) : - (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { + (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) + { if (select_id != -1) { DRW_select_load_id(select_id | BONESEL_ROOT); } @@ -1681,7 +1684,8 @@ static void draw_bone_envelope(ArmatureDrawContext *ctx, } if ((select_id == -1) && (boneflag & BONE_NO_DEFORM) == 0 && - ((boneflag & BONE_SELECTED) || (eBone && (boneflag & (BONE_ROOTSEL | BONE_TIPSEL))))) { + ((boneflag & BONE_SELECTED) || (eBone && (boneflag & (BONE_ROOTSEL | BONE_TIPSEL))))) + { drw_shgroup_bone_envelope_distance( ctx, BONE_VAR(eBone, pchan, disp_mat), rad_head, rad_tail, distance); } @@ -1732,7 +1736,8 @@ static void draw_bone_line(ArmatureDrawContext *ctx, /* Draw root point if we are not connected to our parent. */ if (!(eBone ? (eBone->parent && (boneflag & BONE_CONNECTED)) : - (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { + (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) + { if (eBone) { col_head = (eBone->flag & BONE_ROOTSEL) ? &G_draw.block.color_vertex_select.x : col_bone; @@ -2060,7 +2065,8 @@ static void draw_bone_relations(ArmatureDrawContext *ctx, /* Only draw if bone or its parent is selected - reduces viewport complexity with complex * rigs */ if ((boneflag & BONE_SELECTED) || - (pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED))) { + (pchan->parent->bone && (pchan->parent->bone->flag & BONE_SELECTED))) + { if ((boneflag & BONE_CONNECTED) == 0) { draw_bone_bone_relationship_line(ctx, pchan->pose_head, @@ -2261,7 +2267,8 @@ static void draw_armature_edit(ArmatureDrawContext *ctx) for (eBone = static_cast(arm->edbo->first), index = ob_orig->runtime.select_id; eBone; - eBone = eBone->next, index += 0x10000) { + eBone = eBone->next, index += 0x10000) + { if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A) == 0) { const int select_id = is_select ? index : uint(-1); @@ -2366,11 +2373,12 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) /* In weight paint mode retrieve the vertex group lock status. */ if ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && (draw_ctx->object_pose == ob) && - (draw_ctx->obact != nullptr)) { + (draw_ctx->obact != nullptr)) + { draw_locked_weights = true; - for (pchan = static_cast(ob->pose->chanbase.first); pchan; - pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { pchan->bone->flag &= ~BONE_DRAW_LOCKED_WEIGHT; } @@ -2391,7 +2399,8 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) const DRWView *view = is_pose_select ? DRW_view_default_get() : nullptr; for (pchan = static_cast(ob->pose->chanbase.first); pchan; - pchan = pchan->next, index += 0x10000) { + pchan = pchan->next, index += 0x10000) + { Bone *bone = pchan->bone; const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; diff --git a/source/blender/draw/engines/overlay/overlay_background.cc b/source/blender/draw/engines/overlay/overlay_background.cc index 2442efc033e..41e59fe3b9f 100644 --- a/source/blender/draw/engines/overlay/overlay_background.cc +++ b/source/blender/draw/engines/overlay/overlay_background.cc @@ -51,7 +51,8 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) color_override[3] = 1.0f; } else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_VIEWPORT && - v3d->shading.type <= OB_SOLID) { + v3d->shading.type <= OB_SOLID) + { background_type = BG_SOLID; copy_v3_v3(color_override, v3d->shading.background_color); color_override[3] = 1.0f; diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index d712b163c9b..90c83357477 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -416,7 +416,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) * first one in the order that is used during uv editing. We can only trust that the first object * has the correct batches with the correct selection state. See #83187. */ if ((pd->edit_uv.do_uv_overlay || pd->edit_uv.do_uv_shadow_overlay) && - draw_ctx->obact->type == OB_MESH) { + draw_ctx->obact->type == OB_MESH) + { uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data( draw_ctx->scene, draw_ctx->view_layer, nullptr, &objects_len, draw_ctx->object_mode); diff --git a/source/blender/draw/engines/overlay/overlay_extra.cc b/source/blender/draw/engines/overlay/overlay_extra.cc index 13feaf708aa..bc0b19f3aaa 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.cc +++ b/source/blender/draw/engines/overlay/overlay_extra.cc @@ -317,7 +317,8 @@ void OVERLAY_empty_shape(OVERLAY_ExtraCallBuffers *cb, void OVERLAY_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) { if (((ob->base_flag & BASE_FROM_DUPLI) != 0) && ((ob->transflag & OB_DUPLICOLLECTION) != 0) && - ob->instance_collection) { + ob->instance_collection) + { return; } @@ -980,7 +981,8 @@ static void camera_view3d_reconstruction( } if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA) && - !is_select) { + !is_select) + { const MovieTrackingReconstruction *reconstruction = &tracking_object->reconstruction; if (reconstruction->camnr) { @@ -1295,7 +1297,8 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, for (GpencilModifierData *md = static_cast(ob->greasepencil_modifiers.first); md; - md = md->next) { + md = md->next) + { if (md->type == eGpencilModifierType_Hook) { HookGpencilModifierData *hmd = (HookGpencilModifierData *)md; float center[3]; diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.cc b/source/blender/draw/engines/overlay/overlay_gpencil.cc index 7e0ac4f3d06..b9868e794ad 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil.cc +++ b/source/blender/draw/engines/overlay/overlay_gpencil.cc @@ -97,7 +97,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) (ts->gpencil_selectmode_edit != GP_SELECTMODE_STROKE)); if (!GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd) && - ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask)) { + ((!GPENCIL_VERTEX_MODE(gpd) && !GPENCIL_PAINT_MODE(gpd)) || use_vertex_mask)) + { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->edit_gpencil_ps, state | pd->clipping_state); @@ -187,7 +188,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3_copy(grp, "pPosition", ts->gp_sculpt.guide.location); } else if (ts->gp_sculpt.guide.reference_point == GP_GUIDE_REF_OBJECT && - ts->gp_sculpt.guide.reference_object != nullptr) { + ts->gp_sculpt.guide.reference_object != nullptr) + { UI_GetThemeColor4fv(TH_GIZMO_SECONDARY, color); DRW_shgroup_uniform_vec3_copy(grp, "pPosition", ts->gp_sculpt.guide.reference_object->loc); } @@ -440,7 +442,8 @@ void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob) /* don't show object extras in set's */ if ((ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) == 0) { if ((v3d->gp_flag & V3D_GP_SHOW_MATERIAL_NAME) && (ob->mode == OB_MODE_EDIT_GPENCIL) && - DRW_state_show_text()) { + DRW_state_show_text()) + { OVERLAY_gpencil_color_names(ob); } } diff --git a/source/blender/draw/engines/overlay/overlay_grid.cc b/source/blender/draw/engines/overlay/overlay_grid.cc index b38825723f4..2ff8022ed26 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.cc +++ b/source/blender/draw/engines/overlay/overlay_grid.cc @@ -89,7 +89,8 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) const bool show_ortho_grid = (pd->v3d_gridflag & V3D_SHOW_ORTHO_GRID) != 0; if (pd->hide_overlays || !(pd->v3d_gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z | - V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID))) { + V3D_SHOW_FLOOR | V3D_SHOW_ORTHO_GRID))) + { return; } diff --git a/source/blender/draw/engines/overlay/overlay_image.cc b/source/blender/draw/engines/overlay/overlay_image.cc index e6b5a386aa7..01a136e3a26 100644 --- a/source/blender/draw/engines/overlay/overlay_image.cc +++ b/source/blender/draw/engines/overlay/overlay_image.cc @@ -454,7 +454,8 @@ void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; if (DRW_state_is_fbo() && (!DRW_pass_is_empty(psl->image_background_scene_ps) || - !DRW_pass_is_empty(psl->image_foreground_scene_ps))) { + !DRW_pass_is_empty(psl->image_foreground_scene_ps))) + { const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); GPU_framebuffer_bind(dfbl->default_fb); diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 7114c01cd3a..51ac7a29fec 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -99,8 +99,8 @@ void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) { populate_selection_overlay(vedata, object); const View3DOverlay &overlay = vedata->stl->pd->overlay; - if ((overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) && - overlay.sculpt_curves_cage_opacity > 0.0f) { + if ((overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) && overlay.sculpt_curves_cage_opacity > 0.0f) + { populate_edit_overlay(vedata, object); } } diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.cc b/source/blender/draw/engines/overlay/overlay_wireframe.cc index fd6259f4cb1..67f80e5844b 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.cc +++ b/source/blender/draw/engines/overlay/overlay_wireframe.cc @@ -195,7 +195,8 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (use_wire && pd->wireframe_mode && ob->particlesystem.first) { for (ParticleSystem *psys = static_cast(ob->particlesystem.first); psys != nullptr; - psys = psys->next) { + psys = psys->next) + { if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) { continue; } diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_curve_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_curve_point_vert.glsl index dc359099a5b..8b1dc6fa88b 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_curve_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_curve_point_vert.glsl @@ -27,7 +27,8 @@ void main() bool show_handle = showCurveHandles; if ((uint(curveHandleDisplay) == CURVE_HANDLE_SELECTED) && - ((data & VERT_SELECTED_BEZT_HANDLE) == 0u)) { + ((data & VERT_SELECTED_BEZT_HANDLE) == 0u)) + { show_handle = false; } diff --git a/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl index 2b333696f94..1a44c5ccb84 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl @@ -106,7 +106,8 @@ void main() if (flag_test(grid_flag, PLANE_IMAGE) && /* Grid begins to appear when the length of one grid unit is at least * (256/grid_size) pixels Value of grid_size defined in `overlay_grid.c`. */ - !flag_test(grid_flag, CUSTOM_GRID)) { + !flag_test(grid_flag, CUSTOM_GRID)) + { grid_res = grid_buf.zoom_factor; } diff --git a/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_gpencil_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_gpencil_frag.glsl index c5d6bae390b..626d606c0ea 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_gpencil_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_outline_prepass_gpencil_frag.glsl @@ -16,7 +16,8 @@ void main() gp_interp.sspos.zw, gp_interp.aspect, gp_interp.thickness.x, - gp_interp.hardness) < 0.001) { + gp_interp.hardness) < 0.001) + { discard; return; } diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index afe36903cfa..1cf5586c146 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -51,7 +51,8 @@ static void select_engine_framebuffer_setup(void) } if ((e_data.texture_u32 != NULL) && ((GPU_texture_width(e_data.texture_u32) != size[0]) || - (GPU_texture_height(e_data.texture_u32) != size[1]))) { + (GPU_texture_height(e_data.texture_u32) != size[1]))) + { GPU_texture_free(e_data.texture_u32); e_data.texture_u32 = NULL; } diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index a7247f4e9a6..54a1f813fba 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -130,7 +130,8 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata) Camera *cam = camera != NULL && camera->type == OB_CAMERA ? camera->data : NULL; if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) || - ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) { + ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) + { wpd->dof_enabled = false; /* Cleanup. */ @@ -226,7 +227,8 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata) float ratio = 1.0f / cam->dof.aperture_ratio; if (wpd->vldata->dof_sample_ubo == NULL || blades != wpd->dof_blades || - rotation != wpd->dof_rotation || ratio != wpd->dof_ratio) { + rotation != wpd->dof_rotation || ratio != wpd->dof_ratio) + { wpd->dof_blades = blades; wpd->dof_rotation = rotation; wpd->dof_ratio = ratio; diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 2fea8bfe805..7eeea7eba66 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -342,7 +342,8 @@ static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd, } if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR && - BKE_pbvh_type(BKE_object_sculpt_pbvh_get(ob)) != PBVH_FACES) { + BKE_pbvh_type(BKE_object_sculpt_pbvh_get(ob)) != PBVH_FACES) + { /* Force use of material color for sculpt. */ color_type = V3D_SHADING_MATERIAL_COLOR; } diff --git a/source/blender/draw/engines/workbench/workbench_shadow.c b/source/blender/draw/engines/workbench/workbench_shadow.c index 655093a3fd4..3503ec82c13 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.c +++ b/source/blender/draw/engines/workbench/workbench_shadow.c @@ -221,7 +221,8 @@ static float workbench_shadow_object_shadow_distance(WORKBENCH_PrivateData *wpd, wpd->shadow_cached_direction, wpd->shadow_far_plane, &dist_isect, - true)) { + true)) + { if (dist_isect < dist) { dist = dist_isect; } @@ -251,7 +252,8 @@ static bool workbench_shadow_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, if ((oed->shadow_min[0] > wpd->shadow_near_max[0]) || (oed->shadow_max[0] < wpd->shadow_near_min[0]) || (oed->shadow_min[1] > wpd->shadow_near_max[1]) || - (oed->shadow_max[1] < wpd->shadow_near_min[1])) { + (oed->shadow_max[1] < wpd->shadow_near_min[1])) + { return false; } /* Test projected near rectangle sides */ diff --git a/source/blender/draw/engines/workbench/workbench_state.cc b/source/blender/draw/engines/workbench/workbench_state.cc index 3c8f95addd7..21e1b930d99 100644 --- a/source/blender/draw/engines/workbench/workbench_state.cc +++ b/source/blender/draw/engines/workbench/workbench_state.cc @@ -87,7 +87,8 @@ void SceneState::init(Object *camera_ob /*= nullptr*/) shading.flag &= ~(V3D_SHADING_SHADOW | V3D_SHADING_CAVITY | V3D_SHADING_DEPTH_OF_FIELD); } if (SHADING_XRAY_ENABLED(shading) != SHADING_XRAY_ENABLED(previous_shading) || - shading.flag != previous_shading.flag) { + shading.flag != previous_shading.flag) + { reset_taa = true; } diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index 54a00787ebc..7f625a2801e 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -75,7 +75,8 @@ static void workbench_volume_modifier_cache_populate(WORKBENCH_Data *vedata, } if ((!fds->use_coba && (fds->tex_density == NULL && fds->tex_color == NULL)) || - (fds->use_coba && fds->tex_field == NULL)) { + (fds->use_coba && fds->tex_field == NULL)) + { return; } diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 82288a5fe86..7606aff4b55 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -889,7 +889,8 @@ class Texture : NonCopyable { int3 size(0); GPU_texture_get_mipmap_size(tx_, 0, size); if (size != int3(w, h, d) || GPU_texture_format(tx_) != format || - GPU_texture_is_cube(tx_) != cubemap || GPU_texture_is_array(tx_) != layered) { + GPU_texture_is_cube(tx_) != cubemap || GPU_texture_is_array(tx_) != layered) + { free(); } } diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index a6755c6adea..73e7dabd117 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -10,7 +10,8 @@ static bool drw_attributes_has_request(const DRW_Attributes *requests, for (int i = 0; i < requests->num_requests; i++) { const DRW_AttributeRequest &src_req = requests->requests[i]; if (src_req.domain == req.domain && src_req.layer_index == req.layer_index && - src_req.cd_type == req.cd_type) { + src_req.cd_type == req.cd_type) + { return true; } } @@ -63,7 +64,8 @@ void drw_attributes_add_request(DRW_Attributes *attrs, const eAttrDomain domain) { if (attrs->num_requests >= GPU_MAX_ATTR || - drw_attributes_has_request(attrs, {type, layer_index, domain})) { + drw_attributes_has_request(attrs, {type, layer_index, domain})) + { return; } diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 326019c20f6..0ce5ce3f32e 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -803,7 +803,8 @@ void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, /* We use only one extractor for face dots, as the work is done in a single compute shader. */ if (DRW_vbo_requested(mbuflist->vbo.fdots_nor) || DRW_vbo_requested(mbuflist->vbo.fdots_pos) || - DRW_ibo_requested(mbuflist->ibo.fdots)) { + DRW_ibo_requested(mbuflist->ibo.fdots)) + { extractors.append(&extract_fdots_pos); } diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index ab207399a89..f32467a15de 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -135,8 +135,8 @@ void mesh_render_data_update_loose_geom(MeshRenderData *mr, const eMRIterType iter_type, const eMRDataType data_flag) { - if ((iter_type & (MR_ITER_LOOSE_EDGE | MR_ITER_LOOSE_VERT)) || - (data_flag & MR_DATA_LOOSE_GEOM)) { + if ((iter_type & (MR_ITER_LOOSE_EDGE | MR_ITER_LOOSE_VERT)) || (data_flag & MR_DATA_LOOSE_GEOM)) + { mesh_render_data_loose_geom_ensure(mr, cache); mr->loose_edges = cache->loose_geom.edges; mr->loose_verts = cache->loose_geom.verts; @@ -464,7 +464,8 @@ MeshRenderData *mesh_render_data_create(Object *object, * using the cage mesh with deformed coordinates. */ if ((is_mode_active && mr->me->runtime->is_original_bmesh && mr->me->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) || - (do_uvedit && !do_final)) { + (do_uvedit && !do_final)) + { mr->extract_type = MR_EXTRACT_BMESH; } else { diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index cede4e279ab..9ef4f4b3e38 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -121,7 +121,8 @@ static int curve_render_normal_len_get(const ListBase *lb, const CurveCache *ob_ const BevList *bl; const Nurb *nu; for (bl = (const BevList *)ob_curve_cache->bev.first, nu = (const Nurb *)lb->first; nu && bl; - bl = bl->next, nu = nu->next) { + bl = bl->next, nu = nu->next) + { int nr = bl->nr; int skip = nu->resolu / 16; #if 0 @@ -584,7 +585,8 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, for (bl = (const BevList *)rdata->ob_curve_cache->bev.first, nu = (const Nurb *)rdata->nurbs->first; nu && bl; - bl = bl->next, nu = nu->next) { + bl = bl->next, nu = nu->next) + { const BevPoint *bevp = bl->bevpoints; int nr = bl->nr; int skip = nu->resolu / 16; @@ -900,7 +902,8 @@ void DRW_curve_batch_cache_create_requested(Object *ob, const struct Scene *scen curve_create_curves_lines(rdata, cache->ibo.curves_lines); } if (DRW_vbo_requested(cache->edit.pos) || DRW_vbo_requested(cache->edit.data) || - DRW_ibo_requested(cache->ibo.edit_verts) || DRW_ibo_requested(cache->ibo.edit_lines)) { + DRW_ibo_requested(cache->ibo.edit_verts) || DRW_ibo_requested(cache->ibo.edit_lines)) + { curve_create_edit_data_and_handles( rdata, cache->edit.pos, cache->edit.data, cache->ibo.edit_verts, cache->ibo.edit_lines); } diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 9831f477929..28e9d589ce0 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -231,7 +231,8 @@ static bool lattice_batch_cache_valid(Lattice *lt) if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) || (cache->dims.w_len != lt->pntsw) || - (cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0))) { + (cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0))) + { return false; } diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 5cc568fe2ab..10ab77e2dab 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -519,7 +519,8 @@ static void drw_mesh_weight_state_extract(Object *ob, BKE_object_defgroup_check_lock_relative_multi(wstate->defgroup_len, wstate->defgroup_locked, wstate->defgroup_sel, - wstate->defgroup_sel_count)) { + wstate->defgroup_sel_count)) + { wstate->flags |= DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE; /* Compute the set of locked and unlocked deform vertex groups. */ @@ -1404,7 +1405,8 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, if (batch_requested & (MBC_SURFACE | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA | - MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { + MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) + { /* Modifiers will only generate an orco layer if the mesh is deformed. */ if (cache->cd_needed.orco != 0) { /* Orco is always extracted from final mesh. */ @@ -1428,7 +1430,8 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, cd_uv_update = true; } if ((cache->cd_used.tan & cache->cd_needed.tan) != cache->cd_needed.tan || - cache->cd_used.tan_orco != cache->cd_needed.tan_orco) { + cache->cd_used.tan_orco != cache->cd_needed.tan_orco) + { GPU_VERTBUF_DISCARD_SAFE(mbc->buff.vbo.tan); } if (cache->cd_used.orco != cache->cd_needed.orco) { diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 6ae592f9bb6..e1c15dcaa78 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -248,7 +248,8 @@ static void ensure_seg_pt_count(PTCacheEdit *edit, ParticleHairCache *hair_cache) { if ((hair_cache->pos != NULL && hair_cache->indices != NULL) || - (hair_cache->proc_point_buf != NULL)) { + (hair_cache->proc_point_buf != NULL)) + { return; } @@ -978,8 +979,8 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit } else { int curr_point = 0; - if ((psys->pathcache != NULL) && - (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) { + if ((psys->pathcache != NULL) && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) + { curr_point = particle_batch_cache_fill_strands_data(psys, psmd, psys->pathcache, @@ -1078,8 +1079,8 @@ static void particle_batch_cache_ensure_procedural_indices(PTCacheEdit *edit, } else { int curr_point = 0; - if ((psys->pathcache != NULL) && - (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) { + if ((psys->pathcache != NULL) && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) + { curr_point = particle_batch_cache_fill_segments_indices( psys->pathcache, 0, psys->totpart, verts_per_hair, &elb); } @@ -1269,8 +1270,8 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, hair_cache); } else { - if ((psys->pathcache != NULL) && - (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) { + if ((psys->pathcache != NULL) && (!psys->childcache || (psys->part->draw & PART_DRAW_PARENT))) + { curr_point = particle_batch_cache_fill_segments(psys, psmd, psys->pathcache, @@ -1702,7 +1703,8 @@ bool particles_ensure_procedural_data(Object *object, /* Refreshed on combing and simulation. */ if ((*r_hair_cache)->proc_point_buf == NULL || - (gpu_material && (*r_hair_cache)->proc_length_buf == NULL)) { + (gpu_material && (*r_hair_cache)->proc_length_buf == NULL)) + { ensure_seg_pt_count(source.edit, source.psys, &cache->hair); particle_batch_cache_ensure_procedural_pos( source.edit, source.psys, &cache->hair, gpu_material); diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 704bbb46469..4796ec177a9 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -192,8 +192,8 @@ void DRW_pointcloud_batch_cache_free_old(PointCloud *pointcloud, int ctime) bool do_discard = false; - if (drw_attributes_overlap(&cache->eval_cache.attr_used_over_time, - &cache->eval_cache.attr_used)) { + if (drw_attributes_overlap(&cache->eval_cache.attr_used_over_time, &cache->eval_cache.attr_used)) + { cache->eval_cache.last_attr_matching_time = ctime; } diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index d63da3d9bd3..9e512fdb634 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -273,7 +273,8 @@ static GPUShader *get_subdiv_shader(int shader_type) SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FVAR, SHADER_PATCH_EVALUATION_FACE_DOTS, - SHADER_PATCH_EVALUATION_ORCO)) { + SHADER_PATCH_EVALUATION_ORCO)) + { return get_patch_evaluation_shader(shader_type); } @@ -291,7 +292,8 @@ static GPUShader *get_subdiv_shader(int shader_type) SHADER_BUFFER_LINES, SHADER_BUFFER_LNOR, SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, - SHADER_BUFFER_UV_STRETCH_AREA)) { + SHADER_BUFFER_UV_STRETCH_AREA)) + { defines = "#define SUBDIV_POLYGON_OFFSET\n"; } else if (shader_type == SHADER_BUFFER_TRIS) { @@ -1199,8 +1201,8 @@ static bool draw_subdiv_build_cache(DRWSubdivCache *cache, cache_building_context.cache = cache; do_subdiv_traversal(&cache_building_context, subdiv); - if (cache->num_subdiv_loops == 0 && cache->num_subdiv_verts == 0 && - !cache->may_have_loose_geom) { + if (cache->num_subdiv_loops == 0 && cache->num_subdiv_verts == 0 && !cache->may_have_loose_geom) + { /* Either the traversal failed, or we have an empty mesh, either way we cannot go any further. * The subdiv_polygon_offset cannot then be reliably stored in the cache, so free it directly. */ @@ -2128,7 +2130,8 @@ static bool draw_subdiv_create_requested_buffers(Object *ob, } if (!BKE_subdiv_eval_begin_from_mesh( - subdiv, mesh_eval, nullptr, SUBDIV_EVALUATOR_TYPE_GPU, evaluator_cache)) { + subdiv, mesh_eval, nullptr, SUBDIV_EVALUATOR_TYPE_GPU, evaluator_cache)) + { /* This could happen in two situations: * - OpenSubdiv is disabled. * - Something totally bad happened, and OpenSubdiv rejected our @@ -2351,7 +2354,8 @@ void DRW_create_subdivision(Object *ob, do_cage, ts, use_hide, - g_evaluator_cache)) { + g_evaluator_cache)) + { return; } diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc index a5d73f93780..b77e404aef9 100644 --- a/source/blender/draw/intern/draw_color_management.cc +++ b/source/blender/draw/intern/draw_color_management.cc @@ -35,7 +35,8 @@ static float dither_get(eDRWColorManagementType color_management_type, const Sce { if (ELEM(color_management_type, eDRWColorManagementType::ViewTransformAndLook, - eDRWColorManagementType::UseRenderSettings)) { + eDRWColorManagementType::UseRenderSettings)) + { return scene.r.dither_intensity; } return 0.0f; @@ -67,7 +68,8 @@ static eDRWColorManagementType drw_color_management_type_for_space_image(const S const bool display_color_channel = (display_channels_mode & (SI_SHOW_ALPHA | SI_SHOW_ZBUF)) == 0; if (display_color_channel && image && (image->source != IMA_SRC_GENERATED) && - ((image->flag & IMA_VIEW_AS_RENDER) != 0)) { + ((image->flag & IMA_VIEW_AS_RENDER) != 0)) + { return eDRWColorManagementType::UseRenderSettings; } return eDRWColorManagementType::ViewTransform; diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 15314ca5337..1c2a1c3b0b2 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -230,7 +230,8 @@ void DRW_globals_update(void) bool user_weight_ramp = (U.flag & USER_CUSTOM_RANGE) != 0; if (weight_ramp_custom != user_weight_ramp || - (user_weight_ramp && memcmp(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand)) != 0)) { + (user_weight_ramp && memcmp(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand)) != 0)) + { DRW_TEXTURE_FREE_SAFE(G_draw.weight_ramp); } @@ -414,7 +415,8 @@ bool DRW_object_is_flat(Object *ob, int *r_axis) OB_FONT, OB_CURVES, OB_POINTCLOUD, - OB_VOLUME)) { + OB_VOLUME)) + { /* Non-meshes object cannot be considered as flat. */ return false; } diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index ae3a908e483..46802f8f4f7 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -38,7 +38,8 @@ BLI_INLINE eParticleRefineShaderType drw_curves_shader_type_get() * parallel with fragment work, whereas compute inserts an explicit dependency, * due to switching of command encoder types. */ if (GPU_compute_shader_support() && GPU_shader_storage_buffer_objects_support() && - (GPU_backend_get_type() != GPU_BACKEND_METAL)) { + (GPU_backend_get_type() != GPU_BACKEND_METAL)) + { return PART_REFINE_SHADER_COMPUTE; } if (GPU_transform_feedback_support()) { diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index 889fa48d18e..a408020a248 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -447,7 +447,8 @@ void DRW_smoke_ensure_coba_field(FluidModifierData *fmd) FLUID_DOMAIN_FIELD_PHI_OUT, FLUID_DOMAIN_FIELD_PHI_OBSTACLE, FLUID_DOMAIN_FIELD_FLAGS, - FLUID_DOMAIN_FIELD_PRESSURE)) { + FLUID_DOMAIN_FIELD_PRESSURE)) + { fds->tex_coba = create_transfer_function(TFUNC_COLOR_RAMP, fds->coba); BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_coba)); } diff --git a/source/blender/draw/intern/draw_hair.cc b/source/blender/draw/intern/draw_hair.cc index 03a222a7157..7919c80c9a7 100644 --- a/source/blender/draw/intern/draw_hair.cc +++ b/source/blender/draw/intern/draw_hair.cc @@ -41,7 +41,8 @@ BLI_INLINE eParticleRefineShaderType drw_hair_shader_type_get() * parallel with fragment work, whereas compute inserts an explicit dependency, * due to switching of command encoder types. */ if (GPU_compute_shader_support() && GPU_shader_storage_buffer_objects_support() && - (GPU_backend_get_type() != GPU_BACKEND_METAL)) { + (GPU_backend_get_type() != GPU_BACKEND_METAL)) + { return PART_REFINE_SHADER_COMPUTE; } if (GPU_transform_feedback_support()) { diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index 6df28032cda..9d45dab851c 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -649,7 +649,8 @@ GPUUniformBuf *drw_ensure_layer_attribute_buffer(void) float value[4]; if (BKE_view_layer_find_rgba_attribute( - DST.draw_ctx.scene, DST.draw_ctx.view_layer, attr->name, value)) { + DST.draw_ctx.scene, DST.draw_ctx.view_layer, attr->name, value)) + { LayerAttribute *item = &buffer[count++]; memcpy(item->data, value, sizeof(item->data)); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 15c63bf6560..2eac1cfff7c 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -253,7 +253,8 @@ bool DRW_object_is_visible_psys_in_active_context(const Object *object, const Pa return false; } if ((part->childtype == 0) && - (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0) { + (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) == 0) + { return false; } } @@ -833,6 +834,7 @@ static bool id_type_can_have_drawdata(const short id_type) case ID_WO: case ID_SCE: case ID_TE: + case ID_MSK: return true; /* no DrawData */ @@ -1263,7 +1265,8 @@ static bool is_compositor_enabled(void) } if (DST.draw_ctx.v3d->shading.use_compositor == V3D_SHADING_USE_COMPOSITOR_CAMERA && - DST.draw_ctx.rv3d->persp != RV3D_CAMOB) { + DST.draw_ctx.rv3d->persp != RV3D_CAMOB) + { return false; } @@ -1570,7 +1573,8 @@ void DRW_draw_callbacks_post_scene(void) /* XR callbacks (controllers, custom draw functions) for session surface. */ if (((v3d->flag2 & V3D_XR_SHOW_CONTROLLERS) != 0) || - ((v3d->flag2 & V3D_XR_SHOW_CUSTOM_OVERLAYS) != 0)) { + ((v3d->flag2 & V3D_XR_SHOW_CUSTOM_OVERLAYS) != 0)) + { GPU_depth_test(GPU_DEPTH_NONE); GPU_apply_state(); @@ -1939,7 +1943,8 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph RenderResult *render_result = RE_engine_get_result(engine); RenderLayer *render_layer = RE_GetRenderLayer(render_result, view_layer->name); for (RenderView *render_view = render_result->views.first; render_view != NULL; - render_view = render_view->next) { + render_view = render_view->next) + { RE_SetActiveRenderView(render, render_view->name); DRW_view_reset(); DST.buffer_finish_called = false; @@ -2020,7 +2025,8 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /*RR_ALL_VIEWS*/ NULL); RenderLayer *render_layer = render_result->layers.first; for (RenderView *render_view = render_result->views.first; render_view != NULL; - render_view = render_view->next) { + render_view = render_view->next) + { RE_SetActiveRenderView(render, render_view->name); DRW_view_reset(); engine_type->draw_engine->render_to_image(data, engine, render_layer, &render_rect); @@ -2329,7 +2335,8 @@ static void draw_select_framebuffer_depth_only_setup(const int size[2]) if ((g_select_buffer.texture_depth != NULL) && ((GPU_texture_width(g_select_buffer.texture_depth) != size[0]) || - (GPU_texture_height(g_select_buffer.texture_depth) != size[1]))) { + (GPU_texture_height(g_select_buffer.texture_depth) != size[1]))) + { GPU_texture_free(g_select_buffer.texture_depth); g_select_buffer.texture_depth = NULL; } diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index 097f271e01c..93d28537865 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -81,7 +81,8 @@ void Manager::sync_layer_attributes() for (uint32_t id : id_list) { if (layer_attributes_buf[count].sync( - DST.draw_ctx.scene, DST.draw_ctx.view_layer, layer_attributes.lookup(id))) { + DST.draw_ctx.scene, DST.draw_ctx.view_layer, layer_attributes.lookup(id))) + { /* Check if the buffer is full. */ if (++count == size) { break; diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 6c3c1db329d..1ee5ed67ee5 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -926,7 +926,8 @@ static void draw_call_batching_do(DRWShadingGroup *shgroup, if ((state->neg_scale != neg_scale) || /* Need to change state. */ (state->resource_chunk != chunk) || /* Need to change UBOs. */ (state->batch != call->batch) /* Need to change VAO. */ - ) { + ) + { draw_call_batching_flush(shgroup, state); state->batch = call->batch; @@ -1222,7 +1223,8 @@ static void drw_draw_pass_ex(DRWPass *pass, /* Fix #67342 for some reason. AMD Pro driver bug. */ if ((DST.state & DRW_STATE_BLEND_CUSTOM) != 0 && - GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) { + GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) + { drw_state_set(DST.state & ~DRW_STATE_BLEND_CUSTOM); } diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index c7c3cc6b718..ad358f86f37 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -571,7 +571,8 @@ void DRW_shader_queue_optimize_material(GPUMaterial *mat) if (ELEM(GPU_material_optimization_status(mat), GPU_MAT_OPTIMIZATION_SKIP, GPU_MAT_OPTIMIZATION_SUCCESS, - GPU_MAT_OPTIMIZATION_QUEUED)) { + GPU_MAT_OPTIMIZATION_QUEUED)) + { return; } diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 31215ec0090..d1c1d9a2294 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -166,7 +166,8 @@ void DRW_text_cache_draw(DRWTextStore *dt, ARegion *region, View3D *v3d) vos->vec, vos->sco, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { tot++; } else { @@ -270,7 +271,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, } if (v3d->overlay.edit_flag & - (V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_EDGE_ANG | V3D_OVERLAY_EDIT_INDICES)) { + (V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_EDGE_ANG | V3D_OVERLAY_EDIT_INDICES)) + { BoundBox bb; const rcti rect = {0, region->winx, 0, region->winy}; @@ -290,7 +292,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, /* draw selected edges, or edges next to selected verts while dragging */ if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || - BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))) { + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))) + { float v1_clip[3], v2_clip[3]; if (vert_coords) { @@ -356,7 +359,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) || BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) || BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) || - BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)))) { + BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)))) + { float v1_clip[3], v2_clip[3]; if (vert_coords) { @@ -495,7 +499,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) { if (is_face_sel || (do_moving && (BM_elem_flag_test(loop->v, BM_ELEM_SELECT) || BM_elem_flag_test(loop->prev->v, BM_ELEM_SELECT) || - BM_elem_flag_test(loop->next->v, BM_ELEM_SELECT)))) { + BM_elem_flag_test(loop->next->v, BM_ELEM_SELECT)))) + { float v2_local[3]; /* lazy init center calc */ diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 060502d1971..feb61ec8e75 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -116,8 +116,8 @@ struct PBVHBatch { string key; GPUBatch *tris = nullptr, *lines = nullptr; int tris_count = 0, lines_count = 0; - bool is_coarse = - false; /* Coarse multires, will use full-sized VBOs only index buffer changes. */ + /* Coarse multi-resolution, will use full-sized VBOs only index buffer changes. */ + bool is_coarse = false; void sort_vbos(Vector &master_vbos) { diff --git a/source/blender/draw/intern/draw_texture_pool.cc b/source/blender/draw/intern/draw_texture_pool.cc index d572cc75b27..bd48e4294de 100644 --- a/source/blender/draw/intern/draw_texture_pool.cc +++ b/source/blender/draw/intern/draw_texture_pool.cc @@ -84,7 +84,8 @@ GPUTexture *DRW_texture_pool_query(DRWTexturePool *pool, if ((GPU_texture_format(handle.texture) == format) && (GPU_texture_width(handle.texture) == width) && (GPU_texture_height(handle.texture) == height) && - (GPU_texture_usage(handle.texture) == usage)) { + (GPU_texture_usage(handle.texture) == usage)) + { handle.users_bits |= user_bit; return handle.texture; } diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 269942edaf8..cc702998ea7 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -107,7 +107,8 @@ void DRW_draw_cursor(void) if (ED_view3d_project_int_global( region, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { RegionView3D *rv3d = region->regiondata; float cursor_quat[4]; diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index bec9e579842..34c54b63230 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -184,7 +184,8 @@ static DRWShadingGroup *drw_volume_object_mesh_init(Scene *scene, /* Smoke Simulation */ if ((md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) && BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime) && - ((FluidModifierData *)md)->domain != nullptr) { + ((FluidModifierData *)md)->domain != nullptr) + { FluidModifierData *fmd = (FluidModifierData *)md; FluidDomainSettings *fds = fmd->domain; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc index 6b487b85e0f..bbaf66987b9 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc @@ -47,7 +47,8 @@ static void extract_lines_paint_mask_iter_poly_mesh(const MeshRenderData *mr, const int e_index = mr->corner_edges[ml_index]; if (!((mr->use_hide && mr->hide_edge && mr->hide_edge[e_index]) || - ((mr->e_origindex) && (mr->e_origindex[e_index] == ORIGINDEX_NONE)))) { + ((mr->e_origindex) && (mr->e_origindex[e_index] == ORIGINDEX_NONE)))) + { const int ml_index_last = poly.size() + poly.start() - 1; const int ml_index_other = (ml_index == ml_index_last) ? poly.start() : (ml_index + 1); @@ -120,7 +121,8 @@ static void extract_lines_paint_mask_iter_subdiv_mesh(const DRWSubdivCache *subd } else { if (!((mr->use_hide && mr->hide_edge && mr->hide_edge[coarse_edge_index]) || - ((mr->e_origindex) && (mr->e_origindex[coarse_edge_index] == ORIGINDEX_NONE)))) { + ((mr->e_origindex) && (mr->e_origindex[coarse_edge_index] == ORIGINDEX_NONE)))) + { const uint ml_index_other = (loop_idx == (end_loop_idx - 1)) ? start_loop_idx : loop_idx + 1; if (mr->select_poly && mr->select_poly[coarse_quad_index]) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc index 2fd6d09dd5e..ce53bbad706 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc @@ -32,7 +32,8 @@ static void mesh_render_data_edge_flag(const MeshRenderData *mr, eattr->e_flag |= VFLAG_EDGE_SELECTED; } if (is_vertex_select_mode && BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) { + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) + { eattr->e_flag |= VFLAG_EDGE_SELECTED; eattr->e_flag |= VFLAG_VERT_SELECTED; } diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc index bd1e91bd4a7..5dbfde46ee1 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc @@ -77,8 +77,8 @@ static void extract_lnor_iter_poly_mesh(const MeshRenderData *mr, const int poly /* Flag for paint mode overlay. * Only use origindex in edit mode where it is used to display the edge-normals. * In paint mode it will use the un-mapped data to draw the wire-frame. */ - if (hidden || - (mr->edit_bmesh && (mr->v_origindex) && mr->v_origindex[vert] == ORIGINDEX_NONE)) { + if (hidden || (mr->edit_bmesh && (mr->v_origindex) && mr->v_origindex[vert] == ORIGINDEX_NONE)) + { lnor_data->w = -1; } else if (mr->select_poly && mr->select_poly[poly_index]) { @@ -199,8 +199,8 @@ static void extract_lnor_hq_iter_poly_mesh(const MeshRenderData *mr, /* Flag for paint mode overlay. * Only use origindex in edit mode where it is used to display the edge-normals. * In paint mode it will use the un-mapped data to draw the wire-frame. */ - if (hidden || - (mr->edit_bmesh && (mr->v_origindex) && mr->v_origindex[vert] == ORIGINDEX_NONE)) { + if (hidden || (mr->edit_bmesh && (mr->v_origindex) && mr->v_origindex[vert] == ORIGINDEX_NONE)) + { lnor_data->w = -1; } else if (mr->select_poly && mr->select_poly[poly_index]) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc index ec875f7e36f..6050089fd25 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc @@ -233,7 +233,8 @@ static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness) hit.dist = face_dists[index]; if ((BLI_bvhtree_ray_cast( tree, ray_co, ray_no, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) && - hit.dist < face_dists[index]) { + hit.dist < face_dists[index]) + { float angle_fac = fabsf(dot_v3v3(mr->poly_normals[index], hit.no)); angle_fac = 1.0f - angle_fac; angle_fac = angle_fac * angle_fac * angle_fac; @@ -350,7 +351,8 @@ static void statvis_calc_intersect(const MeshRenderData *mr, float *r_intersect) for (int i = 0; i < overlap_len; i++) { for (const IndexRange f_hit : {mr->polys[mr->looptris[overlap[i].indexA].poly], - mr->polys[mr->looptris[overlap[i].indexB].poly]}) { + mr->polys[mr->looptris[overlap[i].indexB].poly]}) + { int l_index = f_hit.start(); for (int k = 0; k < f_hit.size(); k++, l_index++) { r_intersect[l_index] = 1.0f; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc index dcdc8b43a36..96d41a987d6 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc @@ -96,7 +96,8 @@ static void extract_pos_nor_iter_poly_mesh(const MeshRenderData *mr, vert->nor = data->normals[vert_i].low; /* Flag for paint mode overlay. */ if (poly_hidden || vert_hidden || - ((mr->v_origindex) && (mr->v_origindex[vert_i] == ORIGINDEX_NONE))) { + ((mr->v_origindex) && (mr->v_origindex[vert_i] == ORIGINDEX_NONE))) + { vert->nor.w = -1; } else if (mr->select_vert && mr->select_vert[vert_i]) { @@ -470,7 +471,8 @@ static void extract_pos_nor_hq_iter_poly_mesh(const MeshRenderData *mr, /* Flag for paint mode overlay. */ if (poly_hidden || vert_hidden || - ((mr->v_origindex) && (mr->v_origindex[vert_i] == ORIGINDEX_NONE))) { + ((mr->v_origindex) && (mr->v_origindex[vert_i] == ORIGINDEX_NONE))) + { vert->nor[3] = -1; } else if (mr->select_vert && mr->select_vert[vert_i]) { diff --git a/source/blender/draw/intern/shaders/common_gpencil_lib.glsl b/source/blender/draw/intern/shaders/common_gpencil_lib.glsl index bb55035f9e6..f48c355835a 100644 --- a/source/blender/draw/intern/shaders/common_gpencil_lib.glsl +++ b/source/blender/draw/intern/shaders/common_gpencil_lib.glsl @@ -316,7 +316,8 @@ vec4 gpencil_vertex(vec4 viewport_size, /* Reminder: we packed the cap flag into the sign of strength and thickness sign. */ if ((is_stroke_start && strength1 > 0.0) || (is_stroke_end && thickness1 > 0.0) || - (miter_break && !is_stroke_start && !is_stroke_end)) { + (miter_break && !is_stroke_start && !is_stroke_end)) + { screen_ofs += line * x; } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 779775e4159..abcb3883f10 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4484,7 +4484,8 @@ void ANIM_channel_draw( if (ELEM(ac->spacetype, SPACE_ACTION, SPACE_GRAPH) && (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) && - !ELEM(ale->type, ANIMTYPE_GPLAYER, ANIMTYPE_DSGPENCIL)) { + !ELEM(ale->type, ANIMTYPE_GPLAYER, ANIMTYPE_DSGPENCIL)) + { /* for F-Curves, draw color-preview of curve left to the visibility icon */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; @@ -4576,7 +4577,8 @@ void ANIM_channel_draw( * - Exception for graph editor, which needs extra space for the scroll bar. */ if (ac->spacetype == SPACE_GRAPH && - ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_GROUP)) { + ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_GROUP)) + { offset = V2D_SCROLL_WIDTH; } else { @@ -4614,8 +4616,8 @@ void ANIM_channel_draw( } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || - (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) + { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; @@ -4658,7 +4660,8 @@ void ANIM_channel_draw( * to keep a clean line down the side. */ if ((draw_sliders) && - ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER)) { + ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER)) + { /* adjust offset */ offset += SLIDER_WIDTH; } @@ -5173,8 +5176,8 @@ static void draw_setting_widget(bAnimContext *ac, } if ((ale->fcurve_owner_id != NULL && !BKE_id_is_editable(ac->bmain, ale->fcurve_owner_id)) || - (ale->fcurve_owner_id == NULL && ale->id != NULL && - !BKE_id_is_editable(ac->bmain, ale->id))) { + (ale->fcurve_owner_id == NULL && ale->id != NULL && !BKE_id_is_editable(ac->bmain, ale->id))) + { if (setting != ACHANNEL_SETTING_EXPAND) { UI_but_disable(but, TIP_("Can't edit this property from a linked data-block")); } @@ -5232,7 +5235,8 @@ void ANIM_channel_draw_widgets(const bContext *C, if (ELEM(ac->spacetype, SPACE_ACTION, SPACE_GRAPH) && (acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) || acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) && - (ale->type != ANIMTYPE_GPLAYER)) { + (ale->type != ANIMTYPE_GPLAYER)) + { /* Pin toggle. */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) { draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_ALWAYS_VISIBLE); @@ -5332,8 +5336,8 @@ void ANIM_channel_draw_widgets(const bContext *C, } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || - (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) + { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset -= ICON_WIDTH; @@ -5367,7 +5371,8 @@ void ANIM_channel_draw_widgets(const bContext *C, /* NLA Action "pushdown" */ if ((ale->type == ANIMTYPE_NLAACTION) && (ale->adt && ale->adt->action) && - !(ale->adt->flag & ADT_NLA_EDIT_ON)) { + !(ale->adt->flag & ADT_NLA_EDIT_ON)) + { uiBut *but; PointerRNA *opptr_b; @@ -5409,7 +5414,8 @@ void ANIM_channel_draw_widgets(const bContext *C, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER)) || - ale->type == ANIMTYPE_SHAPEKEY) { + ale->type == ANIMTYPE_SHAPEKEY) + { /* adjust offset */ /* TODO: make slider width dynamic, * so that they can be easier to use when the view is wide enough. */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 4cb2095698b..4d5c37130c3 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1151,7 +1151,8 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, * (it was either wrong sel status, or full already) */ (is_sel == 0) || /* 4) hidden status changes */ - ((island->flag & REORDER_ISLAND_HIDDEN) != is_hidden)) { + ((island->flag & REORDER_ISLAND_HIDDEN) != is_hidden)) + { /* create a new island now */ island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); BLI_addtail(islands, island); @@ -3012,7 +3013,8 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) /* Don't allow renaming linked/liboverride channels. */ if (ale->fcurve_owner_id != NULL && - (ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) { + (ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) + { ANIM_animdata_freelist(&anim_data); return false; } diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index de1bf8eaa8a..c2b5d0a8daf 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -62,11 +62,8 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) } /* Tag copy on the main object if updating anything directly inside AnimData */ - if (ELEM(ale->type, - ANIMTYPE_ANIMDATA, - ANIMTYPE_NLAACTION, - ANIMTYPE_NLATRACK, - ANIMTYPE_NLACURVE)) { + if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) + { DEG_id_tag_update(id, ID_RECALC_ANIMATION); return; } @@ -370,7 +367,8 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, - ANIMTYPE_NLACURVE)) { + ANIMTYPE_NLACURVE)) + { if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; ANIM_list_elem_update(ac->bmain, ac->scene, ale); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 8fd3cbe2451..a6ed20765b6 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -234,7 +234,8 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) ANIMCONT_FCURVES, ANIMCONT_NLA, ANIMCONT_CHANNEL, - ANIMCONT_TIMELINE)) { + ANIMCONT_TIMELINE)) + { /* handling depends on the type of animation-context we've got */ if (ale) { /* NLA Control Curves occur on NLA strips, diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 990d18af8c2..cb3eb8bdbc6 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1025,7 +1025,8 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id /* Only consider if F-Curve involves `pose.bones`. */ if (fcu->rna_path && - BLI_str_quoted_substr(fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) { + BLI_str_quoted_substr(fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) + { /* Get bone-name, and check if this bone is selected. */ pchan = BKE_pose_channel_find_name(ob->pose, bone_name); @@ -1062,7 +1063,8 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id /* Only consider if F-Curve involves `sequence_editor.sequences`. */ if (fcu->rna_path && - BLI_str_quoted_substr(fcu->rna_path, "sequences_all[", seq_name, sizeof(seq_name))) { + BLI_str_quoted_substr(fcu->rna_path, "sequences_all[", seq_name, sizeof(seq_name))) + { /* Get strip name, and check if this strip is selected. */ Editing *ed = SEQ_editing_get(scene); if (ed) { @@ -1324,7 +1326,8 @@ static size_t animfilter_fcurves(ListBase *anim_data, */ for (fcu = first; (fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id)); - fcu = fcu->next) { + fcu = fcu->next) + { if (UNLIKELY(fcurve_type == ANIMTYPE_NLACURVE)) { /* NLA Control Curve - Basically the same as normal F-Curves, * except we need to set some stuff differently */ @@ -1366,7 +1369,8 @@ static size_t animfilter_act_group(bAnimContext *ac, /* Care about hierarchy but group isn't expanded. */ ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp) == 0) && /* Care about selection status. */ - (filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL))) { + (filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL))) + { /* If the group itself isn't selected appropriately, * we shouldn't consider its children either. */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) { @@ -1692,7 +1696,8 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, /* Skip shapekey if the name doesn't match the filter string. */ if (ads != NULL && ads->searchstr[0] != '\0' && - name_matches_dopesheet_filter(ads, kb->name) == false) { + name_matches_dopesheet_filter(ads, kb->name) == false) + { continue; } @@ -1756,7 +1761,8 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, /* skip layer if the name doesn't match the filter string */ if (ads != NULL && ads->searchstr[0] != '\0' && - name_matches_dopesheet_filter(ads, gpl->info) == false) { + name_matches_dopesheet_filter(ads, gpl->info) == false) + { continue; } @@ -1835,8 +1841,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ViewLayer *view_layer = (ViewLayer *)ac->view_layer; /* Include all annotation datablocks. */ - if (((ads->filterflag & ADS_FILTER_ONLYSEL) == 0) || - (ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { + if (((ads->filterflag & ADS_FILTER_ONLYSEL) == 0) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN)) + { LISTBASE_FOREACH (bGPdata *, gpd, &ac->bmain->gpencils) { if (gpd->flag & GP_DATA_ANNOTATIONS) { items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode); @@ -1863,7 +1869,8 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, /* Layer visibility - we check both object and base, * since these may not be in sync yet. */ if ((base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) == 0 || - (base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) == 0) { + (base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) == 0) + { continue; } @@ -2816,8 +2823,8 @@ static size_t animdata_filter_dopesheet_ob( } /* grease pencil */ - if ((ob->type == OB_GPENCIL_LEGACY) && (ob->data) && - !(ads->filterflag & ADS_FILTER_NOGPENCIL)) { + if ((ob->type == OB_GPENCIL_LEGACY) && (ob->data) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) + { tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, ob->data, filter_mode); } } @@ -3080,7 +3087,8 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ if ((base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) == 0 || - (base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) == 0) { + (base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) == 0) + { return false; } @@ -3245,7 +3253,8 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, BKE_view_layer_synced_ensure(scene, view_layer); ListBase *object_bases = BKE_view_layer_object_bases_get(view_layer); if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) && - (object_bases->first != object_bases->last)) { + (object_bases->first != object_bases->last)) + { /* Filter list of bases (i.e. objects), sort them, then add their contents normally... */ /* TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... */ Base **sorted_bases; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index e319f4d8a03..4b35fc4f1fa 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -87,7 +87,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) char pchanName[256], constName[256]; if (BLI_str_quoted_substr(fcu->rna_path, "bones[", pchanName, sizeof(pchanName)) && - BLI_str_quoted_substr(fcu->rna_path, "constraints[", constName, sizeof(constName))) { + BLI_str_quoted_substr(fcu->rna_path, "constraints[", constName, sizeof(constName))) + { /* assemble the string to display in the UI... */ structname = BLI_sprintfN("%s : %s", pchanName, constName); @@ -111,9 +112,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) if (GS(ptr.owner_id->name) == ID_SCE) { char stripname[256]; if (BLI_str_quoted_substr( - fcu->rna_path, "sequence_editor.sequences_all[", stripname, sizeof(stripname))) { + fcu->rna_path, "sequence_editor.sequences_all[", stripname, sizeof(stripname))) + { if (strstr(fcu->rna_path, ".transform.") || strstr(fcu->rna_path, ".crop.") || - strstr(fcu->rna_path, ".modifiers[")) { + strstr(fcu->rna_path, ".modifiers[")) + { const char *structname_all = BLI_sprintfN("%s : %s", stripname, structname); if (free_structname) { MEM_freeN((void *)structname); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 32f91407330..6a1717fe45e 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -119,7 +119,8 @@ int ED_markers_post_apply_transform( case TFM_TIME_EXTEND: { /* apply delta if marker is on the right side of the current frame */ if ((side == 'B') || (side == 'L' && marker->frame < cfra) || - (side == 'R' && marker->frame >= cfra)) { + (side == 'R' && marker->frame >= cfra)) + { marker->frame += round_fl_to_int(value); changed_tot++; } @@ -812,7 +813,8 @@ static bool ed_marker_move_use_time(MarkerMove *mm) (((SpaceAction *)mm->slink)->flag & SACTION_DRAWTIME)) || ((mm->slink->spacetype == SPACE_GRAPH) && (((SpaceGraph *)mm->slink)->flag & SIPO_DRAWTIME)) || - ((mm->slink->spacetype == SPACE_NLA) && (((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME))) { + ((mm->slink->spacetype == SPACE_NLA) && (((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME))) + { return true; } @@ -1579,7 +1581,8 @@ static void ED_markers_select_leftright(bAnimContext *ac, LISTBASE_FOREACH (TimeMarker *, marker, markers) { if ((mode == MARKERS_LRSEL_LEFT && marker->frame <= scene->r.cfra) || - (mode == MARKERS_LRSEL_RIGHT && marker->frame >= scene->r.cfra)) { + (mode == MARKERS_LRSEL_RIGHT && marker->frame >= scene->r.cfra)) + { marker->flag |= SELECT; } } diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 02c97613269..d751cdcf6e0 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -351,7 +351,8 @@ void animviz_motionpath_compute_range(Object *ob, Scene *scene) const bool has_action = ob->adt && ob->adt->action; if (avs->path_range == MOTIONPATH_RANGE_SCENE || !has_action || - BLI_listbase_is_empty(&ob->adt->action->curves)) { + BLI_listbase_is_empty(&ob->adt->action->curves)) + { /* Default to the scene (preview) range if there is no animation data to * find selected keys in. */ avs->path_sf = PSFRA; diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 5c53cf192d0..d3f563f5886 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -195,8 +195,8 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event) if (area && area->spacetype == SPACE_SEQ) { SpaceSeq *sseq = area->spacedata.first; ARegion *region = CTX_wm_region(C); - if (ED_space_sequencer_check_show_strip(sseq) && - !ED_time_scrub_event_in_region(region, event)) { + if (ED_space_sequencer_check_show_strip(sseq) && !ED_time_scrub_event_in_region(region, event)) + { ED_sequencer_special_preview_set(C, event->mval); } } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index cbc8e1d5105..9a0f0008d51 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -173,14 +173,16 @@ static int add_driver_with_target(ReportList *UNUSED(reports), */ /* XXX: if we have N-1 mapping, should we include all those in the expression? */ if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) && - (RNA_property_unit(src_prop) != PROP_UNIT_ROTATION)) { + (RNA_property_unit(src_prop) != PROP_UNIT_ROTATION)) + { /* Rotation Destination: normal -> radians, so convert src to radians * (However, if both input and output is a rotation, don't apply such corrections) */ BLI_strncpy(driver->expression, "radians(var)", sizeof(driver->expression)); } else if ((RNA_property_unit(src_prop) == PROP_UNIT_ROTATION) && - (RNA_property_unit(dst_prop) != PROP_UNIT_ROTATION)) { + (RNA_property_unit(dst_prop) != PROP_UNIT_ROTATION)) + { /* Rotation Source: radians -> normal, so convert src to degrees * (However, if both input and output is a rotation, don't apply such corrections) */ @@ -203,7 +205,8 @@ static int add_driver_with_target(ReportList *UNUSED(reports), if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) && (STREQ(prop_name, "location") || STREQ(prop_name, "scale") || STRPREFIX(prop_name, "rotation_")) && - (src_ptr->data != dst_ptr->data)) { + (src_ptr->data != dst_ptr->data)) + { /* Transform Channel */ DriverTarget *dtar; @@ -310,7 +313,8 @@ int ANIM_add_driver_with_target(ReportList *reports, RNA_id_pointer_create(src_id, &id_ptr2); if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) || - (mapping_type == CREATEDRIVER_MAPPING_NONE)) { + (mapping_type == CREATEDRIVER_MAPPING_NONE)) + { /* No target - So, fall back to default method for adding a "simple" driver normally */ return ANIM_add_driver( reports, dst_id, dst_path, dst_index, flag | CREATEDRIVER_WITH_DEFAULT_DVAR, driver_type); @@ -992,7 +996,8 @@ static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEv PropertyRNA *prop; if ((prop = RNA_struct_find_property(op->ptr, "mapping_type")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { /* Mapping Type is Set - Directly go into creating drivers */ return add_driver_button_menu_exec(C, op); } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 007e911156e..175bce8266f 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -303,20 +303,17 @@ static void fmodifier_panel_header(const bContext *C, Panel *panel) uiBlock *block = uiLayoutGetBlock(layout); uiLayout *sub = uiLayoutRow(layout, true); - uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); - uiLayoutSetEmboss(sub, UI_EMBOSS_NONE); /* Checkbox for 'active' status (for now). */ uiItemR(sub, ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* Name. */ if (fmi) { - uiItemL(sub, IFACE_(fmi->name), ICON_NONE); + uiItemR(sub, ptr, "name", 0, "", ICON_NONE); } else { uiItemL(sub, IFACE_(""), ICON_NONE); } - /* Right align. */ sub = uiLayoutRow(layout, true); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 1e9b43c8df8..201f5cdb409 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -604,7 +604,8 @@ bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const BLI_rctf_transform_pt_v(data_lasso->rectf_view, data_lasso->rectf_scaled, xy_view, xy); if (BLI_lasso_is_point_inside( - data_lasso->mcoords, data_lasso->mcoords_len, xy_view[0], xy_view[1], INT_MAX)) { + data_lasso->mcoords, data_lasso->mcoords_len, xy_view[0], xy_view[1], INT_MAX)) + { return true; } } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 989086a947b..265e72968ad 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -98,7 +98,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo /* Check if any points. */ if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert == 0) || - (!cleardefault && fcu->totvert == 1)) { + (!cleardefault && fcu->totvert == 1)) + { return; } @@ -227,18 +228,6 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo } } -static void move_key(BezTriple *bezt, const float key_y_value) -{ - const float delta = key_y_value - bezt->vec[1][1]; - bezt->vec[1][1] = key_y_value; - /* When handle type is HD_ALIGN handles would get stuck unless we move them along with the key. - */ - if (ELEM(HD_ALIGN, bezt->h1, bezt->h2)) { - bezt->vec[0][1] += delta; - bezt->vec[2][1] += delta; - } -} - /** * Find the first segment of consecutive selected curve points, starting from \a start_index. * Keys that have BEZT_FLAG_IGNORE_TAG set are treated as unselected. @@ -332,7 +321,7 @@ void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { const float key_y_value = interpf( target_bezt->vec[1][1], fcu->bezt[i].vec[1][1], blend_factor); - move_key(&fcu->bezt[i], key_y_value); + BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value); } } @@ -394,7 +383,7 @@ void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor continue; } const float key_y_value = interpf(default_value, fcu->bezt[i].vec[1][1], factor); - move_key(&fcu->bezt[i], key_y_value); + BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value); } } /* ---------------- */ @@ -444,7 +433,7 @@ void smooth_fcurve_segment(FCurve *fcu, filter_result += samples[sample_index - j] * kernel_value; } const float key_y_value = interpf((float)filter_result, samples[sample_index], factor); - move_key(&fcu->bezt[i], key_y_value); + BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value); } } /* ---------------- */ @@ -484,7 +473,7 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor } const float key_y_value = left_y + normalized_y * key_y_range; - move_key(&fcu->bezt[i], key_y_value); + BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value); } } @@ -498,7 +487,7 @@ void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float f for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { const float key_y_value = interpf(right_bezt->vec[1][1], left_bezt->vec[1][1], factor); - move_key(&fcu->bezt[i], key_y_value); + BKE_fcurve_keyframe_move_value_with_handles(&fcu->bezt[i], key_y_value); } } @@ -558,7 +547,8 @@ static void decimate_fcurve_segment(FCurve *fcu, * has a check that prevents removal of the first and last index in the * passed array. */ if (bezt_segment_len + bezt_segment_start_idx != fcu->totvert && - prepare_for_decimate(fcu, bezt_segment_len + bezt_segment_start_idx)) { + prepare_for_decimate(fcu, bezt_segment_len + bezt_segment_start_idx)) + { bezt_segment_len++; } if (bezt_segment_start_idx != 0 && prepare_for_decimate(fcu, bezt_segment_start_idx - 1)) { @@ -917,7 +907,8 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) * - this check should also eliminate any problems associated with using sample-data */ if (ANIM_fcurve_keyframes_loop( - NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) { + NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) + { continue; } @@ -1151,15 +1142,18 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt) flip = true; } else if (BLI_strn_endswith(aci->rna_path, "rotation_quaternion", slength) && - ELEM(aci->array_index, 2, 3)) { + ELEM(aci->array_index, 2, 3)) + { flip = true; } else if (BLI_strn_endswith(aci->rna_path, "rotation_euler", slength) && - ELEM(aci->array_index, 1, 2)) { + ELEM(aci->array_index, 1, 2)) + { flip = true; } else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) && - ELEM(aci->array_index, 2, 3)) { + ELEM(aci->array_index, 2, 3)) + { flip = true; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index e7c6615e60f..7d27ca18176 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -429,8 +429,8 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) if (flag & INSERTKEY_CYCLE_AWARE) { /* If replacing an end point of a cyclic curve without offset, * modify the other end too. */ - if (ELEM(i, 0, fcu->totvert - 1) && - BKE_fcurve_get_cycle_type(fcu) == FCU_CYCLE_PERFECT) { + if (ELEM(i, 0, fcu->totvert - 1) && BKE_fcurve_get_cycle_type(fcu) == FCU_CYCLE_PERFECT) + { replace_bezt_keyframe_ypos(&fcu->bezt[i == 0 ? fcu->totvert - 1 : 0], bezt); } } @@ -1567,7 +1567,8 @@ int insert_keyframe(Main *bmain, &remapped_context, values[array_index], keytype, - flag)) { + flag)) + { ret++; exclude = array_index; break; @@ -1624,7 +1625,8 @@ int insert_keyframe(Main *bmain, /* Key a single index. */ else { if (array_index >= 0 && array_index < value_count && - BLI_BITMAP_TEST_BOOL(successful_remaps, array_index)) { + BLI_BITMAP_TEST_BOOL(successful_remaps, array_index)) + { ret += insert_keyframe_fcurve_value(bmain, reports, &ptr, @@ -2307,8 +2309,8 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) /* Get bone-name, and check if this bone is selected. */ bPoseChannel *pchan = NULL; char bone_name[sizeof(pchan->name)]; - if (BLI_str_quoted_substr( - fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) { + if (BLI_str_quoted_substr(fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) + { pchan = BKE_pose_channel_find_name(ob->pose, bone_name); /* Delete if bone is selected. */ if ((pchan) && (pchan->bone)) { @@ -2593,7 +2595,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } else if ((ptr.type == &RNA_Object) && (strstr(identifier, "location") || strstr(identifier, "rotation") || - strstr(identifier, "scale"))) { + strstr(identifier, "scale"))) + { /* NOTE: Keep this label in sync with the "ID" case in * keyingsets_utils.py :: get_transform_generators_base_info() */ diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 806da5ee286..812d6e6d3f2 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -510,15 +510,18 @@ static void updateDuplicateActionConstraintSettings( flip = true; } else if (BLI_strn_endswith(new_curve->rna_path, "rotation_quaternion", slength) && - ELEM(new_curve->array_index, 2, 3)) { + ELEM(new_curve->array_index, 2, 3)) + { flip = true; } else if (BLI_strn_endswith(new_curve->rna_path, "rotation_euler", slength) && - ELEM(new_curve->array_index, 1, 2)) { + ELEM(new_curve->array_index, 1, 2)) + { flip = true; } else if (BLI_strn_endswith(new_curve->rna_path, "rotation_axis_angle", slength) && - ELEM(new_curve->array_index, 2, 3)) { + ELEM(new_curve->array_index, 2, 3)) + { flip = true; } @@ -723,7 +726,8 @@ static void updateDuplicateTransformConstraintSettings(Object *ob, for (int i = 0; i < 3; i++) { if ((trans->from == TRANS_LOCATION && trans->map[i] == X) || - (trans->from == TRANS_ROTATION && trans->map[i] != X)) { + (trans->from == TRANS_ROTATION && trans->map[i] != X)) + { /* X Loc to X/Y/Z Scale: Min/Max Flipped */ /* Y Rot to X/Y/Z Scale: Min/Max Flipped */ /* Z Rot to X/Y/Z Scale: Min/Max Flipped */ @@ -741,7 +745,8 @@ static void updateDuplicateTransformConstraintSettings(Object *ob, for (int i = 0; i < 3; i++) { if ((trans->from == TRANS_LOCATION && trans->map[i] == X) || - (trans->from == TRANS_ROTATION && trans->map[i] != X)) { + (trans->from == TRANS_ROTATION && trans->map[i] != X)) + { /* X Loc to X/Y/Z Loc: Min/Max Flipped (and Inverted) * Y Rot to X/Y/Z Loc: Min/Max Flipped * Z Rot to X/Y/Z Loc: Min/Max Flipped */ @@ -756,7 +761,8 @@ static void updateDuplicateTransformConstraintSettings(Object *ob, trans->to_max_rot[2] *= -1; if ((trans->from == TRANS_LOCATION && trans->map[1] != X) || - (trans->from == TRANS_ROTATION && trans->map[1] != Y) || trans->from == TRANS_SCALE) { + (trans->from == TRANS_ROTATION && trans->map[1] != Y) || trans->from == TRANS_SCALE) + { /* Invert the Y rotation */ trans->to_min_rot[1] *= -1; trans->to_max_rot[1] *= -1; @@ -767,7 +773,8 @@ static void updateDuplicateTransformConstraintSettings(Object *ob, for (int i = 0; i < 3; i++) { if ((trans->from == TRANS_LOCATION && trans->map[i] == X && i != 1) || (trans->from == TRANS_ROTATION && trans->map[i] == Y && i != 1) || - (trans->from == TRANS_ROTATION && trans->map[i] == Z)) { + (trans->from == TRANS_ROTATION && trans->map[i] == Z)) + { /* X Loc to X/Z Rot: Flipped * Y Rot to X/Z Rot: Flipped * Z Rot to X/Y/Z rot: Flipped */ @@ -803,7 +810,8 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig ListBase *conlist; if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name)) == NULL || - (conlist = &pchan->constraints) == NULL) { + (conlist = &pchan->constraints) == NULL) + { return; } @@ -960,7 +968,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Find the selected bones and duplicate them as needed */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { EditBone *ebone; char new_bone_name_buff[MAXBONENAME]; @@ -987,7 +996,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Run though the list and fix the pointers */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { EditBone *ebone = ebone_iter->temp.ebone; @@ -1033,7 +1043,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Deselect the old bones and select the new ones */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter)) { ebone_iter->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } @@ -1178,7 +1189,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* Find the selected bones and duplicate them as needed, with mirrored name. */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { if (ebone_iter->temp.ebone != NULL) { /* This will be set if the mirror bone already exists (no need to make a new one) @@ -1213,7 +1225,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* Run through the list and fix the pointers. */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (ebone_iter->temp.ebone) { /* copy all flags except for ... */ const int flag_copy = ((int)~0) & ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); @@ -1281,7 +1294,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* Deselect the old bones and select the new ones */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter)) { ebone_iter->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } @@ -1289,7 +1303,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* New bones will be selected, but some of the bones may already exist */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; - ebone_iter = ebone_iter->next) { + ebone_iter = ebone_iter->next) + { EditBone *ebone = ebone_iter->temp.ebone; if (ebone && EBONE_SELECTABLE(arm, ebone)) { ED_armature_ebone_select_set(ebone, true); diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 0e3748ad661..77a37b98612 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -750,7 +750,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) ebp_b = ebp_a->next; if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) || - ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL))) { + ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL))) + { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); return OPERATOR_CANCELLED; @@ -1018,7 +1019,8 @@ static void fix_connected_bone(EditBone *ebone) float diff[3]; if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || - equals_v3v3(ebone->parent->tail, ebone->head)) { + equals_v3v3(ebone->parent->tail, ebone->head)) + { return; } @@ -1381,12 +1383,14 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* break connections for unseen bones */ if (((arm->layer & ebone->layer) && - (ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0) { + (ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0) + { ebone->temp.ebone = NULL; } if (((arm->layer & ebone->layer) && - (ED_armature_ebone_selectflag_get(ebone) & (BONE_ROOTSEL | BONE_SELECTED))) == 0) { + (ED_armature_ebone_selectflag_get(ebone) & (BONE_ROOTSEL | BONE_SELECTED))) == 0) + { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { ebone->parent->temp.ebone = NULL; } diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index d2eb718401d..dff422a8852 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -831,7 +831,8 @@ cache_end: * Otherwise ensure the value is the smallest it can be, * relative to the active bone, as long as it's not the active bone. */ if ((cycle_order.best.as_u32 == 0) || - (cycle_order.test.as_u32 && (cycle_order.test.as_u32 < cycle_order.best.as_u32))) { + (cycle_order.test.as_u32 && (cycle_order.test.as_u32 < cycle_order.best.as_u32))) + { cycle_order.best = cycle_order.test; result_cycle.hitresult = hitresult; result_cycle.base = base; @@ -1254,7 +1255,8 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) /* When there is a partial selection without both endpoints, only select an endpoint. */ if ((is_inside_flag & BONESEL_BONE) && - ELEM(is_inside_flag & (BONESEL_ROOT | BONESEL_TIP), BONESEL_ROOT, BONESEL_TIP)) { + ELEM(is_inside_flag & (BONESEL_ROOT | BONESEL_TIP), BONESEL_ROOT, BONESEL_TIP)) + { is_inside_flag &= ~BONESEL_BONE; } @@ -1428,8 +1430,8 @@ static void armature_select_more(bArmature *arm, EditBone *ebone) static void armature_select_less(bArmature *UNUSED(arm), EditBone *ebone) { - if ((EBONE_PREV_FLAG_GET(ebone) & (BONE_ROOTSEL | BONE_TIPSEL)) != - (BONE_ROOTSEL | BONE_TIPSEL)) { + if ((EBONE_PREV_FLAG_GET(ebone) & (BONE_ROOTSEL | BONE_TIPSEL)) != (BONE_ROOTSEL | BONE_TIPSEL)) + { ED_armature_ebone_select_set(ebone, false); } @@ -1736,7 +1738,7 @@ static void select_similar_prefix(bContext *C) char body_tmp[MAXBONENAME]; char prefix_act[MAXBONENAME]; - BLI_string_split_prefix(ebone_act->name, prefix_act, body_tmp, sizeof(ebone_act->name)); + BLI_string_split_prefix(ebone_act->name, sizeof(ebone_act->name), prefix_act, body_tmp); if (prefix_act[0] == '\0') { return; @@ -1754,7 +1756,7 @@ static void select_similar_prefix(bContext *C) LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { char prefix_other[MAXBONENAME]; - BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name)); + BLI_string_split_prefix(ebone->name, sizeof(ebone->name), prefix_other, body_tmp); if (STREQ(prefix_act, prefix_other)) { ED_armature_ebone_select_set(ebone, true); changed = true; @@ -1779,7 +1781,7 @@ static void select_similar_suffix(bContext *C) char body_tmp[MAXBONENAME]; char suffix_act[MAXBONENAME]; - BLI_string_split_suffix(ebone_act->name, body_tmp, suffix_act, sizeof(ebone_act->name)); + BLI_string_split_suffix(ebone_act->name, sizeof(ebone_act->name), body_tmp, suffix_act); if (suffix_act[0] == '\0') { return; @@ -1797,7 +1799,7 @@ static void select_similar_suffix(bContext *C) LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_SELECTABLE(arm, ebone)) { char suffix_other[MAXBONENAME]; - BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name)); + BLI_string_split_suffix(ebone->name, sizeof(ebone->name), body_tmp, suffix_other); if (STREQ(suffix_act, suffix_other)) { ED_armature_ebone_select_set(ebone, true); changed = true; @@ -2137,7 +2139,8 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0; if ((ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone)) && - EBONE_VISIBLE(arm, ebone_mirror)) { + EBONE_VISIBLE(arm, ebone_mirror)) + { const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror); flag_new |= flag_mirror; @@ -2271,7 +2274,8 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const if (ebone_isect_parent) { if (armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, true) && - armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, true)) { + armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, true)) + { armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, false); armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, false); changed = true; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 39d558638ce..e990a12b7c0 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -199,7 +199,8 @@ static void envelope_bone_weighting(Object *ob, bool use_mask = false; if ((ob->mode & OB_MODE_WEIGHT_PAINT) && - (mesh->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL))) { + (mesh->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL))) + { use_mask = true; } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 75800318fef..26ac342b707 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -191,8 +191,8 @@ EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const ui } /* only need search the first chain */ - for (EditBone *ebone_iter = ebone_child[0]->parent; ebone_iter; - ebone_iter = ebone_iter->parent) { + for (EditBone *ebone_iter = ebone_child[0]->parent; ebone_iter; ebone_iter = ebone_iter->parent) + { if (EBONE_TEMP_UINT(ebone_iter) == ebone_child_tot) { return ebone_iter; } diff --git a/source/blender/editors/armature/meshlaplacian.cc b/source/blender/editors/armature/meshlaplacian.cc index 156e7bf597d..a990e434988 100644 --- a/source/blender/editors/armature/meshlaplacian.cc +++ b/source/blender/editors/armature/meshlaplacian.cc @@ -1023,7 +1023,8 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, &hit, harmonic_ray_callback, &data, - BVH_RAYCAST_WATERTIGHT) != -1) { + BVH_RAYCAST_WATERTIGHT) != -1) + { const blender::Span corner_verts = mdb->cagemesh_cache.corner_verts; const MLoopTri *lt = &mdb->cagemesh_cache.looptris[hit.index]; const blender::IndexRange poly = mdb->cagemesh_cache.polys[lt->poly]; @@ -1171,7 +1172,8 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) if (b != -1) { if (tag[b] == MESHDEFORM_TAG_UNTYPED || - (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i - 1])) { + (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i - 1])) + { tag[b] = MESHDEFORM_TAG_EXTERIOR; stack[stacksize++] = b; } diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c index db490c8b32e..9a35a9dd530 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.c @@ -138,7 +138,8 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) } if (BKE_pose_backup_is_selection_relevant(pbd->pose_backup) && - !PBONE_SELECTED(armature, pchan->bone)) { + !PBONE_SELECTED(armature, pchan->bone)) + { continue; } @@ -222,7 +223,8 @@ static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const /* Handle the release confirm event directly, it has priority over others. */ if (pbd->release_confirm_info.use_release_confirm && - (event->type == pbd->release_confirm_info.init_event_type) && (event->val == KM_RELEASE)) { + (event->type == pbd->release_confirm_info.init_event_type) && (event->val == KM_RELEASE)) + { pbd->state = POSE_BLEND_CONFIRM; return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 47a327902fe..d9d28cf6c6b 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -288,8 +288,8 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene, Object *ob_arm = agmd->object; if (ob_arm != NULL) { Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); - if ((base_arm != NULL) && (base_arm != base_select) && - (base_arm->flag & BASE_SELECTED)) { + if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) + { ED_object_base_select(base_arm, BA_DESELECT); } } @@ -305,8 +305,8 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene, Object *ob_arm = amd->object; if (ob_arm != NULL) { Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); - if ((base_arm != NULL) && (base_arm != base_select) && - (base_arm->flag & BASE_SELECTED)) { + if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) + { ED_object_base_select(base_arm, BA_DESELECT); } } @@ -696,7 +696,8 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op /* Any armature that is also in pose mode should be selected. */ if ((ct->subtarget[0] != '\0') && (ob != NULL) && (ob->type == OB_ARMATURE) && - (ob->mode == OB_MODE_POSE)) { + (ob->mode == OB_MODE_POSE)) + { bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; @@ -1237,7 +1238,8 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op) int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0; if ((pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) && - PBONE_VISIBLE(arm, pchan_mirror->bone)) { + PBONE_VISIBLE(arm, pchan_mirror->bone)) + { const int flag_mirror = PBONE_PREV_FLAG_GET(pchan_mirror); flag_new |= flag_mirror; diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 38762913b3d..6dc8d09f291 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -468,7 +468,8 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, BLI_assert(fcu->array_index < 3); if ((lock == 0) || ((lock & PS_LOCK_X) && (idx == 0)) || ((lock & PS_LOCK_Y) && (idx == 1)) || - ((lock & PS_LOCK_Z) && (idx == 2))) { + ((lock & PS_LOCK_Z) && (idx == 2))) + { /* Just work on these channels one by one... there's no interaction between values. */ pose_slide_apply_val(pso, fcu, pfl->ob, &vec[fcu->array_index]); } @@ -739,7 +740,8 @@ static void pose_slide_rest_pose_apply_vec3(tPoseSlideOp *pso, float vec[3], flo const int lock = pso->axislock; for (int idx = 0; idx < 3; idx++) { if ((lock == 0) || ((lock & PS_LOCK_X) && (idx == 0)) || ((lock & PS_LOCK_Y) && (idx == 1)) || - ((lock & PS_LOCK_Z) && (idx == 2))) { + ((lock & PS_LOCK_Z) && (idx == 2))) + { float diff_val = default_value - vec[idx]; if (pso->mode == POSESLIDE_RELAX_REST) { vec[idx] += ED_slider_factor_get(pso->slider) * diff_val; diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index 04554382716..253b099d277 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -119,7 +119,7 @@ class BlendFile : public AbstractFile { std::string get_filename() const { char filename[FILE_MAX]; - BLI_split_file_part(get_file_path(), filename, sizeof(filename)); + BLI_path_split_file_part(get_file_path(), filename, sizeof(filename)); return std::string(filename); } @@ -761,9 +761,7 @@ class AssetIndexFile : public AbstractFile { bool ensure_parent_path_exists() const { - /* `BLI_make_existing_file` only ensures parent path, otherwise than expected from the name of - * the function. */ - return BLI_make_existing_file(get_file_path()); + return BLI_file_ensure_parent_dir_exists(get_file_path()); } void write_contents(AssetIndex &content) diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index 6f2aedcbad5..6afbea919c5 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -43,25 +43,32 @@ using namespace blender; using PointerRNAVec = blender::Vector; /** - * Return the IDs to operate on as PointerRNA vector. Either a single one ("id" context member) or - * multiple ones ("selected_ids" context member). + * Return the IDs to operate on as PointerRNA vector. Prioritizes multiple selected ones + * ("selected_ids" context member) over a single active one ("id" context member), since usually + * batch operations are more useful. */ static PointerRNAVec asset_operation_get_ids_from_context(const bContext *C) { PointerRNAVec ids; - PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID); - if (idptr.data) { - /* Single ID. */ - ids.append(idptr); - } - else { + /* "selected_ids" context member. */ + { ListBase list; CTX_data_selected_ids(C, &list); LISTBASE_FOREACH (CollectionPointerLink *, link, &list) { ids.append(link->ptr); } BLI_freelistN(&list); + + if (!ids.is_empty()) { + return ids; + } + } + + /* "id" context member. */ + PointerRNA idptr = CTX_data_pointer_get_type(C, "id", &RNA_ID); + if (idptr.data) { + ids.append(idptr); } return ids; @@ -279,7 +286,8 @@ void AssetClearHelper::reportResults(const bContext *C, ReportList &reports) con /* Dedicated error message for when there is an active asset detected, but it's not an ID local * to this file. Helps users better understanding what's going on. */ if (AssetHandle active_asset = CTX_wm_asset_handle(C, &is_valid); - is_valid && !ED_asset_handle_get_local_id(&active_asset)) { + is_valid && !ED_asset_handle_get_local_id(&active_asset)) + { BKE_report(&reports, RPT_ERROR, "No asset data-blocks from the current file selected (assets must be stored in " diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f1ac1924ff6..6da8a8c4bf0 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1174,7 +1174,8 @@ static void remap_hooks_and_vertex_parents(Main *bmain, Object *obedit) LISTBASE_FOREACH (Object *, object, &bmain->objects) { int index; if ((object->parent) && (object->parent->data == curve) && - ELEM(object->partype, PARVERT1, PARVERT3)) { + ELEM(object->partype, PARVERT1, PARVERT3)) + { if (old_to_new_map == NULL) { old_to_new_map = init_index_map(obedit, &old_totvert); } @@ -1994,7 +1995,8 @@ static int sel_to_copy_ints(const BPoint *bp, if (selected_leg_count && /* Prevents leading and trailing unselected legs if all selected. * Unless it is extrusion from point or curve. */ - (selected_leg_count < max_j || max_j == 1)) { + (selected_leg_count < max_j || max_j == 1)) + { /* Prepend unselected leg if more than one leg selected at the starting edge. * max_j == 1 handles extrusion from point to curve and from curve to surface cases. */ if (is_first_sel && (copy_intervals[0] < copy_intervals[1] || max_j == 1)) { @@ -2085,7 +2087,8 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag) for (int j = 1; j <= intvl_cnt_v; j++, selected_v = !selected_v) { BPoint *old_bp_v = nu->bp + intvls_v[j - 1] * nu->pntsu; for (int v_j = intvls_v[j - 1]; v_j <= intvls_v[j]; - v_j++, new_bp_v += new_pntsu, old_bp_v += nu->pntsu) { + v_j++, new_bp_v += new_pntsu, old_bp_v += nu->pntsu) + { BPoint *new_bp_u_v = new_bp_v; bool selected_u = is_first_sel_u; for (int i = 1; i <= intvl_cnt_u; i++, selected_u = !selected_u) { @@ -2322,7 +2325,8 @@ static void adduplicateflagNurb( MEM_freeN(usel); if ((newu == 0 || newv == 0) || - (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT))) { + (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT))) + { if (G.debug & G_DEBUG) { printf("Can't duplicate Nurb\n"); } @@ -2395,7 +2399,8 @@ static void adduplicateflagNurb( cu->actvert, starta, cu->actvert % nu->pntsu + newu + - b * newnu->pntsu)) { + b * newnu->pntsu)) + { /* actvert in cyclicu selection */ break; } @@ -2404,7 +2409,8 @@ static void adduplicateflagNurb( cu, starta, starta + newu, - cu->actvert - starta + b * newnu->pntsu)) { + cu->actvert - starta + b * newnu->pntsu)) + { /* actvert in 'current' iteration selection */ break; } @@ -2447,7 +2453,8 @@ static void adduplicateflagNurb( starta, starta + newu, cu->actvert - (a / nu->pntsu * nu->pntsu + diffa + - (starta % nu->pntsu)))) { + (starta % nu->pntsu)))) + { break; } } @@ -2487,7 +2494,8 @@ static void adduplicateflagNurb( cu, starta, starta + newu, - cu->actvert - (diffa + (starta % nu->pntsu)))) { + cu->actvert - (diffa + (starta % nu->pntsu)))) + { break; } } @@ -3437,8 +3445,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) break; } - if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt) && - BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nextbezt)) { + if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt) && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nextbezt)) + { amount += number_cuts; } bezt++; @@ -4676,13 +4684,15 @@ static int make_segment_exec(bContext *C, wmOperator *op) if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu > 1) { if (nu1->type == CU_BEZIER && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, nu1->bezt) && - BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu1->bezt[nu1->pntsu - 1])) { + BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, &nu1->bezt[nu1->pntsu - 1])) + { nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_handles_calc(nu1); ok = true; } else if (ELEM(nu1->type, CU_NURBS, CU_POLY) && nu1->bp->f1 & SELECT && - (nu1->bp[nu1->pntsu - 1].f1 & SELECT)) { + (nu1->bp[nu1->pntsu - 1].f1 & SELECT)) + { nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu1); ok = true; @@ -4723,7 +4733,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) /* All curves failed: If there is more than one error give a generic error report. */ if (((status.error_selected_few ? 1 : 0) + (status.error_resolution ? 1 : 0) + - (status.error_generic ? 1 : 0)) > 1) { + (status.error_generic ? 1 : 0)) > 1) + { BKE_report(op->reports, RPT_ERROR, "Could not make new segments"); } @@ -5675,7 +5686,8 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) float location_test[3]; madd_v3_v3v3fl(location_test, location, view_dir, lambda); if ((vc.rv3d->is_persp == false) || - (mul_project_m4_v3_zfac(vc.rv3d->persmat, location_test) > 0.0f)) { + (mul_project_m4_v3_zfac(vc.rv3d->persmat, location_test) > 0.0f)) + { copy_v3_v3(location, location_test); } } @@ -6084,7 +6096,8 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split) bezt2 = &nu->bezt[nu->pntsu - 2]; if ((nu->flagu & CU_NURB_CYCLIC) && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1) && - BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt2)) { + BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt2)) + { /* check if need to join start of spline to end */ nu1 = BKE_nurb_copy(nu, cut + 1, 1); ED_curve_beztcpy(editnurb, &nu1->bezt[1], nu->bezt, cut); @@ -6108,7 +6121,8 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split) bezt2 = &nu->bezt[1]; if ((nu->flagu & CU_NURB_CYCLIC) && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1) && - BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt2)) { + BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt2)) + { /* check if need to join start of spline to end */ nu1 = BKE_nurb_copy(nu, cut + 1, 1); ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, 1); @@ -6673,7 +6687,8 @@ static int curve_dissolve_exec(bContext *C, wmOperator *UNUSED(op)) test_bezt_is_sel_any, v3d, span_step, - &span_len)) { + &span_len)) + { BezTriple *bezt_prev = &nu->bezt[mod_i(span_step[0] - 1, nu->pntsu)]; BezTriple *bezt_next = &nu->bezt[mod_i(span_step[1] + 1, nu->pntsu)]; diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 15d6592baae..c256fafe1d2 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -509,7 +509,8 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) { + C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index b4fa97a0e0a..20a2aca6158 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -144,7 +144,8 @@ static void stroke_elem_pressure_set(const struct CurveDrawData *cdd, float pressure) { if ((cdd->project.surface_offset != 0.0f) && !cdd->project.use_surface_offset_absolute && - !is_zero_v3(selem->normal_local)) { + !is_zero_v3(selem->normal_local)) + { const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) - stroke_elem_radius_from_pressure(cdd, selem->pressure); madd_v3_v3fl(selem->location_local, selem->normal_local, adjust); @@ -182,8 +183,8 @@ static bool stroke_elem_project(const struct CurveDrawData *cdd, /* project to 'location_world' */ if (cdd->project.use_plane) { /* get the view vector to 'location' */ - if (ED_view3d_win_to_3d_on_plane( - region, cdd->project.plane, mval_fl, true, r_location_world)) { + if (ED_view3d_win_to_3d_on_plane(region, cdd->project.plane, mval_fl, true, r_location_world)) + { if (r_normal_world) { zero_v3(r_normal_world); } @@ -505,7 +506,8 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event) curve_draw_event_add(op, event); if ((cps->depth_mode == CURVE_PAINT_PROJECT_SURFACE) && cdd->project.use_depth && - (cps->flag & CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS)) { + (cps->flag & CURVE_PAINT_FLAG_DEPTH_STROKE_ENDPOINTS)) + { RegionView3D *rv3d = cdd->vc.rv3d; cdd->project.use_depth = false; @@ -514,7 +516,8 @@ static void curve_draw_event_add_first(wmOperator *op, const wmEvent *event) float normal[3] = {0.0f}; if (ELEM(cps->surface_plane, CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW, - CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE)) { + CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE)) + { if (ED_view3d_depth_read_cached_normal(cdd->vc.region, cdd->depths, event->mval, normal)) { if (cps->surface_plane == CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW) { float cross_a[3], cross_b[3]; @@ -684,7 +687,8 @@ static void curve_draw_exec_precalc(wmOperator *op) } if (len_squared_v2v2(selem_first->mval, selem_last->mval) <= - square_f(STROKE_CYCLIC_DIST_PX * UI_SCALE_FAC)) { + square_f(STROKE_CYCLIC_DIST_PX * UI_SCALE_FAC)) + { use_cyclic = true; } } diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index 60e2dda504a..49e5fd93d1d 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -165,7 +165,8 @@ static void update_location_for_2d_curve(const ViewContext *vc, float location[3 float location_test[3]; madd_v3_v3v3fl(location_test, location, view_dir, lambda); if ((vc->rv3d->is_persp == false) || - (mul_project_m4_v3_zfac(vc->rv3d->persmat, location_test) > 0.0f)) { + (mul_project_m4_v3_zfac(vc->rv3d->persmat, location_test) > 0.0f)) + { copy_v3_v3(location, location_test); } } @@ -496,7 +497,8 @@ static bool get_closest_vertex_to_point_in_nurbs(const ViewContext *vc, /* Consider handles only if visible. Else only consider the middle point of the triple. */ int handle_display = vc->v3d->overlay.handle_display; if (handle_display == CURVE_HANDLE_NONE || - (handle_display == CURVE_HANDLE_SELECTED && !BEZT_ISSEL_ANY(bezt))) { + (handle_display == CURVE_HANDLE_SELECTED && !BEZT_ISSEL_ANY(bezt))) + { start = 1; end = 2; } @@ -1389,7 +1391,8 @@ static bool make_cyclic_if_endpoints(ViewContext *vc, if (nu == sel_nu && ((nu->type == CU_BEZIER && bezt != sel_bezt && ELEM(bezt, nu->bezt, nu->bezt + nu->pntsu - 1) && bezt_idx == 1) || - (nu->type != CU_BEZIER && bp != sel_bp && ELEM(bp, nu->bp, nu->bp + nu->pntsu - 1)))) { + (nu->type != CU_BEZIER && bp != sel_bp && ELEM(bp, nu->bp, nu->bp + nu->pntsu - 1)))) + { View3D *v3d = vc->v3d; ListBase *nurbs = object_editcurve_get(vc->obedit); curve_toggle_cyclic(v3d, nurbs, 0); @@ -1661,7 +1664,8 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Close spline on Click, if enabled. */ if (!cpd->acted && close_spline && close_spline_method == ON_CLICK && cpd->found_point && - !cpd->dragging) { + !cpd->dragging) + { if (cpd->nu && !is_cyclic(cpd->nu)) { copy_v2_v2_int(vc.mval, event->mval); cpd->acted = make_cyclic_if_endpoints(&vc, cpd->nu, cpd->bezt, cpd->bp); @@ -1776,7 +1780,8 @@ static int curve_pen_invoke(bContext *C, wmOperator *op, const wmEvent *event) &vc, nurbs, mval_fl, &nu1, &bezt1, &bp1, &bezt_idx); if (move_point && nu1 && !nu1->hide && - (bezt || (bezt1 && !BEZT_ISSEL_IDX(bezt1, bezt_idx)) || (bp1 && !(bp1->f1 & SELECT)))) { + (bezt || (bezt1 && !BEZT_ISSEL_IDX(bezt1, bezt_idx)) || (bp1 && !(bp1->f1 & SELECT)))) + { /* Select the closest bezt or bp. */ ED_curve_deselect_all(cu->editnurb); if (bezt1) { diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 99a146c84d0..6d786fedf46 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1075,7 +1075,8 @@ static int paste_text_exec(bContext *C, wmOperator *op) } else { if ((clipboard_system.len <= MAXTEXT) && - font_paste_utf8(C, clipboard_system.buf, clipboard_system.len)) { + font_paste_utf8(C, clipboard_system.buf, clipboard_system.len)) + { text_update_edited(C, obedit, FO_EDIT); retval = OPERATOR_FINISHED; } @@ -1811,8 +1812,6 @@ void FONT_OT_text_insert(wmOperatorType *ot) static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const wmEvent *event) { - Curve *cu = obedit->data; - /* Calculate a plane from the text object's orientation. */ float plane[4]; plane_from_point_normal_v3(plane, obedit->object_to_world[3], obedit->object_to_world[2]); @@ -1825,7 +1824,7 @@ static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const /* Convert to object space and scale by font size. */ mul_m4_v3(obedit->world_to_object, mouse_loc); - float curs_loc[2] = {mouse_loc[0] / cu->fsize, mouse_loc[1] / cu->fsize}; + float curs_loc[2] = {mouse_loc[0], mouse_loc[1]}; return BKE_vfont_cursor_to_text_index(obedit, curs_loc); } @@ -2399,7 +2398,8 @@ bool ED_curve_editfont_select_pick( for (j = 0; j < 4; j++) { if (ED_view3d_project_float_object( - vc.region, obedit_co[j], screen_co[j], V3D_PROJ_TEST_CLIP_BB) == V3D_PROJ_RET_OK) { + vc.region, obedit_co[j], screen_co[j], V3D_PROJ_TEST_CLIP_BB) == V3D_PROJ_RET_OK) + { project_ok |= (1 << j); } } diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index fa08fa8a04f..34bfdddd928 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -796,7 +796,8 @@ static int curves_set_selection_domain_exec(bContext *C, wmOperator *op) if (!attributes.add(".selection", domain, bke::cpp_type_to_custom_data_type(type), - bke::AttributeInitMoveArray(dst))) { + bke::AttributeInitMoveArray(dst))) + { MEM_freeN(dst); } } diff --git a/source/blender/editors/curves/intern/curves_selection.cc b/source/blender/editors/curves/intern/curves_selection.cc index 8b2e5aec326..d79c4a6ea22 100644 --- a/source/blender/editors/curves/intern/curves_selection.cc +++ b/source/blender/editors/curves/intern/curves_selection.cc @@ -726,7 +726,8 @@ bool select_lasso(const ViewContext &vc, /* Check the lasso bounding box first as an optimization. */ if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) && BLI_lasso_is_point_inside( - coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) { + coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) + { apply_selection_operation_at_index(selection.span, point_i, sel_op); changed = true; } @@ -744,7 +745,8 @@ bool select_lasso(const ViewContext &vc, /* Check the lasso bounding box first as an optimization. */ if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) && BLI_lasso_is_point_inside( - coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) { + coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) + { apply_selection_operation_at_index(selection.span, curve_i, sel_op); changed = true; } @@ -766,7 +768,8 @@ bool select_lasso(const ViewContext &vc, int(pos1_proj.y), int(pos2_proj.x), int(pos2_proj.y), - IS_CLIPPED)) { + IS_CLIPPED)) + { apply_selection_operation_at_index(selection.span, curve_i, sel_op); changed = true; break; diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 6150f78bcde..65685ff394d 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -263,7 +263,8 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op) name.c_str(), eCustomDataType(RNA_enum_get(op->ptr, "data_type")), eAttrDomain(RNA_enum_get(op->ptr, "domain")), - op->reports)) { + op->reports)) + { return OPERATOR_CANCELLED; } break; @@ -565,7 +566,8 @@ static bool geometry_color_attribute_convert_poll(bContext *C) return false; } if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) || - !(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) { + !(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) + { return false; } diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 731b1b07193..0399e8b2c2a 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -336,7 +336,8 @@ static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { ARegion *region = CTX_wm_region(C); if (ED_view3d_project_float_global(region, matrix_final[3], co_proj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float matrix_final_no_offset[4][4]; const RegionView3D *rv3d = region->regiondata; WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 12572584f8f..89c794335dc 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -589,7 +589,8 @@ static void cage2d_draw_rect_corner_handles(const rctf *r, { /* Only draw corner handles when hovering over the corners. */ if (highlighted < ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y || - highlighted > ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y) { + highlighted > ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y) + { return; } @@ -1013,7 +1014,8 @@ static int gizmo_cage2d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) WM_gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset); if (gizmo_window_project_2d( - C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) { + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) + { zero_v2(data->orig_mouse); } diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index f244e56ce21..ce8bac5b318 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -93,7 +93,8 @@ static void gizmo_rect_pivot_from_scale_part(int part, bool has_translation) { if (part >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - part <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) { + part <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + { int index = (part - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); int range[3]; range[2] = index % 3; @@ -145,7 +146,8 @@ static void cage3d_draw_box_interaction(const RegionView3D *rv3d, const float margin[3]) { if (highlighted >= ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z && - highlighted <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) { + highlighted <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z) + { int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z); int range[3]; range[2] = index % 3; @@ -321,7 +323,8 @@ static void gizmo_cage3d_draw_intern( if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE) { for (int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; i <= ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z; - i++) { + i++) + { if (i == ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z) { continue; } @@ -446,7 +449,8 @@ static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true); if (gizmo_window_project_3d( - C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) { + C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) + { zero_v3(data->orig_mouse); } diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c index 866952015f1..c11b3461cb7 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c @@ -251,7 +251,8 @@ static int gizmo_move_modal(bContext *C, float mval_proj_init[2], mval_proj_curr[2]; if ((gizmo_window_project_2d(C, gz, inter->init.mval, 2, false, mval_proj_init) == false) || (gizmo_window_project_2d( - C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) { + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) + { return OPERATOR_RUNNING_MODAL; } sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init); @@ -288,7 +289,8 @@ static int gizmo_move_modal(bContext *C, NULL, &dist_px, co, - NULL)) { + NULL)) + { float matrix_space_inv[4][4]; invert_m4_m4(matrix_space_inv, gz->matrix_space); mul_v3_m4v3(move->prop_co, matrix_space_inv, co); diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c index df4222fe154..cccc3243640 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c @@ -222,7 +222,8 @@ static bool snap_cursor_poll(ARegion *region, void *data) { SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)data; if (!(snap_gizmo->gizmo.state & WM_GIZMO_STATE_HIGHLIGHT) && - !(snap_gizmo->gizmo.flag & WM_GIZMO_DRAW_VALUE)) { + !(snap_gizmo->gizmo.flag & WM_GIZMO_DRAW_VALUE)) + { return false; } diff --git a/source/blender/editors/gpencil_legacy/annotate_draw.c b/source/blender/editors/gpencil_legacy/annotate_draw.c index e3346fe9690..5a35c06153b 100644 --- a/source/blender/editors/gpencil_legacy/annotate_draw.c +++ b/source/blender/editors/gpencil_legacy/annotate_draw.c @@ -218,7 +218,8 @@ static void annotation_draw_stroke_buffer(bGPdata *gps, } /* Draw starting arrow stroke. */ if ((sflag & GP_STROKE_USE_ARROW_START) && - (runtime.arrow_start_style != GP_STROKE_ARROWSTYLE_NONE)) { + (runtime.arrow_start_style != GP_STROKE_ARROWSTYLE_NONE)) + { float start[2]; copy_v2_v2(start, points[0].m_xy); annotation_draw_stroke_arrow_buffer( diff --git a/source/blender/editors/gpencil_legacy/annotate_paint.c b/source/blender/editors/gpencil_legacy/annotate_paint.c index 17c1fcefb89..f4fc06d8b18 100644 --- a/source/blender/editors/gpencil_legacy/annotate_paint.c +++ b/source/blender/editors/gpencil_legacy/annotate_paint.c @@ -317,8 +317,8 @@ static void annotation_stroke_convertcoords(tGPsdata *p, if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { int mval_i[2]; round_v2i_v2fl(mval_i, mval); - if (annotation_project_check(p) && - ED_view3d_autodist_simple(p->region, mval_i, out, 0, depth)) { + if (annotation_project_check(p) && ED_view3d_autodist_simple(p->region, mval_i, out, 0, depth)) + { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ @@ -340,7 +340,8 @@ static void annotation_stroke_convertcoords(tGPsdata *p, const float zfac = ED_view3d_calc_zfac(p->region->regiondata, rvec); if (ED_view3d_project_float_global(p->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float dvec[3]; float xy_delta[2]; sub_v2_v2v2(xy_delta, mval_prj, mval); @@ -897,7 +898,8 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) /** Create arrow strokes. */ /* End arrow stroke. */ if ((runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_END) && - (runtime.arrow_end_style != GP_STROKE_ARROWSTYLE_NONE)) { + (runtime.arrow_end_style != GP_STROKE_ARROWSTYLE_NONE)) + { int totarrowpoints = runtime.arrow_end_style; /* Setting up arrow stroke. */ @@ -918,7 +920,8 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) } /* Start arrow stroke. */ if ((runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_START) && - (runtime.arrow_start_style != GP_STROKE_ARROWSTYLE_NONE)) { + (runtime.arrow_start_style != GP_STROKE_ARROWSTYLE_NONE)) + { int totarrowpoints = runtime.arrow_start_style; /* Setting up arrow stroke. */ @@ -968,7 +971,8 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_depth_read_cached_seg( - depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { interp_depth = true; } else { @@ -1022,8 +1026,8 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) pt = gps->points; /* convert all points (normal behavior) */ - for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; - i++, ptc++, pt++) { + for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; i++, ptc++, pt++) + { /* convert screen-coordinates to appropriate coordinates (and store them) */ annotation_stroke_convertcoords(p, ptc->m_xy, &pt->x, depth_arr ? depth_arr + i : NULL); @@ -1160,14 +1164,16 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p, /* Check that point segment of the bound-box of the eraser stroke. */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1]) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { + (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + { /* Check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that line-width is irrelevant. */ if (gpencil_stroke_inside_circle(mval, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { if ((annotation_stroke_eraser_is_occluded(p, pt1, pc1[0], pc1[1]) == false) || - (annotation_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) { + (annotation_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) + { /* Edge is affected - Check individual points now */ if (len_v2v2_int(mval_i, pc1) <= radius) { pt1->flag |= GP_SPOINT_TAG; @@ -2464,7 +2470,8 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve EVT_DOWNARROWKEY, EVT_RIGHTARROWKEY, EVT_UPARROWKEY, - EVT_ZKEY)) { + EVT_ZKEY)) + { /* allow some keys: * - For frame changing #33412. * - For undo (during sketching sessions). @@ -2480,7 +2487,8 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve EVT_PAD6, EVT_PAD7, EVT_PAD8, - EVT_PAD9)) { + EVT_PAD9)) + { /* Allow numpad keys so that camera/view manipulations can still take place * - #EVT_PAD0 in particular is really important for Grease Pencil drawing, * as animators may be working "to camera", so having this working @@ -2506,7 +2514,8 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve * as that would break polyline #32647. */ if (event->val == KM_PRESS && - ELEM(event->type, EVT_RETKEY, EVT_PADENTER, EVT_ESCKEY, EVT_SPACEKEY, EVT_EKEY)) { + ELEM(event->type, EVT_RETKEY, EVT_PADENTER, EVT_ESCKEY, EVT_SPACEKEY, EVT_EKEY)) + { /* exit() ends the current stroke before cleaning up */ p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; @@ -2661,7 +2670,8 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve } /* eraser size */ else if ((p->paintmode == GP_PAINTMODE_ERASER) && - ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, EVT_PADPLUSKEY, EVT_PADMINUS)) { + ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, EVT_PADPLUSKEY, EVT_PADMINUS)) + { /* just resize the brush (local version) * TODO: fix the hardcoded size jumps (set to make a visible difference) and hardcoded keys */ diff --git a/source/blender/editors/gpencil_legacy/drawgpencil.c b/source/blender/editors/gpencil_legacy/drawgpencil.c index f7068c32db8..3c422a07aec 100644 --- a/source/blender/editors/gpencil_legacy/drawgpencil.c +++ b/source/blender/editors/gpencil_legacy/drawgpencil.c @@ -319,13 +319,15 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) if ((gp_style == NULL) || (gp_style->flag & GP_MATERIAL_HIDE) || /* If onion and ghost flag do not draw. */ - (tgpw->onion && (gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN))) { + (tgpw->onion && (gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN))) + { continue; } /* if disable fill, the colors with fill must be omitted too except fill boundary strokes */ if ((tgpw->disable_fill == 1) && (gp_style->fill_rgba[3] > 0.0f) && - ((gps->flag & GP_STROKE_NOFILL) == 0) && (gp_style->flag & GP_MATERIAL_FILL_SHOW)) { + ((gps->flag & GP_STROKE_NOFILL) == 0) && (gp_style->flag & GP_MATERIAL_FILL_SHOW)) + { continue; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_convert.c b/source/blender/editors/gpencil_legacy/gpencil_convert.c index 97763060269..1ddb512826b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_convert.c +++ b/source/blender/editors/gpencil_legacy/gpencil_convert.c @@ -792,7 +792,8 @@ static void gpencil_stroke_to_path(bContext *C, /* add points */ for (i = (stitch) ? 1 : 0, pt = &gps->points[(stitch) ? 1 : 0], bp = &nu->bp[old_nbp]; i < gps->totpoints; - i++, pt++, bp++) { + i++, pt++, bp++) + { float p[3]; float width = pt->pressure * (gps->thickness + gpl->line_change) * WIDTH_CORR_FAC; @@ -1415,7 +1416,8 @@ static bool gpencil_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, bool valid = true; if (!gpl || !(gpf = BKE_gpencil_layer_frame_get(gpl, scene->r.cfra, GP_GETFRAME_USE_PREV)) || - !(gps = gpf->strokes.first)) { + !(gps = gpf->strokes.first)) + { return false; } @@ -1579,7 +1581,8 @@ static bool gpencil_convert_poll_property(const bContext *UNUSED(C), "radius_multiplier", "use_link_strokes", "bevel_depth", - "bevel_resolution")) { + "bevel_resolution")) + { return true; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_data.c b/source/blender/editors/gpencil_legacy/gpencil_data.c index 25d424b92cb..7ba73cc0268 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_data.c +++ b/source/blender/editors/gpencil_legacy/gpencil_data.c @@ -2229,7 +2229,8 @@ static bool gpencil_vertex_group_poll(bContext *C) Main *bmain = CTX_data_main(C); const bGPdata *gpd = (const bGPdata *)ob->data; if (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, ob->data) && - !BLI_listbase_is_empty(&gpd->vertex_group_names)) { + !BLI_listbase_is_empty(&gpd->vertex_group_names)) + { if (ELEM(ob->mode, OB_MODE_EDIT_GPENCIL, OB_MODE_SCULPT_GPENCIL)) { return true; } @@ -2247,7 +2248,8 @@ static bool gpencil_vertex_group_weight_poll(bContext *C) Main *bmain = CTX_data_main(C); const bGPdata *gpd = (const bGPdata *)ob->data; if (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, ob->data) && - !BLI_listbase_is_empty(&gpd->vertex_group_names)) { + !BLI_listbase_is_empty(&gpd->vertex_group_names)) + { if (ob->mode == OB_MODE_WEIGHT_GPENCIL) { return true; } @@ -2928,7 +2930,8 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) old_idx++; } if (!BLI_listbase_is_empty(&gpd_dst->vertex_group_names) && - gpd_dst->vertex_group_active_index == 0) { + gpd_dst->vertex_group_active_index == 0) + { gpd_dst->vertex_group_active_index = 1; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit.c b/source/blender/editors/gpencil_legacy/gpencil_edit.c index 6c54a9f7d53..545c4973d86 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit.c +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.c @@ -1876,8 +1876,8 @@ static int gpencil_move_to_layer_exec(bContext *C, wmOperator *op) } bGPDframe *init_gpf = (is_multiedit) ? gpl_src->frames.first : gpl_src->actframe; for (bGPDframe *gpf_src = init_gpf; gpf_src; gpf_src = gpf_src->next) { - if ((gpf_src == gpl_src->actframe) || - ((gpf_src->flag & GP_FRAME_SELECT) && (is_multiedit))) { + if ((gpf_src == gpl_src->actframe) || ((gpf_src->flag & GP_FRAME_SELECT) && (is_multiedit))) + { if (gpf_src == NULL) { continue; } @@ -3278,8 +3278,8 @@ static int gpencil_stroke_cyclical_set_exec(bContext *C, wmOperator *op) for (gps = gpf->strokes.first; gps; gps = gps->next) { MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); /* skip strokes that are not selected or invalid for current view */ - if (((gps->flag & GP_STROKE_SELECT) == 0) || - ED_gpencil_stroke_can_use(C, gps) == false) { + if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false) + { continue; } /* skip hidden or locked colors */ @@ -4473,7 +4473,8 @@ static int gpencil_count_subdivision_cuts(bGPDstroke *gps) } if ((gps->flag & GP_STROKE_CYCLIC) && (gps->points[0].flag & GP_SPOINT_SELECT) && - (gps->points[gps->totpoints - 1].flag & GP_SPOINT_SELECT)) { + (gps->points[gps->totpoints - 1].flag & GP_SPOINT_SELECT)) + { totnewpoints++; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c index 26890004238..c32c38e28c4 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.c @@ -73,7 +73,8 @@ static int gpencil_stroke_enter_editcurve_mode_exec(bContext *C, wmOperator *op) LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { /* only allow selected and non-converted strokes to be transformed */ if ((gps->flag & GP_STROKE_SELECT && gps->editcurve == NULL) || - (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) { + (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) + { BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps); /* Update the selection from the stroke to the curve. */ BKE_gpencil_editcurve_stroke_sync_selection(gpd, gps, gps->editcurve); diff --git a/source/blender/editors/gpencil_legacy/gpencil_fill.c b/source/blender/editors/gpencil_legacy/gpencil_fill.c index e085325735f..1e072f9362a 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_fill.c +++ b/source/blender/editors/gpencil_legacy/gpencil_fill.c @@ -516,7 +516,8 @@ static void gpencil_stroke_collision( gps_a->boundbox_max, gps_b->boundbox_min, gps_b->boundbox_max, - 1.1f)) { + 1.1f)) + { continue; } @@ -524,7 +525,8 @@ static void gpencil_stroke_collision( for (int i = 0; i < gps_b->totpoints - 1; i++) { /* Skip segments over same pixel. */ if (((int)a1xy[0] == (int)stroke->points2d[i + 1][0]) && - ((int)a1xy[1] == (int)stroke->points2d[i + 1][1])) { + ((int)a1xy[1] == (int)stroke->points2d[i + 1][1])) + { continue; } @@ -624,7 +626,8 @@ static void gpencil_cut_extensions(tGPDfill *tgpf) gps_a->boundbox_max, gps_b->boundbox_min, gps_b->boundbox_max, - 1.1f)) { + 1.1f)) + { continue; } @@ -791,7 +794,8 @@ static void gpencil_create_extensions_radius(tGPDfill *tgpf) BLI_gset_add(connected_endpoints, stroke1_end); } for (bGPDstroke *gps2 = (bGPDstroke *)(((Link *)gps)->next); gps2 != NULL; - gps2 = (bGPDstroke *)(((Link *)gps2)->next)) { + gps2 = (bGPDstroke *)(((Link *)gps2)->next)) + { /* Don't check distance to temporary extensions. */ if ((gps2->flag & GP_STROKE_NOFILL) && (gps2->flag & GP_STROKE_TAG)) { continue; @@ -803,7 +807,8 @@ static void gpencil_create_extensions_radius(tGPDfill *tgpf) gps->boundbox_max, gps2->boundbox_min, gps2->boundbox_max, - connection_dist)) { + connection_dist)) + { continue; } @@ -867,8 +872,8 @@ static bool gpencil_stroke_is_drawable(tGPDfill *tgpf, bGPDstroke *gps) const bool is_help_stroke = (gps->flag & GP_STROKE_NOFILL) && (gps->flag & GP_STROKE_HELP); const bool stroke_collide = (gps->flag & GP_STROKE_COLLIDE) != 0; - if (is_line_mode && is_extend_stroke && tgpf->is_render && use_stroke_collide && - !stroke_collide) { + if (is_line_mode && is_extend_stroke && tgpf->is_render && use_stroke_collide && !stroke_collide) + { return false; } @@ -1171,7 +1176,8 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4]) /* Normal strokes. */ if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_STROKE, GP_FILL_DMODE_BOTH)) { if (gpencil_stroke_is_drawable(tgpf, gps) && ((gps->flag & GP_STROKE_TAG) == 0) && - ((gps->flag & GP_STROKE_HELP) == 0)) { + ((gps->flag & GP_STROKE_HELP) == 0)) + { ED_gpencil_draw_fill(&tgpw); } /* In stroke mode, still must draw the extend lines. */ @@ -2017,7 +2023,8 @@ static void gpencil_get_outline_points(tGPDfill *tgpf, const bool dilate) } /* Current pixel is equal to starting or first pixel. */ if ((boundary_co[0] == start_co[0] && boundary_co[1] == start_co[1]) || - (boundary_co[0] == first_co[0] && boundary_co[1] == first_co[1])) { + (boundary_co[0] == first_co[0] && boundary_co[1] == first_co[1])) + { BLI_stack_pop(tgpf->stack, &v); break; } @@ -2072,7 +2079,8 @@ static void gpencil_get_depth_array(tGPDfill *tgpf) if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, tgpf->depth_arr + i) == 0) && (i && (ED_view3d_depth_read_cached_seg( - depths, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) { + depths, mval_i, mval_prev, depth_margin + 1, tgpf->depth_arr + i) == 0))) + { interp_depth = true; } else { @@ -2326,7 +2334,8 @@ static bool gpencil_fill_poll(bContext *C) ScrArea *area = CTX_wm_area(C); if (area->spacetype == SPACE_VIEW3D) { if ((obact == NULL) || (obact->type != OB_GPENCIL_LEGACY) || - (obact->mode != OB_MODE_PAINT_GPENCIL)) { + (obact->mode != OB_MODE_PAINT_GPENCIL)) + { return false; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_interpolate.c b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c index 7be70b305f3..5386bcb74ea 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_interpolate.c +++ b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c @@ -418,7 +418,8 @@ static bGPDframe *gpencil_get_previous_keyframe(bGPDlayer *gpl, { if (gpl->actframe != NULL && gpl->actframe->framenum < cfra) { if ((!exclude_breakdowns) || - ((exclude_breakdowns) && (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN))) { + ((exclude_breakdowns) && (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN))) + { return gpl->actframe; } } @@ -535,8 +536,8 @@ static void gpencil_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) BKE_gpencil_stroke_flip(gps_to); } else if (tgpi->flipmode == GP_INTERPOLATE_FLIPAUTO) { - if (gpencil_stroke_need_flip( - tgpi->depsgraph, tgpi->ob, gpl, &tgpi->gsc, gps_from, gps_to)) { + if (gpencil_stroke_need_flip(tgpi->depsgraph, tgpi->ob, gpl, &tgpi->gsc, gps_from, gps_to)) + { BKE_gpencil_stroke_flip(gps_to); } } @@ -1310,8 +1311,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) LISTBASE_FOREACH (bGPDstroke *, gps_from, &prevFrame->strokes) { bGPDstroke *gps_to = NULL; /* Only selected. */ - if (GPENCIL_EDIT_MODE(gpd) && (only_selected) && - ((gps_from->flag & GP_STROKE_SELECT) == 0)) { + if (GPENCIL_EDIT_MODE(gpd) && (only_selected) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) + { continue; } /* Skip strokes that are invalid for current view. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_paint.c b/source/blender/editors/gpencil_legacy/gpencil_paint.c index 41979f33273..3ef4083b08a 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_paint.c @@ -457,7 +457,8 @@ static void gpencil_stroke_convertcoords(tGPsdata *p, const float zfac = ED_view3d_calc_zfac(p->region->regiondata, rvec); if (ED_view3d_project_float_global(p->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float dvec[3]; float xy_delta[2]; sub_v2_v2v2(xy_delta, mval_prj, mval); @@ -1142,8 +1143,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) gpencil_world_to_object_space(depsgraph, obact, gpl, gps); /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ - if ((!is_depth) && - (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || (is_camera))) { + if ((!is_depth) && (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || (is_camera))) + { ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); } } @@ -1166,7 +1167,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_depth_read_cached_seg( - depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { interp_depth = true; } else { @@ -1186,7 +1188,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) else { if ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) || - (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST))) { + (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST))) + { int first_valid = 0; int last_valid = 0; @@ -1231,8 +1234,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* convert all points (normal behavior) */ int i; - for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; - i++, ptc++, pt++) { + for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; i++, ptc++, pt++) + { /* convert screen-coordinates to appropriate coordinates (and store them) */ gpencil_stroke_convertcoords(p, ptc->m_xy, &pt->x, depth_arr ? depth_arr + i : NULL); @@ -1279,7 +1282,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* Simplify adaptive */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && - (brush->gpencil_settings->simplify_f > 0.0f)) { + (brush->gpencil_settings->simplify_f > 0.0f)) + { BKE_gpencil_stroke_simplify_adaptive(gpd, gps, brush->gpencil_settings->simplify_f); } @@ -1296,7 +1300,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* Convert to Outline. */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && - (brush->gpencil_settings->flag & GP_BRUSH_OUTLINE_STROKE)) { + (brush->gpencil_settings->flag & GP_BRUSH_OUTLINE_STROKE)) + { gps = gpencil_stroke_to_outline(p, gps); } @@ -1338,7 +1343,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* post process stroke */ if ((p->brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && - p->brush->gpencil_settings->flag & GP_BRUSH_TRIM_STROKE) { + p->brush->gpencil_settings->flag & GP_BRUSH_TRIM_STROKE) + { BKE_gpencil_stroke_trim(gpd, gps); } @@ -1566,7 +1572,8 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, } } else if ((p->flags & GP_PAINTFLAG_STROKE_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_STROKE)) { + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_STROKE)) + { for (i = 0; (i + 1) < gps->totpoints; i++) { /* only process if it hasn't been masked out... */ @@ -1653,7 +1660,8 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, /* Check that point segment of the bound-box of the eraser stroke. */ if ((!ELEM(V2D_IS_CLIPPED, pc0[0], pc0[1]) && BLI_rcti_isect_pt(rect, pc0[0], pc0[1])) || (!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1]) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { + (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + { /* Check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that line-width is irrelevant. @@ -1713,13 +1721,13 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, pt0->flag |= GP_SPOINT_TAG; do_cull = true; } - if ((pt1->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || - (pt1->pressure < cull_thresh)) { + if ((pt1->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || (pt1->pressure < cull_thresh)) + { pt1->flag |= GP_SPOINT_TAG; do_cull = true; } - if ((pt2->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || - (pt2->pressure < cull_thresh)) { + if ((pt2->strength <= GPENCIL_ALPHA_OPACITY_THRESH) || (pt2->pressure < cull_thresh)) + { pt2->flag |= GP_SPOINT_TAG; do_cull = true; } @@ -1746,13 +1754,15 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p, /* 2) Tag any point with overly low influence for removal in the next pass */ if ((inf1 > 0.0f) && ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD))) { + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD))) + { pt1->flag |= GP_SPOINT_TAG; do_cull = true; } if ((inf1 > 2.0f) && ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || - (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD))) { + (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_HARD))) + { pt2->flag |= GP_SPOINT_TAG; do_cull = true; } @@ -1845,8 +1855,8 @@ static void gpencil_stroke_doeraser(tGPsdata *p) } /* Check if the stroke collide with mouse. */ - if (!ED_gpencil_stroke_check_collision( - &p->gsc, gps, p->mval, calc_radius, p->diff_mat)) { + if (!ED_gpencil_stroke_check_collision(&p->gsc, gps, p->mval, calc_radius, p->diff_mat)) + { continue; } @@ -2098,7 +2108,8 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) /* lock axis (in some modes, disable) */ if (((*p->align_flag & GP_PROJECT_DEPTH_VIEW) == 0) && - ((*p->align_flag & GP_PROJECT_DEPTH_STROKE) == 0)) { + ((*p->align_flag & GP_PROJECT_DEPTH_STROKE) == 0)) + { p->lock_axis = ts->gp_sculpt.lock_axis; } else { @@ -2877,7 +2888,8 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra } } else if ((p->brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) && - (gpd->runtime.sbuffer_used > 0)) { + (gpd->runtime.sbuffer_used > 0)) + { pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1; if (p->paintmode != GP_PAINTMODE_ERASER) { ED_gpencil_toggle_brush_cursor(C, true, pt->m_xy); @@ -2906,7 +2918,8 @@ static void gpencil_draw_apply_event(bContext *C, /* verify direction for straight lines and guides */ if ((is_speed_guide) || - ((event->modifier & KM_ALT) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) { + ((event->modifier & KM_ALT) && (RNA_boolean_get(op->ptr, "disable_straight") == false))) + { if (p->straight == 0) { int dx = (int)fabsf(p->mval[0] - p->mvali[0]); int dy = (int)fabsf(p->mval[1] - p->mvali[1]); @@ -2983,8 +2996,8 @@ static void gpencil_draw_apply_event(bContext *C, copy_v2_v2(p->mvali, p->mval); if (is_speed_guide && !ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) && - ((guide->use_snapping && (guide->type == GP_GUIDE_GRID)) || - (guide->type == GP_GUIDE_ISO))) { + ((guide->use_snapping && (guide->type == GP_GUIDE_GRID)) || (guide->type == GP_GUIDE_ISO))) + { p->flags |= GP_PAINTFLAG_REQ_VECTOR; } @@ -3011,11 +3024,13 @@ static void gpencil_draw_apply_event(bContext *C, p->guide.stroke_angle = atan2f(pt[1], pt[0]); /* determine iso angle, less weight is given for vertical strokes */ if (((p->guide.stroke_angle >= 0.0f) && (p->guide.stroke_angle < DEG2RAD(75))) || - (p->guide.stroke_angle < DEG2RAD(-105))) { + (p->guide.stroke_angle < DEG2RAD(-105))) + { p->guide.rot_angle = guide->angle; } else if (((p->guide.stroke_angle < 0.0f) && (p->guide.stroke_angle > DEG2RAD(-75))) || - (p->guide.stroke_angle > DEG2RAD(105))) { + (p->guide.stroke_angle > DEG2RAD(105))) + { p->guide.rot_angle = -guide->angle; } else { @@ -3143,7 +3158,8 @@ static void gpencil_guide_event_handling(bContext *C, /* Enter or exit set center point mode */ if ((event->type == EVT_OKEY) && (event->val == KM_RELEASE)) { if ((p->paintmode == GP_PAINTMODE_DRAW) && guide->use_guide && - (guide->reference_point != GP_GUIDE_REF_OBJECT)) { + (guide->reference_point != GP_GUIDE_REF_OBJECT)) + { add_notifier = true; p->paintmode = GP_PAINTMODE_SET_CP; ED_gpencil_toggle_brush_cursor(C, false, NULL); @@ -3709,7 +3725,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) EVT_PAD6, EVT_PAD7, EVT_PAD8, - EVT_PAD9)) { + EVT_PAD9)) + { /* Allow numpad keys so that camera/view manipulations can still take place * - #EVT_PAD0 in particular is really important for Grease Pencil drawing, * as animators may be working "to camera", so having this working @@ -3827,7 +3844,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) int size_before = p->gpd->runtime.sbuffer_used; if (((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) && (p->paintmode != GP_PAINTMODE_ERASER) && - !(is_speed_guide && (p->flags & GP_PAINTFLAG_REQ_VECTOR))) { + !(is_speed_guide && (p->flags & GP_PAINTFLAG_REQ_VECTOR))) + { gpencil_add_fake_points(event, p); } @@ -3854,7 +3872,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* eraser size */ else if ((p->paintmode == GP_PAINTMODE_ERASER) && - ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, EVT_PADPLUSKEY, EVT_PADMINUS)) { + ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, EVT_PADPLUSKEY, EVT_PADMINUS)) + { /* Just resize the brush (local version). */ switch (event->type) { case WHEELDOWNMOUSE: /* larger */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_primitive.c b/source/blender/editors/gpencil_legacy/gpencil_primitive.c index c46a1311dc6..cce222cfad9 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_primitive.c +++ b/source/blender/editors/gpencil_legacy/gpencil_primitive.c @@ -452,7 +452,8 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi GP_STROKE_ARC, GP_STROKE_LINE, GP_STROKE_BOX, - GP_STROKE_POLYLINE)) { + GP_STROKE_POLYLINE)) + { if (hasNumInput(&tgpi->num)) { char str_ofs[NUM_STR_REP_LEN]; @@ -788,7 +789,8 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) round_v2i_v2fl(mval_i, ptc->m_xy); if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_depth_read_cached_seg( - depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { + depths, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { interp_depth = true; } else { @@ -818,7 +820,8 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) else { if ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) || - (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST))) { + (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST))) + { int first_valid = 0; int last_valid = 0; @@ -1491,7 +1494,8 @@ static void gpencil_primitive_edit_event_handling( copy_v2_v2(tgpi->end, tgpi->mval); } else if (tgpi->sel_cp == SELECT_CP1 || - (tgpi->sel_cp == SELECT_CP2 && tgpi->type != GP_STROKE_CURVE)) { + (tgpi->sel_cp == SELECT_CP2 && tgpi->type != GP_STROKE_CURVE)) + { float dx = (tgpi->mval[0] - tgpi->mvalo[0]); float dy = (tgpi->mval[1] - tgpi->mvalo[1]); tgpi->cp1[0] += dx; @@ -1808,14 +1812,16 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e } } else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) && - !ELEM(tgpi->type, GP_STROKE_POLYLINE)) { + !ELEM(tgpi->type, GP_STROKE_POLYLINE)) + { /* set control points and enter edit mode */ tgpi->flag = IN_CURVE_EDIT; gpencil_primitive_update_cps(tgpi); gpencil_primitive_update(C, op, tgpi); } else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) && - !ELEM(tgpi->type, GP_STROKE_CURVE, GP_STROKE_POLYLINE)) { + !ELEM(tgpi->type, GP_STROKE_CURVE, GP_STROKE_POLYLINE)) + { /* stop drawing primitive */ tgpi->flag = IDLE; gpencil_primitive_interaction_end(C, op, win, tgpi); @@ -1823,7 +1829,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_FINISHED; } else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS) && - ELEM(tgpi->type, GP_STROKE_POLYLINE)) { + ELEM(tgpi->type, GP_STROKE_POLYLINE)) + { /* set control points and enter edit mode */ tgpi->flag = IN_POLYLINE; gpencil_primitive_update(C, op, tgpi); @@ -1973,7 +1980,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e } default: { if (tgpi->flag != IN_CURVE_EDIT && (event->val == KM_PRESS) && - handleNumInput(C, &tgpi->num, event)) { + handleNumInput(C, &tgpi->num, event)) + { float value; /* Grab data from numeric input, and store this new value (the user see an int) */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c index 899e401d1ff..fa21fdd9c1c 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c @@ -639,7 +639,8 @@ static void gpencil_brush_calc_midpoint(tGP_BrushEditData *gso) float mval_prj[2]; if (ED_view3d_project_float_global(gso->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float dvec[3]; float xy_delta[2]; sub_v2_v2v2(xy_delta, mval_prj, gso->mval); @@ -1529,7 +1530,8 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, /* Check that point segment of the bound-box of the selection stroke. */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1]) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { + (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + { /* Check if point segment of stroke had anything to do with * brush region (either within stroke painted, or on its lines) * - this assumes that line-width is irrelevant. @@ -1647,7 +1649,8 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C, /* Check if the stroke collide with brush. */ if ((gps->totpoints > 1) && - !ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat)) { + !ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat)) + { continue; } @@ -1914,7 +1917,8 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso) /* Check if the stroke collide with brush. */ if ((is_masking_stroke) && - ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat)) { + ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, bound_mat)) + { bGPDspoint *pt1, *pt2; int pc1[2] = {0}; @@ -1956,8 +1960,9 @@ static bool get_automasking_strokes_list(tGP_BrushEditData *gso) } /* Check segment. */ - if (!pick_stroke && gpencil_stroke_inside_circle( - gso->mval, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { + if (!pick_stroke && + gpencil_stroke_inside_circle(gso->mval, radius, pc1[0], pc1[1], pc2[0], pc2[1])) + { pick_stroke = true; i = gps->totpoints; } @@ -2139,7 +2144,8 @@ static void gpencil_sculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA * (ts->gp_sculpt.flag & (GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE | GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE | GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE | GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE | - GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE))) { + GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE))) + { gso->automasking_ready = get_automasking_strokes_list(gso); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_select.c b/source/blender/editors/gpencil_legacy/gpencil_select.c index ed7093a8f35..58b8c1bb0bb 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_select.c +++ b/source/blender/editors/gpencil_legacy/gpencil_select.c @@ -127,7 +127,8 @@ static bool gpencil_3d_point_to_screen_space(ARegion *region, int screen_co[2]; if (ED_view3d_project_int_global( region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { if (!ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1])) { copy_v2_v2_int(r_co, screen_co); return true; @@ -1606,13 +1607,15 @@ static bool gpencil_do_curve_circle_sel(bContext *C, /* do 2d projection */ if (ED_view3d_project_int_global( region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { continue; } /* view and bounding box test */ if (ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1]) && - !BLI_rcti_isect_pt(rect, screen_co[0], screen_co[1])) { + !BLI_rcti_isect_pt(rect, screen_co[0], screen_co[1])) + { continue; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c index fd7e13f70a8..992684d6338 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c +++ b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.c @@ -211,8 +211,8 @@ static void trace_start_job(void *customdata, bool *stop, bool *do_update, float G.is_break = false; /* Single Image. */ - if ((trace_job->image->source == IMA_SRC_FILE) || - (trace_job->mode == GPENCIL_TRACE_MODE_SINGLE)) { + if ((trace_job->image->source == IMA_SRC_FILE) || (trace_job->mode == GPENCIL_TRACE_MODE_SINGLE)) + { void *lock; ImageUser *iuser = trace_job->ob_active->iuser; diff --git a/source/blender/editors/gpencil_legacy/gpencil_utils.c b/source/blender/editors/gpencil_legacy/gpencil_utils.c index 34da7c160c4..c1f95104c6f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_utils.c +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.c @@ -672,8 +672,8 @@ void gpencil_point_to_xy( BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->area->spacetype != SPACE_VIEW3D)); if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + if (ED_view3d_project_int_global(region, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) + { *r_x = xyval[0]; *r_y = xyval[1]; } @@ -827,7 +827,8 @@ bool gpencil_point_xy_to_3d(const GP_SpaceConversion *gsc, float mval_prj[2]; if (ED_view3d_project_float_global(gsc->region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float dvec[3]; float xy_delta[2]; sub_v2_v2v2(xy_delta, mval_prj, screen_co); @@ -1157,7 +1158,8 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph, &ray_normal[0], &depth, &location[0], - &normal[0])) { + &normal[0])) + { /* Apply offset over surface. */ float normal_vector[3]; sub_v3_v3v3(normal_vector, ray_start, location); @@ -1787,7 +1789,8 @@ float ED_gpencil_radial_control_scale(struct bContext *C, { float scale_fac = 1.0f; if ((brush && brush->gpencil_settings) && (brush->ob_mode == OB_MODE_PAINT_GPENCIL) && - (brush->gpencil_tool == GPAINT_TOOL_DRAW)) { + (brush->gpencil_tool == GPAINT_TOOL_DRAW)) + { float cursor_radius = ED_gpencil_cursor_radius(C, mval[0], mval[1]); scale_fac = max_ff(cursor_radius, 1.0f) / max_ff(initial_value, 1.0f); } @@ -1833,7 +1836,8 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat /* while drawing hide */ if ((gpd->runtime.sbuffer_used > 0) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && - ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0)) { + ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0)) + { return; } @@ -1860,7 +1864,8 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat if ((gp_style) && GPENCIL_PAINT_MODE(gpd) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) && - (brush->gpencil_tool == GPAINT_TOOL_DRAW)) { + (brush->gpencil_tool == GPAINT_TOOL_DRAW)) + { const bool is_vertex_stroke = (GPENCIL_USE_VERTEX_COLOR_STROKE(ts, brush) && @@ -1904,8 +1909,8 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat } radius = brush->size; - if (brush->gpencil_settings->sculpt_flag & - (GP_SCULPT_FLAG_INVERT | GP_SCULPT_FLAG_TMP_INVERT)) { + if (brush->gpencil_settings->sculpt_flag & (GP_SCULPT_FLAG_INVERT | GP_SCULPT_FLAG_TMP_INVERT)) + { copy_v3_v3(color, brush->sub_col); } else { @@ -1924,8 +1929,8 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat } radius = brush->size; - if (brush->gpencil_settings->sculpt_flag & - (GP_SCULPT_FLAG_INVERT | GP_SCULPT_FLAG_TMP_INVERT)) { + if (brush->gpencil_settings->sculpt_flag & (GP_SCULPT_FLAG_INVERT | GP_SCULPT_FLAG_TMP_INVERT)) + { copy_v3_v3(color, brush->sub_col); } else { @@ -2089,8 +2094,8 @@ static void gpencil_stroke_convertcoords(ARegion *region, const float zfac = ED_view3d_calc_zfac(region->regiondata, rvec); - if (ED_view3d_project_float_global(region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_global(region, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) + { float dvec[3]; float xy_delta[2]; sub_v2_v2v2(xy_delta, mval_prj, point2D->m_xy); @@ -3160,7 +3165,8 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C, /* Check if one of the ends is inside target stroke bounding box. */ if (!ED_gpencil_stroke_check_collision(gsc, gps_target, pt2d_start, radius, diff_mat) && - !ED_gpencil_stroke_check_collision(gsc, gps_target, pt2d_end, radius, diff_mat)) { + !ED_gpencil_stroke_check_collision(gsc, gps_target, pt2d_end, radius, diff_mat)) + { continue; } /* Check the distance of the ends with the ends of target stroke to avoid middle contact. @@ -3180,14 +3186,16 @@ bGPDstroke *ED_gpencil_stroke_nearest_to_ends(bContext *C, if ((len_squared_v2v2(ctrl1, pt2d_target_start) > radius_sqr) && (len_squared_v2v2(ctrl1, pt2d_target_end) > radius_sqr) && (len_squared_v2v2(ctrl2, pt2d_target_start) > radius_sqr) && - (len_squared_v2v2(ctrl2, pt2d_target_end) > radius_sqr)) { + (len_squared_v2v2(ctrl2, pt2d_target_end) > radius_sqr)) + { continue; } if ((len_squared_v2v2(pt2d_start, pt2d_target_start) > radius_sqr) && (len_squared_v2v2(pt2d_start, pt2d_target_end) > radius_sqr) && (len_squared_v2v2(pt2d_end, pt2d_target_start) > radius_sqr) && - (len_squared_v2v2(pt2d_end, pt2d_target_end) > radius_sqr)) { + (len_squared_v2v2(pt2d_end, pt2d_target_end) > radius_sqr)) + { continue; } @@ -3356,7 +3364,8 @@ void ED_gpencil_layer_merge(bGPdata *gpd, LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl_src->mask_layers) { /* Don't add merged layers or missing layer names. */ if (!BKE_gpencil_layer_named_get(gpd, mask->name) || STREQ(mask->name, gpl_src->info) || - STREQ(mask->name, gpl_dst->info)) { + STREQ(mask->name, gpl_dst->info)) + { continue; } if (!BKE_gpencil_layer_mask_named_get(gpl_dst, mask->name)) { diff --git a/source/blender/editors/gpencil_legacy/gpencil_uv.c b/source/blender/editors/gpencil_legacy/gpencil_uv.c index bed0b5ba295..c1e4afa295a 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_uv.c +++ b/source/blender/editors/gpencil_legacy/gpencil_uv.c @@ -412,7 +412,8 @@ static int gpencil_transform_fill_modal(bContext *C, wmOperator *op, const wmEve case EVT_PADENTER: case EVT_RETKEY: { if ((event->val == KM_PRESS) || - ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) { + ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) + { gpencil_uv_transform_calc(C, op); gpencil_uv_transform_exit(C, op); return OPERATOR_FINISHED; diff --git a/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c index d040d4fa8b9..b55db6417e6 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.c @@ -674,7 +674,8 @@ static bool gpencil_extract_palette_from_vertex(bContext *C, /* Only solid strokes or stencil. */ if ((use_stroke) && ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && - ((gp_style->flag & GP_MATERIAL_STROKE_PATTERN) == 0))) { + ((gp_style->flag & GP_MATERIAL_STROKE_PATTERN) == 0))) + { continue; } @@ -863,7 +864,8 @@ static int gpencil_material_to_vertex_exec(bContext *C, wmOperator *op) /* Only solid strokes or stencil. */ if ((use_stroke) && ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && - ((gp_style->flag & GP_MATERIAL_STROKE_PATTERN) == 0))) { + ((gp_style->flag & GP_MATERIAL_STROKE_PATTERN) == 0))) + { continue; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c index a68b5fc2e88..44bca62af43 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.c @@ -892,7 +892,8 @@ static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso, /* Check that point segment of the bound-box of the selection stroke. */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1]) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { + (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + { /* Check if point segment of stroke had anything to do with * brush region (either within stroke painted, or on its lines) * - this assumes that line-width is irrelevant. @@ -904,8 +905,8 @@ static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso, pt_active = pt->runtime.pt_orig; if (pt_active != NULL) { /* If masked and the point is not selected, skip it. */ - if (GPENCIL_ANY_VERTEX_MASK(gso->mask) && - ((pt_active->flag & GP_SPOINT_SELECT) == 0)) { + if (GPENCIL_ANY_VERTEX_MASK(gso->mask) && ((pt_active->flag & GP_SPOINT_SELECT) == 0)) + { continue; } index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; diff --git a/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c index c27a6073b35..fb800c33581 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.c @@ -1059,13 +1059,14 @@ static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso, /* Check that point segment of the bound-box of the selection stroke */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1]) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || - (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { + (!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1]) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) + { /* Check if point segment of stroke had anything to do with * brush region (either within stroke painted, or on its lines) * - this assumes that line-width is irrelevant. */ - if (gpencil_stroke_inside_circle( - gso->mouse, radius_wide, pc1[0], pc1[1], pc2[0], pc2[1])) { + if (gpencil_stroke_inside_circle(gso->mouse, radius_wide, pc1[0], pc1[1], pc2[0], pc2[1])) + { if (widen_brush) { within_brush = (gpencil_stroke_inside_circle( gso->mouse, radius_brush, pc1[0], pc1[1], pc2[0], pc2[1])); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 52d1648614b..b2e9328d54e 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -122,8 +122,6 @@ struct wmKeyConfig; struct wmOperator; struct wmOperatorType; -typedef struct View2DScrollers View2DScrollers; - /** \} */ /* -------------------------------------------------------------------- */ @@ -167,10 +165,6 @@ void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D void UI_view2d_curRect_changed(const struct bContext *C, struct View2D *v2d); void UI_view2d_totRect_set(struct View2D *v2d, int width, int height); -/** - * Change the size of the maximum viewable area (i.e. 'tot' rect). - */ -void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize); void UI_view2d_mask_from_win(const struct View2D *v2d, struct rcti *r_mask); @@ -271,13 +265,6 @@ void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *region, /** \name Scroll-bar Drawing * \{ */ -/** - * Calculate relevant scroller properties. - */ -void UI_view2d_scrollers_calc(struct View2D *v2d, - const struct rcti *mask_custom, - struct View2DScrollers *r_scrollers); - /** * Draw scroll-bars in the given 2D-region. */ @@ -560,8 +547,6 @@ typedef struct View2DEdgePanData { double edge_pan_start_time_x, edge_pan_start_time_y; } View2DEdgePanData; -bool UI_view2d_edge_pan_poll(struct bContext *C); - void UI_view2d_edge_pan_init(struct bContext *C, struct View2DEdgePanData *vpd, float inside_pad, diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index c3ca44ceb3c..96a782f9360 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -89,6 +89,7 @@ set(SRC eyedroppers/eyedropper_intern.hh interface_intern.hh interface_regions_intern.hh + view2d_intern.hh ) set(LIB diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc index 37ba23a0ed3..726cac2c3a0 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc @@ -92,7 +92,8 @@ static bool eyedropper_init(bContext *C, wmOperator *op) (RNA_property_editable(&eye->ptr, eye->prop) == false) || (RNA_property_array_length(&eye->ptr, eye->prop) < 3) || (RNA_property_type(eye->prop) != PROP_FLOAT) || - (ELEM(prop_subtype, PROP_COLOR, PROP_COLOR_GAMMA) == 0)) { + (ELEM(prop_subtype, PROP_COLOR, PROP_COLOR_GAMMA) == 0)) + { MEM_freeN(eye); return false; } @@ -173,7 +174,8 @@ static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_lay LISTBASE_FOREACH (RenderPass *, render_pass, &render_layer->passes) { if (STRPREFIX(render_pass->name, render_pass_name_prefix) && - !STREQLEN(render_pass->name, render_pass_name_prefix, sizeof(render_pass->name))) { + !STREQLEN(render_pass->name, render_pass_name_prefix, sizeof(render_pass->name))) + { BLI_assert(render_pass->channels == 4); const int x = int(fpos[0] * render_pass->rectx); const int y = int(fpos[1] * render_pass->recty); diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc index 1791b3fd6e6..714538f912b 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc @@ -83,7 +83,8 @@ static int datadropper_init(bContext *C, wmOperator *op) if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) || - (RNA_property_type(ddr->prop) != PROP_POINTER)) { + (RNA_property_type(ddr->prop) != PROP_POINTER)) + { MEM_freeN(ddr); return false; } @@ -342,7 +343,8 @@ static bool datadropper_poll(bContext *C) /* data dropper only supports object data */ if ((CTX_wm_window(C) != nullptr) && (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && - (but->type == UI_BTYPE_SEARCH_MENU) && (but->flag & UI_BUT_VALUE_CLEAR)) { + (but->type == UI_BTYPE_SEARCH_MENU) && (but->flag & UI_BUT_VALUE_CLEAR)) + { if (prop && RNA_property_type(prop) == PROP_POINTER) { StructRNA *type = RNA_property_pointer_type(&ptr, prop); const short idcode = RNA_type_to_ID_code(type); diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc index 8dd6c9c1239..8c52926b27b 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc @@ -88,7 +88,8 @@ static int depthdropper_init(bContext *C, wmOperator *op) if (rv3d && rv3d->persp == RV3D_CAMOB) { View3D *v3d = CTX_wm_view3d(C); if (v3d->camera && v3d->camera->data && - BKE_id_is_editable(CTX_data_main(C), static_cast(v3d->camera->data))) { + BKE_id_is_editable(CTX_data_main(C), static_cast(v3d->camera->data))) + { Camera *camera = (Camera *)v3d->camera->data; RNA_pointer_create(&camera->id, &RNA_CameraDOFSettings, &camera->dof, &ddr->ptr); ddr->prop = RNA_struct_find_property(&ddr->ptr, "focus_distance"); @@ -102,7 +103,8 @@ static int depthdropper_init(bContext *C, wmOperator *op) if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) || - (RNA_property_type(ddr->prop) != PROP_FLOAT)) { + (RNA_property_type(ddr->prop) != PROP_FLOAT)) + { MEM_freeN(ddr); return false; } @@ -337,10 +339,12 @@ static bool depthdropper_poll(bContext *C) /* check if there's an active button taking depth value */ if ((CTX_wm_window(C) != nullptr) && (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && - (but->type == UI_BTYPE_NUM) && (prop != nullptr)) { + (but->type == UI_BTYPE_NUM) && (prop != nullptr)) + { if ((RNA_property_type(prop) == PROP_FLOAT) && (RNA_property_subtype(prop) & PROP_UNIT_LENGTH) && - (RNA_property_array_check(prop) == false)) { + (RNA_property_array_check(prop) == false)) + { return true; } } @@ -349,7 +353,8 @@ static bool depthdropper_poll(bContext *C) if (rv3d && rv3d->persp == RV3D_CAMOB) { View3D *v3d = CTX_wm_view3d(C); if (v3d->camera && v3d->camera->data && - BKE_id_is_editable(CTX_data_main(C), static_cast(v3d->camera->data))) { + BKE_id_is_editable(CTX_data_main(C), static_cast(v3d->camera->data))) + { return true; } } diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc b/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc index 034cc5365b3..382845d1459 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc @@ -54,7 +54,8 @@ static bool driverdropper_init(bContext *C, wmOperator *op) if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) || - (RNA_property_animateable(&ddr->ptr, ddr->prop) == false) || (but->flag & UI_BUT_DRIVEN)) { + (RNA_property_animateable(&ddr->ptr, ddr->prop) == false) || (but->flag & UI_BUT_DRIVEN)) + { MEM_freeN(ddr); return false; } diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 4061de0f9c0..b14d9626c7a 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -729,7 +729,8 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) /* If the buttons have own identity comparator callbacks (and they match), use this to * determine equality. */ if (but->identity_cmp_func && (but->type == oldbut->type) && - (but->identity_cmp_func == oldbut->identity_cmp_func)) { + (but->identity_cmp_func == oldbut->identity_cmp_func)) + { /* Test if the comparison is symmetrical (if a == b then b == a), may help catch some issues. */ BLI_assert(but->identity_cmp_func(but, oldbut) == but->identity_cmp_func(oldbut, but)); @@ -759,7 +760,8 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) return false; } if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || - (but->pointype != oldbut->pointype))) { + (but->pointype != oldbut->pointype))) + { return false; } if (but->optype != oldbut->optype) { @@ -773,7 +775,8 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) uiButViewItem *but_item = (uiButViewItem *)but; uiButViewItem *oldbut_item = (uiButViewItem *)oldbut; if (!but_item->view_item || !oldbut_item->view_item || - !UI_view_item_matches(but_item->view_item, oldbut_item->view_item)) { + !UI_view_item_matches(but_item->view_item, oldbut_item->view_item)) + { return false; } } @@ -1144,7 +1147,8 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) UI_BTYPE_PULLDOWN, /* For PIE-menus. */ UI_BTYPE_ROW) || - (but->flag & UI_HIDDEN)) { + (but->flag & UI_HIDDEN)) + { continue; } @@ -1250,13 +1254,9 @@ static bool ui_but_event_operator_string_from_operator(const bContext *C, static_cast(op_call_params->opptr->data) : nullptr; - if (WM_key_event_operator_string(C, - op_call_params->optype->idname, - op_call_params->opcontext, - prop, - true, - buf, - buf_len)) { + if (WM_key_event_operator_string( + C, op_call_params->optype->idname, op_call_params->opcontext, prop, true, buf, buf_len)) + { found = true; } return found; @@ -1275,10 +1275,11 @@ static bool ui_but_event_operator_string_from_menu(const bContext *C, /* annoying, create a property */ const IDPropertyTemplate val = {0}; IDProperty *prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* Dummy, name is unimportant. */ - IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname))); + IDP_AddToGroup(prop_menu, IDP_NewStringMaxSize(mt->idname, "name", sizeof(mt->idname))); if (WM_key_event_operator_string( - C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, buf, buf_len)) { + C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, buf, buf_len)) + { found = true; } @@ -1301,7 +1302,7 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C, const IDPropertyTemplate group_val = {0}; IDProperty *prop_panel = IDP_New( IDP_GROUP, &group_val, __func__); /* Dummy, name is unimportant. */ - IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname))); + IDP_AddToGroup(prop_panel, IDP_NewStringMaxSize(pt->idname, "name", sizeof(pt->idname))); IDPropertyTemplate space_type_val = {0}; space_type_val.i = pt->space_type; IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &space_type_val, "space_type")); @@ -1316,7 +1317,8 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C, IDP_ReplaceInGroup(prop_panel, IDP_New(IDP_INT, &val, "keep_open")); if (WM_key_event_operator_string( - C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true, buf, buf_len)) { + C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true, buf, buf_len)) + { found = true; break; } @@ -1410,7 +1412,8 @@ static bool ui_but_event_property_operator_string(const bContext *C, ELEM(but_parent->menu_create_func, ui_def_but_rna__menu, ui_def_but_rna__panel_type, - ui_def_but_rna__menu_type)) { + ui_def_but_rna__menu_type)) + { prop_enum_value = int(but->hardmin); ptr = &but_parent->rnapoin; prop = but_parent->rnaprop; @@ -1477,7 +1480,8 @@ static bool ui_but_event_property_operator_string(const bContext *C, bool found = false; for (int data_path_index = 0; data_path_index < data_path_variations_num && (found == false); - data_path_index++) { + data_path_index++) + { const char *data_path = data_path_variations[data_path_index]; if (data_path || (prop_enum_value_ok && prop_enum_value_id)) { /* Create a property to host the "data_path" property we're sending to the operators. */ @@ -1486,7 +1490,7 @@ static bool ui_but_event_property_operator_string(const bContext *C, const IDPropertyTemplate group_val = {0}; prop_path = IDP_New(IDP_GROUP, &group_val, __func__); if (data_path) { - IDP_AddToGroup(prop_path, IDP_NewString(data_path, "data_path", strlen(data_path) + 1)); + IDP_AddToGroup(prop_path, IDP_NewString(data_path, "data_path")); } if (prop_enum_value_ok) { const EnumPropertyItem *item; @@ -1503,7 +1507,7 @@ static bool ui_but_event_property_operator_string(const bContext *C, } else { const char *id = item[index].identifier; - prop_value = IDP_NewString(id, prop_enum_value_id, strlen(id) + 1); + prop_value = IDP_NewString(id, prop_enum_value_id); } IDP_AddToGroup(prop_path, prop_value); } @@ -1519,7 +1523,8 @@ static bool ui_but_event_property_operator_string(const bContext *C, for (int i = 0; (i < opnames_len) && (opnames[i]); i++) { if (WM_key_event_operator_string( - C, opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false, buf, buf_len)) { + C, opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false, buf, buf_len)) + { found = true; break; } @@ -2166,7 +2171,8 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u if ((but_prev && (but_prev->rnaprop == but->rnaprop) && (but_prev->rnapoin.type == but->rnapoin.type) && (but_prev->rnapoin.data == but->rnapoin.data) && - (but_prev->rnapoin.owner_id == but->rnapoin.owner_id)) == false) { + (but_prev->rnapoin.owner_id == but->rnapoin.owner_id)) == false) + { /* TODO: could make this into utility function. */ wmMsgSubscribeValue value = {}; value.owner = region; @@ -2436,7 +2442,8 @@ bool ui_but_is_bool(const uiBut *but) UI_BTYPE_TOGGLE_N, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N, - UI_BTYPE_TAB)) { + UI_BTYPE_TAB)) + { return true; } @@ -2849,7 +2856,8 @@ void ui_but_string_get_ex(uiBut *but, &but->rnapoin, but->rnaprop, value, - &buf)) { + &buf)) + { BLI_strncpy(str, buf, maxlen); buf = str; } @@ -2969,7 +2977,8 @@ char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size) &but->rnapoin, but->rnaprop, value, - &value_id)) { + &value_id)) + { value_id = ""; } @@ -3161,7 +3170,8 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str) * is utterly weak and should be redesigned IMHO, but that's not a simple task. */ if (search_but && search_but->rnasearchprop && RNA_property_collection_lookup_string( - &search_but->rnasearchpoin, search_but->rnasearchprop, str, &rptr)) { + &search_but->rnasearchpoin, search_but->rnasearchprop, str, &rptr)) + { RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, nullptr); } else if (search_but->item_active != nullptr) { @@ -3181,7 +3191,8 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str) &but->rnapoin, but->rnaprop, str, - &value)) { + &value)) + { RNA_property_enum_set(&but->rnapoin, but->rnaprop, value); return true; } @@ -3803,8 +3814,8 @@ static void ui_but_update_ex(uiBut *but, const bool validate) case UI_BTYPE_ICON_TOGGLE: case UI_BTYPE_ICON_TOGGLE_N: - if ((but->rnaprop == nullptr) || - (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if ((but->rnaprop == nullptr) || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) + { if (but->rnaprop && RNA_property_flag(but->rnaprop) & PROP_ICONS_REVERSE) { but->drawflag |= UI_BUT_ICON_REVERSE; } @@ -3837,7 +3848,8 @@ static void ui_but_update_ex(uiBut *but, const bool validate) &but->rnapoin, but->rnaprop, value_enum, - &item)) { + &item)) + { const size_t slen = strlen(item.name); ui_but_string_free_internal(but); ui_but_string_set_internal(but, item.name, slen); @@ -4196,7 +4208,8 @@ static uiBut *ui_def_but(uiBlock *block, UI_BTYPE_BLOCK, UI_BTYPE_BUT_MENU, UI_BTYPE_SEARCH_MENU, - UI_BTYPE_POPOVER)) { + UI_BTYPE_POPOVER)) + { but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT); } #ifdef USE_NUMBUTS_LR_ALIGN @@ -4228,7 +4241,8 @@ static uiBut *ui_def_but(uiBlock *block, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER) || - (but->type >= UI_BTYPE_SEARCH_MENU)) { + (but->type >= UI_BTYPE_SEARCH_MENU)) + { /* pass */ } else { @@ -5005,11 +5019,10 @@ int UI_preview_tile_size_y(void) { const uiStyle *style = UI_style_get(); const float font_height = style->widget.points * UI_SCALE_FAC; + /* Add some extra padding to make things less tight vertically. */ const float pad = PREVIEW_TILE_PAD; - return round_fl_to_int(UI_preview_tile_size_y_no_label() + font_height + - /* Add some extra padding to make things less tight vertically. */ - pad); + return round_fl_to_int(UI_preview_tile_size_y_no_label() + font_height + pad); } int UI_preview_tile_size_y_no_label(void) @@ -6410,8 +6423,8 @@ static void operator_enum_search_update_fn(const struct bContext *C, const EnumPropertyItem *item = filtered_items[i]; /* NOTE: need to give the index rather than the * identifier because the enum can be freed */ - if (!UI_search_item_add( - items, item->name, POINTER_FROM_INT(item->value), item->icon, 0, 0)) { + if (!UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), item->icon, 0, 0)) + { break; } } diff --git a/source/blender/editors/interface/interface_align.cc b/source/blender/editors/interface/interface_align.cc index 9deefb2d25d..0c902a8b52b 100644 --- a/source/blender/editors/interface/interface_align.cc +++ b/source/blender/editors/interface/interface_align.cc @@ -270,7 +270,8 @@ static void block_align_stitch_neighbors(ButAlign *butal, * it may have both of its stitching flags * set, but would not be the case of its immediate neighbor! */ while ((butal->flags[side] & stitch_s1) && (butal = butal->neighbors[side_s1]) && - (butal->flags[side] & stitch_s2)) { + (butal->flags[side] & stitch_s2)) + { butal_neighbor = butal->neighbors[side]; /* If we actually do have a neighbor, we directly set its values accordingly, diff --git a/source/blender/editors/interface/interface_anim.cc b/source/blender/editors/interface/interface_anim.cc index 3e78457f142..f8ab1f5ab7f 100644 --- a/source/blender/editors/interface/interface_anim.cc +++ b/source/blender/editors/interface/interface_anim.cc @@ -123,7 +123,8 @@ static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but) LISTBASE_CIRCULAR_BACKWARD_BEGIN (uiBut *, &but->block->buttons, but_iter, but->prev) { if (but_iter != but && ui_but_rna_equals_ex( - but_iter, &but->decorated_rnapoin, but->decorated_rnaprop, but->decorated_rnaindex)) { + but_iter, &but->decorated_rnapoin, but->decorated_rnaprop, but->decorated_rnaindex)) + { return but_iter; } } diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index eb944b7f30e..3aa369ae1c4 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -66,7 +66,7 @@ static IDProperty *shortcut_property_from_rna(bContext *C, uiBut *but) /* Create ID property of data path, to pass to the operator. */ const IDPropertyTemplate val = {0}; IDProperty *prop = IDP_New(IDP_GROUP, &val, __func__); - IDP_AddToGroup(prop, IDP_NewString(final_data_path, "data_path", strlen(final_data_path) + 1)); + IDP_AddToGroup(prop, IDP_NewString(final_data_path, "data_path")); MEM_freeN((void *)final_data_path); @@ -128,7 +128,8 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int /*event*/) /* complex code to change name of button */ if (WM_key_event_operator_string( - C, idname, but->opcontext, prop, true, shortcut_str, sizeof(shortcut_str))) { + C, idname, but->opcontext, prop, true, shortcut_str, sizeof(shortcut_str))) + { ui_but_add_shortcut(but, shortcut_str, true); } else { @@ -440,7 +441,7 @@ static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, Pr UNUSED_VARS_NDEBUG(subtype); RNA_property_string_get(ptr, prop, filepath); - BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(filepath, dir, sizeof(dir), file, sizeof(file)); if (file[0]) { BLI_assert(subtype == PROP_FILEPATH); @@ -969,7 +970,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev if (((prop_type == PROP_POINTER) || (prop_type == PROP_STRING && but->type == UI_BTYPE_SEARCH_MENU && ((uiButSearch *)but)->items_update_fn == ui_rna_collection_search_update_fn)) && - ui_jump_to_target_button_poll(C)) { + ui_jump_to_target_button_poll(C)) + { uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Jump to Target"), ICON_NONE, diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 74761daa430..2c74b32e626 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -728,7 +728,8 @@ void ui_draw_but_WAVEFORM(ARegion * /*region*/, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709, - SCOPES_WAVEFRM_YCC_JPEG)) { + SCOPES_WAVEFRM_YCC_JPEG)) + { const int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE); GPU_matrix_push(); @@ -2035,7 +2036,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion * /*region*/, } else if ((scopes->track_search) && ((!scopes->track_preview) || - (scopes->track_preview->x != width || scopes->track_preview->y != height))) { + (scopes->track_preview->x != width || scopes->track_preview->y != height))) + { if (scopes->track_preview) { IMB_freeImBuf(scopes->track_preview); } diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index fb4468a4f0f..818f7d5c082 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -876,8 +876,8 @@ static void ui_apply_but_func(bContext *C, uiBut *but) /* Ensure this callback runs once and last. */ uiAfterFunc *after_prev = after->prev; - if (after_prev && - (after_prev->custom_interaction_handle == data->custom_interaction_handle)) { + if (after_prev && (after_prev->custom_interaction_handle == data->custom_interaction_handle)) + { after_prev->custom_interaction_handle = nullptr; memset(&after_prev->custom_interaction_callbacks, 0x0, @@ -953,7 +953,8 @@ static void ui_apply_but_undo(uiBut *but) /* XXX: disable all undo pushes from UI changes from sculpt mode as they cause memfile undo * steps to be written which cause lag: #71434. */ if (BKE_paintmode_get_active_from_context(static_cast(but->block->evil_C)) == - PAINT_MODE_SCULPT) { + PAINT_MODE_SCULPT) + { skip_undo = true; } } @@ -1491,7 +1492,8 @@ static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *dat * NOTE: if we mix buttons which are proportional and others which are not, * this may work a bit strangely. */ if ((but_active->rnaprop && (RNA_property_flag(but_active->rnaprop) & PROP_PROPORTIONAL)) || - ELEM(but_active->unit_type, RNA_SUBTYPE_UNIT_VALUE(PROP_UNIT_LENGTH))) { + ELEM(but_active->unit_type, RNA_SUBTYPE_UNIT_VALUE(PROP_UNIT_LENGTH))) + { if (data->origvalue != 0.0) { data->multi_data.is_proportional = true; } @@ -1704,7 +1706,8 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const * chances are high the button won't move about :) */ if (len_manhattan_v2v2(drag_info->but_cent_start, but_cent_new) > 1.0f) { if (fabsf(drag_info->but_cent_start[0] - but_cent_new[0]) < - fabsf(drag_info->but_cent_start[1] - but_cent_new[1])) { + fabsf(drag_info->but_cent_start[1] - but_cent_new[1])) + { drag_info->xy_lock[0] = true; } else { @@ -1819,7 +1822,8 @@ static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore const int rna_type = RNA_property_type(prop); if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) && - !BLI_listbase_is_empty(&lb)) { + !BLI_listbase_is_empty(&lb)) + { selctx_data->elems_len = BLI_listbase_count(&lb); selctx_data->elems = static_cast( MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__)); @@ -1830,7 +1834,8 @@ static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore } if (!UI_context_copy_to_selected_check( - &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) { + &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) + { selctx_data->elems_len -= 1; i -= 1; continue; @@ -1963,7 +1968,8 @@ static void ui_selectcontext_apply(bContext *C, if ((rna_type == PROP_BOOLEAN) && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER) && is_array && /* could check for 'handle_layer_buttons' */ - but->func) { + but->func) + { wmWindow *win = CTX_wm_window(C); if ((win->eventstate->modifier & KM_SHIFT) == 0) { const int len = RNA_property_array_length(&but->rnapoin, prop); @@ -2063,8 +2069,8 @@ static bool ui_but_drag_init(bContext *C, WM_event_drag_threshold(event), int((UI_UNIT_Y / 2) * ui_block_to_window_scale(data->region, but->block))); - if (abs(data->dragstartx - event->xy[0]) + abs(data->dragstarty - event->xy[1]) > - drag_threshold) { + if (abs(data->dragstartx - event->xy[0]) + abs(data->dragstarty - event->xy[1]) > drag_threshold) + { button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel = true; #ifdef USE_DRAG_TOGGLE @@ -2101,7 +2107,8 @@ static bool ui_but_drag_init(bContext *C, RGN_TYPE_NAV_BAR, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, - RGN_TYPE_FOOTER)) { + RGN_TYPE_FOOTER)) + { const int region_alignment = RGN_ALIGN_ENUM_FROM_MASK(data->region->alignment); int lock_axis = -1; @@ -2119,7 +2126,8 @@ static bool ui_but_drag_init(bContext *C, } else #endif - if (but->type == UI_BTYPE_COLOR) { + if (but->type == UI_BTYPE_COLOR) + { bool valid = false; uiDragColorHandle *drag_info = MEM_cnew(__func__); @@ -2237,7 +2245,8 @@ static void ui_apply_but( } else # endif - if (data->select_others.elems_len == 0) { + if (data->select_others.elems_len == 0) + { wmWindow *win = CTX_wm_window(C); /* may have been enabled before activating */ if (data->select_others.is_enabled || IS_ALLSELECT_EVENT(win->eventstate)) { @@ -2377,7 +2386,8 @@ static void ui_apply_but( #ifdef USE_DRAG_MULTINUM if (data->multi_data.has_mbuts) { if ((data->multi_data.init == uiHandleButtonMulti::INIT_ENABLE) && - (data->multi_data.skip == false)) { + (data->multi_data.skip == false)) + { if (data->cancel) { ui_multibut_restore(C, data, block); } @@ -3419,7 +3429,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) } if (ui_but_is_float(but) && !ui_but_is_unit(but) && - !ui_but_anim_expression_get(but, nullptr, 0) && !no_zero_strip) { + !ui_but_anim_expression_get(but, nullptr, 0) && !no_zero_strip) + { BLI_str_rstrip_float_zero(data->str, '\0'); } @@ -3508,7 +3519,8 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) if ((ui_searchbox_apply(but, data->searchbox) == false) && (ui_searchbox_find_index(data->searchbox, but->editstr) == -1) && - !but_search->results_are_suggestions) { + !but_search->results_are_suggestions) + { if (but->flag & UI_BUT_VALUE_CLEAR) { /* It is valid for _VALUE_CLEAR flavor to have no active element @@ -3557,7 +3569,8 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, - UI_BTYPE_LISTBOX)) { + UI_BTYPE_LISTBOX)) + { return; } @@ -3589,7 +3602,8 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_ROUNDBOX, - UI_BTYPE_LISTBOX)) { + UI_BTYPE_LISTBOX)) + { return; } @@ -3633,7 +3647,8 @@ static void ui_do_but_textedit( if (data->searchbox) { #ifdef USE_KEYNAV_LIMIT if ((event->type == MOUSEMOVE) && - ui_mouse_motion_keynav_test(&data->searchbox_keynav_state, event)) { + ui_mouse_motion_keynav_test(&data->searchbox_keynav_state, event)) + { /* pass */ } else { @@ -3872,7 +3887,8 @@ static void ui_do_but_textedit( #if defined(__APPLE__) ((event->modifier & KM_OSKEY) && ((event->modifier & (KM_ALT | KM_CTRL)) == 0)) || #endif - ((event->modifier & KM_CTRL) && ((event->modifier & (KM_ALT | KM_OSKEY)) == 0))) { + ((event->modifier & KM_CTRL) && ((event->modifier & (KM_ALT | KM_OSKEY)) == 0))) + { int undo_pos; const char *undo_str = ui_textedit_undo( data->undo_stack_text, is_redo ? 1 : -1, &undo_pos); @@ -3896,7 +3912,8 @@ static void ui_do_but_textedit( #ifdef WITH_INPUT_IME && !is_ime_composing && !WM_event_is_ime_switch(event) #endif - ) { + ) + { char utf8_buf_override[2] = {'\0', '\0'}; const char *utf8_buf = event->utf8_buf; @@ -3932,7 +3949,8 @@ static void ui_do_but_textedit( } if (event->type == WM_IME_COMPOSITE_EVENT && ime_data->result_len) { if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && - STREQ(ime_data->str_result, "\xE3\x80\x82")) { + STREQ(ime_data->str_result, "\xE3\x80\x82")) + { /* Convert Ideographic Full Stop (U+3002) to decimal point when entering numbers. */ ui_textedit_insert_ascii(but, data, '.'); } @@ -4028,11 +4046,8 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) data->coba = (ColorBand *)but->poin; but_coba->edit_coba = data->coba; } - else if (ELEM(but->type, - UI_BTYPE_UNITVEC, - UI_BTYPE_HSVCUBE, - UI_BTYPE_HSVCIRCLE, - UI_BTYPE_COLOR)) { + else if (ELEM(but->type, UI_BTYPE_UNITVEC, UI_BTYPE_HSVCUBE, UI_BTYPE_HSVCIRCLE, UI_BTYPE_COLOR)) + { ui_but_v3_get(but, data->origvec); copy_v3_v3(data->vec, data->origvec); but->editvec = data->vec; @@ -4504,7 +4519,8 @@ static int ui_do_but_HOTKEYEVT(bContext *C, if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY, EVT_BUT_OPEN) && - (event->val == KM_PRESS)) { + (event->val == KM_PRESS)) + { but->drawstr[0] = 0; hotkey_but->modifier_key = 0; button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); @@ -4616,7 +4632,8 @@ static int ui_do_but_TAB( if (is_property && ELEM(rna_type, PROP_POINTER, PROP_STRING) && (but->custom_data != nullptr) && (event->type == LEFTMOUSE) && - ((event->val == KM_DBL_CLICK) || (event->modifier & KM_CTRL))) { + ((event->val == KM_DBL_CLICK) || (event->modifier & KM_CTRL))) + { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); return WM_UI_HANDLER_BREAK; } @@ -4650,7 +4667,8 @@ static int ui_do_but_TEX( /* pass - allow filesel, enter to execute */ } else if (ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS) && - ((event->modifier & KM_CTRL) == 0)) { + ((event->modifier & KM_CTRL) == 0)) + { /* pass */ } else { @@ -4837,7 +4855,8 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con int ret = WM_UI_HANDLER_BREAK; /* XXX: (a bit ugly) Special case handling for file-browser drag button. */ if (ui_but_drag_is_draggable(but) && but->imb && - ui_but_contains_point_px_icon(but, data->region, event)) { + ui_but_contains_point_px_icon(but, data->region, event)) + { ret = WM_UI_HANDLER_CONTINUE; } /* Same special case handling for UI lists. Return CONTINUE so that a tweak or CLICK event @@ -5400,7 +5419,8 @@ static int ui_do_but_NUM( (ui_but_is_cursor_warp(but) ? screen_mx : mx), is_motion, snap, - fac)) { + fac)) + { ui_numedit_apply(C, block, but, data); } #ifdef USE_DRAG_MULTINUM @@ -5508,7 +5528,8 @@ static bool ui_numedit_but_SLI(uiBut *but, /* prevent unwanted drag adjustments, test motion so modifier keys refresh. */ if ((but->type != UI_BTYPE_SCROLL) && (is_motion || data->draglock) && - (ui_but_dragedit_update_mval(data, mx) == false)) { + (ui_but_dragedit_update_mval(data, mx) == false)) + { return changed; } @@ -5749,7 +5770,8 @@ static int ui_do_but_SLI( true, is_motion, event->modifier & KM_CTRL, - event->modifier & KM_SHIFT)) { + event->modifier & KM_SHIFT)) + { ui_numedit_apply(C, block, but, data); } @@ -5977,7 +5999,8 @@ static int ui_do_but_LISTROW(bContext *C, */ if ((ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY) && (event->val == KM_PRESS) && (event->modifier & KM_CTRL)) || - (event->type == LEFTMOUSE && event->val == KM_DBL_CLICK)) { + (event->type == LEFTMOUSE && event->val == KM_DBL_CLICK)) + { uiBut *labelbut = ui_but_list_row_text_activate( C, but, data, event, BUTTON_ACTIVATE_TEXT_EDITING); if (labelbut) { @@ -6017,8 +6040,8 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_BREAK; } if (ui_but_supports_cycling(but)) { - if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && - (event->modifier & KM_CTRL)) { + if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && (event->modifier & KM_CTRL)) + { int type = event->type; int val = event->val; @@ -7331,7 +7354,8 @@ static int ui_do_but_CURVE( event->xy[0], event->xy[1], event->modifier & KM_CTRL, - event->modifier & KM_SHIFT)) { + event->modifier & KM_SHIFT)) + { ui_numedit_apply(C, block, but, data); } } @@ -7542,8 +7566,8 @@ static int ui_do_but_CURVEPROFILE( /* Check for selecting of a point by finding closest point in radius. */ CurveProfilePoint *pts = profile->path; - float dist_min_sq = square_f(UI_SCALE_FAC * - 14.0f); /* 14 pixels radius for selecting points. */ + /* 14 pixels radius for selecting points. */ + float dist_min_sq = square_f(UI_SCALE_FAC * 14.0f); int i_selected = -1; short selection_type = 0; /* For handle selection. */ for (int i = 0; i < profile->path_len; i++) { @@ -7641,7 +7665,8 @@ static int ui_do_but_CURVEPROFILE( if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { if (ui_numedit_but_CURVEPROFILE( - block, but, data, mx, my, event->modifier & KM_CTRL, event->modifier & KM_SHIFT)) { + block, but, data, mx, my, event->modifier & KM_CTRL, event->modifier & KM_SHIFT)) + { ui_numedit_apply(C, block, but, data); } } @@ -7937,7 +7962,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * if ((event->type == RIGHTMOUSE) && (event->modifier & (KM_SHIFT | KM_CTRL | KM_ALT | KM_OSKEY)) == 0 && - (event->val == KM_PRESS)) { + (event->val == KM_PRESS)) + { /* For some button types that are typically representing entire sets of data, right-clicking * to spawn the context menu should also activate the item. This makes it clear which item * will be operated on. @@ -7975,7 +8001,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN, EVT_PADENTER, EVT_RETKEY) && (event->val == KM_RELEASE) && /* Only returns true if the event was handled. */ - ui_do_but_extra_operator_icon(C, but, data, event)) { + ui_do_but_extra_operator_icon(C, but, data, event)) + { return WM_UI_HANDLER_BREAK; } } @@ -8112,9 +8139,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * if (data) { if (ISMOUSE_MOTION(event->type) || /* if we started dragging, progress on any event */ - (data->multi_data.init == uiHandleButtonMulti::INIT_SETUP)) { + (data->multi_data.init == uiHandleButtonMulti::INIT_SETUP)) + { if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && - ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING)) { + ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING)) + { /* initialize! */ if (data->multi_data.init == uiHandleButtonMulti::INIT_UNSET) { /* --> (uiHandleButtonMulti::INIT_SETUP | uiHandleButtonMulti::INIT_DISABLE) */ @@ -8145,7 +8174,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING)) || ((abs(data->multi_data.drag_lock_x - event->xy[0]) > margin_x) && /* Just to be sure, check we're dragging more horizontally then vertically. */ - abs(event->prev_xy[0] - event->xy[0]) > abs(event->prev_xy[1] - event->xy[1]))) { + abs(event->prev_xy[0] - event->xy[0]) > abs(event->prev_xy[1] - event->xy[1]))) + { if (data->multi_data.has_mbuts) { ui_multibut_states_create(but, data); data->multi_data.init = uiHandleButtonMulti::INIT_ENABLE; @@ -8295,7 +8325,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* Menu button types may draw as popovers, check for this case * ignoring other kinds of menus (mainly enums). (see #66538). */ ((but->type == UI_BTYPE_MENU) && - (UI_but_paneltype_get(but) || ui_but_menu_draw_as_popover(but)))) { + (UI_but_paneltype_get(but) || ui_but_menu_draw_as_popover(but)))) + { if (data->used_mouse && !data->autoopentimer) { int time; @@ -8303,7 +8334,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s time = 1; } else if ((but->block->flag & UI_BLOCK_LOOP && but->type != UI_BTYPE_BLOCK) || - (but->block->auto_open == true)) { + (but->block->auto_open == true)) + { time = 5 * U.menuthreshold2; } else if (U.uiflag & USER_MENUOPENAUTO) { @@ -9181,7 +9213,8 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) /* always deactivate button for pie menus, * else moving to blank space will leave activated */ if ((!ui_block_is_menu(block) || ui_block_is_pie_menu(block)) && - !ui_but_contains_point_px(but, region, event->xy)) { + !ui_but_contains_point_px(but, region, event->xy)) + { exit = true; } else if (but_other && ui_but_is_editable(but_other) && (but_other != but)) { @@ -9359,7 +9392,8 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) /* Reset the button value when empty text is typed. */ if ((data->cancel == false) && (data->str != nullptr) && (data->str[0] == '\0') && - (but->rnaprop && ELEM(RNA_property_type(but->rnaprop), PROP_FLOAT, PROP_INT))) { + (but->rnaprop && ELEM(RNA_property_type(but->rnaprop), PROP_FLOAT, PROP_INT))) + { MEM_SAFE_FREE(data->str); ui_button_value_default(but, &data->value); @@ -9427,7 +9461,8 @@ static int ui_list_activate_hovered_row(bContext *C, if (!ui_list_invoke_item_operator(C, hovered_but, ui_list->dyn_data->custom_drag_optype, - &ui_list->dyn_data->custom_drag_opptr)) { + &ui_list->dyn_data->custom_drag_opptr)) + { return WM_UI_HANDLER_CONTINUE; } } @@ -9540,7 +9575,8 @@ static int ui_list_get_increment(const uiList *ui_list, const int type, const in /* Handle column offsets for grid layouts. */ if (ELEM(type, EVT_UPARROWKEY, EVT_DOWNARROWKEY) && - ELEM(ui_list->layout_type, UILST_LAYOUT_GRID, UILST_LAYOUT_BIG_PREVIEW_GRID)) { + ELEM(ui_list->layout_type, UILST_LAYOUT_GRID, UILST_LAYOUT_BIG_PREVIEW_GRID)) + { increment = (type == EVT_UPARROWKEY) ? -columns : columns; } else { @@ -9595,7 +9631,8 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi if ((ELEM(type, EVT_UPARROWKEY, EVT_DOWNARROWKEY, EVT_LEFTARROWKEY, EVT_RIGHTARROWKEY) && (event->modifier & (KM_SHIFT | KM_CTRL | KM_ALT | KM_OSKEY)) == 0) || (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && (event->modifier & KM_CTRL) && - (event->modifier & (KM_SHIFT | KM_ALT | KM_OSKEY)) == 0)) { + (event->modifier & (KM_SHIFT | KM_ALT | KM_OSKEY)) == 0)) + { const int value_orig = RNA_property_int_get(&listbox->rnapoin, listbox->rnaprop); int value, min, max; @@ -9614,7 +9651,8 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi for (int i = 0; i < len; i++) { if (!dyn_data->items_filter_flags || - ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) { + ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) + { org_order[new_order ? new_order[++org_idx] : ++org_idx] = i; if (i == value) { current_idx = new_order ? new_order[org_idx] : org_idx; @@ -9919,7 +9957,8 @@ static void ui_mouse_motion_keynav_init(uiKeyNavLock *keynav, const wmEvent *eve static bool ui_mouse_motion_keynav_test(uiKeyNavLock *keynav, const wmEvent *event) { if (keynav->is_keynav && - (len_manhattan_v2v2_int(keynav->event_xy, event->xy) > BUTTON_KEYNAV_PX_LIMIT)) { + (len_manhattan_v2v2_int(keynav->event_xy, event->xy) > BUTTON_KEYNAV_PX_LIMIT)) + { keynav->is_keynav = false; } @@ -10539,7 +10578,8 @@ static int ui_handle_menu_event(bContext *C, /* exception for rna layer buts */ if (but->rnapoin.data && but->rnaprop && - ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) { + ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) + { if (but->rnaindex == act - 1) { doit = true; } @@ -10550,7 +10590,8 @@ static int ui_handle_menu_event(bContext *C, UI_BTYPE_MENU, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN) && - count == act) { + count == act) + { doit = true; } @@ -10604,7 +10645,8 @@ static int ui_handle_menu_event(bContext *C, ((event->modifier & (KM_SHIFT | KM_CTRL | KM_OSKEY)) == 0) && /* Only respond to explicit press to avoid the event that opened the menu * activating an item when the key is held. */ - (event->flag & WM_EVENT_IS_REPEAT) == 0) { + (event->flag & WM_EVENT_IS_REPEAT) == 0) + { if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval)) { break; } @@ -10712,7 +10754,8 @@ static int ui_handle_menu_event(bContext *C, } #ifdef USE_DRAG_POPUP else if ((event->type == LEFTMOUSE) && (event->val == KM_PRESS) && - (inside && is_floating && inside_title)) { + (inside && is_floating && inside_title)) + { if (!but || !ui_but_contains_point_px(but, region, event->xy)) { if (but) { UI_but_tooltip_timer_remove(C, but); @@ -10774,7 +10817,8 @@ static int ui_handle_menu_event(bContext *C, * for example when mouse was not over submenu */ if ((event->type == TIMER) || (/* inside && */ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && - retval == WM_UI_HANDLER_CONTINUE)) { + retval == WM_UI_HANDLER_CONTINUE)) + { retval = ui_handle_menu_button(C, event, menu); } @@ -11041,15 +11085,16 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle ED_region_tag_redraw(region); } else { - if ((duration < 0.01 * U.pie_tap_timeout) && - !(block->pie_data.flags & UI_PIE_DRAG_STYLE)) { + if ((duration < 0.01 * U.pie_tap_timeout) && !(block->pie_data.flags & UI_PIE_DRAG_STYLE)) + { block->pie_data.flags |= UI_PIE_CLICK_STYLE; } else { uiBut *but = ui_region_find_active_but(menu->region); if (but && (U.pie_menu_confirm > 0) && - (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) { + (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) + { return ui_but_pie_menu_apply(C, menu, but, true); } @@ -11074,7 +11119,8 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle /* here instead, we use the offset location to account for the initial * direction timeout */ if ((U.pie_menu_confirm > 0) && - (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) { + (dist >= UI_SCALE_FAC * (U.pie_menu_threshold + U.pie_menu_confirm))) + { block->pie_data.flags |= UI_PIE_GESTURE_END_WAIT; copy_v2_v2(block->pie_data.last_pos, event_xy); block->pie_data.duration_gesture = duration; @@ -11130,7 +11176,8 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle case EVT_YKEY: case EVT_ZKEY: { if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK) && - ((event->modifier & (KM_SHIFT | KM_CTRL | KM_OSKEY)) == 0)) { + ((event->modifier & (KM_SHIFT | KM_CTRL | KM_OSKEY)) == 0)) + { LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->menu_key == event->type) { ui_but_pie_button_activate(C, but, menu); @@ -11332,7 +11379,8 @@ static int ui_region_handler(bContext *C, const wmEvent *event, void * /*userdat /* Re-enable tool-tips. */ if (event->type == MOUSEMOVE && - (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) { + (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) + { ui_blocks_set_tooltips(region, true); } @@ -11401,7 +11449,8 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void * /*us (((data->menu->direction & (UI_DIR_LEFT | UI_DIR_RIGHT)) && BLI_rctf_isect_rect_x(&but->rect, &but_other->rect, nullptr)) || ((data->menu->direction & (UI_DIR_DOWN | UI_DIR_UP)) && - BLI_rctf_isect_rect_y(&but->rect, &but_other->rect, nullptr)))) { + BLI_rctf_isect_rect_y(&but->rect, &but_other->rect, nullptr)))) + { /* if mouse moves to a different root-level menu button, * open it to replace the current menu */ if ((but_other->flag & UI_BUT_DISABLED) == 0) { @@ -11436,7 +11485,8 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void * /*us /* Re-enable tool-tips. */ if (event->type == MOUSEMOVE && - (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) { + (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) + { ui_blocks_set_tooltips(region, true); } @@ -11531,7 +11581,8 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata) else { /* Re-enable tool-tips */ if (event->type == MOUSEMOVE && - (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) { + (event->xy[0] != event->prev_xy[0] || event->xy[1] != event->prev_xy[1])) + { ui_blocks_set_tooltips(menu->region, true); } } @@ -11600,12 +11651,14 @@ void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup) wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base; if (handler->handle_fn == ui_popup_handler && - handler->remove_fn == ui_popup_handler_remove && handler->user_data == popup) { + handler->remove_fn == ui_popup_handler_remove && handler->user_data == popup) + { /* tag refresh parent popup */ wmEventHandler_UI *handler_next = (wmEventHandler_UI *)handler->head.next; if (handler_next && handler_next->head.type == WM_HANDLER_TYPE_UI && handler_next->handle_fn == ui_popup_handler && - handler_next->remove_fn == ui_popup_handler_remove) { + handler_next->remove_fn == ui_popup_handler_remove) + { uiPopupBlockHandle *parent_popup = static_cast( handler_next->user_data); ED_region_tag_refresh_ui(parent_popup->region); diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 772f45ceb02..0cbf98d614f 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -2300,7 +2300,8 @@ int UI_icon_from_library(const ID *id) } if (ID_IS_OVERRIDE_LIBRARY(id)) { if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || - (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) != 0) { + (id->override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) != 0) + { return ICON_LIBRARY_DATA_OVERRIDE_NONEDITABLE; } return ICON_LIBRARY_DATA_OVERRIDE; diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 1b5330acc19..d70221affa9 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -859,7 +859,8 @@ static void ui_item_enum_expand_exec(uiLayout *layout, } } else if (ELEM(layout->item.type, ITEM_LAYOUT_GRID_FLOW, ITEM_LAYOUT_COLUMN_FLOW) || - layout->root->type == UI_LAYOUT_MENU) { + layout->root->type == UI_LAYOUT_MENU) + { UI_block_layout_set_current(block, layout); } else { @@ -929,7 +930,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, BLI_assert(last != block->buttons.last); for (uiBut *tab = last ? last->next : static_cast(block->buttons.first); tab; - tab = tab->next) { + tab = tab->next) + { UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C))); } @@ -942,7 +944,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, int i = 0; for (uiBut *tab_but = last ? last->next : static_cast(block->buttons.first); (tab_but != nullptr) && (i < highlight_array_len); - tab_but = tab_but->next, i++) { + tab_but = tab_but->next, i++) + { SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE); } } @@ -1006,7 +1009,8 @@ static uiBut *ui_item_with_label(uiLayout *layout, #ifdef UI_PROP_DECORATE || use_prop_decorate #endif - ) { + ) + { /* Also avoid setting 'align' if possible. Set the space to zero instead as aligning a large * number of labels can end up aligning thousands of buttons when displaying key-map search (a * heavy operation), see: #78636. */ @@ -2164,7 +2168,8 @@ void uiItemFullR(uiLayout *layout, /* Menus and pie-menus don't show checkbox without this. */ if ((layout->root->type == UI_LAYOUT_MENU) || /* Use check-boxes only as a fallback in pie-menu's, when no icon is defined. */ - ((layout->root->type == UI_LAYOUT_PIEMENU) && (icon == ICON_NONE))) { + ((layout->root->type == UI_LAYOUT_PIEMENU) && (icon == ICON_NONE))) + { const int prop_flag = RNA_property_flag(prop); if (type == PROP_BOOLEAN) { if ((is_array == false) || (index != RNA_NO_INDEX)) { @@ -2446,7 +2451,8 @@ void uiItemFullR(uiLayout *layout, UI_BTYPE_CHECKBOX, UI_BTYPE_CHECKBOX_N, UI_BTYPE_ICON_TOGGLE, - UI_BTYPE_ICON_TOGGLE_N)) { + UI_BTYPE_ICON_TOGGLE_N)) + { but->drawflag |= UI_BUT_CHECKBOX_INVERT; } } @@ -2478,7 +2484,8 @@ void uiItemFullR(uiLayout *layout, /* Mark non-embossed text-fields inside a list-box. */ if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == UI_BTYPE_TEXT) && - ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) { + ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) + { UI_but_flag_enable(but, UI_BUT_LIST_ITEM); } @@ -3043,7 +3050,8 @@ static uiBut *ui_item_menu(uiLayout *layout, if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR) || /* We never want a drop-down in menu! */ - (force_menu && layout->root->type != UI_LAYOUT_MENU)) { + (force_menu && layout->root->type != UI_LAYOUT_MENU)) + { UI_but_type_set_menu_from_pulldown(but); } @@ -3581,7 +3589,8 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout, if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) { char keybuf[128]; if (WM_key_event_operator_string( - C, ot->idname, layout->root->opcontext, nullptr, false, keybuf, sizeof(keybuf))) { + C, ot->idname, layout->root->opcontext, nullptr, false, keybuf, sizeof(keybuf))) + { ui_but_add_shortcut(but, keybuf, false); } } @@ -3776,7 +3785,8 @@ static void ui_litem_layout_row(uiLayout *litem) if (item->type != ITEM_BUTTON && ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) && litem->alignment == UI_LAYOUT_ALIGN_EXPAND && - ((uiItem *)litem)->flag & UI_ITEM_FIXED_SIZE) { + ((uiItem *)litem)->flag & UI_ITEM_FIXED_SIZE) + { min_flag = false; } @@ -3853,7 +3863,8 @@ static void ui_litem_layout_row(uiLayout *litem) uiItem *last_item = static_cast(litem->items.last); extra_pixel = litem->w - (x - litem->x); if (extra_pixel > 0 && litem->alignment == UI_LAYOUT_ALIGN_EXPAND && last_free_item && - last_item && last_item->flag & UI_ITEM_AUTO_FIXED_SIZE) { + last_item && last_item->flag & UI_ITEM_AUTO_FIXED_SIZE) + { ui_item_move(last_free_item, 0, extra_pixel); for (uiItem *item = last_free_item->next; item; item = item->next) { ui_item_move(item, extra_pixel, extra_pixel); @@ -4482,7 +4493,8 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) for (gflow->tot_rows = int(ceilf(float(gflow->tot_items) / gflow->tot_columns)); (gflow->tot_columns - step) > 0 && int(ceilf(float(gflow->tot_items) / (gflow->tot_columns - step))) <= gflow->tot_rows; - gflow->tot_columns -= step) { + gflow->tot_columns -= step) + { /* pass */ } } @@ -4496,7 +4508,8 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem) for (gflow->tot_columns = int(ceilf(float(gflow->tot_items) / gflow->tot_rows)); (gflow->tot_rows - step) > 0 && int(ceilf(float(gflow->tot_items) / (gflow->tot_rows - step))) <= gflow->tot_columns; - gflow->tot_rows -= step) { + gflow->tot_rows -= step) + { /* pass */ } } @@ -5917,7 +5930,8 @@ static bool ui_layout_has_panel_label(const uiLayout *layout, const PanelType *p if (subitem->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)subitem; if (!(bitem->but->flag & UI_HIDDEN) && - STREQ(bitem->but->str, CTX_IFACE_(pt->translation_context, pt->label))) { + STREQ(bitem->but->str, CTX_IFACE_(pt->translation_context, pt->label))) + { return true; } } diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 8168faba377..8f1dcb5b330 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -198,7 +198,8 @@ static bool copy_as_driver_button_poll(bContext *C) if (ptr.owner_id && ptr.data && prop && ELEM(RNA_property_type(prop), PROP_BOOLEAN, PROP_INT, PROP_FLOAT, PROP_ENUM) && - (index >= 0 || !RNA_property_array_check(prop))) { + (index >= 0 || !RNA_property_array_check(prop))) + { path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -476,7 +477,8 @@ static int unset_property_button_exec(bContext *C, wmOperator * /*op*/) /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop) && /* RNA_property_is_idprop(prop) && */ - RNA_property_is_set(&ptr, prop)) { + RNA_property_is_set(&ptr, prop)) + { RNA_property_unset(&ptr, prop); return operator_button_property_finish(C, &ptr, prop); } @@ -566,20 +568,20 @@ static int override_type_set_button_exec(bContext *C, wmOperator *op) switch (op_type) { case UIOverride_Type_NOOP: - operation = IDOVERRIDE_LIBRARY_OP_NOOP; + operation = LIBOVERRIDE_OP_NOOP; break; case UIOverride_Type_Replace: - operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + operation = LIBOVERRIDE_OP_REPLACE; break; case UIOverride_Type_Difference: /* override code will automatically switch to subtract if needed. */ - operation = IDOVERRIDE_LIBRARY_OP_ADD; + operation = LIBOVERRIDE_OP_ADD; break; case UIOverride_Type_Factor: - operation = IDOVERRIDE_LIBRARY_OP_MULTIPLY; + operation = LIBOVERRIDE_OP_MULTIPLY; break; default: - operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + operation = LIBOVERRIDE_OP_REPLACE; BLI_assert(0); break; } @@ -617,7 +619,7 @@ static int override_type_set_button_invoke(bContext *C, wmOperator *op, const wm #if 0 /* Disabled for now */ return WM_menu_invoke_ex(C, op, WM_OP_INVOKE_DEFAULT); #else - RNA_enum_set(op->ptr, "type", IDOVERRIDE_LIBRARY_OP_REPLACE); + RNA_enum_set(op->ptr, "type", LIBOVERRIDE_OP_REPLACE); return override_type_set_button_exec(C, op); #endif } @@ -1080,10 +1082,11 @@ bool UI_context_copy_to_selected_list(bContext *C, char *idpath = nullptr; /* First, check the active PoseBone and PoseBone->Bone. */ - if (NOT_RNA_NULL( - owner_ptr = CTX_data_pointer_get_type(C, "active_pose_bone", &RNA_PoseBone))) { + if (NOT_RNA_NULL(owner_ptr = CTX_data_pointer_get_type(C, "active_pose_bone", &RNA_PoseBone))) + { if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty( - &owner_ptr, static_cast(ptr->data)))) { + &owner_ptr, static_cast(ptr->data)))) + { *r_lb = CTX_data_collection_get(C, "selected_pose_bones"); } else { @@ -1091,7 +1094,8 @@ bool UI_context_copy_to_selected_list(bContext *C, RNA_pointer_create(owner_ptr.owner_id, &RNA_Bone, pchan->bone, &owner_ptr); if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty( - &owner_ptr, static_cast(ptr->data)))) { + &owner_ptr, static_cast(ptr->data)))) + { ui_context_selected_bones_via_pose(C, r_lb); } } @@ -1102,7 +1106,8 @@ bool UI_context_copy_to_selected_list(bContext *C, if (NOT_RNA_NULL( owner_ptr = CTX_data_pointer_get_type_silent(C, "active_bone", &RNA_EditBone)) && NOT_NULL(idpath = RNA_path_from_struct_to_idproperty( - &owner_ptr, static_cast(ptr->data)))) { + &owner_ptr, static_cast(ptr->data)))) + { *r_lb = CTX_data_collection_get(C, "selected_editable_bones"); } @@ -1155,7 +1160,8 @@ bool UI_context_copy_to_selected_list(bContext *C, } else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) && (path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) != - nullptr) { + nullptr) + { *r_lb = CTX_data_collection_get(C, "selected_pose_bones"); *r_path = path_from_bone; } @@ -1227,7 +1233,8 @@ bool UI_context_copy_to_selected_list(bContext *C, ID *id_data = static_cast(ob->data); if ((id_data == nullptr) || (id_data->tag & LIB_TAG_DOIT) == 0 || - ID_IS_LINKED(id_data) || (GS(id_data->name) != id_code)) { + ID_IS_LINKED(id_data) || (GS(id_data->name) != id_code)) + { BLI_remlink(&lb, link); MEM_freeN(link); } @@ -1249,8 +1256,8 @@ bool UI_context_copy_to_selected_list(bContext *C, /* Sequencer's ID is scene :/ */ /* Try to recursively find an RNA_Sequence ancestor, * to handle situations like #41062... */ - if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != - nullptr) { + if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != nullptr) + { /* Special case when we do this for 'Sequence.lock'. * (if the sequence is locked, it won't be in "selected_editable_sequences"). */ const char *prop_id = RNA_property_identifier(prop); @@ -1274,7 +1281,8 @@ bool UI_context_copy_to_selected_list(bContext *C, const char *prop_id = RNA_property_identifier(prop); LISTBASE_FOREACH_MUTABLE (CollectionPointerLink *, link, r_lb) { if ((ptr->type != link->ptr.type) && - (RNA_struct_type_find_property(link->ptr.type, prop_id) != prop)) { + (RNA_struct_type_find_property(link->ptr.type, prop_id) != prop)) + { BLI_remlink(r_lb, link); MEM_freeN(link); } @@ -1347,7 +1355,8 @@ bool UI_context_copy_to_selected_check(PointerRNA *ptr, */ bool ignore_prop_eq = RNA_property_is_idprop(lprop) && RNA_property_is_idprop(prop); if (RNA_struct_is_a(lptr.type, &RNA_NodesModifier) && - RNA_struct_is_a(ptr->type, &RNA_NodesModifier)) { + RNA_struct_is_a(ptr->type, &RNA_NodesModifier)) + { ignore_prop_eq = false; NodesModifierData *nmd_link = (NodesModifierData *)lptr.data; @@ -1416,7 +1425,8 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll) } if (!UI_context_copy_to_selected_check( - &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) { + &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) + { continue; } @@ -1686,7 +1696,8 @@ static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) && (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && (but_a->unit_type == but_b->unit_type) && - STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) { + STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) + { return true; } return false; @@ -1796,7 +1807,8 @@ static int editsource_exec(bContext *C, wmOperator *op) for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash); BLI_ghashIterator_done(&ghi) == false; - BLI_ghashIterator_step(&ghi)) { + BLI_ghashIterator_step(&ghi)) + { uiBut *but_key = static_cast(BLI_ghashIterator_getKey(&ghi)); if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) { but_store = static_cast(BLI_ghashIterator_getValue(&ghi)); @@ -1888,7 +1900,7 @@ static void edittranslation_find_po_file(const char *root, } BLI_path_join(path, maxlen, root, tstr); - strcat(tstr, ".po"); + BLI_strncat(tstr, ".po", sizeof(tstr)); BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) { return; @@ -2157,7 +2169,8 @@ bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent * /*even } if (sima && (sima->mode == SI_MODE_PAINT) && sima->image && - (region && region->regiontype == RGN_TYPE_WINDOW)) { + (region && region->regiontype == RGN_TYPE_WINDOW)) + { return true; } } @@ -2379,8 +2392,8 @@ static int ui_view_drop_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * std::unique_ptr drop_target = region_views_find_drop_target_at(region, event->xy); - if (!drop_target_apply_drop( - *C, *drop_target, *static_cast(event->customdata))) { + if (!drop_target_apply_drop(*C, *drop_target, *static_cast(event->customdata))) + { return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index a08cd0b6310..f5948afa4b0 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -991,14 +991,16 @@ void UI_panels_draw(const bContext *C, ARegion *region) * and we need child panels to draw on top. */ LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) { if (block->active && block->panel && !UI_panel_is_dragging(block->panel) && - !UI_block_is_search_only(block)) { + !UI_block_is_search_only(block)) + { UI_block_draw(C, block); } } LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) { if (block->active && block->panel && UI_panel_is_dragging(block->panel) && - !UI_block_is_search_only(block)) { + !UI_block_is_search_only(block)) + { UI_block_draw(C, block); } } @@ -2323,7 +2325,8 @@ int ui_handler_panel_region(bContext *C, } } else if (((event->type == EVT_TABKEY) && (event->modifier & KM_CTRL)) || - ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { + ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) + { /* Cycle tabs. */ retval = ui_handle_panel_category_cycling(event, region, active_but); } diff --git a/source/blender/editors/interface/interface_query.cc b/source/blender/editors/interface/interface_query.cc index 562c05df77f..502b0bb4e3f 100644 --- a/source/blender/editors/interface/interface_query.cc +++ b/source/blender/editors/interface/interface_query.cc @@ -84,7 +84,8 @@ bool ui_but_is_interactive_ex(const uiBut *but, const bool labeledit, const bool return false; } if ((but->type == UI_BTYPE_TEXT) && - ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS) && !labeledit) { + ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS) && !labeledit) + { return false; } if ((but->type == UI_BTYPE_LISTROW) && labeledit) { @@ -551,7 +552,8 @@ bool ui_but_is_cursor_warp(const uiBut *but) UI_BTYPE_HSVCUBE, UI_BTYPE_HSVCIRCLE, UI_BTYPE_CURVE, - UI_BTYPE_CURVEPROFILE)) { + UI_BTYPE_CURVEPROFILE)) + { return true; } } @@ -764,7 +766,8 @@ bool ui_region_contains_point_px(const ARegion *region, const int xy[2]) ui_window_to_region(region, &mx, &my); if (!BLI_rcti_isect_pt(&v2d->mask, mx, my) || - UI_view2d_mouse_in_scrollers(region, ®ion->v2d, xy)) { + UI_view2d_mouse_in_scrollers(region, ®ion->v2d, xy)) + { return false; } } @@ -786,7 +789,8 @@ bool ui_region_contains_rect_px(const ARegion *region, const rcti *rect_px) rcti rect_region; ui_window_to_region_rcti(region, &rect_region, rect_px); if (!BLI_rcti_isect(&v2d->mask, &rect_region, nullptr) || - UI_view2d_rect_in_scrollers(region, ®ion->v2d, rect_px)) { + UI_view2d_rect_in_scrollers(region, ®ion->v2d, rect_px)) + { return false; } } diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index efb3d13de87..0913a591c01 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -321,7 +321,8 @@ static void ui_colorpicker_hide_reveal(uiBlock *block, ePickerType colormode) /* tag buttons */ LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { if ((bt->func == ui_colorpicker_rgba_update_cb) && (bt->type == UI_BTYPE_NUM_SLIDER) && - (bt->rnaindex != 3)) { + (bt->rnaindex != 3)) + { /* RGB sliders (color circle and alpha are always shown) */ SET_FLAG_FROM_TEST(bt->flag, (colormode != PICKER_TYPE_RGB), UI_HIDDEN); } diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index 090aec4dcc1..85c96d52adb 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -172,7 +172,8 @@ static void hud_region_layout(const bContext *C, ARegion *region) ED_region_panels_layout(C, region); if (region->panels.first && - ((area->flag & AREA_FLAG_REGION_SIZE_UPDATE) || (region->sizey != size_y))) { + ((area->flag & AREA_FLAG_REGION_SIZE_UPDATE) || (region->sizey != size_y))) + { int winx_new = UI_SCALE_FAC * (region->sizex + 0.5f); int winy_new = UI_SCALE_FAC * (region->sizey + 0.5f); View2D *v2d = ®ion->v2d; diff --git a/source/blender/editors/interface/interface_region_menu_popup.cc b/source/blender/editors/interface/interface_region_menu_popup.cc index c1e0632a5bc..3a03b4c2753 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.cc +++ b/source/blender/editors/interface/interface_region_menu_popup.cc @@ -136,8 +136,8 @@ static uiBut *ui_popup_menu_memory__internal(uiBlock *block, uiBut *but) if (ELEM(but_iter->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { continue; } - if (mem[hash_mod] == - ui_popup_string_hash(but_iter->str, but_iter->flag & UI_BUT_HAS_SEP_CHAR)) { + if (mem[hash_mod] == ui_popup_string_hash(but_iter->str, but_iter->flag & UI_BUT_HAS_SEP_CHAR)) + { return but_iter; } } diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 68a50b77633..158ecb643c2 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -376,9 +376,9 @@ bool ui_searchbox_event( * (a little confusing if this isn't the case, although it does work). */ rcti rect; ui_searchbox_butrect(&rect, data, data->active); - if (BLI_rcti_isect_pt(&rect, - event->xy[0] - region->winrct.xmin, - event->xy[1] - region->winrct.ymin)) { + if (BLI_rcti_isect_pt( + &rect, event->xy[0] - region->winrct.xmin, event->xy[1] - region->winrct.ymin)) + { void *active = data->items.pointers[data->active]; if (search_but->item_context_menu_fn(C, search_but->arg, active, event)) { @@ -399,7 +399,8 @@ bool ui_searchbox_event( for (a = 0; a < data->items.totitem; a++) { ui_searchbox_butrect(&rect, data, a); if (BLI_rcti_isect_pt( - &rect, event->xy[0] - region->winrct.xmin, event->xy[1] - region->winrct.ymin)) { + &rect, event->xy[0] - region->winrct.xmin, event->xy[1] - region->winrct.ymin)) + { is_inside = true; if (data->active != a) { data->active = a; diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index e5e216c8cfc..6505a5b5299 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -550,7 +550,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is static_cast(op_props.data), true, shortcut_brush, - ARRAY_SIZE(shortcut_brush))) { + ARRAY_SIZE(shortcut_brush))) + { shortcut = BLI_strdup(shortcut_brush); } WM_operator_properties_free(&op_props); @@ -567,7 +568,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is nullptr, true, shortcut_toolbar, - ARRAY_SIZE(shortcut_toolbar))) { + ARRAY_SIZE(shortcut_toolbar))) + { /* Generate keymap in order to inspect it. * NOTE: we could make a utility to avoid the keymap generation part of this. */ const char *expr_imports[] = { @@ -645,7 +647,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is /* pass */ } else if (BPY_run_string_as_string_and_size( - C, expr_imports, expr, nullptr, &expr_result, &expr_result_len)) { + C, expr_imports, expr, nullptr, &expr_result, &expr_result_len)) + { /* pass. */ } } @@ -668,7 +671,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is static_cast(op_props.data), true, shortcut, - ARRAY_SIZE(shortcut))) { + ARRAY_SIZE(shortcut))) + { break; } item_step += strlen(item_step) + 1; @@ -1062,7 +1066,8 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz) IDProperty *prop = static_cast(gzop->ptr.data); char buf[128]; if (WM_key_event_operator_string( - C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true, buf, ARRAY_SIZE(buf))) { + C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true, buf, ARRAY_SIZE(buf))) + { uiTooltipField *field = text_field_add( data, uiTooltipFormat::Style::Normal, uiTooltipFormat::ColorID::Value, true); field->text = BLI_sprintfN(TIP_("Shortcut: %s"), buf); diff --git a/source/blender/editors/interface/interface_template_asset_view.cc b/source/blender/editors/interface/interface_template_asset_view.cc index 71bd66ff651..a21d5693a6a 100644 --- a/source/blender/editors/interface/interface_template_asset_view.cc +++ b/source/blender/editors/interface/interface_template_asset_view.cc @@ -188,8 +188,8 @@ static void populate_asset_collection(const AssetLibraryReference &asset_library RNA_warning("Expected a collection property"); return; } - if (!RNA_struct_is_a(RNA_property_pointer_type(&assets_dataptr, assets_prop), - &RNA_AssetHandle)) { + if (!RNA_struct_is_a(RNA_property_pointer_type(&assets_dataptr, assets_prop), &RNA_AssetHandle)) + { RNA_warning("Expected a collection property for AssetHandle items"); return; } diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index 28ffee73ca3..01b573fee2a 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -432,7 +432,8 @@ static void ui_template_list_collect_items(PointerRNA *list_ptr, RNA_PROP_BEGIN (list_ptr, itemptr, list_prop) { if (!dyn_data->items_filter_flags || - ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) { + ((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude)) + { int new_order_idx; if (dyn_data->items_filter_neworder) { new_order_idx = dyn_data->items_filter_neworder[reorder_i++]; @@ -838,7 +839,8 @@ static void ui_template_list_layout_draw(const bContext *C, row = uiLayoutRow(layout, true); if ((input_data->dataptr.data && input_data->prop) && (dyn_data->items_shown > 0) && - (items->active_item_idx >= 0) && (items->active_item_idx < dyn_data->items_shown)) { + (items->active_item_idx >= 0) && (items->active_item_idx < dyn_data->items_shown)) + { PointerRNA *itemptr = &items->item_vec[items->active_item_idx].item; const int org_i = items->item_vec[items->active_item_idx].org_idx; @@ -1229,7 +1231,8 @@ uiList *uiTemplateList_ex(uiLayout *layout, active_propname, item_dyntip_propname, &input_data, - &ui_list_type)) { + &ui_list_type)) + { return nullptr; } diff --git a/source/blender/editors/interface/interface_template_search_menu.cc b/source/blender/editors/interface/interface_template_search_menu.cc index 547811ef1f8..a04c1cbfa18 100644 --- a/source/blender/editors/interface/interface_template_search_menu.cc +++ b/source/blender/editors/interface/interface_template_search_menu.cc @@ -197,7 +197,8 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data, &but->rnapoin, but->rnaprop, value_enum, - &enum_item)) { + &enum_item)) + { drawstr_override = enum_item.name; } else { @@ -378,8 +379,8 @@ static void menu_items_from_all_operators(bContext *C, MenuSearch_Data *data) MemArena *memarena = data->memarena; GHashIterator iter; - for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); - BLI_ghashIterator_step(&iter)) { + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) + { wmOperatorType *ot = (wmOperatorType *)BLI_ghashIterator_getValue(&iter); if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) { @@ -562,7 +563,8 @@ static MenuSearch_Data *menu_items_from_ui_create( GHashIterator iter; for (int space_type_ui_index = -1; space_type_ui_index < space_type_ui_items_len; - space_type_ui_index += 1) { + space_type_ui_index += 1) + { ScrArea *area = nullptr; ARegion *region = nullptr; diff --git a/source/blender/editors/interface/interface_template_search_operator.cc b/source/blender/editors/interface/interface_template_search_operator.cc index 3e28461e0f6..6ceb419291d 100644 --- a/source/blender/editors/interface/interface_template_search_operator.cc +++ b/source/blender/editors/interface/interface_template_search_operator.cc @@ -58,8 +58,8 @@ static void operator_search_update_fn(const bContext *C, const int words_len = BLI_string_find_split_words( str, str_len, ' ', (int(*)[2])words.data(), words_max); - for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); - BLI_ghashIterator_step(&iter)) { + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) + { wmOperatorType *ot = static_cast(BLI_ghashIterator_getValue(&iter)); const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name); @@ -83,7 +83,8 @@ static void operator_search_update_fn(const bContext *C, nullptr, true, &name[len + 1], - sizeof(name) - len - 1)) { + sizeof(name) - len - 1)) + { name[len] = UI_SEP_CHAR; } } diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 2b5365420c4..df75a04446d 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -399,7 +399,8 @@ static bool id_search_add(const bContext *C, TemplateID *template_ui, uiSearchIt id, iconid, has_sep_char ? int(UI_BUT_HAS_SEP_CHAR) : 0, - name_prefix_offset)) { + name_prefix_offset)) + { return false; } @@ -605,7 +606,8 @@ static void template_id_liboverride_hierarchy_collection_root_find_recursive( } for (CollectionParent *iter = static_cast(collection->runtime.parents.first); iter != nullptr; - iter = iter->next) { + iter = iter->next) + { if (iter->collection->id.lib != collection->id.lib && ID_IS_LINKED(iter->collection)) { continue; } @@ -625,7 +627,8 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive( for (CollectionParent *iter = static_cast(root_collection->runtime.parents.first); iter != nullptr; - iter = iter->next) { + iter = iter->next) + { if (ID_IS_LINKED(iter->collection)) { continue; } @@ -635,7 +638,8 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive( for (CollectionChild *iter = static_cast(root_collection->children.first); iter != nullptr; - iter = iter->next) { + iter = iter->next) + { if (iter->collection->id.lib != root_collection->id.lib && ID_IS_LINKED(root_collection)) { continue; } @@ -643,11 +647,13 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive( continue; } if (GS(target_id->name) == ID_OB && - !BKE_collection_has_object_recursive(iter->collection, (Object *)target_id)) { + !BKE_collection_has_object_recursive(iter->collection, (Object *)target_id)) + { continue; } if (GS(target_id->name) == ID_GR && - !BKE_collection_has_collection(iter->collection, (Collection *)target_id)) { + !BKE_collection_has_collection(iter->collection, (Collection *)target_id)) + { continue; } template_id_liboverride_hierarchy_collections_tag_recursive( @@ -669,8 +675,8 @@ ID *ui_template_id_liboverride_hierarchy_make( if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { BKE_lib_override_library_get(bmain, id, nullptr, &id); } - if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) { - id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + if (id->override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) { + id->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; *r_undo_push_label = "Make Library Override Hierarchy Editable"; } else { @@ -698,8 +704,8 @@ ID *ui_template_id_liboverride_hierarchy_make( } if (object_active != nullptr) { if (ID_IS_LINKED(object_active)) { - if (object_active->id.lib != id->lib || - !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(object_active)) { + if (object_active->id.lib != id->lib || !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(object_active)) + { /* The active object is from a different library than the overridden ID, or otherwise * cannot be used in hierarchy. */ object_active = nullptr; @@ -718,7 +724,8 @@ ID *ui_template_id_liboverride_hierarchy_make( if (collection_active != nullptr) { if (ID_IS_LINKED(collection_active)) { if (collection_active->id.lib != id->lib || - !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(collection_active)) { + !ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(collection_active)) + { /* The active collection is from a different library than the overridden ID, or otherwise * cannot be used in hierarchy. */ collection_active = nullptr; @@ -737,7 +744,8 @@ ID *ui_template_id_liboverride_hierarchy_make( } } if (collection_active == nullptr && object_active != nullptr && - (ID_IS_LINKED(object_active) || ID_IS_OVERRIDE_LIBRARY_REAL(object_active))) { + (ID_IS_LINKED(object_active) || ID_IS_OVERRIDE_LIBRARY_REAL(object_active))) + { /* If we failed to find a valid 'active' collection so far for our override hierarchy, but do * have a valid 'active' object, try to find a collection from that object. */ LISTBASE_FOREACH (Collection *, collection_iter, &bmain->collections) { @@ -762,7 +770,8 @@ ID *ui_template_id_liboverride_hierarchy_make( switch (GS(id->name)) { case ID_GR: if (collection_active != nullptr && - BKE_collection_has_collection(collection_active, (Collection *)id)) { + BKE_collection_has_collection(collection_active, (Collection *)id)) + { template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); if (object_active != nullptr) { object_active->id.tag |= LIB_TAG_DOIT; @@ -778,7 +787,8 @@ ID *ui_template_id_liboverride_hierarchy_make( false); } else if (object_active != nullptr && !ID_IS_LINKED(object_active) && - &object_active->instance_collection->id == id) { + &object_active->instance_collection->id == id) + { object_active->id.tag |= LIB_TAG_DOIT; BKE_lib_override_library_create(bmain, scene, @@ -793,7 +803,8 @@ ID *ui_template_id_liboverride_hierarchy_make( break; case ID_OB: if (collection_active != nullptr && - BKE_collection_has_object_recursive(collection_active, (Object *)id)) { + BKE_collection_has_object_recursive(collection_active, (Object *)id)) + { template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); if (object_active != nullptr) { object_active->id.tag |= LIB_TAG_DOIT; @@ -833,7 +844,8 @@ ID *ui_template_id_liboverride_hierarchy_make( case ID_NT: /* Essentially geometry nodes from modifier currently. */ if (object_active != nullptr) { if (collection_active != nullptr && - BKE_collection_has_object_recursive(collection_active, object_active)) { + BKE_collection_has_object_recursive(collection_active, object_active)) + { template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true); if (object_active != nullptr) { object_active->id.tag |= LIB_TAG_DOIT; @@ -883,7 +895,7 @@ ID *ui_template_id_liboverride_hierarchy_make( } if (id_override != nullptr) { - id_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id_override->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; *r_undo_push_label = "Make Library Override Hierarchy"; /* In theory we could rely on setting/updating the RNA ID pointer property (as done by calling @@ -1445,7 +1457,8 @@ static void template_ID(const bContext *C, but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ALONE)); if (!BKE_id_copy_is_allowed(id) || (idfrom && idfrom->lib) || (!editable) || /* object in editmode - don't change data */ - (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT))) { + (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT))) + { UI_but_flag_enable(but, UI_BUT_DISABLED); } } @@ -1470,8 +1483,8 @@ static void template_ID(const bContext *C, UI_UNIT_Y, nullptr); } - else if (!ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS) && - (hide_buttons == false)) { + else if (!ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS) && (hide_buttons == false)) + { uiDefIconButR(block, UI_BTYPE_ICON_TOGGLE, 0, @@ -2152,7 +2165,8 @@ static PropertyRNA *template_search_get_searchprop(PointerRNA *targetptr, } /* check if searchprop has same type as targetprop */ else if (RNA_property_pointer_type(searchptr, searchprop) != - RNA_property_pointer_type(targetptr, targetprop)) { + RNA_property_pointer_type(targetptr, targetprop)) + { RNA_warning("search collection items from %s.%s are not of type %s", RNA_struct_identifier(searchptr->type), searchpropname, @@ -2447,7 +2461,8 @@ void uiTemplateConstraints(uiLayout * /*layout*/, bContext *C, bool use_bone_con for (bConstraint *con = (constraints == nullptr) ? nullptr : static_cast(constraints->first); con; - con = con->next) { + con = con->next) + { /* Don't show invalid/legacy constraints. */ if (con->type == CONSTRAINT_TYPE_NULL) { continue; @@ -2538,7 +2553,8 @@ void uiTemplateGpencilModifiers(uiLayout * /*layout*/, bContext *C) if (!panels_match) { UI_panels_free_instanced(C, region); for (GpencilModifierData *md = static_cast(modifiers->first); md; - md = md->next) { + md = md->next) + { const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( GpencilModifierType(md->type)); if (mti->panelRegister == nullptr) { @@ -2674,7 +2690,8 @@ static bool ui_layout_operator_buts_poll_property(PointerRNA * /*ptr*/, user_data); if ((params->flag & UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED) && - (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) { + (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) + { return false; } return params->op->type->poll_property(params->C, params->op, prop); @@ -6193,7 +6210,8 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) break; } if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) || - WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE)) { + WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE)) + { /* Skip bake jobs in compositor to avoid compo header displaying * progress bar which is not being updated (bake jobs only need * to update NC_IMAGE context. diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index c6b6db261d7..bbb726811d3 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -148,7 +148,8 @@ uiBut *uiDefAutoButR(uiBlock *block, } } else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || - RNA_property_subtype(prop) == PROP_FACTOR) { + RNA_property_subtype(prop) == PROP_FACTOR) + { but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, @@ -1116,8 +1117,9 @@ static bool ui_key_event_property_match(const char *opname, bool match = false; if (properties) { - if (ui_opptr && IDP_EqualsProperties_ex( - properties, static_cast(ui_opptr->data), is_strict)) { + if (ui_opptr && + IDP_EqualsProperties_ex(properties, static_cast(ui_opptr->data), is_strict)) + { match = true; } } @@ -1175,7 +1177,8 @@ const char *UI_key_event_operator_string(const bContext *C, properties, is_strict, dyn_data->custom_activate_optype, - dyn_data->custom_activate_opptr)) { + dyn_data->custom_activate_opptr)) + { event_val = KM_CLICK; event_type = LEFTMOUSE; } @@ -1184,7 +1187,8 @@ const char *UI_key_event_operator_string(const bContext *C, properties, is_strict, dyn_data->custom_drag_optype, - dyn_data->custom_drag_opptr)) { + dyn_data->custom_drag_opptr)) + { event_val = KM_CLICK_DRAG; event_type = LEFTMOUSE; } diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index ca2834be58b..7bb662845aa 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -1273,7 +1273,8 @@ static void widgetbase_draw_ex(uiWidgetBase *wtb, /* Draw everything in one draw-call. */ if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || - show_alpha_checkers) { + show_alpha_checkers) + { widgetbase_set_uniform_colors_ubv( wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, show_alpha_checkers); @@ -1391,7 +1392,8 @@ static void widget_draw_icon( if (but->drawflag & UI_BUT_ICON_LEFT) { /* special case - icon_only pie buttons */ if (ui_block_is_pie_menu(but->block) && !ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && - but->str && but->str[0] == '\0') { + but->str && but->str[0] == '\0') + { xs = rect->xmin + 2.0f * ofs; } else if (but->emboss == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) { @@ -2070,7 +2072,8 @@ static void widget_draw_text(const uiFontStyle *fstyle, if (!drawstr_right && (but->drawflag & UI_BUT_TEXT_LEFT) && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && /* if we're editing or multi-drag (fake editing), then use left alignment */ - (but->editstr == nullptr) && (drawstr == but->drawstr)) { + (but->editstr == nullptr) && (drawstr == but->drawstr)) + { drawstr_right = strrchr(drawstr + but->ofs, ':'); if (drawstr_right) { drawstr_right++; @@ -2128,7 +2131,8 @@ static void widget_draw_text(const uiFontStyle *fstyle, if (ul_index != -1) { rcti bounds; if (BLF_str_offset_to_glyph_bounds(fstyle->uifont_id, drawstr_ofs, ul_index, &bounds) && - !BLI_rcti_is_empty(&bounds)) { + !BLI_rcti_is_empty(&bounds)) + { int ul_width = round_fl_to_int(BLF_width(fstyle->uifont_id, "_", 2)); int pos_x = rect->xmin + font_xofs + bounds.xmin + (bounds.xmax - bounds.xmin - ul_width) / 2; @@ -2371,8 +2375,8 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* Menu contains sub-menu items with triangle icon on their right. Shortcut * strings should be drawn with some padding to the right then. */ - if (ui_block_is_menu(but->block) && - (but->block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT)) { + if (ui_block_is_menu(but->block) && (but->block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT)) + { rect->xmax -= UI_MENU_SUBMENU_PADDING; } @@ -3841,7 +3845,8 @@ static void widget_swatch(uiBut *but, if ((state->but_flag & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_OVERRIDDEN | UI_BUT_REDALERT)) || - (state->but_drawflag & UI_BUT_ANIMATED_CHANGED)) { + (state->but_drawflag & UI_BUT_ANIMATED_CHANGED)) + { /* draw based on state - color for keyed etc */ widgetbase_draw(&wtb, wcol); @@ -3871,7 +3876,8 @@ static void widget_swatch(uiBut *but, widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers); if (color_but->is_pallete_color && - ((Palette *)but->rnapoin.owner_id)->active_color == color_but->palette_color_index) { + ((Palette *)but->rnapoin.owner_id)->active_color == color_but->palette_color_index) + { const float width = rect->xmax - rect->xmin; const float height = rect->ymax - rect->ymin; /* find color luminance and change it slightly */ @@ -3919,7 +3925,8 @@ static void widget_icon_has_anim(uiBut *but, { if (state->but_flag & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT) && - but->emboss != UI_EMBOSS_NONE) { + but->emboss != UI_EMBOSS_NONE) + { uiWidgetBase wtb; widget_init(&wtb); wtb.draw_outline = false; @@ -4796,7 +4803,8 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but, * add up/down arrows if there is room. */ if ((!but->str[0] && but->icon && (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect) + 2)) || /* disable for brushes also */ - (but->flag & UI_BUT_ICON_PREVIEW)) { + (but->flag & UI_BUT_ICON_PREVIEW)) + { /* no arrows */ wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); } diff --git a/source/blender/editors/interface/resources.cc b/source/blender/editors/interface/resources.cc index 6a2e2ff9073..30eae24505c 100644 --- a/source/blender/editors/interface/resources.cc +++ b/source/blender/editors/interface/resources.cc @@ -1404,8 +1404,8 @@ bool UI_GetIconThemeColor4ubv(int colorid, uchar col[4]) g_theme_state.regionid == RGN_TYPE_WINDOW) || (g_theme_state.spacetype == SPACE_PROPERTIES && g_theme_state.regionid == RGN_TYPE_NAV_BAR) || - (g_theme_state.spacetype == SPACE_FILE && - g_theme_state.regionid == RGN_TYPE_WINDOW))) { + (g_theme_state.spacetype == SPACE_FILE && g_theme_state.regionid == RGN_TYPE_WINDOW))) + { /* Only colored icons in specific places, overall UI is intended * to stay monochrome and out of the way except a few places where it * is important to communicate different data types. */ diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 1c551d0b525..fd5800f67ea 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -44,6 +44,7 @@ #include "UI_view2d.h" #include "interface_intern.hh" +#include "view2d_intern.hh" static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); @@ -368,7 +369,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* set 'tot' rect before setting cur? */ /* XXX confusing stuff here still */ if (tot_changed) { - UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init); + view2d_totRect_set_resize(v2d, winx, winy, !do_init); } else { ui_view2d_curRect_validate_resize(v2d, !do_init); @@ -960,7 +961,7 @@ void UI_view2d_curRect_reset(View2D *v2d) /* ------------------ */ -void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize) +void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize) { /* don't do anything if either value is 0 */ width = abs(width); @@ -1021,7 +1022,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz void UI_view2d_totRect_set(View2D *v2d, int width, int height) { - UI_view2d_totRect_set_resize(v2d, width, height, false); + view2d_totRect_set_resize(v2d, width, height, false); } void UI_view2d_zoom_cache_reset(void) @@ -1367,28 +1368,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, /** \name Scrollers * \{ */ -/** - * View2DScrollers is typedef'd in UI_view2d.h - * - * \warning The start of this struct must not change, as view2d_ops.c uses this too. - * For now, we don't need to have a separate (internal) header for structs like this... - */ -struct View2DScrollers { - /* focus bubbles */ - /* focus bubbles */ - /* focus bubbles */ - int vert_min, vert_max; /* vertical scroll-bar */ - int hor_min, hor_max; /* horizontal scroll-bar */ - - /** Exact size of slider backdrop. */ - rcti hor, vert; - /* set if sliders are full, we don't draw them */ - /* int horfull, vertfull; */ /* UNUSED */ -}; - -void UI_view2d_scrollers_calc(View2D *v2d, - const rcti *mask_custom, - struct View2DScrollers *r_scrollers) +void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers) { rcti vert, hor; float fac1, fac2, totsize, scrollsize; @@ -1515,7 +1495,7 @@ void UI_view2d_scrollers_calc(View2D *v2d, void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_full_hide) { View2DScrollers scrollers; - UI_view2d_scrollers_calc(v2d, mask_custom, &scrollers); + view2d_scrollers_calc(v2d, mask_custom, &scrollers); bTheme *btheme = UI_GetTheme(); rcti vert, hor; const int scroll = view2d_scroll_mapped(v2d->scroll); @@ -1559,7 +1539,8 @@ void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_ * and only the time-grids with their zoom-ability can do so). */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) && - (BLI_rcti_size_x(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) { + (BLI_rcti_size_x(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) + { state |= UI_SCROLL_ARROWS; } @@ -1594,7 +1575,8 @@ void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_ * and only the time-grids with their zoomability can do so) */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) && - (BLI_rcti_size_y(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) { + (BLI_rcti_size_y(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) + { state |= UI_SCROLL_ARROWS; } @@ -1827,7 +1809,8 @@ bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1]; if (((rect_tmp.xmax < 0.0f) || (rect_tmp.xmin > 1.0f) || (rect_tmp.ymax < 0.0f) || - (rect_tmp.ymin > 1.0f)) == 0) { + (rect_tmp.ymin > 1.0f)) == 0) + { /* Step 2: convert proportional distances to screen coordinates. */ rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]); rect_tmp.xmax = v2d->mask.ymin + (rect_tmp.xmax * mask_size[0]); diff --git a/source/blender/editors/interface/view2d_edge_pan.cc b/source/blender/editors/interface/view2d_edge_pan.cc index c5392ba024a..aa531099ae7 100644 --- a/source/blender/editors/interface/view2d_edge_pan.cc +++ b/source/blender/editors/interface/view2d_edge_pan.cc @@ -25,11 +25,13 @@ #include "WM_api.h" #include "WM_types.h" +#include "view2d_intern.hh" + /* -------------------------------------------------------------------- */ /** \name Edge Pan Operator Utilities * \{ */ -bool UI_view2d_edge_pan_poll(bContext *C) +bool view2d_edge_pan_poll(bContext *C) { ARegion *region = CTX_wm_region(C); @@ -58,7 +60,7 @@ void UI_view2d_edge_pan_init(bContext *C, float delay, float zoom_influence) { - if (!UI_view2d_edge_pan_poll(C)) { + if (!view2d_edge_pan_poll(C)) { return; } diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.cc b/source/blender/editors/interface/view2d_gizmo_navigate.cc index 9e7a62e140e..9074f6ab62c 100644 --- a/source/blender/editors/interface/view2d_gizmo_navigate.cc +++ b/source/blender/editors/interface/view2d_gizmo_navigate.cc @@ -214,7 +214,8 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g const rcti *rect_visible = ED_region_visible_rect(region); if ((navgroup->state.rect_visible.xmax == rect_visible->xmax) && - (navgroup->state.rect_visible.ymax == rect_visible->ymax)) { + (navgroup->state.rect_visible.ymax == rect_visible->ymax)) + { return; } diff --git a/source/blender/editors/interface/view2d_intern.hh b/source/blender/editors/interface/view2d_intern.hh new file mode 100644 index 00000000000..36c9f5610d6 --- /dev/null +++ b/source/blender/editors/interface/view2d_intern.hh @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup edinterface + * + * Share between view2d_*.cc files. + */ + +#pragma once + +#include "DNA_vec_types.h" + +struct bContext; +struct View2D; + +struct View2DScrollers { + /* focus bubbles */ + int vert_min, vert_max; /* vertical scroll-bar */ + int hor_min, hor_max; /* horizontal scroll-bar */ + + /** Exact size of slider backdrop. */ + rcti hor, vert; +}; + +/** + * Calculate relevant scroller properties. + */ +void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers); + +/** + * Change the size of the maximum viewable area (i.e. 'tot' rect). + */ +void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize); + +bool view2d_edge_pan_poll(bContext *C); diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index ac24bda1d19..7a5566d4007 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -32,6 +32,8 @@ #include "PIL_time.h" /* USER_ZOOM_CONTINUE */ +#include "view2d_intern.hh" + /* -------------------------------------------------------------------- */ /** \name Internal Utilities * \{ */ @@ -388,7 +390,7 @@ static void VIEW2D_OT_edge_pan(wmOperatorType *ot) ot->invoke = view_edge_pan_invoke; ot->modal = view_edge_pan_modal; ot->cancel = view_edge_pan_cancel; - ot->poll = UI_view2d_edge_pan_poll; + ot->poll = view2d_edge_pan_poll; /* operator is modal */ ot->flag = OPTYPE_INTERNAL; @@ -1244,7 +1246,8 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event /* Only respect user setting zoom axis if the view does not have any zoom restrictions * any will be scaled uniformly */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && - (v2d->keepzoom & V2D_KEEPASPECT)) { + (v2d->keepzoom & V2D_KEEPASPECT)) + { if (U.uiflag & USER_ZOOM_HORIZ) { facy = 0.0f; } @@ -1751,23 +1754,6 @@ struct v2dScrollerMove { int lastx, lasty; }; -/** - * #View2DScrollers is typedef'd in UI_view2d.h - * This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c, - * as we only need focus bubble info. - * - * \warning The start of this struct must not change, - * so that it stays in sync with the 'real' version. - * For now, we don't need to have a separate (internal) header for structs like this... - */ -struct View2DScrollers { - int vert_min, vert_max; /* vertical scrollbar */ - int hor_min, hor_max; /* horizontal scrollbar */ - - /* These values are written into, even if we don't use them. */ - rcti _hor, _vert; -}; - /* quick enum for vsm->zone (scroller handles) */ enum { SCROLLHANDLE_MIN = -1, @@ -1873,7 +1859,7 @@ static void scroller_activate_init(bContext *C, * - zooming must be allowed on this axis, otherwise, default to pan */ View2DScrollers scrollers; - UI_view2d_scrollers_calc(v2d, nullptr, &scrollers); + view2d_scrollers_calc(v2d, nullptr, &scrollers); /* Use a union of 'cur' & 'tot' in case the current view is far outside 'tot'. In this cases * moving the scroll bars has far too little effect and the view can get stuck #31476. */ @@ -2120,7 +2106,8 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent * */ if (ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { if (((vsm->scroller == 'h') && (v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) == 0) || - ((vsm->scroller == 'v') && (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) { + ((vsm->scroller == 'v') && (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) == 0)) + { /* switch to bar (i.e. no scaling gets handled) */ vsm->zone = SCROLLHANDLE_BAR; } @@ -2129,7 +2116,8 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent * /* check if zone is inappropriate (i.e. 'bar' but panning is banned), so cannot continue */ if (vsm->zone == SCROLLHANDLE_BAR) { if (((vsm->scroller == 'h') && (v2d->keepofs & V2D_LOCKOFS_X)) || - ((vsm->scroller == 'v') && (v2d->keepofs & V2D_LOCKOFS_Y))) { + ((vsm->scroller == 'v') && (v2d->keepofs & V2D_LOCKOFS_Y))) + { /* free customdata initialized */ scroller_activate_exit(C, op); @@ -2140,7 +2128,8 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent * /* zone is also inappropriate if scroller is not visible... */ if (((vsm->scroller == 'h') && (v2d->scroll & V2D_SCROLL_HORIZONTAL_FULLR)) || - ((vsm->scroller == 'v') && (v2d->scroll & V2D_SCROLL_VERTICAL_FULLR))) { + ((vsm->scroller == 'v') && (v2d->scroll & V2D_SCROLL_VERTICAL_FULLR))) + { /* free customdata initialized */ scroller_activate_exit(C, op); diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index 37d7ffef499..8b0c42e2bda 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -368,7 +368,8 @@ void GridViewLayoutBuilder::build_from_view(const AbstractGridView &grid_view, * stretch over the entire width. */ if (grid_view.get_item_count() < cols_per_row) { for (int padding_item_idx = 0; padding_item_idx < (cols_per_row - grid_view.get_item_count()); - padding_item_idx++) { + padding_item_idx++) + { uiItemS(grid_layout); } } diff --git a/source/blender/editors/interface/views/interface_view.cc b/source/blender/editors/interface/views/interface_view.cc index 2e62c7d425b..4c6fd59361a 100644 --- a/source/blender/editors/interface/views/interface_view.cc +++ b/source/blender/editors/interface/views/interface_view.cc @@ -293,7 +293,8 @@ uiButViewItem *ui_block_view_find_matching_view_item_but_in_old_block( } if (UI_view_item_matches(reinterpret_cast(&new_item), - reinterpret_cast(&old_item))) { + reinterpret_cast(&old_item))) + { return old_item_but; } } diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 9732c23a519..1027fd6d37e 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -372,7 +372,8 @@ bool AbstractTreeViewItem::matches(const AbstractViewItem &other) const for (AbstractTreeViewItem *parent = parent_, *other_parent = other_tree_item.parent_; parent && other_parent; - parent = parent->parent_, other_parent = other_parent->parent_) { + parent = parent->parent_, other_parent = other_parent->parent_) + { if (!parent->matches_single(*other_parent)) { return false; } @@ -437,7 +438,8 @@ void TreeViewLayoutBuilder::polish_layout(const uiBlock &block) LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block.buttons) { if (AbstractTreeViewItem::is_collapse_chevron_but(but) && but->next && /* Embossed buttons with padding-less text padding look weird, so don't touch them. */ - ELEM(but->next->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) { + ELEM(but->next->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) + { UI_but_drawflag_enable(static_cast(but->next), UI_BUT_NO_TEXT_PADDING); } diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index b0301ca9009..fe8dde53b5e 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -503,11 +503,11 @@ static int get_sequence_len(const char *filename, int *ofs) } char path[FILE_MAX]; - BLI_split_dir_part(filename, path, FILE_MAX); + BLI_path_split_dir_part(filename, path, FILE_MAX); if (path[0] == '\0') { /* The filename had no path, so just use the blend file path. */ - BLI_split_dir_part(BKE_main_blendfile_path_from_global(), path, FILE_MAX); + BLI_path_split_dir_part(BKE_main_blendfile_path_from_global(), path, FILE_MAX); } else { BLI_path_abs(path, BKE_main_blendfile_path_from_global()); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 5de69694616..e12bd6c52a3 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -93,7 +93,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* Avoid File write exceptions in Collada */ if (!BLI_exists(filepath)) { - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); if (!BLI_file_touch(filepath)) { BKE_report(op->reports, RPT_ERROR, "Can't create export file"); fprintf(stdout, "Collada export: Can not create: %s\n", filepath); diff --git a/source/blender/editors/io/io_gpencil_import.c b/source/blender/editors/io/io_gpencil_import.c index 91c719849cc..4ecd3782361 100644 --- a/source/blender/editors/io/io_gpencil_import.c +++ b/source/blender/editors/io/io_gpencil_import.c @@ -66,7 +66,8 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false) || - !RNA_struct_find_property(op->ptr, "directory")) { + !RNA_struct_find_property(op->ptr, "directory")) + { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/io/io_stl_ops.c b/source/blender/editors/io/io_stl_ops.c index bbdb494e48a..558bd55a7fe 100644 --- a/source/blender/editors/io/io_stl_ops.c +++ b/source/blender/editors/io/io_stl_ops.c @@ -76,7 +76,8 @@ static bool wm_stl_import_check(bContext *UNUSED(C), wmOperator *op) const int num_axes = 3; /* Both forward and up axes cannot be the same (or same except opposite sign). */ if (RNA_enum_get(op->ptr, "forward_axis") % num_axes == - (RNA_enum_get(op->ptr, "up_axis") % num_axes)) { + (RNA_enum_get(op->ptr, "up_axis") % num_axes)) + { RNA_enum_set(op->ptr, "up_axis", RNA_enum_get(op->ptr, "up_axis") % num_axes + 1); return true; } diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index 22a9d41fcf7..37e51277939 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -303,7 +303,8 @@ static int lattice_select_more_less(bContext *C, const bool select) lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) || lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) || lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) || - lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select)) { + lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select)) + { SET_FLAG_FROM_TEST(bp->f1, select, SELECT); } } diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 58767877750..fda54e1bbb4 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -256,7 +256,8 @@ static bool add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2 &spline, &point, &u, - NULL)) { + NULL)) + { Scene *scene = CTX_data_scene(C); const float ctime = scene->r.cfra; @@ -320,7 +321,8 @@ static bool add_vertex_extrude(const bContext *C, MASKPOINT_DESEL_ALL(point); if ((spline->flag & MASK_SPLINE_CYCLIC) || - (point_index > 0 && point_index != spline->tot_point - 1)) { + (point_index > 0 && point_index != spline->tot_point - 1)) + { BKE_mask_calc_tangent_polyline(spline, point, tangent_point); sub_v2_v2v2(tangent_co, co, point->bezt.vec[1]); @@ -530,7 +532,8 @@ static int add_vertex_exec(bContext *C, wmOperator *op) /* TODO: having an active point but no active spline is possible, why? */ if (mask_layer && mask_layer->act_spline && mask_layer->act_point && - MASKPOINT_ISSEL_ANY(mask_layer->act_point)) { + MASKPOINT_ISSEL_ANY(mask_layer->act_point)) + { MaskSpline *spline = mask_layer->act_spline; MaskSplinePoint *active_point = mask_layer->act_point; const int cyclic_result = add_vertex_handle_cyclic(C, mask, spline, active_point, co); @@ -623,19 +626,9 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - if (ED_mask_find_nearest_diff_point(C, - mask, - co, - threshold, - true, - NULL, - true, - true, - &mask_layer, - &spline, - &point, - &u, - NULL)) { + if (ED_mask_find_nearest_diff_point( + C, mask, co, threshold, true, NULL, true, true, &mask_layer, &spline, &point, &u, NULL)) + { float w = BKE_mask_point_weight(spline, point, u); float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 8e9384cd2d9..fbd89e54634 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -600,7 +600,8 @@ static void draw_mask_layers( MaskLayer *active = NULL; for (mask_layer = mask->masklayers.first, i = 0; mask_layer != NULL; - mask_layer = mask_layer->next, i++) { + mask_layer = mask_layer->next, i++) + { const bool is_active = (i == mask->masklay_act); if (mask_layer->visibility_flag & MASK_HIDE_VIEW) { @@ -800,7 +801,8 @@ void ED_mask_draw_frames( for (MaskLayerShape *mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape != NULL; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { int frame = mask_layer_shape->frame; // draw_keyframe(i, scene->r.cfra, sfra, framelen, 1); diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 8ec6c356fd7..45107a8a248 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -49,7 +49,8 @@ bool ED_masklayer_frames_looper(MaskLayer *mask_layer, /* do loop */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { /* execute callback */ if (mask_layer_shape_cb(mask_layer_shape, scene)) { return true; @@ -75,7 +76,8 @@ void ED_masklayer_make_cfra_list(MaskLayer *mask_layer, ListBase *elems, bool on /* loop through mask-frames, adding */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { if ((onlysel == false) || (mask_layer_shape->flag & MASK_SHAPE_SELECT)) { ce = MEM_callocN(sizeof(CfraElem), "CfraElem"); @@ -101,7 +103,8 @@ bool ED_masklayer_frame_select_check(const MaskLayer *mask_layer) /* stop at the first one found */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { return true; } @@ -142,7 +145,8 @@ void ED_mask_select_frames(MaskLayer *mask_layer, short select_mode) /* handle according to mode */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { mask_layer_shape_select(mask_layer_shape, select_mode); } } @@ -183,7 +187,8 @@ void ED_masklayer_frames_select_box(MaskLayer *mask_layer, float min, float max, /* only select those frames which are in bounds */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { if (IN_RANGE(mask_layer_shape->frame, min, max)) { mask_layer_shape_select(mask_layer_shape, select_mode); } @@ -203,7 +208,8 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked, /* only select frames which are within the region */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { /* construct a dummy point coordinate to do this testing with */ float pt[2] = {0}; @@ -241,7 +247,8 @@ bool ED_masklayer_frames_delete(MaskLayer *mask_layer) /* check for frames to delete */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape_next) { + mask_layer_shape = mask_layer_shape_next) + { mask_layer_shape_next = mask_layer_shape->next; if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { @@ -264,7 +271,8 @@ void ED_masklayer_frames_duplicate(MaskLayer *mask_layer) /* Duplicate selected frames. */ for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = gpfn) { + mask_layer_shape = gpfn) + { gpfn = mask_layer_shape->next; /* Duplicate this frame. */ diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 58b3b07e1be..485386e4dae 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -274,14 +274,16 @@ static bool spline_under_mouse_get(const bContext *C, for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { if ((spline_orig->flag & SELECT) == 0) { continue; } @@ -308,7 +310,8 @@ static bool spline_under_mouse_get(const bContext *C, float dist_squared = len_squared_v2v2(pixel_co, center); float max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height); if (dist_squared <= max_bb_side * max_bb_side * 0.5f && - (closest_spline == NULL || dist_squared < closest_dist_squared)) { + (closest_spline == NULL || dist_squared < closest_dist_squared)) + { closest_layer = mask_layer_orig; closest_spline = spline_orig; closest_dist_squared = dist_squared; @@ -329,7 +332,8 @@ static bool spline_under_mouse_get(const bContext *C, NULL, NULL, NULL, - &diff_score)) { + &diff_score)) + { if (square_f(diff_score) < closest_dist_squared) { return false; } @@ -444,7 +448,8 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent * &feather_spline, &feather_point, &uw, - &feather_score)) { + &feather_score)) + { if (slide_feather || !cv_point || feather_score < cv_score) { action = SLIDE_ACTION_FEATHER; @@ -687,7 +692,8 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) if (data->is_sliding_new_point && data->which_handle == MASK_WHICH_HANDLE_STICK) { if (ELEM(data->point, &data->spline->points[0], - &data->spline->points[data->spline->tot_point - 1])) { + &data->spline->points[data->spline->tot_point - 1])) + { SWAP(float, delta[0], delta[1]); delta[1] *= -1; @@ -1004,7 +1010,8 @@ static SlideSplineCurvatureData *slide_spline_curvature_customdata(bContext *C, &spline, &point, &u, - NULL)) { + NULL)) + { return NULL; } diff --git a/source/blender/editors/mask/mask_query.c b/source/blender/editors/mask/mask_query.c index 720820df420..4a121dad1b9 100644 --- a/source/blender/editors/mask/mask_query.c +++ b/source/blender/editors/mask/mask_query.c @@ -70,7 +70,8 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } @@ -78,13 +79,15 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { int i; MaskSplinePoint *cur_point_eval; for (i = 0, cur_point_eval = use_deform ? spline_eval->points_deform : spline_eval->points; i < spline_eval->tot_point; - i++, cur_point_eval++) { + i++, cur_point_eval++) + { uint tot_diff_point; float *diff_points = BKE_mask_point_segment_diff( spline_eval, cur_point_eval, width, height, &tot_diff_point); @@ -229,7 +232,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; @@ -238,7 +242,8 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval); for (int i = 0; i < spline_orig->tot_point; i++) { @@ -384,12 +389,14 @@ bool ED_mask_feather_find_nearest(const bContext *C, for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { // MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); int i, tot_feather_point; @@ -620,7 +627,8 @@ bool ED_mask_selected_minmax(const bContext *C, INIT_MINMAX2(min, max); for (MaskLayer *mask_layer = mask_eval->masklayers.first; mask_layer != NULL; - mask_layer = mask_layer->next) { + mask_layer = mask_layer->next) + { if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 2493429c36f..7ec061fea67 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -453,14 +453,16 @@ static int box_select_exec(bContext *C, wmOperator *op) for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval); @@ -546,14 +548,16 @@ static bool do_lasso_select_mask(bContext *C, for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval); @@ -579,7 +583,8 @@ static bool do_lasso_select_mask(bContext *C, &screen_co[1]); if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && - BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) { + BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) + { BKE_mask_point_select_set(point, select); BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select); changed = true; @@ -695,14 +700,16 @@ static int circle_select_exec(bContext *C, wmOperator *op) for (MaskLayer *mask_layer_orig = mask_orig->masklayers.first, *mask_layer_eval = mask_eval->masklayers.first; mask_layer_orig != NULL; - mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) { + mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next) + { if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) { continue; } for (MaskSpline *spline_orig = mask_layer_orig->splines.first, *spline_eval = mask_layer_eval->splines.first; spline_orig != NULL; - spline_orig = spline_orig->next, spline_eval = spline_eval->next) { + spline_orig = spline_orig->next, spline_eval = spline_eval->next) + { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval); diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 12a34f51de4..ce376c5a99d 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -142,7 +142,8 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op) BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape_reset); for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape->next) { + mask_layer_shape = mask_layer_shape->next) + { if (mask_layer_shape_reset->tot_vert == mask_layer_shape->tot_vert) { int i_abs = 0; @@ -237,7 +238,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) MaskLayerShape *mask_layer_shape_lastsel = NULL; for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; - mask_layer_shape = mask_layer_shape_next) { + mask_layer_shape = mask_layer_shape_next) + { MaskLayerShape *mask_layer_shape_a = NULL; MaskLayerShape *mask_layer_shape_b = NULL; @@ -249,7 +251,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) mask_layer_shape_lastsel = mask_layer_shape; } if ((mask_layer_shape->next == NULL) || - (((MaskLayerShape *)mask_layer_shape->next)->flag & MASK_SHAPE_SELECT) == 0) { + (((MaskLayerShape *)mask_layer_shape->next)->flag & MASK_SHAPE_SELECT) == 0) + { mask_layer_shape_a = mask_layer_shape_lastsel; mask_layer_shape_b = mask_layer_shape; mask_layer_shape_lastsel = NULL; @@ -270,7 +273,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) /* move keys */ for (mask_layer_shape_tmp = mask_layer_shape_a; mask_layer_shape_tmp && (mask_layer_shape_tmp != mask_layer_shape_tmp_last); - mask_layer_shape_tmp = mask_layer_shape_tmp_next) { + mask_layer_shape_tmp = mask_layer_shape_tmp_next) + { mask_layer_shape_tmp_next = mask_layer_shape_tmp->next; BLI_remlink(&mask_layer->splines_shapes, mask_layer_shape_tmp); BLI_addtail(&shapes_tmp, mask_layer_shape_tmp); @@ -278,7 +282,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) /* re-key, NOTE: can't modify the keys here since it messes up. */ for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp; - mask_layer_shape_tmp = mask_layer_shape_tmp->next) { + mask_layer_shape_tmp = mask_layer_shape_tmp->next) + { BKE_mask_layer_evaluate(mask_layer, mask_layer_shape_tmp->frame, true); mask_layer_shape_tmp_rekey = BKE_mask_layer_shape_verify_frame( mask_layer, mask_layer_shape_tmp->frame); @@ -288,7 +293,8 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) /* restore unselected points and free copies */ for (mask_layer_shape_tmp = shapes_tmp.first; mask_layer_shape_tmp; - mask_layer_shape_tmp = mask_layer_shape_tmp_next) { + mask_layer_shape_tmp = mask_layer_shape_tmp_next) + { /* restore */ int i_abs = 0; MaskLayerShapeElem *shape_ele_src; diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index 151272ca212..9baf7982026 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -393,8 +393,8 @@ void paintface_select_more(Mesh *mesh, const bool face_step) continue; } const IndexRange poly = polys[i]; - if (poly_has_selected_neighbor( - corner_edges.slice(poly), edges, select_vert.span, face_step)) { + if (poly_has_selected_neighbor(corner_edges.slice(poly), edges, select_vert.span, face_step)) + { select_poly.span[i] = true; } } @@ -460,7 +460,8 @@ void paintface_select_less(Mesh *mesh, const bool face_step) } const IndexRange poly = polys[i]; if (poly_has_unselected_neighbor( - corner_edges.slice(poly), edges, verts_of_unselected_faces, face_step)) { + corner_edges.slice(poly), edges, verts_of_unselected_faces, face_step)) + { select_poly.span[i] = false; } } @@ -747,8 +748,8 @@ void paintvert_select_linked_pick(bContext *C, const bool select) { uint index = uint(-1); - if (!ED_mesh_pick_vert( - C, ob, region_coordinates, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) { + if (!ED_mesh_pick_vert(C, ob, region_coordinates, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) + { return; } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index e19ff371637..d727a86a8d7 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -126,7 +126,8 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) 0, RNA_float_get(op->ptr, "size") / 2.0f, creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -188,7 +189,8 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) "create_cube matrix=%m4 size=%f calc_uvs=%b", creation_data.mat, RNA_float_get(op->ptr, "size"), - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -266,7 +268,8 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) cap_end, cap_tri, creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -340,7 +343,8 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) cap_tri, RNA_float_get(op->ptr, "depth"), creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -416,7 +420,8 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) cap_tri, RNA_float_get(op->ptr, "depth"), creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -489,7 +494,8 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) RNA_int_get(op->ptr, "y_subdivisions"), RNA_float_get(op->ptr, "size") / 2.0f, creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -562,7 +568,8 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) false, "create_monkey matrix=%m4 calc_uvs=%b", creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -627,7 +634,8 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) RNA_int_get(op->ptr, "ring_count"), RNA_float_get(op->ptr, "radius"), creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } @@ -694,7 +702,8 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) RNA_int_get(op->ptr, "subdivisions"), RNA_float_get(op->ptr, "radius"), creation_data.mat, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c index c6ee36b2c57..05eb8103a0a 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.c +++ b/source/blender/editors/mesh/editmesh_add_gizmo.c @@ -338,7 +338,8 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) "create_cube matrix=%m4 size=%f calc_uvs=%b", matrix, 1.0f, - calc_uvs)) { + calc_uvs)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 92e993f74a2..866c68bef53 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -671,13 +671,15 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) /* When activated from toolbar, need to convert left-mouse release to confirm. */ if (ELEM(etype, LEFTMOUSE, opdata->launch_event) && (eval == KM_RELEASE) && - RNA_boolean_get(op->ptr, "release_confirm")) { + RNA_boolean_get(op->ptr, "release_confirm")) + { etype = EVT_MODAL_MAP; eval = BEV_MODAL_CONFIRM; } /* Modal numinput active, try to handle numeric inputs first... */ if (etype != EVT_MODAL_MAP && eval == KM_PRESS && has_numinput && - handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) { + handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) + { edbm_bevel_numinput_set_value(op); edbm_bevel_calc(op); edbm_bevel_update_status_text(C, op); @@ -882,7 +884,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Modal numinput inactive, try to handle numeric inputs last... */ if (!handled && eval == KM_PRESS && - handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) { + handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) + { edbm_bevel_numinput_set_value(op); edbm_bevel_calc(op); edbm_bevel_update_status_text(C, op); diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index fa60e44d6ae..1160f27eaee 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -106,7 +106,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* If the properties are set or there is no rv3d, * skip modal and exec immediately. */ if ((CTX_wm_region_view3d(C) == NULL) || (RNA_struct_property_is_set(op->ptr, "plane_co") && - RNA_struct_property_is_set(op->ptr, "plane_no"))) { + RNA_struct_property_is_set(op->ptr, "plane_no"))) + { return mesh_bisect_exec(C, op); } diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 104d88878bf..566ef62b0e7 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -61,7 +61,8 @@ static void edbm_extrude_edge_exclude_mirror( BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(edge, hflag) && BM_edge_is_boundary(edge) && - BM_elem_flag_test(edge->l->f, hflag)) { + BM_elem_flag_test(edge->l->f, hflag)) + { float co1[3], co2[3]; copy_v3_v3(co1, edge->v1->co); @@ -787,7 +788,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w if ((ED_view3d_project_float_object(vc.region, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && (ED_view3d_project_float_object(vc.region, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK)) { + V3D_PROJ_RET_OK)) + { /* 2D rotate by 90d while adding. * (x, y) = (y, -x) * diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c index a6ed3379f7a..01858d12322 100644 --- a/source/blender/editors/mesh/editmesh_extrude_screw.c +++ b/source/blender/editors/mesh/editmesh_extrude_screw.c @@ -127,7 +127,8 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) turns * steps, DEG2RADF(360.0f * turns), obedit->object_to_world, - false)) { + false)) + { continue; } diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 9127fdff3d6..7bcbc1c5017 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -80,7 +80,8 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) obedit->object_to_world, use_normal_flip, dupli, - use_auto_merge)) { + use_auto_merge)) + { continue; } BMO_op_exec(bm, &spinop); diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index fa4ae7f984c..b3d48c8bfd5 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -388,7 +388,8 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } if ((event->type == opdata->launch_event) && (event->val == KM_RELEASE) && - RNA_boolean_get(op->ptr, "release_confirm")) { + RNA_boolean_get(op->ptr, "release_confirm")) + { edbm_inset_calc(op); edbm_inset_exit(C, op); return OPERATOR_FINISHED; @@ -448,7 +449,8 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) case EVT_PADENTER: case EVT_RETKEY: if ((event->val == KM_PRESS) || - ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) { + ((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm"))) + { edbm_inset_calc(op); edbm_inset_exit(C, op); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 83cefd1c09d..3e894bec727 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -655,7 +655,8 @@ static void bm_face_split_by_edges_island_connect( true, mem_arena_edgenet, &edge_arr_holes, - &edge_arr_holes_len)) { + &edge_arr_holes_len)) + { edge_arr_len = edge_arr_holes_len; edge_arr = edge_arr_holes; /* owned by the arena */ } @@ -921,7 +922,8 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) if (angle_signed_on_axis_v3v3v3_v3( l->prev->v->co, l->v->co, v_other->co, l->f->no) < angle_signed_on_axis_v3v3v3_v3( - l->prev->v->co, l->v->co, l->next->v->co, l->f->no)) { + l->prev->v->co, l->v->co, l->next->v->co, l->f->no)) + { dot_best = dot_test; l_best = l; } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 967a9e25fe6..aa932d78040 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -735,7 +735,8 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) /* Check for most recent cut (if cage is part of previous cut). */ if (!compare_v3v3(kfe->v1->cageco, kcd->prev.cage, KNIFE_FLT_EPSBIG) && - !compare_v3v3(kfe->v2->cageco, kcd->prev.cage, KNIFE_FLT_EPSBIG)) { + !compare_v3v3(kfe->v2->cageco, kcd->prev.cage, KNIFE_FLT_EPSBIG)) + { /* Determine acute angle. */ float angle1 = angle_v3v3v3(kcd->prev.cage, kcd->curr.cage, kfe->v1->cageco); float angle2 = angle_v3v3v3(kcd->prev.cage, kcd->curr.cage, kfe->v2->cageco); @@ -1360,7 +1361,8 @@ static void knife_bvh_raycast_cb(void *userdata, /* Discard clipped points. */ if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) && - ED_view3d_clipping_test(kcd->vc.rv3d, hit->co, false)) { + ED_view3d_clipping_test(kcd->vc.rv3d, hit->co, false)) + { return; } @@ -1977,7 +1979,8 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) for (int j = i - 1; j >= 0; j--) { KnifeLineHit *lhj = &linehits[j]; if (!lhj->kfe || fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || - fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) { + fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) + { break; } @@ -2061,7 +2064,8 @@ static bool knife_add_single_cut__is_linehit_outside_face(BMFace *f, else if (lh->kfe && lh->kfe->e) { BMLoop *l; /* side-of-edge */ if ((l = BM_face_edge_share_loop(f, lh->kfe->e)) && - (BM_loop_point_side_of_edge_test(l, co) < 0.0f)) { + (BM_loop_point_side_of_edge_test(l, co) < 0.0f)) + { return true; } } @@ -2083,11 +2087,13 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd, /* If the cut is on an edge. */ if ((lh1->v && lh2->v) && (lh1->v->v && lh2->v && lh2->v->v) && - (e_base = BM_edge_exists(lh1->v->v, lh2->v->v))) { + (e_base = BM_edge_exists(lh1->v->v, lh2->v->v))) + { return; } if (knife_add_single_cut__is_linehit_outside_face(f, lh1, lh2->hit) || - knife_add_single_cut__is_linehit_outside_face(f, lh2, lh1->hit)) { + knife_add_single_cut__is_linehit_outside_face(f, lh2, lh1->hit)) + { return; } @@ -2240,7 +2246,8 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li true, kcd->edgenet.arena, &edge_array_holes, - &edge_array_holes_len)) { + &edge_array_holes_len)) + { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { for (i = edge_array_len; i < edge_array_holes_len; i++) { BM_edge_select_set(bm, edge_array_holes[i], true); @@ -2371,7 +2378,8 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) /* Split bmesh edges where needed. */ for (list = BLI_smallhash_iternew(ehash, &hiter, (uintptr_t *)&e); list; - list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&e)) { + list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&e)) + { BLI_listbase_sort_r(list, sort_verts_by_dist_cb, e->v1->co); for (ref = list->first; ref; ref = ref->next) { @@ -2387,7 +2395,8 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) /* Do cuts for each face. */ for (list = BLI_smallhash_iternew(fhash, &hiter, (uintptr_t *)&f); list; - list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) { + list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) + { knife_make_face_cuts(kcd, bm, f, list); } @@ -2596,13 +2605,14 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd, * tessellation edge and might not hit either tessellation tri with * an exact test; * We will exclude hits near real edges by a later test. */ - if (isect_ray_tri_epsilon_v3( - v1, raydir, UNPACK3(tri_cos), &lambda, ray_tri_uv, KNIFE_FLT_EPS)) { + if (isect_ray_tri_epsilon_v3(v1, raydir, UNPACK3(tri_cos), &lambda, ray_tri_uv, KNIFE_FLT_EPS)) + { /* Check if line coplanar with tri. */ normal_tri_v3(tri_norm, UNPACK3(tri_cos)); plane_from_point_normal_v3(tri_plane, tri_cos[0], tri_norm); if ((dist_squared_to_plane_v3(v1, tri_plane) < KNIFE_FLT_EPS) && - (dist_squared_to_plane_v3(v2, tri_plane) < KNIFE_FLT_EPS)) { + (dist_squared_to_plane_v3(v2, tri_plane) < KNIFE_FLT_EPS)) + { return false; } interp_v3_v3v3v3_uv(hit_cageco, UNPACK3(tri_cos), ray_tri_uv); @@ -2676,7 +2686,8 @@ static bool coinciding_edges(BMEdge *e1, BMEdge *e2) co21 = e2->v1->co; co22 = e2->v2->co; if ((equals_v3v3(co11, co21) && equals_v3v3(co12, co22)) || - (equals_v3v3(co11, co22) && equals_v3v3(co12, co21))) { + (equals_v3v3(co11, co22) && equals_v3v3(co12, co21))) + { return true; } return false; @@ -2738,7 +2749,8 @@ static bool point_is_visible(KnifeTool_OpData *kcd, /* If box clipping on, make sure p is not clipped. */ if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) && - ED_view3d_clipping_test(kcd->vc.rv3d, p, false)) { + ED_view3d_clipping_test(kcd->vc.rv3d, p, false)) + { return false; } @@ -2766,12 +2778,9 @@ static bool point_is_visible(KnifeTool_OpData *kcd, copy_v3_v3(view_clip[0], p_ofs); madd_v3_v3v3fl(view_clip[1], p_ofs, view, dist); - if (clip_segment_v3_plane_n(view_clip[0], - view_clip[1], - kcd->vc.rv3d->clip_local, - 6, - view_clip[0], - view_clip[1])) { + if (clip_segment_v3_plane_n( + view_clip[0], view_clip[1], kcd->vc.rv3d->clip_local, 6, view_clip[0], view_clip[1])) + { dist = len_v3v3(p_ofs, view_clip[1]); } } @@ -2990,7 +2999,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* First look for vertex hits. */ for (val_p = BLI_smallhash_iternew_p(&kfvs, &hiter, (uintptr_t *)&v); val_p; - val_p = BLI_smallhash_iternext_p(&hiter, (uintptr_t *)&v)) { + val_p = BLI_smallhash_iternext_p(&hiter, (uintptr_t *)&v)) + { KnifeEdge *kfe_hit = NULL; bool kfv_is_in_cut = false; @@ -3006,7 +3016,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) knife_project_v2(kcd, v->cageco, s); float d = dist_squared_to_line_segment_v2(s, s1, s2); if ((d <= vert_tol_sq) && - point_is_visible(kcd, v->cageco, s, bm_elem_from_knife_vert(v, &kfe_hit))) { + point_is_visible(kcd, v->cageco, s, bm_elem_from_knife_vert(v, &kfe_hit))) + { kfv_is_in_cut = true; } } @@ -3040,11 +3051,13 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* Now edge hits; don't add if a vertex at end of edge should have hit. */ for (val = BLI_smallhash_iternew(&kfes, &hiter, (uintptr_t *)&kfe); val; - val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&kfe)) { + val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&kfe)) + { /* If we intersect any of the vertices, don't attempt to intersect the edge. */ if (BLI_smallhash_lookup(&kfvs, (intptr_t)kfe->v1) || - BLI_smallhash_lookup(&kfvs, (intptr_t)kfe->v2)) { + BLI_smallhash_lookup(&kfvs, (intptr_t)kfe->v2)) + { continue; } @@ -3116,14 +3129,16 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) !kcd->is_drag_hold; if (use_hit_prev || use_hit_curr) { for (val = BLI_smallhash_iternew(&faces, &hiter, (uintptr_t *)&f); val; - val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) { + val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) + { float p[3], p_cage[3]; uint ob_index = (uint)(uintptr_t)BLI_smallhash_lookup(&fobs, (uintptr_t)f); ob = kcd->objects[ob_index]; if (use_hit_prev && - knife_ray_intersect_face(kcd, s1, v1, v3, ob, ob_index, f, face_tol_sq, p, p_cage)) { + knife_ray_intersect_face(kcd, s1, v1, v3, ob, ob_index, f, face_tol_sq, p, p_cage)) + { if (point_is_visible(kcd, p_cage, s1, (BMElem *)f)) { memset(&hit, 0, sizeof(hit)); hit.f = f; @@ -3138,7 +3153,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) } if (use_hit_curr && - knife_ray_intersect_face(kcd, s2, v2, v4, ob, ob_index, f, face_tol_sq, p, p_cage)) { + knife_ray_intersect_face(kcd, s2, v2, v4, ob, ob_index, f, face_tol_sq, p, p_cage)) + { if (point_is_visible(kcd, p_cage, s2, (BMElem *)f)) { memset(&hit, 0, sizeof(hit)); hit.f = f; @@ -3421,7 +3437,8 @@ static KnifeEdge *knife_find_closest_edge_of_face( /* Check if we're close enough and calculate 'lambda'. */ /* In constrained mode calculate lambda differently, unless constrained along kcd->prev.edge */ if ((kcd->is_angle_snapping || kcd->axis_constrained) && (kfe != kcd->prev.edge) && - (kcd->mode == MODE_DRAGGING)) { + (kcd->mode == MODE_DRAGGING)) + { dis_sq = curdis_sq; if (!knife_snap_edge_constrained(kcd, sco, kfv1_sco, kfv2_sco, &dis_sq, &lambda)) { continue; @@ -3520,7 +3537,8 @@ static KnifeVert *knife_find_closest_vert_of_edge(KnifeTool_OpData *kcd, dis_sq = len_squared_v2v2(kfv_sco, sco); if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { if (!RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) || - !ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, false)) { + !ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, false)) + { curv = kfv; curdis_sq = dis_sq; copy_v2_v2(cur_kfv_sco, kfv_sco); @@ -3569,7 +3587,8 @@ static bool knife_snap_angle_screen(KnifeTool_OpData *kcd) float snap_step; /* Currently user can input any float between 0 and 180. */ if (kcd->angle_snapping_increment > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT && - kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) { + kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) + { snap_step = DEG2RADF(kcd->angle_snapping_increment); } else { @@ -3723,7 +3742,8 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) /* Calculate snap step. */ float snap_step; if (kcd->angle_snapping_increment > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT && - kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) { + kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) + { snap_step = DEG2RADF(kcd->angle_snapping_increment); } else { @@ -4260,7 +4280,8 @@ static int knife_update_active(KnifeTool_OpData *kcd) knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs); if (!isect_line_plane_v3( - kcd->curr.cage, origin, origin_ofs, kcd->prev.cage, kcd->vc.rv3d->viewinv[2])) { + kcd->curr.cage, origin, origin_ofs, kcd->prev.cage, kcd->vc.rv3d->viewinv[2])) + { copy_v3_v3(kcd->curr.cage, kcd->prev.cage); /* Should never fail! */ @@ -4438,7 +4459,8 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (kcd->angle_snapping) { if (kcd->num.str_cur >= 3 || - kcd->angle_snapping_increment > KNIFE_MAX_ANGLE_SNAPPING_INCREMENT / 10) { + kcd->angle_snapping_increment > KNIFE_MAX_ANGLE_SNAPPING_INCREMENT / 10) + { knife_reset_snap_angle_input(kcd); } knife_update_header(C, op, kcd); /* Update the angle multiple. */ @@ -4448,7 +4470,8 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) applyNumInput(&kcd->num, &snapping_increment_temp); /* Restrict number key input to 0 - 180 degree range. */ if (snapping_increment_temp > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT && - snapping_increment_temp <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) { + snapping_increment_temp <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) + { kcd->angle_snapping_increment = snapping_increment_temp; } knife_update_active(kcd); @@ -4701,7 +4724,8 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (kcd->angle_snapping) { if (kcd->num.str_cur >= 3 || - kcd->angle_snapping_increment > KNIFE_MAX_ANGLE_SNAPPING_INCREMENT / 10) { + kcd->angle_snapping_increment > KNIFE_MAX_ANGLE_SNAPPING_INCREMENT / 10) + { knife_reset_snap_angle_input(kcd); } if (event->type != EVT_MODAL_MAP) { @@ -4710,7 +4734,8 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) applyNumInput(&kcd->num, &snapping_increment_temp); /* Restrict number key input to 0 - 180 degree range. */ if (snapping_increment_temp > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT && - snapping_increment_temp <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) { + snapping_increment_temp <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) + { kcd->angle_snapping_increment = snapping_increment_temp; } knife_update_active(kcd); @@ -5108,7 +5133,8 @@ void EDBM_mesh_knife(ViewContext *vc, mul_m4_v3(ob->object_to_world, cent); knife_project_v2(kcd, cent, cent_ss); if ((kcd->cut_through || point_is_visible(kcd, cent, cent_ss, (BMElem *)f)) && - edbm_mesh_knife_point_isect(polys, cent_ss)) { + edbm_mesh_knife_point_isect(polys, cent_ss)) + { BM_elem_flag_enable(f, BM_ELEM_TAG); keep_search = true; } diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 0f22865b348..061394d2fb7 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -387,7 +387,8 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) for (uint base_index = 0; base_index < bases_len; base_index++) { Object *ob_iter = bases[base_index]->object; if (BKE_modifiers_is_deformed_by_lattice(ob_iter) || - BKE_modifiers_is_deformed_by_armature(ob_iter)) { + BKE_modifiers_is_deformed_by_armature(ob_iter)) + { BKE_report( op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display"); break; diff --git a/source/blender/editors/mesh/editmesh_mask_extract.cc b/source/blender/editors/mesh/editmesh_mask_extract.cc index 2eefc364dd2..bbf15411d5e 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.cc +++ b/source/blender/editors/mesh/editmesh_mask_extract.cc @@ -149,7 +149,8 @@ static int geometry_extract_apply(bContext *C, 0.1, true, true, - true)) { + true)) + { continue; } } @@ -172,7 +173,8 @@ static int geometry_extract_apply(bContext *C, 0.1, true, true, - true)) { + true)) + { continue; } } diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index 91973e352f1..e65a0875dee 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -230,7 +230,8 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { verttag_set_cb((BMVert *)node->link, !all_set, &user_data); if (is_path_ordered) { v_dst_last = node->link; @@ -429,7 +430,8 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { edgetag_set_cb((BMEdge *)node->link, !all_set, &user_data); if (is_path_ordered) { e_dst_last = node->link; @@ -564,7 +566,8 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { facetag_set_cb((BMFace *)node->link, !all_set, &user_data); if (is_path_ordered) { f_dst_last = node->link; @@ -720,11 +723,13 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE BMElem *ele_src, *ele_dst; if (!(ele_src = edbm_elem_active_elem_or_face_get(em->bm)) || - !(ele_dst = edbm_elem_find_nearest(&vc, ele_src->head.htype))) { + !(ele_dst = edbm_elem_find_nearest(&vc, ele_src->head.htype))) + { /* special case, toggle edge tags even when we don't have a path */ if (((em->selectmode & SCE_SELECT_EDGE) && (op_params.edge_mode != EDGE_MODE_SELECT)) && /* check if we only have a destination edge */ - ((ele_src == NULL) && (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE)))) { + ((ele_src == NULL) && (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE)))) + { ele_src = ele_dst; track_active = false; } @@ -767,7 +772,8 @@ static int edbm_shortest_path_pick_exec(bContext *C, wmOperator *op) BMElem *ele_src, *ele_dst; if (!(ele_src = edbm_elem_active_elem_or_face_get(em->bm)) || - !(ele_dst = EDBM_elem_from_index_any(em, index))) { + !(ele_dst = EDBM_elem_from_index_any(em, index))) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.c index cfd07a6ff35..a3ce6c36295 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.c +++ b/source/blender/editors/mesh/editmesh_polybuild.c @@ -225,7 +225,8 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, "dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b", BM_ELEM_TAG, false, - false)) { + false)) + { return OPERATOR_CANCELLED; } changed = true; @@ -345,7 +346,8 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMEdge *e_iter = v_act->e; do { if ((BM_elem_flag_test(e_iter, BM_ELEM_HIDDEN) == false) && - (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) { + (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) + { if (i == 2) { e_pair[0] = e_pair[1] = NULL; break; @@ -579,7 +581,8 @@ static int edbm_polybuild_dissolve_at_cursor_invoke(bContext *C, "dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b", BM_ELEM_TAG, false, - false)) { + false)) + { return OPERATOR_CANCELLED; } } diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c index 832390331c3..bed6a6f930d 100644 --- a/source/blender/editors/mesh/editmesh_preselect_edgering.c +++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c @@ -305,7 +305,8 @@ static void view3d_preselect_mesh_edgering_update_edges_from_edge( #else BM_edge_share_quad_check(eed_last, eed_start) #endif - ) { + ) + { v[1][0] = v[0][0]; v[1][1] = v[0][1]; diff --git a/source/blender/editors/mesh/editmesh_preselect_elem.c b/source/blender/editors/mesh/editmesh_preselect_elem.c index 5d8ce7cae44..f9449cfd163 100644 --- a/source/blender/editors/mesh/editmesh_preselect_elem.c +++ b/source/blender/editors/mesh/editmesh_preselect_elem.c @@ -231,7 +231,8 @@ static void view3d_preselect_update_preview_triangle_from_vert(struct EditMesh_P BMEdge *e_iter = v_act->e; do { if ((BM_elem_flag_test(e_iter, BM_ELEM_HIDDEN) == false) && - (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) { + (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) + { if (i == 2) { e_pair[0] = e_pair[1] = NULL; break; diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 988d1e7e869..e955336f135 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -138,7 +138,8 @@ static float edbm_rip_edge_side_measure( score = len_v2v2(e_v1_co, e_v2_co); if (dist_squared_to_line_segment_v2(fmval_tweak, e_v1_co, e_v2_co) > - dist_squared_to_line_segment_v2(fmval, e_v1_co, e_v2_co)) { + dist_squared_to_line_segment_v2(fmval, e_v1_co, e_v2_co)) + { return score; } return -score; diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index dfe8af1bb92..945c7b0186b 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -246,7 +246,8 @@ static void findnearestvert__doClosest(void *userData, if (data->use_cycle) { if ((data->hit_cycle.vert == nullptr) && (index > data->cycle_index_prev) && - (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) { + (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) + { data->hit_cycle.dist_bias = dist_test_bias; data->hit_cycle.dist = dist_test; data->hit_cycle.index = index; @@ -320,7 +321,8 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, Base *base_iter = bases[base_index]; ED_view3d_viewcontext_init_object(vc, base_iter->object); if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_vert_at_index_find_or_table(vc->em->bm, prev_select.index)) { + prev_select.elem == BM_vert_at_index_find_or_table(vc->em->bm, prev_select.index)) + { data.cycle_index_prev = prev_select.index; /* No need to compare in the rest of the loop. */ use_cycle = false; @@ -465,7 +467,8 @@ static void find_nearest_edge__doClosest( if (data->use_cycle) { if ((data->hit_cycle.edge == nullptr) && (index > data->cycle_index_prev) && - (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) { + (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) + { float screen_co_mid[2]; data->hit_cycle.dist_bias = dist_test_bias; @@ -570,7 +573,8 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, Base *base_iter = bases[base_index]; ED_view3d_viewcontext_init_object(vc, base_iter->object); if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_edge_at_index_find_or_table(vc->em->bm, prev_select.index)) { + prev_select.elem == BM_edge_at_index_find_or_table(vc->em->bm, prev_select.index)) + { data.cycle_index_prev = prev_select.index; /* No need to compare in the rest of the loop. */ use_cycle = false; @@ -683,7 +687,8 @@ static void findnearestface__doClosest(void *userData, if (data->use_cycle) { if ((data->hit_cycle.face == nullptr) && (index > data->cycle_index_prev) && - (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) { + (dist_test_bias < FIND_NEAR_CYCLE_THRESHOLD_MIN)) + { data->hit_cycle.dist_bias = dist_test_bias; data->hit_cycle.dist = dist_test; data->hit_cycle.index = index; @@ -791,7 +796,8 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, Base *base_iter = bases[base_index]; ED_view3d_viewcontext_init_object(vc, base_iter->object); if (use_cycle && prev_select.bm == vc->em->bm && - prev_select.elem == BM_face_at_index_find_or_table(vc->em->bm, prev_select.index)) { + prev_select.elem == BM_face_at_index_find_or_table(vc->em->bm, prev_select.index)) + { data.cycle_index_prev = prev_select.index; /* No need to compare in the rest of the loop. */ use_cycle = false; @@ -1041,7 +1047,8 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, } best_face = {0, nullptr}; if (ED_view3d_win_to_ray_clipped( - vc->depsgraph, vc->region, vc->v3d, mval_fl, ray_origin, ray_direction, true)) { + vc->depsgraph, vc->region, vc->v3d, mval_fl, ray_origin, ray_direction, true)) + { float dist_sq_best = FLT_MAX; float dist_sq_best_vert = FLT_MAX; float dist_sq_best_edge = FLT_MAX; @@ -1395,7 +1402,8 @@ static char *edbm_select_mode_get_description(bContext * /*C*/, if (RNA_struct_property_is_set(values, "type") && !RNA_struct_property_is_set(values, "use_extend") && !RNA_struct_property_is_set(values, "use_expand") && - !RNA_struct_property_is_set(values, "action")) { + !RNA_struct_property_is_set(values, "action")) + { switch (type) { case SCE_SELECT_VERTEX: return BLI_strdup(TIP_( @@ -1479,7 +1487,8 @@ static void walker_select_count(BMEditMesh *em, BMW_NIL_LAY); for (ele = static_cast(BMW_begin(&walker, start)); ele; - ele = static_cast(BMW_step(&walker))) { + ele = static_cast(BMW_step(&walker))) + { r_count_by_select[BM_elem_flag_test(ele, BM_ELEM_SELECT) ? 1 : 0] += 1; /* Early exit when mixed (could be optional if needed. */ @@ -1508,7 +1517,8 @@ static void walker_select(BMEditMesh *em, int walkercode, void *start, const boo BMW_NIL_LAY); for (ele = static_cast(BMW_begin(&walker, start)); ele; - ele = static_cast(BMW_step(&walker))) { + ele = static_cast(BMW_step(&walker))) + { if (!select) { BM_select_history_remove(bm, ele); } @@ -1776,12 +1786,14 @@ static bool mouse_mesh_loop( ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); if (ED_view3d_project_float_object(vc.region, eed->v1->co, v1_co, V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { length_1 = len_squared_v2v2(mvalf, v1_co); } if (ED_view3d_project_float_object(vc.region, eed->v2->co, v2_co, V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { length_2 = len_squared_v2v2(mvalf, v2_co); } #if 0 @@ -1811,7 +1823,8 @@ static bool mouse_mesh_loop( BM_face_calc_center_median(f, cent); if (ED_view3d_project_float_object(vc.region, cent, co, V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { tdist = len_squared_v2v2(mvalf, co); if (tdist < best_dist) { // printf("Best face: %p (%f)\n", f, tdist); @@ -1846,7 +1859,8 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *e RNA_boolean_get(op->ptr, "extend"), RNA_boolean_get(op->ptr, "deselect"), RNA_boolean_get(op->ptr, "toggle"), - RNA_boolean_get(op->ptr, "ring"))) { + RNA_boolean_get(op->ptr, "ring"))) + { return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; @@ -3175,7 +3189,8 @@ static bool select_linked_delimit_test(BMEdge *e, int delimit, const DelimitData if (delimit & BMO_DELIM_UV) { if (BM_edge_is_contiguous_loop_cd( - e, delimit_data->cd_loop_type, delimit_data->cd_loop_offset) == 0) { + e, delimit_data->cd_loop_type, delimit_data->cd_loop_offset) == 0) + { return true; } } @@ -4232,7 +4247,8 @@ static void walker_deselect_nth(BMEditMesh *em, BLI_assert(walker.order == BMW_BREADTH_FIRST); for (ele = static_cast(BMW_begin(&walker, h_act)); ele != nullptr; - ele = static_cast(BMW_step(&walker))) { + ele = static_cast(BMW_step(&walker))) + { if (!BM_elem_flag_test(ele, BM_ELEM_TAG)) { /* Deselect elements that aren't at "nth" depth from active */ const int depth = BMW_current_depth(&walker) - 1; @@ -4510,8 +4526,8 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { if ((BM_elem_flag_test(f, BM_ELEM_HIDDEN) != 0) || - (BM_elem_flag_test(f, BM_ELEM_TAG) != 0) || - (BM_elem_flag_test(f, BM_ELEM_SELECT) == 0)) { + (BM_elem_flag_test(f, BM_ELEM_TAG) != 0) || (BM_elem_flag_test(f, BM_ELEM_SELECT) == 0)) + { continue; } @@ -4526,8 +4542,8 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l2, &liter2, l, BM_LOOPS_OF_LOOP) { float angle_cos; - if (BM_elem_flag_test(l2->f, BM_ELEM_TAG) || - BM_elem_flag_test(l2->f, BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(l2->f, BM_ELEM_TAG) || BM_elem_flag_test(l2->f, BM_ELEM_HIDDEN)) + { continue; } @@ -4636,7 +4652,8 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { if ((use_wire && BM_edge_is_wire(e)) || (use_boundary && BM_edge_is_boundary(e)) || (use_non_contiguous && (BM_edge_is_manifold(e) && !BM_edge_is_contiguous(e))) || - (use_multi_face && BM_edge_face_count_is_over(e, 2))) { + (use_multi_face && BM_edge_face_count_is_over(e, 2))) + { /* check we never select perfect edge (in test above) */ BLI_assert(!(BM_edge_is_manifold(e) && BM_edge_is_contiguous(e))); diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index a9c2cd4236b..88e5f5614d6 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -435,7 +435,8 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) if (BLI_kdtree_4d_find_nearest(tree_4d, plane, &nearest) != -1) { if (nearest.dist <= thresh) { if ((fabsf(plane[3] - nearest.co[3]) <= thresh) && - (angle_v3v3(plane, nearest.co) <= thresh_radians)) { + (angle_v3v3(plane, nearest.co) <= thresh_radians)) + { select = true; } } @@ -459,7 +460,8 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) fface = CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE); if (((fface != NULL) && (fface->flag & FREESTYLE_FACE_MARK)) == - ((face_data_value & SIMFACE_DATA_TRUE) != 0)) { + ((face_data_value & SIMFACE_DATA_TRUE) != 0)) + { select = true; } break; @@ -888,7 +890,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) fedge = CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE); if (((fedge != NULL) && (fedge->flag & FREESTYLE_EDGE_MARK)) == - ((edge_data_value & SIMEDGE_DATA_TRUE) != 0)) { + ((edge_data_value & SIMEDGE_DATA_TRUE) != 0)) + { select = true; } break; @@ -1393,7 +1396,8 @@ static bool edbm_select_similar_poll_property(const bContext *UNUSED(C), SIMFACE_AREA, SIMFACE_PERIMETER, SIMFACE_NORMAL, - SIMFACE_COPLANAR)) { + SIMFACE_COPLANAR)) + { return false; } } diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index 7411bd4a4f8..6c486cda58b 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -316,7 +316,8 @@ static int edbm_subdivide_edge_ring_exec(bContext *C, wmOperator *op) op_props.cuts, op_props.smooth, op_props.profile_shape, - op_props.profile_shape_factor)) { + op_props.profile_shape_factor)) + { continue; } @@ -490,8 +491,8 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) continue; } BM_custom_loop_normals_to_vector_layer(em->bm); - if (!EDBM_op_callf( - em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) { + if (!EDBM_op_callf(em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) + { continue; } break; @@ -812,7 +813,8 @@ static BMElem *edbm_add_edge_face_exec__tricky_extend_sel(BMesh *bm) ((edbm_add_edge_face_exec__vert_edge_lookup( v, nullptr, ed_pair, 3, BM_edge_is_boundary) == 2) && - (BM_edge_share_face_check(ed_pair[0], ed_pair[1]) == false))) { + (BM_edge_share_face_check(ed_pair[0], ed_pair[1]) == false))) + { BMEdge *e_other = BM_edge_exists(BM_edge_other_vert(ed_pair[0], v), BM_edge_other_vert(ed_pair[1], v)); BM_edge_select_set(bm, ed_pair[0], true); @@ -865,7 +867,8 @@ static BMElem *edbm_add_edge_face_exec__tricky_extend_sel(BMesh *bm) (edbm_add_edge_face_exec__vert_edge_lookup( e->v2, e, ed_pair_v2, 2, BM_edge_is_boundary) == 1) && (BM_edge_share_face_check(e, ed_pair_v1[0]) == false) && - (BM_edge_share_face_check(e, ed_pair_v2[0]) == false))) { + (BM_edge_share_face_check(e, ed_pair_v2[0]) == false))) + { BMVert *v1_other = BM_edge_other_vert(ed_pair_v1[0], e->v1); BMVert *v2_other = BM_edge_other_vert(ed_pair_v2[0], e->v2); BMEdge *e_other = (v1_other != v2_other) ? BM_edge_exists(v1_other, v2_other) : nullptr; @@ -960,7 +963,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) "contextual_create geom=%hfev mat_nr=%i use_smooth=%b", BM_ELEM_SELECT, em->mat_nr, - use_smooth)) { + use_smooth)) + { continue; } @@ -976,7 +980,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) * but being able to press F many times to add geometry is too useful! */ if (ele_desel && (BMO_slot_buffer_len(bmop.slots_out, "faces.out") == 1) && (ele_desel_face = static_cast( - BMO_slot_buffer_get_first(bmop.slots_out, "faces.out")))) { + BMO_slot_buffer_get_first(bmop.slots_out, "faces.out")))) + { edbm_add_edge_face_exec__tricky_finalize_sel(em->bm, ele_desel, ele_desel_face); } else @@ -1231,9 +1236,8 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, Mesh *me, wmOperator *op) } if (BM_vert_pair_share_face_check_cb( - verts[0], - verts[1], - BM_elem_cb_check_hflag_disabled_simple(BMFace *, BM_ELEM_HIDDEN))) { + verts[0], verts[1], BM_elem_cb_check_hflag_disabled_simple(BMFace *, BM_ELEM_HIDDEN))) + { check_degenerate = false; is_pair = false; } @@ -1247,7 +1251,8 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, Mesh *me, wmOperator *op) verts, verts_len, BM_ELEM_HIDDEN, - BM_ELEM_HIDDEN)) { + BM_ELEM_HIDDEN)) + { checks_succeded = false; } } @@ -1259,7 +1264,8 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, Mesh *me, wmOperator *op) verts, verts_len, BM_ELEM_HIDDEN, - check_degenerate)) { + check_degenerate)) + { checks_succeded = false; } } @@ -1362,7 +1368,8 @@ static bool bm_vert_is_select_history_open(BMesh *bm) if ((BM_iter_elem_count_flag(BM_EDGES_OF_VERT, (BMVert *)ele_a->ele, BM_ELEM_SELECT, true) == 1) && (BM_iter_elem_count_flag(BM_EDGES_OF_VERT, (BMVert *)ele_b->ele, BM_ELEM_SELECT, true) == - 1)) { + 1)) + { return true; } } @@ -1671,7 +1678,8 @@ static int edbm_vert_connect_concave_exec(bContext *C, wmOperator *op) } if (!EDBM_op_call_and_selectf( - em, op, "faces.out", true, "connect_verts_concave faces=%hf", BM_ELEM_SELECT)) { + em, op, "faces.out", true, "connect_verts_concave faces=%hf", BM_ELEM_SELECT)) + { continue; } EDBMUpdate_Params params{}; @@ -1729,7 +1737,8 @@ static int edbm_vert_connect_nonplaner_exec(bContext *C, wmOperator *op) true, "connect_verts_nonplanar faces=%hf angle_limit=%f", BM_ELEM_SELECT, - angle_limit)) { + angle_limit)) + { continue; } @@ -1798,12 +1807,9 @@ static int edbm_face_make_planar_exec(bContext *C, wmOperator *op) continue; } - if (!EDBM_op_callf(em, - op, - "planar_faces faces=%hf iterations=%i factor=%f", - BM_ELEM_SELECT, - repeat, - fac)) { + if (!EDBM_op_callf( + em, op, "planar_faces faces=%hf iterations=%i factor=%f", BM_ELEM_SELECT, repeat, fac)) + { continue; } @@ -1887,9 +1893,9 @@ static bool edbm_edge_split_selected_verts(wmOperator *op, Object *obedit, BMEdi BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { BM_elem_flag_disable(eed, BM_ELEM_TAG); if (eed->l != nullptr) { - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && - (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || - BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) + { BM_elem_flag_enable(eed, BM_ELEM_TAG); } /* Store selection in loop tags. */ @@ -1905,7 +1911,8 @@ static bool edbm_edge_split_selected_verts(wmOperator *op, Object *obedit, BMEdi "split_edges edges=%he verts=%hv use_verts=%b", BM_ELEM_TAG, BM_ELEM_SELECT, - true)) { + true)) + { return false; } @@ -2736,7 +2743,8 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) clip_dist, xaxis, yaxis, - zaxis)) { + zaxis)) + { continue; } } @@ -2842,7 +2850,8 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) usex, usey, usez, - preserve_volume)) { + preserve_volume)) + { failed_repeat_loop = true; break; } @@ -3333,13 +3342,14 @@ static bool merge_firstlast(BMEditMesh *em, if (use_uvmerge) { if (!EDBM_op_callf( - em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) { + em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) + { return false; } } - if (!EDBM_op_callf( - em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) { + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) + { return false; } @@ -3507,7 +3517,8 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C, if (em->selectmode & SCE_SELECT_VERTEX) { if (em->bm->selected.first && em->bm->selected.last && ((BMEditSelection *)em->bm->selected.first)->htype == BM_VERT && - ((BMEditSelection *)em->bm->selected.last)->htype == BM_VERT) { + ((BMEditSelection *)em->bm->selected.last)->htype == BM_VERT) + { RNA_enum_items_add_value(&item, &totitem, merge_type_items, MESH_MERGE_FIRST); RNA_enum_items_add_value(&item, &totitem, merge_type_items, MESH_MERGE_LAST); } @@ -3893,7 +3904,8 @@ static const EnumPropertyItem *shape_itemf(bContext *C, int totitem = 0; if ((obedit && obedit->type == OB_MESH) && (em = BKE_editmesh_from_object(obedit)) && - CustomData_has_layer(&em->bm->vdata, CD_SHAPEKEY)) { + CustomData_has_layer(&em->bm->vdata, CD_SHAPEKEY)) + { EnumPropertyItem tmp = {0, "", 0, "", ""}; int a; @@ -3987,8 +3999,8 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op) BMOperator bmop; - if (!EDBM_op_init( - em, &bmop, op, "solidify geom=%hf thickness=%f", BM_ELEM_SELECT, thickness)) { + if (!EDBM_op_init(em, &bmop, op, "solidify geom=%hf thickness=%f", BM_ELEM_SELECT, thickness)) + { continue; } @@ -4281,7 +4293,8 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) { if (ED_view3d_project_float_object(region, bv->co, *sco, V3D_PROJ_TEST_CLIP_NEAR) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { copy_v2_fl(*sco, FLT_MAX); /* set error value */ } BM_elem_index_set(bv, i); /* set_inline */ @@ -4874,7 +4887,8 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) BMOperator bmop; if (!EDBM_op_init( - em, &bmop, op, "triangle_fill edges=%he use_beauty=%b", BM_ELEM_SELECT, use_beauty)) { + em, &bmop, op, "triangle_fill edges=%he use_beauty=%b", BM_ELEM_SELECT, use_beauty)) + { continue; } @@ -5016,7 +5030,8 @@ static bool edbm_fill_grid_prepare(BMesh *bm, int offset, int *span_p, const boo int i; if (v_act && (v_act_link = static_cast( - BLI_findptr(verts, v_act, offsetof(LinkData, data))))) { + BLI_findptr(verts, v_act, offsetof(LinkData, data))))) + { /* pass */ } else { @@ -5081,7 +5096,8 @@ static bool edbm_fill_grid_prepare(BMesh *bm, int offset, int *span_p, const boo /* now find the first... */ for (v_link = static_cast(verts->first), i = 0; i < verts_len / 2; - v_link = v_link->next, i++) { + v_link = v_link->next, i++) + { BMVert *v = static_cast(v_link->data); if (BM_elem_flag_test(v, BM_ELEM_TAG)) { if (v != v_act) { @@ -5146,7 +5162,8 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op) /* Only reuse on redo because these settings need to match the current selection. * We never want to use them on other geometry, repeat last for eg, see: #60777. */ if (((op->flag & OP_IS_INVOKE) || (op->flag & OP_IS_REPEAT_LAST) == 0) && - RNA_property_is_set(op->ptr, prop_span)) { + RNA_property_is_set(op->ptr, prop_span)) + { span = RNA_property_int_get(op->ptr, prop_span); calc_span = false; } @@ -5173,7 +5190,8 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op) use_prepare ? BM_ELEM_TAG : BM_ELEM_SELECT, em->mat_nr, use_smooth, - use_interp_simple)) { + use_interp_simple)) + { continue; } @@ -5271,7 +5289,8 @@ static int edbm_fill_holes_exec(bContext *C, wmOperator *op) } if (!EDBM_op_call_and_selectf( - em, op, "faces.out", true, "holes_fill edges=%he sides=%i", BM_ELEM_SELECT, sides)) { + em, op, "faces.out", true, "holes_fill edges=%he sides=%i", BM_ELEM_SELECT, sides)) + { continue; } @@ -5353,13 +5372,9 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) hflag = BM_ELEM_TAG; } - if (!EDBM_op_call_and_selectf(em, - op, - "geom.out", - true, - "beautify_fill faces=%hf edges=%he", - BM_ELEM_SELECT, - hflag)) { + if (!EDBM_op_call_and_selectf( + em, op, "geom.out", true, "beautify_fill faces=%hf edges=%he", BM_ELEM_SELECT, hflag)) + { continue; } @@ -5673,7 +5688,8 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) do_sharp, do_uvs, do_vcols, - do_materials)) { + do_materials)) + { continue; } @@ -6007,7 +6023,8 @@ static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op) "dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b", BM_ELEM_SELECT, use_face_split, - use_boundary_tear)) { + use_boundary_tear)) + { continue; } @@ -6073,7 +6090,8 @@ static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op) "dissolve_edges edges=%he use_verts=%b use_face_split=%b", BM_ELEM_SELECT, use_verts, - use_face_split)) { + use_face_split)) + { continue; } @@ -6139,7 +6157,8 @@ static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op) true, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, - use_verts)) { + use_verts)) + { continue; } @@ -6475,7 +6494,8 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op) "dissolve_edges edges=%he use_verts=%b use_face_split=%b", BM_ELEM_SELECT, true, - use_face_split)) { + use_face_split)) + { continue; } @@ -7139,7 +7159,8 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) if (!((elem_types & BM_VERT && bm->totvertsel > 0) || (elem_types & BM_EDGE && bm->totedgesel > 0) || - (elem_types & BM_FACE && bm->totfacesel > 0))) { + (elem_types & BM_FACE && bm->totfacesel > 0))) + { continue; } @@ -7782,7 +7803,8 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) &bmop, "geom.out", angle_face_threshold, - angle_shape_threshold)) { + angle_shape_threshold)) + { EDBM_op_finish(em, &bmop, op, true); continue; } @@ -7983,7 +8005,8 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op) BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { if ((BM_elem_flag_test(v, BM_ELEM_SELECT) != false) && - (BM_elem_flag_test(v, BM_ELEM_TAG) == false)) { + (BM_elem_flag_test(v, BM_ELEM_TAG) == false)) + { int i_mirr = index[i]; if (i_mirr != -1) { @@ -8952,7 +8975,8 @@ static void normals_split(BMesh *bm) do { if (BM_elem_flag_test(l_curr->v, BM_ELEM_SELECT) && (!BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) || - (!BM_elem_flag_test(l_curr, BM_ELEM_TAG) && BM_loop_check_cyclic_smooth_fan(l_curr)))) { + (!BM_elem_flag_test(l_curr, BM_ELEM_TAG) && BM_loop_check_cyclic_smooth_fan(l_curr)))) + { if (!BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) && !BM_elem_flag_test(l_curr->prev->e, BM_ELEM_TAG)) { const int loop_index = BM_elem_index_get(l_curr); @@ -9182,8 +9206,8 @@ static int edbm_average_normals_exec(bContext *C, wmOperator *op) do { if (BM_elem_flag_test(l_curr->v, BM_ELEM_SELECT) && (!BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) || - (!BM_elem_flag_test(l_curr, BM_ELEM_TAG) && - BM_loop_check_cyclic_smooth_fan(l_curr)))) { + (!BM_elem_flag_test(l_curr, BM_ELEM_TAG) && BM_loop_check_cyclic_smooth_fan(l_curr)))) + { if (!BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) && !BM_elem_flag_test(l_curr->prev->e, BM_ELEM_TAG)) { const int loop_index = BM_elem_index_get(l_curr); diff --git a/source/blender/editors/mesh/editmesh_undo.cc b/source/blender/editors/mesh/editmesh_undo.cc index 6f23f9b3dd6..f828dcb6560 100644 --- a/source/blender/editors/mesh/editmesh_undo.cc +++ b/source/blender/editors/mesh/editmesh_undo.cc @@ -686,8 +686,9 @@ static UndoMesh **mesh_undostep_reference_elems_from_objects(Object **object, in UndoMesh *um_iter = static_cast(um_arraystore.local_links.last); while (um_iter && (uuid_map_len != 0)) { UndoMesh **um_p; - if ((um_p = static_cast(BLI_ghash_popkey( - uuid_map, POINTER_FROM_INT(um_iter->me.id.session_uuid), nullptr)))) { + if ((um_p = static_cast( + BLI_ghash_popkey(uuid_map, POINTER_FROM_INT(um_iter->me.id.session_uuid), nullptr)))) + { *um_p = um_iter; uuid_map_len--; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a661a82500f..8b068dd5308 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -913,7 +913,8 @@ static bool seam_connected_recursive(BMEdge *edge, const float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->prev, cd_loop_uv_offset); if (seam_connected_recursive( - loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { + loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) + { return true; } } @@ -929,7 +930,8 @@ static bool seam_connected_recursive(BMEdge *edge, const float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->next->next, cd_loop_uv_offset); if (seam_connected_recursive( - loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { + loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) + { return true; } } @@ -1429,7 +1431,8 @@ BMEdge *EDBM_verts_mirror_get_edge(BMEditMesh *em, BMEdge *e) if ((v1_mirr = EDBM_verts_mirror_get(em, e->v1)) && (v2_mirr = EDBM_verts_mirror_get(em, e->v2)) && /* While highly unlikely, a zero length central edges vertices can match, see #89342. */ - LIKELY(v1_mirr != v2_mirr)) { + LIKELY(v1_mirr != v2_mirr)) + { return BM_edge_exists(v1_mirr, v2_mirr); } @@ -1957,7 +1960,8 @@ void EDBM_project_snap_verts( NULL, NULL, co_proj, - NULL)) { + NULL)) + { mul_v3_m4v3(eve->co, obedit->world_to_object, co_proj); } } diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index 95741378530..9c0a393d52a 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -441,7 +441,8 @@ bool ED_mesh_color_ensure(Mesh *me, const char *name) char unique_name[MAX_CUSTOMDATA_LAYER_NAME]; BKE_id_attribute_calc_unique_name(&me->id, name, unique_name); if (!me->attributes_for_write().add( - unique_name, ATTR_DOMAIN_CORNER, CD_PROP_BYTE_COLOR, bke::AttributeInitDefaultValue())) { + unique_name, ATTR_DOMAIN_CORNER, CD_PROP_BYTE_COLOR, bke::AttributeInitDefaultValue())) + { return false; } @@ -473,7 +474,8 @@ int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool do_init, Rep } if (const CustomDataLayer *layer = BKE_id_attribute_find( - &me->id, me->active_color_attribute, CD_PROP_COLOR, ATTR_DOMAIN_POINT)) { + &me->id, me->active_color_attribute, CD_PROP_COLOR, ATTR_DOMAIN_POINT)) + { int dummy; const CustomData *data = mesh_customdata_get_type(me, BM_LOOP, &dummy); return CustomData_get_named_layer(data, CD_PROP_BYTE_COLOR, layer->name); diff --git a/source/blender/editors/mesh/mesh_mirror.cc b/source/blender/editors/mesh/mesh_mirror.cc index 43945ad3a6f..3215cd8c92e 100644 --- a/source/blender/editors/mesh/mesh_mirror.cc +++ b/source/blender/editors/mesh/mesh_mirror.cc @@ -147,7 +147,8 @@ bool ED_mesh_mirrtopo_recalc_check(BMEditMesh *em, Mesh *me, MirrTopoStore_t *me if ((mesh_topo_store->index_lookup == nullptr) || (mesh_topo_store->prev_is_editmode != is_editmode) || - (totvert != mesh_topo_store->prev_vert_tot) || (totedge != mesh_topo_store->prev_edge_tot)) { + (totvert != mesh_topo_store->prev_vert_tot) || (totedge != mesh_topo_store->prev_edge_tot)) + { return true; } return false; diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index 9bcdf03cc04..279a02d4c38 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -1238,7 +1238,8 @@ static void ed_mesh_pick_face_vert__mpoly_find( float sco[2]; const int v_idx = corner_verts[poly[j]]; if (ED_view3d_project_float_object(region, vert_positions[v_idx], sco, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { const float len_test = len_manhattan_v2v2(mval, sco); if (len_test < *r_len_best) { *r_len_best = len_test; @@ -1348,7 +1349,8 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, } float sco[2]; if (ED_view3d_project_float_object(data->region, co, sco, V3D_PROJ_TEST_CLIP_DEFAULT) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { const float len = len_manhattan_v2v2(data->mval_f, sco); if (len < data->len_best) { data->len_best = len; diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 7e26d156208..108c74e11ae 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -688,7 +688,8 @@ static int object_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3], radius; WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } radius = RNA_float_get(op->ptr, "radius"); @@ -757,7 +758,8 @@ static int lightprobe_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } int type = RNA_enum_get(op->ptr, "type"); @@ -849,7 +851,8 @@ static int effector_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } const ePFieldType type = static_cast(RNA_enum_get(op->ptr, "type")); @@ -928,7 +931,8 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) bool enter_editmode; float loc[3], rot[3]; if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } Object *ob = ED_object_add_type(C, OB_CAMERA, nullptr, loc, rot, false, local_view_bits); @@ -989,7 +993,8 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } @@ -1061,7 +1066,8 @@ static int object_add_text_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } if (obedit && obedit->type == OB_FONT) { @@ -1116,7 +1122,8 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } if ((obedit == nullptr) || (obedit->type != OB_ARMATURE)) { @@ -1178,7 +1185,8 @@ static int object_empty_add_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } ob = ED_object_add_type(C, OB_EMPTY, nullptr, loc, rot, false, local_view_bits); @@ -1239,7 +1247,8 @@ static int empty_drop_named_image_invoke(bContext *C, wmOperator *op, const wmEv float rot[3]; if (!ED_object_add_generic_get_opts( - C, op, 'Z', nullptr, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', nullptr, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } ob = ED_object_add_type(C, OB_EMPTY, nullptr, nullptr, rot, false, local_view_bits); @@ -1333,7 +1342,8 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) /* NOTE: We use 'Y' here (not 'Z'), as. */ WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Y', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Y', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } /* Add new object if not currently editing a GP object. */ @@ -1592,7 +1602,8 @@ static int object_light_add_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } ob = ED_object_add_type(C, OB_LAMP, get_light_defname(type), loc, rot, false, local_view_bits); @@ -1705,7 +1716,8 @@ static std::optional collection_add_info_get_from_op(bContext nullptr, nullptr, &add_info.local_view_bits, - nullptr)) { + nullptr)) + { return std::nullopt; } @@ -1938,7 +1950,8 @@ static int object_data_instance_add_exec(bContext *C, wmOperator *op) } if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } @@ -1986,7 +1999,8 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) ushort local_view_bits; float loc[3], rot[3]; if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } Object *ob = ED_object_add_type(C, OB_SPEAKER, nullptr, loc, rot, false, local_view_bits); @@ -2046,7 +2060,8 @@ static int object_curves_random_add_exec(bContext *C, wmOperator *op) ushort local_view_bits; float loc[3], rot[3]; if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } @@ -2081,7 +2096,8 @@ static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op) ushort local_view_bits; if (!ED_object_add_generic_get_opts( - C, op, 'Z', nullptr, nullptr, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', nullptr, nullptr, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } @@ -2163,7 +2179,8 @@ static int object_pointcloud_add_exec(bContext *C, wmOperator *op) ushort local_view_bits; float loc[3], rot[3]; if (!ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) { + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { return OPERATOR_CANCELLED; } @@ -2199,7 +2216,8 @@ void OBJECT_OT_pointcloud_add(wmOperatorType *ot) void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob) { if (ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0 && - BKE_library_ID_is_indirectly_used(bmain, ob)) { + BKE_library_ID_is_indirectly_used(bmain, ob)) + { /* We cannot delete indirectly used object... */ printf( "WARNING, undeletable object '%s', should have been caught before reaching this " @@ -2259,7 +2277,8 @@ static int object_delete_exec(bContext *C, wmOperator *op) } if (ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0 && - BKE_library_ID_is_indirectly_used(bmain, ob)) { + BKE_library_ID_is_indirectly_used(bmain, ob)) + { BKE_reportf(op->reports, RPT_WARNING, "Cannot delete object '%s' from scene '%s', indirectly used objects need at " @@ -2509,8 +2528,8 @@ static void make_object_duplilist_real(bContext *C, Object *object_eval = DEG_get_evaluated_object(depsgraph, base->object); - if (!(base->object->transflag & OB_DUPLI) && - !BKE_object_has_geometry_set_instances(object_eval)) { + if (!(base->object->transflag & OB_DUPLI) && !BKE_object_has_geometry_set_instances(object_eval)) + { return; } @@ -2821,7 +2840,8 @@ static bool object_convert_poll(bContext *C) Object *obact = base_act ? base_act->object : nullptr; if (obact == nullptr || obact->data == nullptr || ID_IS_LINKED(obact) || - ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) { + ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) + { return false; } @@ -2949,7 +2969,8 @@ static int object_convert_exec(bContext *C, wmOperator *op) * But at the very least, do not do that with linked IDs! */ if ((!BKE_id_is_editable(bmain, &ob->id) || (ob->data && !BKE_id_is_editable(bmain, static_cast(ob->data)))) && - !keep_original) { + !keep_original) + { keep_original = true; BKE_report(op->reports, RPT_INFO, @@ -3225,7 +3246,8 @@ static int object_convert_exec(bContext *C, wmOperator *op) /* other users */ if (ID_REAL_USERS(&cu->id) > 1) { for (ob1 = static_cast(bmain->objects.first); ob1; - ob1 = static_cast(ob1->id.next)) { + ob1 = static_cast(ob1->id.next)) + { if (ob1->data == ob->data) { ob1->type = OB_CURVES_LEGACY; DEG_id_tag_update(&ob1->id, @@ -3455,7 +3477,8 @@ static int object_convert_exec(bContext *C, wmOperator *op) if (ob_mball->type == OB_MBALL) { Object *ob_basis = nullptr; if (!BKE_mball_is_basis(ob_mball) && - ((ob_basis = BKE_mball_basis_find(scene, ob_mball)) && (ob_basis->flag & OB_DONE))) { + ((ob_basis = BKE_mball_basis_find(scene, ob_mball)) && (ob_basis->flag & OB_DONE))) + { ED_object_base_free_and_unlink(bmain, scene, ob_mball); } } @@ -4107,7 +4130,8 @@ static bool object_join_poll(bContext *C) Object *ob = CTX_data_active_object(C); if (ob == nullptr || ob->data == nullptr || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) || - ID_IS_OVERRIDE_LIBRARY(ob->data)) { + ID_IS_OVERRIDE_LIBRARY(ob->data)) + { return false; } @@ -4213,7 +4237,8 @@ static bool join_shapes_poll(bContext *C) Object *ob = CTX_data_active_object(C); if (ob == nullptr || ob->data == nullptr || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) || - ID_IS_OVERRIDE_LIBRARY(ob->data)) { + ID_IS_OVERRIDE_LIBRARY(ob->data)) + { return false; } diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index 49cc126c6a6..1c2f182ae20 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -550,11 +550,13 @@ static bool bake_pass_filter_check(eScenePassType pass_type, } if (((pass_filter & R_BAKE_PASS_FILTER_DIRECT) != 0) || - ((pass_filter & R_BAKE_PASS_FILTER_INDIRECT) != 0)) { + ((pass_filter & R_BAKE_PASS_FILTER_INDIRECT) != 0)) + { if (((pass_filter & R_BAKE_PASS_FILTER_DIFFUSE) != 0) || ((pass_filter & R_BAKE_PASS_FILTER_GLOSSY) != 0) || ((pass_filter & R_BAKE_PASS_FILTER_TRANSM) != 0) || - ((pass_filter & R_BAKE_PASS_FILTER_SUBSURFACE) != 0)) { + ((pass_filter & R_BAKE_PASS_FILTER_SUBSURFACE) != 0)) + { return true; } @@ -576,7 +578,8 @@ static bool bake_pass_filter_check(eScenePassType pass_type, case SCE_PASS_SUBSURFACE_COLOR: if (((pass_filter & R_BAKE_PASS_FILTER_COLOR) != 0) || ((pass_filter & R_BAKE_PASS_FILTER_DIRECT) != 0) || - ((pass_filter & R_BAKE_PASS_FILTER_INDIRECT) != 0)) { + ((pass_filter & R_BAKE_PASS_FILTER_INDIRECT) != 0)) + { return true; } else { @@ -871,9 +874,9 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, BakeImage *bk_image = &targets->images[i]; BakeData *bake = &bkr->scene->r.bake; - char name[FILE_MAX]; + char filepath[FILE_MAX]; - BKE_image_path_from_imtype(name, + BKE_image_path_from_imtype(filepath, bkr->filepath, BKE_main_blendfile_path(bkr->main), 0, @@ -883,33 +886,33 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, nullptr); if (bkr->is_automatic_name) { - BLI_path_suffix(name, FILE_MAX, ob->id.name + 2, "_"); - BLI_path_suffix(name, FILE_MAX, bkr->identifier, "_"); + BLI_path_suffix(filepath, FILE_MAX, ob->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, bkr->identifier, "_"); } if (bkr->is_split_materials) { if (ob_eval->mat[i]) { - BLI_path_suffix(name, FILE_MAX, ob_eval->mat[i]->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, ob_eval->mat[i]->id.name + 2, "_"); } else if (mesh_eval->mat[i]) { - BLI_path_suffix(name, FILE_MAX, mesh_eval->mat[i]->id.name + 2, "_"); + BLI_path_suffix(filepath, FILE_MAX, mesh_eval->mat[i]->id.name + 2, "_"); } else { /* if everything else fails, use the material index */ char tmp[5]; BLI_snprintf(tmp, sizeof(tmp), "%d", i % 1000); - BLI_path_suffix(name, FILE_MAX, tmp, "_"); + BLI_path_suffix(filepath, FILE_MAX, tmp, "_"); } } if (bk_image->tile_number) { char tmp[FILE_MAX]; SNPRINTF(tmp, "%d", bk_image->tile_number); - BLI_path_suffix(name, FILE_MAX, tmp, "_"); + BLI_path_suffix(filepath, FILE_MAX, tmp, "_"); } /* save it externally */ - const bool ok = write_external_bake_pixels(name, + const bool ok = write_external_bake_pixels(filepath, pixel_array + bk_image->offset, targets->result + bk_image->offset * targets->channels_num, @@ -924,11 +927,11 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, bk_image->uv_offset); if (!ok) { - BKE_reportf(reports, RPT_ERROR, "Problem saving baked map in \"%s\"", name); + BKE_reportf(reports, RPT_ERROR, "Problem saving baked map in \"%s\"", filepath); all_ok = false; } else { - BKE_reportf(reports, RPT_INFO, "Baking map written to \"%s\"", name); + BKE_reportf(reports, RPT_INFO, "Baking map written to \"%s\"", filepath); } if (!bkr->is_split_materials) { @@ -1430,7 +1433,8 @@ static int bake(const BakeAPIRender *bkr, /* for multires bake, use linear UV subdivision to match low res UVs */ if (bkr->pass_type == SCE_PASS_NORMAL && bkr->normal_space == R_BAKE_SPACE_TANGENT && - !bkr->is_selected_to_active) { + !bkr->is_selected_to_active) + { mmd_low = (MultiresModifierData *)BKE_modifiers_findby_type(ob_low, eModifierType_Multires); if (mmd_low) { mmd_flags_low = mmd_low->flags; @@ -1466,7 +1470,8 @@ static int bake(const BakeAPIRender *bkr, if (ob_cage) { me_cage_eval = bake_mesh_new_from_object(depsgraph, ob_cage_eval, preserve_origindex); if ((me_low_eval->totpoly != me_cage_eval->totpoly) || - (me_low_eval->totloop != me_cage_eval->totloop)) { + (me_low_eval->totloop != me_cage_eval->totloop)) + { BKE_report(reports, RPT_ERROR, "Invalid cage object, the cage mesh must have the same number " @@ -1565,7 +1570,8 @@ static int bake(const BakeAPIRender *bkr, bkr->max_ray_distance, ob_low_eval->object_to_world, (ob_cage ? ob_cage->object_to_world : ob_low_eval->object_to_world), - me_cage_eval)) { + me_cage_eval)) + { BKE_report(reports, RPT_ERROR, "Error handling selected objects"); goto cleanup; } @@ -1616,7 +1622,8 @@ static int bake(const BakeAPIRender *bkr, case R_BAKE_SPACE_WORLD: { /* Cycles internal format */ if ((bkr->normal_swizzle[0] == R_BAKE_POSX) && (bkr->normal_swizzle[1] == R_BAKE_POSY) && - (bkr->normal_swizzle[2] == R_BAKE_POSZ)) { + (bkr->normal_swizzle[2] == R_BAKE_POSZ)) + { break; } RE_bake_normal_world_to_world(pixel_array_low, @@ -1801,7 +1808,8 @@ static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr) } if (((bkr->pass_type == SCE_PASS_NORMAL) && (bkr->normal_space == R_BAKE_SPACE_TANGENT)) || - bkr->pass_type == SCE_PASS_UV) { + bkr->pass_type == SCE_PASS_UV) + { bkr->margin_type = R_BAKE_EXTEND; } } @@ -1835,7 +1843,8 @@ static int bake_exec(bContext *C, wmOperator *op) &bkr.selected_objects, bkr.reports, bkr.is_selected_to_active, - bkr.target)) { + bkr.target)) + { goto finally; } @@ -1854,7 +1863,8 @@ static int bake_exec(bContext *C, wmOperator *op) CollectionPointerLink *link; bkr.is_clear = bkr.is_clear && BLI_listbase_is_single(&bkr.selected_objects); for (link = static_cast(bkr.selected_objects.first); link; - link = link->next) { + link = link->next) + { Object *ob_iter = static_cast(link->ptr.data); result = bake(&bkr, ob_iter, nullptr, bkr.reports); } @@ -1890,7 +1900,8 @@ static void bake_startjob(void *bkv, bool * /*stop*/, bool *do_update, float *pr &bkr->selected_objects, bkr->reports, bkr->is_selected_to_active, - bkr->target)) { + bkr->target)) + { bkr->result = OPERATOR_CANCELLED; return; } @@ -1908,7 +1919,8 @@ static void bake_startjob(void *bkv, bool * /*stop*/, bool *do_update, float *pr CollectionPointerLink *link; bkr->is_clear = bkr->is_clear && BLI_listbase_is_single(&bkr->selected_objects); for (link = static_cast(bkr->selected_objects.first); link; - link = link->next) { + link = link->next) + { Object *ob_iter = static_cast(link->ptr.data); bkr->result = bake(bkr, ob_iter, nullptr, bkr->reports); diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c index 8d96dce3fc8..23c14078867 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.c @@ -578,7 +578,8 @@ static int collection_unlink_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (ID_IS_OVERRIDE_LIBRARY(collection) && - collection->id.override_library->hierarchy_root != &collection->id) { + collection->id.override_library->hierarchy_root != &collection->id) + { BKE_report(op->reports, RPT_ERROR, "Cannot unlink a library override collection which is not the root of its override " diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 19e51bfa2d4..7202e954911 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -522,8 +522,8 @@ static void test_constraint( if (ct->tar->type != OB_ARMATURE) { con->flag |= CONSTRAINT_DISABLE; } - else if (!BKE_armature_find_bone_name(BKE_armature_from_object(ct->tar), - ct->subtarget)) { + else if (!BKE_armature_find_bone_name(BKE_armature_from_object(ct->tar), ct->subtarget)) + { /* bone must exist in armature... */ con->flag |= CONSTRAINT_DISABLE; } @@ -719,7 +719,8 @@ static bool edit_constraint_invoke_properties(bContext *C, ListBase *list; if (RNA_struct_property_is_set(op->ptr, "constraint") && - RNA_struct_property_is_set(op->ptr, "owner")) { + RNA_struct_property_is_set(op->ptr, "owner")) + { return true; } @@ -1064,7 +1065,8 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) Curve *cu = (Curve *)data->tar->data; if (ELEM(NULL, cu->adt, cu->adt->action) || - (BKE_fcurve_find(&cu->adt->action->curves, "eval_time", 0) == NULL)) { + (BKE_fcurve_find(&cu->adt->action->curves, "eval_time", 0) == NULL)) + { /* create F-Curve for path animation */ act = ED_id_action_ensure(bmain, &cu->id); fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, "eval_time", 0); @@ -2043,7 +2045,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Pose Constraints"; ot->idname = "POSE_OT_constraints_clear"; - ot->description = "Clear all the constraints for the selected bones"; + ot->description = "Clear all constraints from the selected bones"; /* callbacks */ ot->exec = pose_constraints_clear_exec; @@ -2082,7 +2084,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Object Constraints"; ot->idname = "OBJECT_OT_constraints_clear"; - ot->description = "Clear all the constraints for the active object only"; + ot->description = "Clear all constraints from the selected objects"; /* callbacks */ ot->exec = object_constraints_clear_exec; @@ -2275,8 +2277,8 @@ static bool get_new_constraint_target( /* for armatures in pose mode, look inside the armature for the active bone * so that we set up cross-armature constraints with less effort */ - if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && - (!only_curve && !only_mesh)) { + if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && (!only_curve && !only_mesh)) + { /* Only use the object & bone if the bone is visible & selected * since we may have multiple objects in pose mode at once. */ diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 4da6d6df959..e51faafe33c 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -519,7 +519,8 @@ static int data_transfer_exec(bContext *C, wmOperator *op) mix_factor, NULL, false, - op->reports)) { + op->reports)) + { if (data_type == DT_TYPE_LNOR && use_create) { ((Mesh *)ob_dst->data)->flag |= ME_AUTOSMOOTH; diff --git a/source/blender/editors/object/object_data_transform.cc b/source/blender/editors/object/object_data_transform.cc index ff670681c31..5cf026393fe 100644 --- a/source/blender/editors/object/object_data_transform.cc +++ b/source/blender/editors/object/object_data_transform.cc @@ -155,7 +155,8 @@ static void edit_armature_coords_and_quats_get(const bArmature *arm, ElemData_Ar { ElemData_Armature *elem = elem_array; for (EditBone *ebone = static_cast(arm->edbo->first); ebone; - ebone = ebone->next, elem++) { + ebone = ebone->next, elem++) + { #define COPY_PTR(member) memcpy(elem->member, ebone->member, sizeof(ebone->member)) #define COPY_VAL(member) memcpy(&elem->member, &ebone->member, sizeof(ebone->member)) @@ -179,7 +180,8 @@ static void edit_armature_coords_and_quats_apply_with_mat4(bArmature *arm, { const ElemData_Armature *elem = elem_array; for (EditBone *ebone = static_cast(arm->edbo->first); ebone; - ebone = ebone->next, elem++) { + ebone = ebone->next, elem++) + { #define COPY_PTR(member) memcpy(ebone->member, elem->member, sizeof(ebone->member)) #define COPY_VAL(member) memcpy(&ebone->member, &elem->member, sizeof(ebone->member)) @@ -220,7 +222,8 @@ static void metaball_coords_and_quats_get(const MetaBall *mb, struct ElemData_Me { struct ElemData_MetaBall *elem = elem_array; for (const MetaElem *ml = static_cast(mb->elems.first); ml; - ml = ml->next, elem++) { + ml = ml->next, elem++) + { copy_v3_v3(elem->co, &ml->x); copy_qt_qt(elem->quat, ml->quat); copy_v3_v3(elem->exp, &ml->expx); diff --git a/source/blender/editors/object/object_edit.cc b/source/blender/editors/object/object_edit.cc index 9bc7b3a3320..2e79d4d59ef 100644 --- a/source/blender/editors/object/object_edit.cc +++ b/source/blender/editors/object/object_edit.cc @@ -171,7 +171,8 @@ Object **ED_object_array_in_mode_or_selected(bContext *C, ob = ob_active; } else if (ob_active && (ob_active->mode & - (OB_MODE_ALL_PAINT | OB_MODE_ALL_SCULPT | OB_MODE_ALL_PAINT_GPENCIL))) { + (OB_MODE_ALL_PAINT | OB_MODE_ALL_SCULPT | OB_MODE_ALL_PAINT_GPENCIL))) + { /* When painting, limit to active. */ ob = ob_active; } @@ -796,7 +797,8 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag bool ok = false; if (ELEM(nullptr, ob, ob->data) || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob) || - ID_IS_OVERRIDE_LIBRARY(ob->data)) { + ID_IS_OVERRIDE_LIBRARY(ob->data)) + { return false; } @@ -958,7 +960,8 @@ static bool editmode_toggle_poll(bContext *C) /* Covers liboverrides too. */ if (ELEM(nullptr, ob, ob->data) || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob) || - ID_IS_OVERRIDE_LIBRARY(ob->data)) { + ID_IS_OVERRIDE_LIBRARY(ob->data)) + { return false; } @@ -1045,7 +1048,8 @@ static int posemode_exec(bContext *C, wmOperator *op) const View3D *v3d = CTX_wm_view3d(C); FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) { if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_OBJECT) && - BKE_id_is_editable(bmain, &ob->id)) { + BKE_id_is_editable(bmain, &ob->id)) + { ED_object_posemode_enter_ex(bmain, ob); } } @@ -1091,7 +1095,8 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object) /* add/remove modifier as needed */ if (!md) { if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && - !ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) { + !ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) + { if (ELEM(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVES_LEGACY)) { ED_object_modifier_add(nullptr, bmain, scene, object, nullptr, eModifierType_Surface); } @@ -1099,7 +1104,8 @@ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object) } else { if (!pd || (pd->shape != PFIELD_SHAPE_SURFACE) || - ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) { + ELEM(pd->forcefield, 0, PFIELD_GUIDE, PFIELD_TEXTURE)) + { ED_object_modifier_remove(nullptr, bmain, scene, object, md); } } @@ -1632,7 +1638,8 @@ static bool shade_poll(bContext *C) if (obact != nullptr) { /* Doesn't handle edit-data, sculpt dynamic-topology, or their undo systems. */ if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == nullptr || - ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) { + ID_IS_OVERRIDE_LIBRARY(obact) || ID_IS_OVERRIDE_LIBRARY(obact->data)) + { return false; } } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 11973901ad7..868bc12fe46 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -669,7 +669,8 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); if (add_hook_object( - C, bmain, scene, view_layer, v3d, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) { + C, bmain, scene, view_layer, v3d, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) + { DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); diff --git a/source/blender/editors/object/object_modes.cc b/source/blender/editors/object/object_modes.cc index 36ff752e60d..66ecf468f70 100644 --- a/source/blender/editors/object/object_modes.cc +++ b/source/blender/editors/object/object_modes.cc @@ -109,7 +109,8 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) switch (ob->type) { case OB_MESH: if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | - OB_MODE_TEXTURE_PAINT)) { + OB_MODE_TEXTURE_PAINT)) + { return true; } if (mode & OB_MODE_PARTICLE_EDIT) { diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index ca9ae5e255d..4306722b071 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -272,7 +272,8 @@ bool ED_object_iter_other(Main *bmain, int totfound = include_orig ? 0 : 1; for (ob = static_cast(bmain->objects.first); ob && totfound < users; - ob = reinterpret_cast(ob->id.next)) { + ob = reinterpret_cast(ob->id.next)) + { if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) { if (callback(ob, callback_data)) { return true; @@ -365,7 +366,8 @@ static bool object_modifier_remove( } if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && - BLI_listbase_is_empty(&ob->particlesystem)) { + BLI_listbase_is_empty(&ob->particlesystem)) + { ob->mode &= ~OB_MODE_PARTICLE_EDIT; } @@ -782,7 +784,8 @@ static Mesh *create_applied_mesh_for_modifier(Depsgraph *depsgraph, for (ModifierData *md_eval_virt = BKE_modifiers_get_virtual_modifierlist(ob_eval, &virtualModifierData); md_eval_virt && (md_eval_virt != ob_eval->modifiers.first); - md_eval_virt = md_eval_virt->next) { + md_eval_virt = md_eval_virt->next) + { if (!BKE_modifier_is_enabled(scene, md_eval_virt, eModifierMode_Realtime)) { continue; } @@ -935,12 +938,14 @@ static void remove_invalid_attribute_strings(Mesh &mesh) bke::AttributeAccessor attributes = mesh.attributes(); if (!meta_data_matches(attributes.lookup_meta_data(mesh.active_color_attribute), ATTR_DOMAIN_MASK_COLOR, - CD_MASK_COLOR_ALL)) { + CD_MASK_COLOR_ALL)) + { MEM_SAFE_FREE(mesh.active_color_attribute); } if (!meta_data_matches(attributes.lookup_meta_data(mesh.default_color_attribute), ATTR_DOMAIN_MASK_COLOR, - CD_MASK_COLOR_ALL)) { + CD_MASK_COLOR_ALL)) + { MEM_SAFE_FREE(mesh.default_color_attribute); } } @@ -1147,7 +1152,8 @@ bool ED_object_modifier_apply(Main *bmain, return false; } if ((ob->mode & OB_MODE_SCULPT) && find_multires_modifier_before(scene, md) && - (BKE_modifier_is_same_topology(md) == false)) { + (BKE_modifier_is_same_topology(md) == false)) + { BKE_report(reports, RPT_ERROR, "Constructive modifier cannot be applied to multi-res data in sculpt mode"); @@ -1172,7 +1178,8 @@ bool ED_object_modifier_apply(Main *bmain, * * The idea is to create a dependency graph which does not perform those optimizations. */ if ((ob_eval->base_flag & BASE_ENABLED_VIEWPORT) == 0 || - (md_eval->mode & eModifierMode_Realtime) == 0) { + (md_eval->mode & eModifierMode_Realtime) == 0) + { ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); local_depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_VIEWPORT); @@ -1716,7 +1723,8 @@ static bool modifier_apply_poll(bContext *C) } if (md != nullptr) { if ((ob->mode & OB_MODE_SCULPT) && find_multires_modifier_before(scene, md) && - (BKE_modifier_is_same_topology(md) == false)) { + (BKE_modifier_is_same_topology(md) == false)) + { CTX_wm_operator_poll_msg_set( C, "Constructive modifier cannot be applied to multi-res data in sculpt mode"); return false; @@ -1762,12 +1770,14 @@ static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, boo } if (!ED_object_modifier_apply( - bmain, op->reports, depsgraph, scene, ob, md, apply_as, keep_modifier)) { + bmain, op->reports, depsgraph, scene, ob, md, apply_as, keep_modifier)) + { return OPERATOR_CANCELLED; } if (ob->type == OB_MESH && do_merge_customdata && - (mti->type & (eModifierTypeType_Constructive | eModifierTypeType_Nonconstructive))) { + (mti->type & (eModifierTypeType_Constructive | eModifierTypeType_Nonconstructive))) + { BKE_mesh_merge_customdata_for_apply_modifier((Mesh *)ob->data); } @@ -1919,7 +1929,8 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) ModifierData *md = edit_modifier_property_get(op, ob, 0); if (!md || !ED_object_modifier_convert_psys_to_mesh( - op->reports, bmain, depsgraph, scene, view_layer, ob, md)) { + op->reports, bmain, depsgraph, scene, view_layer, ob, md)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 396db04aded..ace5c660bcf 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -823,7 +823,8 @@ static bool parent_set_nonvertex_parent(bContext *C, struct ParentingContext *pa parenting_context->partype, parenting_context->xmirror, parenting_context->keep_transform, - NULL)) { + NULL)) + { return false; } } @@ -854,7 +855,8 @@ static bool parent_set_vertex_parent_with_kdtree(bContext *C, parenting_context->partype, parenting_context->xmirror, parenting_context->keep_transform, - vert_par)) { + vert_par)) + { return false; } } @@ -1431,7 +1433,8 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst /* Linking non-grease-pencil materials to a grease-pencil object causes issues. * We make sure that if one of the objects is a grease-pencil object, the other must be * as well. */ - ((ob_src->type == OB_GPENCIL_LEGACY) == (ob_dst->type == OB_GPENCIL_LEGACY))) { + ((ob_src->type == OB_GPENCIL_LEGACY) == (ob_dst->type == OB_GPENCIL_LEGACY))) + { return true; } break; @@ -1449,8 +1452,8 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst } break; case MAKE_LINKS_FONTS: - if ((ob_src->data != ob_dst->data) && (ob_src->type == OB_FONT) && - (ob_dst->type == OB_FONT)) { + if ((ob_src->data != ob_dst->data) && (ob_src->type == OB_FONT) && (ob_dst->type == OB_FONT)) + { return true; } break; @@ -2289,7 +2292,8 @@ static int make_override_library_exec(bContext *C, wmOperator *op) bool user_overrides_from_selected_objects = false; if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && - ID_IS_LINKED(obact->instance_collection)) { + ID_IS_LINKED(obact->instance_collection)) + { if (!ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) { BKE_reportf(op->reports, RPT_ERROR_INVALID_INPUT, @@ -2331,7 +2335,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op) bool is_active_override = false; FOREACH_SELECTED_OBJECT_BEGIN (view_layer, CTX_wm_view3d(C), ob_iter) { if (ID_IS_OVERRIDE_LIBRARY_REAL(ob_iter) && !ID_IS_LINKED(ob_iter)) { - ob_iter->id.override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + ob_iter->id.override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; is_active_override = is_active_override || (&ob_iter->id == id_root); DEG_id_tag_update(&ob_iter->id, ID_RECALC_COPY_ON_WRITE); } @@ -2385,7 +2389,8 @@ static int make_override_library_exec(bContext *C, wmOperator *op) } LISTBASE_FOREACH (CollectionObject *, coll_ob_iter, &coll_iter->gobject) { if (BLI_gset_haskey(user_overrides_objects_uids, - POINTER_FROM_UINT(coll_ob_iter->ob->id.session_uuid))) { + POINTER_FROM_UINT(coll_ob_iter->ob->id.session_uuid))) + { /* Tag for remapping when creating overrides. */ coll_iter->id.tag |= LIB_TAG_DOIT; break; @@ -2411,12 +2416,14 @@ static int make_override_library_exec(bContext *C, wmOperator *op) ID *id_iter; FOREACH_MAIN_ID_BEGIN (bmain, id_iter) { if (ID_IS_LINKED(id_iter) || !ID_IS_OVERRIDE_LIBRARY_REAL(id_iter) || - id_iter->override_library->hierarchy_root != id_hierarchy_root_override) { + id_iter->override_library->hierarchy_root != id_hierarchy_root_override) + { continue; } if (BLI_gset_haskey(user_overrides_objects_uids, - POINTER_FROM_UINT(id_iter->override_library->reference->session_uuid))) { - id_iter->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + POINTER_FROM_UINT(id_iter->override_library->reference->session_uuid))) + { + id_iter->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } } FOREACH_MAIN_ID_END; @@ -2438,7 +2445,8 @@ static int make_override_library_exec(bContext *C, wmOperator *op) LISTBASE_FOREACH_MUTABLE ( CollectionParent *, collection_parent, &collection_root->runtime.parents) { if (ID_IS_LINKED(collection_parent->collection) || - !BKE_view_layer_has_collection(view_layer, collection_parent->collection)) { + !BKE_view_layer_has_collection(view_layer, collection_parent->collection)) + { continue; } BKE_collection_child_remove(bmain, collection_parent->collection, collection_root); @@ -2479,7 +2487,8 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) || - make_override_library_object_overridable_check(bmain, obact)) { + make_override_library_object_overridable_check(bmain, obact)) + { return make_override_library_exec(C, op); } @@ -2496,7 +2505,8 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve LISTBASE_FOREACH (Collection *, collection, &bmain->collections) { /* Only check for directly linked collections. */ if (!ID_IS_LINKED(&collection->id) || (collection->id.tag & LIB_TAG_INDIRECT) != 0 || - !BKE_view_layer_has_collection(view_layer, collection)) { + !BKE_view_layer_has_collection(view_layer, collection)) + { continue; } if (BKE_collection_has_object_recursive(collection, obact)) { @@ -2637,7 +2647,8 @@ static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) FOREACH_SELECTED_OBJECT_END; for (todo_object_iter = todo_objects; todo_object_iter != NULL; - todo_object_iter = todo_object_iter->next) { + todo_object_iter = todo_object_iter->next) + { Object *ob_iter = todo_object_iter->link; if (BKE_lib_override_library_is_hierarchy_leaf(bmain, &ob_iter->id)) { bool do_remap_active = false; diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index a9ee1d32803..b403c16e8a3 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -388,7 +388,8 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve /* Cancel modal operator */ if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || - (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { + (event->type == RIGHTMOUSE && event->val == KM_PRESS)) + { voxel_size_edit_cancel(C, op); ED_region_tag_redraw(region); return OPERATOR_FINISHED; @@ -397,7 +398,8 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve /* Finish modal operator */ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || (event->type == EVT_RETKEY && event->val == KM_PRESS) || - (event->type == EVT_PADENTER && event->val == KM_PRESS)) { + (event->type == EVT_PADENTER && event->val == KM_PRESS)) + { ED_region_draw_cb_exit(region->type, cd->draw_handle); mesh->remesh_voxel_size = cd->voxel_size; MEM_freeN(op->customdata); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index d99cf32f650..3e5963b6f7b 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -822,7 +822,8 @@ static bool select_grouped_collection(bContext *C, Object *ob) for (collection = bmain->collections.first; collection && (collection_count < COLLECTION_MENU_MAX); - collection = collection->id.next) { + collection = collection->id.next) + { if (BKE_collection_has_object(collection, ob)) { ob_collections[collection_count] = collection; collection_count++; diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index e006afc430a..67efc54f9d6 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -144,7 +144,8 @@ static void object_clear_rot(Object *ob, const bool clear_delta) ob->rotAxis[1] = 1.0f; } if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2]) && - clear_delta) { + clear_delta) + { ob->drotAxis[1] = 1.0f; } } @@ -712,7 +713,8 @@ static int apply_objects_internal(bContext *C, OB_FONT, OB_GPENCIL_LEGACY, OB_CURVES, - OB_POINTCLOUD)) { + OB_POINTCLOUD)) + { ID *obdata = static_cast(ob->data); if (!do_multi_user && ID_REAL_USERS(obdata) > 1) { BKE_reportf(reports, @@ -1397,7 +1399,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (ob->data == nullptr) { /* Special support for instanced collections. */ if ((ob->transflag & OB_DUPLICOLLECTION) && ob->instance_collection && - (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) { + (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) + { if (!BKE_id_is_editable(bmain, &ob->instance_collection->id)) { tot_lib_error++; } @@ -1677,7 +1680,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Curves &curves_id = *static_cast(ob->data); bke::CurvesGeometry &curves = curves_id.geometry.wrap(); if (ELEM(centermode, ORIGIN_TO_CENTER_OF_MASS_SURFACE, ORIGIN_TO_CENTER_OF_MASS_VOLUME) || - !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) { + !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) + { BKE_report( op->reports, RPT_WARNING, "Curves Object does not support this set origin operation"); continue; @@ -1712,7 +1716,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) bke::SpanAttributeWriter positions = attributes.lookup_or_add_for_write_span( "position", ATTR_DOMAIN_POINT); if (ELEM(centermode, ORIGIN_TO_CENTER_OF_MASS_SURFACE, ORIGIN_TO_CENTER_OF_MASS_VOLUME) || - !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) { + !ELEM(around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN)) + { BKE_report(op->reports, RPT_WARNING, "Point cloud object does not support this set origin operation"); @@ -1774,7 +1779,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if ((ob_other->flag & OB_DONE) == 0 && ((ob->data && (ob->data == ob_other->data)) || (ob->instance_collection == ob_other->instance_collection && - (ob->transflag | ob_other->transflag) & OB_DUPLICOLLECTION))) { + (ob->transflag | ob_other->transflag) & OB_DUPLICOLLECTION))) + { ob_other->flag |= OB_DONE; DEG_id_tag_update(&ob_other->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); @@ -2287,7 +2293,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const else { for (XFormAxisItem &item : xfd->object_data) { if (object_orient_to_location( - item.ob, item.rot_mat, item.rot_mat[2], location_world, item.is_z_flip)) { + item.ob, item.rot_mat, item.rot_mat[2], location_world, item.is_z_flip)) + { DEG_id_tag_update(&item.ob->id, ID_RECALC_TRANSFORM); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, item.ob); } diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index 55e7e71b9e2..5c33228726d 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -98,7 +98,8 @@ static bool vertex_group_use_vert_sel(Object *ob) return true; } if ((ob->type == OB_MESH) && - ((Mesh *)ob->data)->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) { + ((Mesh *)ob->data)->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) + { return true; } return false; @@ -274,7 +275,8 @@ void ED_vgroup_parray_mirror_sync(Object *ob, /* get an array of all verts, not only selected */ if (ED_vgroup_parray_alloc( - static_cast(ob->data), &dvert_array_all, &dvert_tot_all, false) == false) { + static_cast(ob->data), &dvert_array_all, &dvert_tot_all, false) == false) + { BLI_assert(0); return; } @@ -314,7 +316,8 @@ void ED_vgroup_parray_mirror_assign(Object *ob, MDeformVert **dvert_array, const /* get an array of all verts, not only selected */ if (ED_vgroup_parray_alloc( - static_cast(ob->data), &dvert_array_all, &dvert_tot_all, false) == false) { + static_cast(ob->data), &dvert_array_all, &dvert_tot_all, false) == false) + { BLI_assert(0); return; } @@ -399,13 +402,15 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from) ED_vgroup_parray_alloc(static_cast(ob->data), &dvert_array, &dvert_tot, false); if ((dvert_array == nullptr) && (dvert_array_from != nullptr) && - BKE_object_defgroup_data_create(static_cast(ob->data))) { + BKE_object_defgroup_data_create(static_cast(ob->data))) + { ED_vgroup_parray_alloc(static_cast(ob->data), &dvert_array, &dvert_tot, false); new_vgroup = true; } if (dvert_tot == 0 || (dvert_tot != dvert_tot_from) || dvert_array_from == nullptr || - dvert_array == nullptr) { + dvert_array == nullptr) + { if (dvert_array) { MEM_freeN(dvert_array); } @@ -2030,7 +2035,8 @@ void ED_vgroup_mirror(Object *ob, const ListBase *defbase = BKE_object_defgroup_list(ob); if ((mirror_weights == false && flip_vgroups == false) || - (BLI_findlink(defbase, def_nr) == nullptr)) { + (BLI_findlink(defbase, def_nr) == nullptr)) + { return; } @@ -3577,7 +3583,8 @@ static char *vgroup_init_remap(Object *ob) name = name_array; for (const bDeformGroup *def = static_cast(defbase->first); def; - def = def->next) { + def = def->next) + { BLI_strncpy(name, def->name, MAX_VGROUP_NAME); name += MAX_VGROUP_NAME; } diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c index 84d2f69497f..5b1177edc39 100644 --- a/source/blender/editors/object/object_volume.c +++ b/source/blender/editors/object/object_volume.c @@ -79,7 +79,7 @@ static int volume_import_exec(bContext *C, wmOperator *op) ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, false); LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) { char filename[FILE_MAX]; - BLI_split_file_part(range->filepath, filename, sizeof(filename)); + BLI_path_split_file_part(range->filepath, filename, sizeof(filename)); BLI_path_extension_strip(filename); Object *object = object_volume_add(C, op, filename); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 1a3f0f0f2ac..6fffa3257ed 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -407,7 +407,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* set filepath */ BLI_path_join( filepath, sizeof(filepath), surface->image_output_path, surface->output_name); - BLI_path_frame(filepath, frame, 4); + BLI_path_frame(filepath, sizeof(filepath), frame, 4); /* save image */ dynamicPaint_outputSurfaceImage(surface, filepath, 0); @@ -417,7 +417,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* set filepath */ BLI_path_join( filepath, sizeof(filepath), surface->image_output_path, surface->output_name2); - BLI_path_frame(filepath, frame, 4); + BLI_path_frame(filepath, sizeof(filepath), frame, 4); /* save image */ dynamicPaint_outputSurfaceImage(surface, filepath, 1); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f6209976d8a..6afd2f34dcc 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -622,7 +622,8 @@ static bool key_inside_circle(const PEData *data, float rad, const float co[3], /* TODO: should this check V3D_PROJ_TEST_CLIP_BB too? */ if (ED_view3d_project_int_global(data->vc.region, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return 0; } @@ -650,12 +651,14 @@ static bool key_inside_rect(PEData *data, const float co[3]) int screen_co[2]; if (ED_view3d_project_int_global(data->vc.region, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return 0; } if (screen_co[0] > data->rect->xmin && screen_co[0] < data->rect->xmax && - screen_co[1] > data->rect->ymin && screen_co[1] < data->rect->ymax) { + screen_co[1] > data->rect->ymin && screen_co[1] < data->rect->ymax) + { return key_test_depth(data, co, screen_co); } @@ -1264,7 +1267,8 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) const float dist = ED_view3d_select_dist_px() * 0.01f; if (edit == NULL || edit->psys == NULL || (pset->flag & PE_DEFLECT_EMITTER) == 0 || - (edit->psys->flag & PSYS_GLOBAL_HAIR)) { + (edit->psys->flag & PSYS_GLOBAL_HAIR)) + { return; } @@ -3769,7 +3773,8 @@ static void brush_cut(PEData *data, int pa_index) } if (ED_view3d_project_int_global(region, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return; } @@ -3797,7 +3802,8 @@ static void brush_cut(PEData *data, int pa_index) if ((ED_view3d_project_int_global(region, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) || - key_test_depth(data, key->co, screen_co) == 0) { + key_test_depth(data, key->co, screen_co) == 0) + { x0 = (float)screen_co[0]; x1 = (float)screen_co[1]; @@ -4347,7 +4353,8 @@ static void brush_add_count_iter(void *__restrict iter_data_v, 0, 0, 0, - 0)) { + 0)) + { if (psys->part->use_modifier_stack && !BKE_mesh_is_deformed_only(psmd_eval->mesh_final)) { add_pars[iter].num = add_pars[iter].num_dmcache; add_pars[iter].num_dmcache = DMCACHE_ISCHILD; @@ -4761,7 +4768,8 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if (((pset->brushtype == PE_BRUSH_ADD) ? (sqrtf(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || - bedit->first) { + bedit->first) + { PEData data = bedit->data; data.context = C; /* TODO(mai): why isn't this set in bedit->data? */ diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 0a2e4f53620..54e2afc4711 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -773,7 +773,8 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, int i; for (i = 0, tpa = target_psys->particles, pa = psys->particles; i < target_psys->totpart; - i++, tpa++, pa++) { + i++, tpa++, pa++) + { float from_co[3]; BVHTreeNearest nearest; @@ -857,7 +858,8 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, if (edit_point) { for (k = 0, key = pa->hair, tkey = tpa->hair, ekey = edit_point->keys; k < tpa->totkey; - k++, key++, tkey++, ekey++) { + k++, key++, tkey++, ekey++) + { float co_orig[3]; if (from_global) { @@ -1128,8 +1130,8 @@ static bool copy_particle_systems_to_object(const bContext *C, psys_start = totpsys > 0 ? tmp_psys[0] : NULL; /* now append psys to the object and make modifiers */ - for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; - ++i, psys_from = PSYS_FROM_NEXT(psys_from)) { + for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; ++i, psys_from = PSYS_FROM_NEXT(psys_from)) + { ParticleSystemModifierData *psmd; psys = tmp_psys[i]; @@ -1164,7 +1166,8 @@ static bool copy_particle_systems_to_object(const bContext *C, * the remapping otherwise makes final_dm invalid! */ for (psys = psys_start, psys_from = PSYS_FROM_FIRST, i = 0; psys; - psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), i++) { + psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), i++) + { float(*from_mat)[4], (*to_mat)[4]; switch (space) { diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 2383a3b85c9..2c95f9e932b 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -617,7 +617,8 @@ static int fluid_free_exec(struct bContext *C, struct wmOperator *op) /* Cannot free data if other bakes currently working */ if (fmd->domain->cache_flag & (FLUID_DOMAIN_BAKING_DATA | FLUID_DOMAIN_BAKING_NOISE | - FLUID_DOMAIN_BAKING_MESH | FLUID_DOMAIN_BAKING_PARTICLES)) { + FLUID_DOMAIN_BAKING_MESH | FLUID_DOMAIN_BAKING_PARTICLES)) + { BKE_report(op->reports, RPT_ERROR, "Bake free failed: pending bake jobs found"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 9fac93187ee..36c330a2d63 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -188,7 +188,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) if (!all) { PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); - Object *ob = (Object *)ptr.owner_id; + ID *id = ptr.owner_id; + Object *ob = (GS(id->name) == ID_OB) ? (Object *)id : NULL; PointCache *cache = ptr.data; baker->pid = BKE_ptcache_id_find(ob, baker->scene, cache); } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index d411465f251..a27e3e23270 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -46,7 +46,8 @@ static bool operator_rigidbody_constraints_editable_poll(Scene *scene) if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && (ID_IS_LINKED(scene->rigidbody_world->constraints) || - ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->constraints)))) { + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->constraints)))) + { return false; } return true; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 8e919170649..2a4d668ba9b 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -49,7 +49,8 @@ static bool operator_rigidbody_editable_poll(Scene *scene) if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && (ID_IS_LINKED(scene->rigidbody_world->group) || - ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->group)))) { + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->group)))) + { return false; } return true; diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index 30d918866f5..0ceff7edc14 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -523,15 +523,19 @@ static void render_progress_update(void *rjv, float progress) */ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, ImageUser *iuser) { - wmWindowManager *wm; ScrArea *first_area = nullptr, *matched_area = nullptr; /* image window, compo node users */ - for (wm = static_cast(rj->main->wm.first); wm && matched_area == nullptr; - wm = static_cast(wm->id.next)) { /* only 1 wm */ + + /* Only ever 1 `wm`. */ + for (wmWindowManager *wm = static_cast(rj->main->wm.first); + wm && matched_area == nullptr; + wm = static_cast(wm->id.next)) + { wmWindow *win; for (win = static_cast(wm->windows.first); win && matched_area == nullptr; - win = win->next) { + win = win->next) + { const bScreen *screen = WM_window_get_active_screen(win); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { @@ -623,7 +627,8 @@ static void image_rect_update(void *rjv, RenderResult *rr, rcti *renrect) * operate with. */ if (!rj->supports_glsl_draw || ibuf->channels == 1 || - ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL) { + ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL) + { image_buffer_rect_update(rj, rr, ibuf, &rj->iuser, &tile_rect, offset_x, offset_y, viewname); } ImageTile *image_tile = BKE_image_get_tile(ima, 0); @@ -690,11 +695,10 @@ static void render_startjob(void *rjv, bool *stop, bool *do_update, float *progr static void render_image_restore_layer(RenderJob *rj) { - wmWindowManager *wm; - /* image window, compo node users */ - for (wm = static_cast(rj->main->wm.first); wm; - wm = static_cast(wm->id.next)) { /* only 1 wm */ + + /* Only ever 1 `wm`. */ + LISTBASE_FOREACH (wmWindowManager *, wm, &rj->main->wm) { wmWindow *win; for (win = static_cast(wm->windows.first); win; win = win->next) { const bScreen *screen = WM_window_get_active_screen(win); @@ -899,8 +903,9 @@ static void clean_viewport_memory(Main *bmain, Scene *scene) BKE_main_id_tag_listbase(&bmain->objects, LIB_TAG_DOIT, true); /* Go over all the visible objects. */ - for (wmWindowManager *wm = static_cast(bmain->wm.first); wm; - wm = static_cast(wm->id.next)) { + + /* Only ever 1 `wm`. */ + LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); BKE_view_layer_synced_ensure(scene, view_layer); diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index 0fb21720b54..0daee0b2c90 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -422,11 +422,11 @@ static void screen_opengl_render_write(OGLRender *oglrender) Scene *scene = oglrender->scene; RenderResult *rr; bool ok; - char name[FILE_MAX]; + char filepath[FILE_MAX]; rr = RE_AcquireResultRead(oglrender->re); - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, @@ -437,15 +437,15 @@ static void screen_opengl_render_write(OGLRender *oglrender) /* write images as individual images or stereo */ BKE_render_result_stamp_info(scene, scene->camera, rr, false); - ok = BKE_image_render_write(oglrender->reports, rr, scene, false, name); + ok = BKE_image_render_write(oglrender->reports, rr, scene, false, filepath); RE_ReleaseResultImage(oglrender->re); if (ok) { - printf("OpenGL Render written to '%s'\n", name); + printf("OpenGL Render written to '%s'\n", filepath); } else { - printf("OpenGL Render failed to write '%s'\n", name); + printf("OpenGL Render failed to write '%s'\n", filepath); } } @@ -495,8 +495,8 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender) } rr = RE_AcquireResultRead(oglrender->re); - for (rv = static_cast(rr->views.first), view_id = 0; rv; - rv = rv->next, view_id++) { + for (rv = static_cast(rr->views.first), view_id = 0; rv; rv = rv->next, view_id++) + { BLI_assert(view_id < oglrender->views_len); RE_SetActiveRenderView(oglrender->re, rv->name); oglrender->view_id = view_id; @@ -1002,7 +1002,8 @@ static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op) oglrender->sizey, oglrender->reports, PRVRANGEON != 0, - suffix)) { + suffix)) + { screen_opengl_render_end(C, oglrender); return false; } @@ -1063,8 +1064,8 @@ static void write_result(TaskPool *__restrict pool, WriteTaskData *task_data) /* TODO(sergey): We can in theory save some CPU ticks here because we * calculate file name again here. */ - char name[FILE_MAX]; - BKE_image_path_from_imformat(name, + char filepath[FILE_MAX]; + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), cfra, @@ -1074,15 +1075,16 @@ static void write_result(TaskPool *__restrict pool, WriteTaskData *task_data) nullptr); BKE_render_result_stamp_info(scene, scene->camera, rr, false); - ok = BKE_image_render_write(nullptr, rr, scene, true, name); + ok = BKE_image_render_write(nullptr, rr, scene, true, filepath); if (!ok) { - BKE_reportf(&reports, RPT_ERROR, "Write error: cannot save %s", name); + BKE_reportf(&reports, RPT_ERROR, "Write error: cannot save %s", filepath); } } if (reports.list.first != nullptr) { BLI_spin_lock(&oglrender->reports_lock); for (Report *report = static_cast(reports.list.first); report != nullptr; - report = report->next) { + report = report->next) + { BKE_report(oglrender->reports, static_cast(report->type), report->message); } BLI_spin_unlock(&oglrender->reports_lock); @@ -1131,7 +1133,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) OGLRender *oglrender = static_cast(op->customdata); Scene *scene = oglrender->scene; Depsgraph *depsgraph = oglrender->depsgraph; - char name[FILE_MAX]; + char filepath[FILE_MAX]; bool ok = false; const bool view_context = (oglrender->v3d != nullptr); bool is_movie; @@ -1149,7 +1151,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype); if (!is_movie) { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(oglrender->bmain), scene->r.cfra, @@ -1158,9 +1160,9 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) true, nullptr); - if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) { + if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(filepath)) { BLI_spin_lock(&oglrender->reports_lock); - BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", name); + BKE_reportf(op->reports, RPT_INFO, "Skipping existing frame \"%s\"", filepath); BLI_spin_unlock(&oglrender->reports_lock); ok = true; goto finally; @@ -1186,7 +1188,8 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op) } if (oglrender->render_frames == nullptr || - BLI_BITMAP_TEST_BOOL(oglrender->render_frames, scene->r.cfra - PSFRA)) { + BLI_BITMAP_TEST_BOOL(oglrender->render_frames, scene->r.cfra - PSFRA)) + { /* render into offscreen buffer */ screen_opengl_render_apply(C, oglrender); } diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index ebc3998333f..24b282ba320 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -140,8 +140,9 @@ struct IconPreview { Depsgraph *depsgraph; /* May be nullptr (see #WM_OT_previews_ensure). */ Scene *scene; void *owner; - ID *id, - *id_copy; /* May be nullptr! (see ICON_TYPE_PREVIEW case in #ui_icon_ensure_deferred()) */ + /** May be nullptr! (see #ICON_TYPE_PREVIEW case in #ui_icon_ensure_deferred()). */ + ID *id; + ID *id_copy; ListBase sizes; /* May be nullptr, is used for rendering IDs that require some other object for it to be applied @@ -744,7 +745,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r * or if the job is running and the size of preview changed */ if ((sbuts != nullptr && sbuts->preview) || (!ok && !WM_jobs_test(wm, area, WM_JOB_TYPE_RENDER_PREVIEW)) || - (sp && (abs(sp->sizex - newx) >= 2 || abs(sp->sizey - newy) > 2))) { + (sp && (abs(sp->sizex - newx) >= 2 || abs(sp->sizey - newy) > 2))) + { if (sbuts != nullptr) { sbuts->preview = 0; } @@ -1576,7 +1578,8 @@ static void icon_preview_startjob_all_sizes(void *customdata, IconPreviewSize *cur_size; for (cur_size = static_cast(ip->sizes.first); cur_size; - cur_size = cur_size->next) { + cur_size = cur_size->next) + { PreviewImage *prv = static_cast(ip->owner); /* Is this a render job or a deferred loading job? */ const ePreviewRenderMethod pr_method = (prv->tag & PRV_TAG_DEFFERED) ? PR_ICON_DEFERRED : @@ -1599,7 +1602,8 @@ static void icon_preview_startjob_all_sizes(void *customdata, * necessary to know here what happens inside lower-level functions. */ const bool use_solid_render_mode = (ip->id != nullptr) && ELEM(GS(ip->id->name), ID_OB, ID_AC); if (!use_solid_render_mode && preview_method_is_render(pr_method) && - !check_engine_supports_preview(ip->scene)) { + !check_engine_supports_preview(ip->scene)) + { continue; } @@ -1810,7 +1814,8 @@ void PreviewLoadJob::run_fn(void *customdata, bool *stop, bool *do_update, float IMB_thumb_locks_acquire(); while (RequestedPreview *request = static_cast( - BLI_thread_queue_pop_timeout(job_data->todo_queue_, 100))) { + BLI_thread_queue_pop_timeout(job_data->todo_queue_, 100))) + { if (*stop) { break; } @@ -1865,7 +1870,8 @@ void PreviewLoadJob::update_fn(void *customdata) PreviewLoadJob *job_data = static_cast(customdata); for (auto request_it = job_data->requested_previews_.begin(); - request_it != job_data->requested_previews_.end();) { + request_it != job_data->requested_previews_.end();) + { RequestedPreview &requested = *request_it; /* Skip items that are not done loading yet. */ if (requested.preview->tag & PRV_TAG_DEFFERED_RENDERING) { diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index f075ffc2e54..9022d5d80c1 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -1169,7 +1169,7 @@ void SCENE_OT_view_layer_add_lightgroup(wmOperatorType *ot) ot->prop = RNA_def_string(ot->srna, "name", nullptr, - sizeof(((ViewLayerLightgroup *)nullptr)->name), + sizeof(ViewLayerLightgroup::name), "Name", "Name of newly created lightgroup"); } @@ -1248,7 +1248,8 @@ static int view_layer_add_used_lightgroups_exec(bContext *C, wmOperator * /*op*/ GSet *used_lightgroups = get_used_lightgroups(scene); GSET_FOREACH_BEGIN (const char *, used_lightgroup, used_lightgroups) { if (!BLI_findstring( - &view_layer->lightgroups, used_lightgroup, offsetof(ViewLayerLightgroup, name))) { + &view_layer->lightgroups, used_lightgroup, offsetof(ViewLayerLightgroup, name))) + { BKE_view_layer_add_lightgroup(view_layer, used_lightgroup); } } diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc index 074c78e716a..835698e9fd1 100644 --- a/source/blender/editors/render/render_update.cc +++ b/source/blender/editors/render/render_update.cc @@ -171,7 +171,8 @@ void ED_render_engine_changed(Main *bmain, const bool update_scene_data) { /* on changing the render engine type, clear all running render engines */ for (bScreen *screen = static_cast(bmain->screens.first); screen; - screen = static_cast(screen->id.next)) { + screen = static_cast(screen->id.next)) + { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { ED_render_engine_area_exit(bmain, area); } @@ -181,7 +182,8 @@ void ED_render_engine_changed(Main *bmain, const bool update_scene_data) DEGEditorUpdateContext update_ctx = {nullptr}; update_ctx.bmain = bmain; for (Scene *scene = static_cast(bmain->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { update_ctx.scene = scene; LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { /* TDODO(sergey): Iterate over depsgraphs instead? */ @@ -248,10 +250,12 @@ static void texture_changed(Main *bmain, Tex *tex) BKE_icon_changed(BKE_icon_id_ensure(&tex->id)); for (scene = static_cast(bmain->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { /* paint overlays */ for (view_layer = static_cast(scene->view_layers.first); view_layer; - view_layer = view_layer->next) { + view_layer = view_layer->next) + { BKE_paint_invalidate_overlay_tex(scene, view_layer, tex); } /* find compositing nodes */ diff --git a/source/blender/editors/render/render_view.cc b/source/blender/editors/render/render_view.cc index 5cfcac3d4ee..c4cd1c1ef3d 100644 --- a/source/blender/editors/render/render_view.cc +++ b/source/blender/editors/render/render_view.cc @@ -156,7 +156,8 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) true, false, true, - WIN_ALIGN_LOCATION_CENTER) == nullptr) { + WIN_ALIGN_LOCATION_CENTER) == nullptr) + { BKE_report(reports, RPT_ERROR, "Failed to open window!"); return nullptr; } @@ -326,7 +327,8 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e if ((WM_window_is_temp_screen(win) && ((ScrArea *)screen->areabase.first)->spacetype == SPACE_IMAGE) || - (win == winshow && winshow != wincur)) { + (win == winshow && winshow != wincur)) + { wm_window_raise(win); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c index 0e4ab60a457..b4599ae8112 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.c @@ -175,8 +175,8 @@ static bool view_layer_remove_poll(const Scene *scene, const ViewLayer *layer) if (act == -1) { return false; } - if ((scene->view_layers.first == scene->view_layers.last) && - (scene->view_layers.first == layer)) { + if ((scene->view_layers.first == scene->view_layers.last) && (scene->view_layers.first == layer)) + { /* ensure 1 layer is kept */ return false; } diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 3bb43bcb975..57f2a4403ef 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -453,7 +453,8 @@ void ED_area_do_mgs_subscribe_for_tool_ui(const wmRegionMessageSubscribeParams * /* Check if a tool category panel is pinned and visible in another category. */ LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { if (UI_panel_is_active(panel) && panel->flag & PNL_PIN && - STREQ(panel->type->category, panel_category_tool)) { + STREQ(panel->type->category, panel_category_tool)) + { update_region = true; break; } @@ -608,8 +609,8 @@ void ED_region_do_draw(bContext *C, ARegion *region) * * This covers most cases and avoids copy-paste similar code for each space type. */ - if (ELEM( - region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS, RGN_TYPE_UI, RGN_TYPE_TOOLS)) { + if (ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS, RGN_TYPE_UI, RGN_TYPE_TOOLS)) + { SpaceLink *sl = static_cast(area->spacedata.first); PointerRNA ptr; @@ -881,7 +882,8 @@ static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area) #ifdef __APPLE__ if (!WM_window_is_fullscreen(win) && ((coords[i][0] == 0 && coords[i][1] == 0) || - (coords[i][0] == WM_window_pixels_x(win) && coords[i][1] == 0))) { + (coords[i][0] == WM_window_pixels_x(win) && coords[i][1] == 0))) + { continue; } #else @@ -1221,7 +1223,8 @@ static void region_overlap_fix(ScrArea *area, ARegion *region) if (region_iter->overlap && (region_iter->alignment & RGN_SPLIT_PREV) == 0) { if ((region_iter->alignment != align) && - BLI_rcti_isect(®ion_iter->winrct, ®ion->winrct, nullptr)) { + BLI_rcti_isect(®ion_iter->winrct, ®ion->winrct, nullptr)) + { /* Left overlapping right or vice-versa, forbid this! */ region->flag |= RGN_FLAG_TOO_SMALL; return; @@ -1247,7 +1250,8 @@ bool ED_region_is_overlap(int spacetype, int regiontype) RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS, RGN_TYPE_FOOTER, - RGN_TYPE_TOOL_HEADER)) { + RGN_TYPE_TOOL_HEADER)) + { return true; } } @@ -1368,13 +1372,13 @@ static void region_rect_recursive( winrct_test.ymax = region->winrct.ymin + size_min[1]; BLI_rcti_isect(&winrct_test, &overlap_remainder_margin, &winrct_test); - if (BLI_rcti_size_x(&winrct_test) < size_min[0] || - BLI_rcti_size_y(&winrct_test) < size_min[1]) { + if (BLI_rcti_size_x(&winrct_test) < size_min[0] || BLI_rcti_size_y(&winrct_test) < size_min[1]) + { region->flag |= RGN_FLAG_TOO_SMALL; } } - else if (rct_fits(remainder, SCREEN_AXIS_V, 1) < 0 || - rct_fits(remainder, SCREEN_AXIS_H, 1) < 0) { + else if (rct_fits(remainder, SCREEN_AXIS_V, 1) < 0 || rct_fits(remainder, SCREEN_AXIS_H, 1) < 0) + { /* remainder is too small for any usage */ region->flag |= RGN_FLAG_TOO_SMALL; } @@ -2233,7 +2237,8 @@ static short region_alignment_from_header_and_tool_header_state( /* Don't prioritize the tool-header if both are hidden (behave as if both are visible). * Without this, switching to a space with headers hidden will flip the alignment * upon switching to a space with visible headers. */ - (header_hidden && tool_header_hidden))) { + (header_hidden && tool_header_hidden))) + { return tool_header_alignment; } if (header_alignment != -1) { @@ -2299,7 +2304,8 @@ static void region_align_info_to_area_for_headers(const RegionTypeAlignInfo *reg * Simply copy the values. */ if (((header_alignment_src != -1) == (header_alignment_dst != -1)) && ((tool_header_alignment_src != -1) == (tool_header_alignment_dst != -1)) && - (tool_header_hidden_src == tool_header_hidden_dst)) { + (tool_header_hidden_src == tool_header_hidden_dst)) + { if (header_alignment_dst != -1) { header_alignment_sync = header_alignment_src; } @@ -2393,7 +2399,8 @@ static void region_align_info_to_area( region_align_info_from_area(area, ®ion_align_info_dst); if ((region_by_type[RGN_TYPE_HEADER] != nullptr) || - (region_by_type[RGN_TYPE_TOOL_HEADER] != nullptr)) { + (region_by_type[RGN_TYPE_TOOL_HEADER] != nullptr)) + { region_align_info_to_area_for_headers( region_align_info_src, ®ion_align_info_dst, region_by_type); } @@ -3007,8 +3014,8 @@ void ED_region_panels_layout_ex(const bContext *C, if (!(panel->type->flag & PANEL_TYPE_INSTANCED)) { continue; } - if (use_category_tabs && panel->type->category[0] && - !STREQ(category, panel->type->category)) { + if (use_category_tabs && panel->type->category[0] && !STREQ(category, panel->type->category)) + { continue; } const int width = panel_draw_width_from_max_width_get(region, panel->type, max_panel_width); @@ -3123,8 +3130,8 @@ void ED_region_panels_draw(const bContext *C, ARegion *region) /* scrollers */ bool use_mask = false; rcti mask; - if (region->runtime.category && - (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT)) { + if (region->runtime.category && (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT)) + { use_mask = true; UI_view2d_mask_from_win(v2d, &mask); mask.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 88762a19778..0b8a5880147 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -386,7 +386,8 @@ static bool screen_areas_can_align(bScreen *screen, ScrArea *sa1, ScrArea *sa2, continue; } if (area->v3->vec.x - area->v1->vec.x < tolerance && - (area->v1->vec.x == xmin || area->v3->vec.x == xmax)) { + (area->v1->vec.x == xmin || area->v3->vec.x == xmax)) + { /* There is a narrow vertical area sharing an edge of the combined bounds. */ return false; } @@ -400,7 +401,8 @@ static bool screen_areas_can_align(bScreen *screen, ScrArea *sa1, ScrArea *sa2, continue; } if (area->v3->vec.y - area->v1->vec.y < tolerance && - (area->v1->vec.y == ymin || area->v3->vec.y == ymax)) { + (area->v1->vec.y == ymin || area->v3->vec.y == ymax)) + { /* There is a narrow horizontal area sharing an edge of the combined bounds. */ return false; } @@ -925,9 +927,11 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) ED_screen_areas_iter (win, screen, area_iter) { if (xy[0] > (area_iter->totrct.xmin + BORDERPADDING) && - xy[0] < (area_iter->totrct.xmax - BORDERPADDING)) { + xy[0] < (area_iter->totrct.xmax - BORDERPADDING)) + { if (xy[1] > (area_iter->totrct.ymin + BORDERPADDING) && - xy[1] < (area_iter->totrct.ymax - BORDERPADDING)) { + xy[1] < (area_iter->totrct.ymax - BORDERPADDING)) + { if (ED_area_azones_update(area_iter, xy) == NULL) { area = area_iter; break; @@ -1479,7 +1483,8 @@ static bScreen *screen_state_to_nonnormal(bContext *C, RGN_TYPE_FOOTER, RGN_TYPE_TOOLS, RGN_TYPE_NAV_BAR, - RGN_TYPE_EXECUTE)) { + RGN_TYPE_EXECUTE)) + { region->flag |= RGN_FLAG_HIDDEN; } } @@ -1631,7 +1636,8 @@ ScrArea *ED_screen_temp_space_open(bContext *C, false, dialog, true, - WIN_ALIGN_LOCATION_CENTER)) { + WIN_ALIGN_LOCATION_CENTER)) + { area = CTX_wm_area(C); } break; diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 309bedda4fd..81f01222f5e 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -177,7 +177,8 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, /* Keep timeline small in video edit workspace. */ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect->ymin && - screen_geom_area_height(area) <= headery * facy + 1) { + screen_geom_area_height(area) <= headery * facy + 1) + { ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3); if (se) { const int yval = area->v1->vec.y + headery - 1; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1f7a162c37d..2cf9c6ebe8f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -778,7 +778,8 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip) if (az->type == AZONE_REGION) { if (region->overlap && (region->v2d.keeptot != V2D_KEEPTOT_STRICT) && /* Only when this isn't hidden (where it's displayed as an button that expands). */ - ((az->region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0)) { + ((az->region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0)) + { /* A floating region to be resized, clip by the visible region. */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: @@ -823,7 +824,8 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b rcti az_rect_clip; if (BLI_rcti_isect_pt_v(&az->rect, xy) && /* Check clipping if this is clipped */ - (!azone_clipped_rect_calc(az, &az_rect_clip) || BLI_rcti_isect_pt_v(&az_rect_clip, xy))) { + (!azone_clipped_rect_calc(az, &az_rect_clip) || BLI_rcti_isect_pt_v(&az_rect_clip, xy))) + { if (az->type == AZONE_AREA) { break; @@ -881,7 +883,8 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b /* Check if we even have scroll bars. */ if (((az->direction == AZ_SCROLL_HOR) && !(scroll_flag & V2D_SCROLL_HORIZONTAL)) || - ((az->direction == AZ_SCROLL_VERT) && !(scroll_flag & V2D_SCROLL_VERTICAL))) { + ((az->direction == AZ_SCROLL_VERT) && !(scroll_flag & V2D_SCROLL_VERTICAL))) + { /* No scroll-bars, do nothing. */ } else if (test_only) { @@ -1109,7 +1112,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Have we dragged off the zone and are not on an edge? */ if ((ED_area_actionzone_find_xy(sad->sa1, event->xy) != sad->az) && (screen_geom_area_map_find_active_scredge( - AREAMAP_FROM_SCREEN(screen), &screen_rect, event->xy[0], event->xy[1]) == NULL)) { + AREAMAP_FROM_SCREEN(screen), &screen_rect, event->xy[0], event->xy[1]) == NULL)) + { /* What area are we now in? */ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy); @@ -2086,7 +2090,8 @@ static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis) } if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX * UI_SCALE_FAC) || - (dir_axis == SCREEN_AXIS_H && area->winy <= 2 * ED_area_headersize())) { + (dir_axis == SCREEN_AXIS_H && area->winy <= 2 * ED_area_headersize())) + { /* Must be at least double minimum sizes to split into two. */ return false; } @@ -2650,14 +2655,14 @@ static int area_max_regionsize(ScrArea *area, ARegion *scale_region, AZEdge edge } else if (scale_region->alignment == RGN_ALIGN_TOP && (region->alignment == RGN_ALIGN_BOTTOM || - ELEM( - region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) { + ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) + { dist -= region->winy; } else if (scale_region->alignment == RGN_ALIGN_BOTTOM && (region->alignment == RGN_ALIGN_TOP || - ELEM( - region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) { + ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER))) + { dist -= region->winy; } } @@ -2704,7 +2709,8 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event * the parent region if the azone edge is not the edge splitting * both regions */ if ((az->region->alignment & RGN_SPLIT_PREV) && az->region->prev && - !is_split_edge(RGN_ALIGN_ENUM_FROM_MASK(az->region->alignment), az->edge)) { + !is_split_edge(RGN_ALIGN_ENUM_FROM_MASK(az->region->alignment), az->edge)) + { rmd->region = az->region->prev; } else { @@ -2779,7 +2785,8 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) ARegion *region_tool_header = BKE_area_find_region_type(rmd->area, RGN_TYPE_TOOL_HEADER); if (region_tool_header != NULL) { if ((region_tool_header->flag & RGN_FLAG_HIDDEN_BY_USER) == 0 && - (region_tool_header->flag & RGN_FLAG_HIDDEN) != 0) { + (region_tool_header->flag & RGN_FLAG_HIDDEN) != 0) + { region_toggle_hidden(C, region_tool_header, 0); } } @@ -2941,12 +2948,13 @@ static void areas_do_frame_follow(bContext *C, bool middle) if (screen_ctx->redraws_flag & TIME_FOLLOW) { if ((region->regiontype == RGN_TYPE_WINDOW && ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || - (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { + (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) + { float w = BLI_rctf_size_x(®ion->v2d.cur); if (middle) { - if ((scene->r.cfra < region->v2d.cur.xmin) || - (scene->r.cfra > region->v2d.cur.xmax)) { + if ((scene->r.cfra < region->v2d.cur.xmin) || (scene->r.cfra > region->v2d.cur.xmax)) + { region->v2d.cur.xmax = scene->r.cfra + (w / 2); region->v2d.cur.xmin = scene->r.cfra - (w / 2); } @@ -4537,7 +4545,8 @@ static void screen_animation_region_tag_redraw( { /* Do follow time here if editor type supports it */ if ((redraws & TIME_FOLLOW) && - screen_animation_region_supports_time_follow(area->spacetype, region->regiontype)) { + screen_animation_region_supports_time_follow(area->spacetype, region->regiontype)) + { float w = BLI_rctf_size_x(®ion->v2d.cur); if (scene->r.cfra < region->v2d.cur.xmin) { region->v2d.cur.xmax = scene->r.cfra; @@ -4637,7 +4646,8 @@ static int screen_animation_step_invoke(bContext *C, wmOperator *UNUSED(op), con * dependency graph update. */ } else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false && - isfinite(time = BKE_sound_sync_scene(scene_eval))) { + isfinite(time = BKE_sound_sync_scene(scene_eval))) + { double newfra = time * FPS; /* give some space here to avoid jumps */ @@ -5097,7 +5107,8 @@ static int userpref_show_exec(bContext *C, wmOperator *op) false, false, true, - WIN_ALIGN_LOCATION_CENTER) != NULL) { + WIN_ALIGN_LOCATION_CENTER) != NULL) + { /* The header only contains the editor switcher and looks empty. * So hiding in the temp window makes sense. */ ScrArea *area = CTX_wm_area(C); @@ -5169,7 +5180,8 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op) false, false, true, - WIN_ALIGN_LOCATION_CENTER) != NULL) { + WIN_ALIGN_LOCATION_CENTER) != NULL) + { ED_drivers_editor_init(C, CTX_wm_area(C)); /* activate driver F-Curve for the property under the cursor */ @@ -5238,7 +5250,8 @@ static int info_log_show_exec(bContext *C, wmOperator *op) false, false, true, - WIN_ALIGN_LOCATION_CENTER) != NULL) { + WIN_ALIGN_LOCATION_CENTER) != NULL) + { return OPERATOR_FINISHED; } BKE_report(op->reports, RPT_ERROR, "Failed to open window!"); diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c index 06d00fbc017..6ba0c1ceba3 100644 --- a/source/blender/editors/screen/screen_user_menu.c +++ b/source/blender/editors/screen/screen_user_menu.c @@ -103,7 +103,8 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb, if (umi->type == USER_MENU_TYPE_OPERATOR) { bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi; if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) && - IDP_EqualsProperties(prop, umi_op->prop)) { + IDP_EqualsProperties(prop, umi_op->prop)) + { return umi_op; } } @@ -134,7 +135,8 @@ struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *l if (umi->type == USER_MENU_TYPE_PROP) { bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi; if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) && - (prop_index == umi_pr->prop_index)) { + (prop_index == umi_pr->prop_index)) + { return umi_pr; } } @@ -270,8 +272,8 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu) if (ptr.type != NULL) { PropertyRNA *prop = NULL; PointerRNA prop_ptr = ptr; - if ((data_path == NULL) || - RNA_path_resolve_full(&ptr, data_path, &prop_ptr, NULL, NULL)) { + if ((data_path == NULL) || RNA_path_resolve_full(&ptr, data_path, &prop_ptr, NULL, NULL)) + { prop = RNA_struct_find_property(&prop_ptr, umi_pr->prop_id); if (prop) { ok = true; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 4d44999f1f3..f8f252c935e 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -127,7 +127,8 @@ static int screenshot_exec(bContext *C, wmOperator *op) } if ((scd->im_format.planes == R_IMF_PLANES_BW) && - (scd->im_format.imtype != R_IMF_IMTYPE_MULTILAYER)) { + (scd->im_format.imtype != R_IMF_IMTYPE_MULTILAYER)) + { /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 03808acc709..4acc384db0f 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -342,7 +342,8 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op) char idname[MAX_ID_NAME - 2], filepath[FILE_MAX]; if (!RNA_struct_property_is_set(op->ptr, "idname") || - !RNA_struct_property_is_set(op->ptr, "filepath")) { + !RNA_struct_property_is_set(op->ptr, "filepath")) + { return OPERATOR_CANCELLED; } RNA_string_get(op->ptr, "idname", idname); @@ -480,7 +481,8 @@ static void workspace_add_menu(bContext *UNUSED(C), uiLayout *layout, void *temp LISTBASE_FOREACH (WorkSpace *, workspace, &builtin_config->workspaces) { if (startup_config && - BLI_findstring(&startup_config->workspaces, workspace->id.name, offsetof(ID, name))) { + BLI_findstring(&startup_config->workspaces, workspace->id.name, offsetof(ID, name))) + { continue; } diff --git a/source/blender/editors/screen/workspace_listen.cc b/source/blender/editors/screen/workspace_listen.cc index 84326007d66..d0a0192c2b2 100644 --- a/source/blender/editors/screen/workspace_listen.cc +++ b/source/blender/editors/screen/workspace_listen.cc @@ -21,7 +21,8 @@ static void validate_viewer_paths(bContext &C, WorkSpace &workspace) const std::optional parsed_path = blender::ed::viewer_path::parse_geometry_nodes_viewer(workspace.viewer_path); if (parsed_path.has_value() && - blender::ed::viewer_path::is_active_geometry_nodes_viewer(C, *parsed_path)) { + blender::ed::viewer_path::is_active_geometry_nodes_viewer(C, *parsed_path)) + { /* The current viewer path is still valid and active. */ return; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 36dbda9fe55..db637e15660 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -233,7 +233,8 @@ struct AddOperationExecutor { add_inputs.corner_normals_su = corner_normals_su; if (add_inputs.interpolate_length || add_inputs.interpolate_shape || - add_inputs.interpolate_point_count || add_inputs.interpolate_resolution) { + add_inputs.interpolate_point_count || add_inputs.interpolate_resolution) + { this->ensure_curve_roots_kdtree(); add_inputs.old_roots_kdtree = self_->curve_roots_kdtree_; } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index c3d7734dd36..374d6b380f1 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -216,7 +216,8 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, if (center_ray_hit.index >= 0) { const float3 hit_position_su = center_ray_hit.co; if (math::distance(center_ray_start_su, center_ray_end_su) > - math::distance(center_ray_start_su, hit_position_su)) { + math::distance(center_ray_start_su, hit_position_su)) + { center_ray_end_su = hit_position_su; center_ray_end_wo = math::transform_point(surface_to_world_mat, center_ray_end_su); } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index bb733f8453e..b53b1ba161f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -305,7 +305,8 @@ struct CurvesEffectOperationExecutor { *ctx_.rv3d, *object_, stroke_extension.mouse_position, - brush_radius_base_re_)) { + brush_radius_base_re_)) + { self.brush_3d_ = *brush_3d; } } diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 0da248ea175..594e6f3533e 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -374,7 +374,8 @@ struct SlideOperationExecutor { ray_direction_su, old_first_pos_eval_su, looptri_index_eval, - hit_pos_eval_su)) { + hit_pos_eval_su)) + { continue; } diff --git a/source/blender/editors/sculpt_paint/paint_canvas.cc b/source/blender/editors/sculpt_paint/paint_canvas.cc index 22e1ecbedd7..1214aa28dac 100644 --- a/source/blender/editors/sculpt_paint/paint_canvas.cc +++ b/source/blender/editors/sculpt_paint/paint_canvas.cc @@ -107,7 +107,8 @@ eV3DShadingColorType ED_paint_shading_color_override(bContext *C, */ if (!ED_paint_tool_use_canvas(C, nullptr) && !(paint_tool_shading_color_follows_last_used_tool(C, ob) && - ob->sculpt->sticky_shading_color)) { + ob->sculpt->sticky_shading_color)) + { return orig_color_type; } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index 20eefa6f2af..3a8a207fa86 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -524,7 +524,8 @@ static int project_brush_radius(ViewContext *vc, float radius, const float locat if ((ED_view3d_project_float_global(vc->region, location, p1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && (ED_view3d_project_float_global(vc->region, offset, p2, V3D_PROJ_TEST_NOP) == - V3D_PROJ_RET_OK)) { + V3D_PROJ_RET_OK)) + { /* The distance between these points is the size of the projected brush in pixels. */ return len_v2v2(p1, p2); } @@ -562,7 +563,8 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups, if (!(mtex->tex) || !((mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) || - (valid && ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED)))) { + (valid && ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED)))) + { return false; } @@ -1312,7 +1314,8 @@ static bool paint_cursor_context_init(bContext *C, /* There is currently no way to check if the direction is inverted before starting the stroke, * so this does not reflect the state of the brush in the UI. */ if (((pcontext->ups->draw_inverted == 0) ^ ((pcontext->brush->flag & BRUSH_DIR_IN) == 0)) && - BKE_brush_sculpt_has_secondary_color(pcontext->brush)) { + BKE_brush_sculpt_has_secondary_color(pcontext->brush)) + { copy_v3_v3(pcontext->outline_col, pcontext->brush->sub_col); } else { @@ -1685,7 +1688,8 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * /* Drawing Cursor overlays in 3D object space. */ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_GRAB && - (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) { + (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) + { SCULPT_geometry_preview_lines_update(pcontext->C, pcontext->ss, pcontext->radius); sculpt_geometry_preview_lines_draw( pcontext->pos, pcontext->brush, pcontext->is_multires, pcontext->ss); @@ -1712,7 +1716,8 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * /* Cloth brush local simulation areas. */ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_CLOTH && - brush->cloth_simulation_area_type != BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) { + brush->cloth_simulation_area_type != BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) + { const float white[3] = {1.0f, 1.0f, 1.0f}; const float zero_v[3] = {0.0f}; /* This functions sets its own drawing space in order to draw the simulation limits when the @@ -1791,12 +1796,14 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont pcontext->pos, ss, pcontext->outline_col, pcontext->outline_alpha); } else if (brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_RADIAL && - brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) { + brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_LOCAL) + { /* Display the simulation limits if sculpting outside them. */ /* This does not makes much sense of plane falloff as the falloff is infinite or global. */ if (len_v3v3(ss->cache->true_location, ss->cache->true_initial_location) > - ss->cache->radius * (1.0f + brush->cloth_sim_limit)) { + ss->cache->radius * (1.0f + brush->cloth_sim_limit)) + { const float red[3] = {1.0f, 0.2f, 0.2f}; SCULPT_cloth_simulation_limits_draw(pcontext->pos, brush, @@ -1846,7 +1853,8 @@ static bool paint_cursor_is_brush_cursor_enabled(PaintCursorContext *pcontext) { if (pcontext->paint->flags & PAINT_SHOW_BRUSH) { if (ELEM(pcontext->mode, PAINT_MODE_TEXTURE_2D, PAINT_MODE_TEXTURE_3D) && - pcontext->brush->imagepaint_tool == PAINT_TOOL_FILL) { + pcontext->brush->imagepaint_tool == PAINT_TOOL_FILL) + { return false; } return true; diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index b7ce4b2973c..996bd6a6252 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -739,7 +739,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, } if (diameter != cache->lastdiameter || (mask_rotation != cache->last_mask_rotation) || - renew_maxmask) { + renew_maxmask) + { MEM_SAFE_FREE(cache->tex_mask); brush_painter_2d_tex_mapping( @@ -760,7 +761,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, /* detect if we need to recreate image brush buffer */ if (diameter != cache->lastdiameter || (tex_rotation != cache->last_tex_rotation) || do_random || - update_color) { + update_color) + { if (cache->ibuf) { IMB_freeImBuf(cache->ibuf); cache->ibuf = NULL; @@ -817,7 +819,8 @@ static bool paint_2d_ensure_tile_canvas(ImagePaintState *s, int i) s->tiles[i].state = PAINT2D_TILE_MISSING; } else if ((s->tiles[0].canvas->rect && !ibuf->rect) || - (s->tiles[0].canvas->rect_float && !ibuf->rect_float)) { + (s->tiles[0].canvas->rect_float && !ibuf->rect_float)) + { s->tiles[i].state = PAINT2D_TILE_MISSING; } else { @@ -1496,7 +1499,8 @@ void paint_2d_stroke(void *ps, sub_v2_v2v2(local_new_uv, new_uv, tile->uv_origin); sub_v2_v2v2(local_old_uv, old_uv, tile->uv_origin); if (!(is_inside_tile(uv_size, local_new_uv, uv_brush_size) || - is_inside_tile(uv_size, local_old_uv, uv_brush_size))) { + is_inside_tile(uv_size, local_old_uv, uv_brush_size))) + { continue; } @@ -1519,7 +1523,8 @@ void paint_2d_stroke(void *ps, const float pixel_brush_size[] = {(s->symmetry & PAINT_TILE_X) ? FLT_MAX : size, (s->symmetry & PAINT_TILE_Y) ? FLT_MAX : size}; if (!(is_inside_tile(tile->size, new_coord, pixel_brush_size) || - is_inside_tile(tile->size, old_coord, pixel_brush_size))) { + is_inside_tile(tile->size, old_coord, pixel_brush_size))) + { continue; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index c5b38d0f049..292fd03aa6c 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -1191,11 +1191,13 @@ static bool check_seam(const ProjPaintState *ps, /* first test if they have the same image */ if ((orig_tpage == tpage) && (orig_tile == tile) && cmp_uv(orig_lt_tri_uv[orig_i1_fidx], lt_tri_uv[i1_fidx]) && - cmp_uv(orig_lt_tri_uv[orig_i2_fidx], lt_tri_uv[i2_fidx])) { + cmp_uv(orig_lt_tri_uv[orig_i2_fidx], lt_tri_uv[i2_fidx])) + { /* if faces don't have the same winding in uv space, * they are on the same side so edge is boundary */ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_CW) != - (ps->faceWindingFlags[orig_face] & PROJ_FACE_WINDING_CW)) { + (ps->faceWindingFlags[orig_face] & PROJ_FACE_WINDING_CW)) + { return true; } @@ -1456,9 +1458,11 @@ static void project_face_seams_init(const ProjPaintState *ps, do { if (init_all || (ps->corner_verts_eval[lt->tri[fidx[0]]] == vert_index) || - (ps->corner_verts_eval[lt->tri[fidx[1]]] == vert_index)) { + (ps->corner_verts_eval[lt->tri[fidx[1]]] == vert_index)) + { if ((ps->faceSeamFlags[tri_index] & - (PROJ_FACE_SEAM0 << fidx[0] | PROJ_FACE_NOSEAM0 << fidx[0])) == 0) { + (PROJ_FACE_SEAM0 << fidx[0] | PROJ_FACE_NOSEAM0 << fidx[0])) == 0) + { if (check_seam(ps, tri_index, fidx[0], fidx[1], &other_face, &other_fidx)) { ps->faceSeamFlags[tri_index] |= PROJ_FACE_SEAM0 << fidx[0]; insert_seam_vert_array(ps, arena, tri_index, fidx[0], ibuf_x, ibuf_y); @@ -2139,7 +2143,8 @@ static bool line_clip_rect2f(const rctf *cliprect, /* top/bottom */ if (line_isect_y(l1, l2, rect->ymin, &isect) && (isect >= cliprect->xmin) && - (isect <= cliprect->xmax)) { + (isect <= cliprect->xmax)) + { if (l1[1] < l2[1]) { /* line 1 is outside */ l1_clip[0] = isect; l1_clip[1] = rect->ymin; @@ -2157,7 +2162,8 @@ static bool line_clip_rect2f(const rctf *cliprect, } if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) && - (isect <= cliprect->xmax)) { + (isect <= cliprect->xmax)) + { if (l1[1] > l2[1]) { /* line 1 is outside */ l1_clip[0] = isect; l1_clip[1] = rect->ymax; @@ -2176,7 +2182,8 @@ static bool line_clip_rect2f(const rctf *cliprect, /* left/right */ if (line_isect_x(l1, l2, rect->xmin, &isect) && (isect >= cliprect->ymin) && - (isect <= cliprect->ymax)) { + (isect <= cliprect->ymax)) + { if (l1[0] < l2[0]) { /* line 1 is outside */ l1_clip[0] = rect->xmin; l1_clip[1] = isect; @@ -2194,7 +2201,8 @@ static bool line_clip_rect2f(const rctf *cliprect, } if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) && - (isect <= cliprect->ymax)) { + (isect <= cliprect->ymax)) + { if (l1[0] > l2[0]) { /* line 1 is outside */ l1_clip[0] = rect->xmax; l1_clip[1] = isect; @@ -2273,7 +2281,8 @@ static bool project_bucket_isect_circle(const float cent[2], #endif if ((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || - (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1])) { + (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1])) + { return true; } @@ -2513,7 +2522,8 @@ static void project_bucket_clip_face(const bool is_ortho, * smooth shading it's a possibility */ if (min_fff(dist_squared_to_line_v2(v1coSS, v2coSS, v3coSS), dist_squared_to_line_v2(v2coSS, v3coSS, v1coSS), - dist_squared_to_line_v2(v3coSS, v1coSS, v2coSS)) < PROJ_PIXEL_TOLERANCE) { + dist_squared_to_line_v2(v3coSS, v1coSS, v2coSS)) < PROJ_PIXEL_TOLERANCE) + { collinear = true; } @@ -2806,7 +2816,8 @@ static void project_bucket_clip_face(const bool is_ortho, for (int i = 0; i < (*tot); i++) { if (fabsf(isectVCosSS[(i + 1) % *tot][0] - isectVCosSS[i][0]) < PROJ_PIXEL_TOLERANCE && - fabsf(isectVCosSS[(i + 1) % *tot][1] - isectVCosSS[i][1]) < PROJ_PIXEL_TOLERANCE) { + fabsf(isectVCosSS[(i + 1) % *tot][1] - isectVCosSS[i][1]) < PROJ_PIXEL_TOLERANCE) + { for (int j = i; j < (*tot) - 1; j++) { isectVCosSS[j][0] = isectVCosSS[j + 1][0]; isectVCosSS[j][1] = isectVCosSS[j + 1][1]; @@ -3120,7 +3131,8 @@ static void project_paint_face_init(const ProjPaintState *ps, /* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesn't work, * could check the poly direction but better to do this */ if ((do_backfacecull == true && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) || - (do_backfacecull == false && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) { + (do_backfacecull == false && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) + { has_x_isect = has_isect = 1; @@ -3151,7 +3163,8 @@ static void project_paint_face_init(const ProjPaintState *ps, /* project_paint_PickFace is less complex, use for testing */ // if (project_paint_PickFace(ps, pixelScreenCo, w, &side) == tri_index) { if ((ps->do_occlude == false) || - !project_bucket_point_occluded(ps, bucketFaceNodes, tri_index, pixelScreenCo)) { + !project_bucket_point_occluded(ps, bucketFaceNodes, tri_index, pixelScreenCo)) + { mask = project_paint_uvpixel_mask(ps, tri_index, w); if (mask > 0.0f) { @@ -3196,7 +3209,8 @@ static void project_paint_face_init(const ProjPaintState *ps, /* are any of our edges un-initialized? */ if ((face_seam_flag & PROJ_FACE_SEAM_INIT0) == 0 || (face_seam_flag & PROJ_FACE_SEAM_INIT1) == 0 || - (face_seam_flag & PROJ_FACE_SEAM_INIT2) == 0) { + (face_seam_flag & PROJ_FACE_SEAM_INIT2) == 0) + { project_face_seams_init(ps, arena, tri_index, 0, true, ibuf->x, ibuf->y); face_seam_flag = ps->faceSeamFlags[tri_index]; # if 0 @@ -3251,7 +3265,8 @@ static void project_paint_face_init(const ProjPaintState *ps, if ((ps->faceSeamFlags[tri_index] & PROJ_FACE_SEAM0) || (ps->faceSeamFlags[tri_index] & PROJ_FACE_SEAM1) || - (ps->faceSeamFlags[tri_index] & PROJ_FACE_SEAM2)) { + (ps->faceSeamFlags[tri_index] & PROJ_FACE_SEAM2)) + { uv_image_outset(ps, lt_uv_pxoffset, lt_puv, tri_index, ibuf->x, ibuf->y); } @@ -3283,7 +3298,8 @@ static void project_paint_face_init(const ProjPaintState *ps, vCoSS[fidx1], vCoSS[fidx2], bucket_clip_edges[0], - bucket_clip_edges[1])) { + bucket_clip_edges[1])) + { /* Avoid div by zero. */ if (len_squared_v2v2(vCoSS[fidx1], vCoSS[fidx2]) > FLT_EPSILON) { uint loop_idx = ps->looptris_eval[tri_index].tri[fidx1]; @@ -3341,13 +3357,15 @@ static void project_paint_face_init(const ProjPaintState *ps, if ((seam_data->corner_dist_sq[0] > 0.0f) && (len_squared_v2v2(puv, seam_data->seam_puvs[0]) < seam_data->corner_dist_sq[0]) && - (len_squared_v2v2(puv, lt_puv[fidx1]) > ps->seam_bleed_px_sq)) { + (len_squared_v2v2(puv, lt_puv[fidx1]) > ps->seam_bleed_px_sq)) + { in_bounds = false; } else if ((seam_data->corner_dist_sq[1] > 0.0f) && (len_squared_v2v2(puv, seam_data->seam_puvs[1]) < seam_data->corner_dist_sq[1]) && - (len_squared_v2v2(puv, lt_puv[fidx2]) > ps->seam_bleed_px_sq)) { + (len_squared_v2v2(puv, lt_puv[fidx2]) > ps->seam_bleed_px_sq)) + { in_bounds = false; } } @@ -3384,7 +3402,8 @@ static void project_paint_face_init(const ProjPaintState *ps, if ((ps->do_occlude == false) || !project_bucket_point_occluded( - ps, bucketFaceNodes, tri_index, pixel_on_edge)) { + ps, bucketFaceNodes, tri_index, pixel_on_edge)) + { /* A pity we need to get the world-space pixel location here * because it is a relatively expensive operation. */ if (do_clip || do_3d_mapping) { @@ -3615,7 +3634,8 @@ static bool project_bucket_face_isect(ProjPaintState *ps, (isect_seg_seg_v2(p1, p2, v1, v2) || isect_seg_seg_v2(p1, p2, v2, v3)) || (isect_seg_seg_v2(p2, p3, v1, v2) || isect_seg_seg_v2(p2, p3, v2, v3)) || (isect_seg_seg_v2(p3, p4, v1, v2) || isect_seg_seg_v2(p3, p4, v2, v3)) || - (isect_seg_seg_v2(p4, p1, v1, v2) || isect_seg_seg_v2(p4, p1, v2, v3))) { + (isect_seg_seg_v2(p4, p1, v1, v2) || isect_seg_seg_v2(p4, p1, v2, v3))) + { return true; } @@ -4155,7 +4175,8 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps, if (lc->slot_clone != lc->slot_last_clone) { if (!lc->slot_clone->uvname || !(lc->mloopuv_clone_base = static_cast(CustomData_get_layer_named( - &ps->me_eval->ldata, CD_PROP_FLOAT2, lc->slot_clone->uvname)))) { + &ps->me_eval->ldata, CD_PROP_FLOAT2, lc->slot_clone->uvname)))) + { lc->mloopuv_clone_base = static_cast( CustomData_get_layer(&ps->me_eval->ldata, CD_PROP_FLOAT2)); } @@ -4198,7 +4219,8 @@ static bool project_paint_check_face_paintable(const ProjPaintState *ps, int orig_index; if ((face_lookup->index_mp_to_orig != nullptr) && - ((orig_index = (face_lookup->index_mp_to_orig[lt->poly])) != ORIGINDEX_NONE)) { + ((orig_index = (face_lookup->index_mp_to_orig[lt->poly])) != ORIGINDEX_NONE)) + { return face_lookup->select_poly_orig && face_lookup->select_poly_orig[orig_index]; } return ps->select_poly_eval && ps->select_poly_eval[lt->poly]; @@ -4207,7 +4229,8 @@ static bool project_paint_check_face_paintable(const ProjPaintState *ps, int orig_index; if ((face_lookup->index_mp_to_orig != nullptr) && - ((orig_index = (face_lookup->index_mp_to_orig[lt->poly])) != ORIGINDEX_NONE)) { + ((orig_index = (face_lookup->index_mp_to_orig[lt->poly])) != ORIGINDEX_NONE)) + { return !(face_lookup->hide_poly_orig && face_lookup->hide_poly_orig[orig_index]); } return !(ps->hide_poly_eval && ps->hide_poly_eval[lt->poly]); @@ -4280,7 +4303,8 @@ static void project_paint_build_proj_ima(ProjPaintState *ps, BLI_memarena_alloc(arena, sizeof(ProjPaintImage) * ps->image_tot)); for (entry = static_cast(used_images->first), i = 0; entry; - entry = entry->next, i++, projIma++) { + entry = entry->next, i++, projIma++) + { projIma->iuser = entry->iuser; int size; projIma->ima = entry->ima; @@ -4343,7 +4367,8 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, if (slot != slot_last) { if (!slot->uvname || !(mloopuv_base = static_cast(CustomData_get_layer_named( - &ps->me_eval->ldata, CD_PROP_FLOAT2, slot->uvname)))) { + &ps->me_eval->ldata, CD_PROP_FLOAT2, slot->uvname)))) + { mloopuv_base = static_cast( CustomData_get_layer(&ps->me_eval->ldata, CD_PROP_FLOAT2)); } @@ -4432,7 +4457,8 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, if (tpage_last != tpage || tile_last != tile) { image_index = 0; for (PrepareImageEntry *e = static_cast(used_images.first); e; - e = e->next, image_index++) { + e = e->next, image_index++) + { if (e->ima == tpage && e->iuser.tile == tile) { break; } @@ -4791,7 +4817,8 @@ static bool project_bucket_iter_next(ProjPaintState *ps, const int max_bucket_idx = ps->bucketMax[0] + (ps->bucketMax[1] - 1) * ps->buckets_x; for (int bidx = atomic_fetch_and_add_int32(&ps->context_bucket_index, 1); bidx < max_bucket_idx; - bidx = atomic_fetch_and_add_int32(&ps->context_bucket_index, 1)) { + bidx = atomic_fetch_and_add_int32(&ps->context_bucket_index, 1)) + { const int bucket_y = bidx / ps->buckets_x; const int bucket_x = bidx - (bucket_y * ps->buckets_x); @@ -4801,7 +4828,8 @@ static bool project_bucket_iter_next(ProjPaintState *ps, project_bucket_bounds(ps, bucket_x, bucket_y, bucket_bounds); if ((ps->source != PROJ_SRC_VIEW) || - project_bucket_isect_circle(mval, float(diameter * diameter), bucket_bounds)) { + project_bucket_isect_circle(mval, float(diameter * diameter), bucket_bounds)) + { *bucket_index = bidx; return true; @@ -5778,7 +5806,8 @@ static void paint_proj_stroke_ps(const bContext * /*C*/, ps->stencil_value = brush->weight; if ((ps->mode == BRUSH_STROKE_INVERT) ^ - ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0)) { + ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0)) + { ps->stencil_value = 1.0f - ps->stencil_value; } } @@ -6121,7 +6150,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ps.reproject_ibuf = BKE_image_acquire_ibuf(image, nullptr, nullptr); if ((ps.reproject_ibuf == nullptr) || - ((ps.reproject_ibuf->rect || ps.reproject_ibuf->rect_float) == false)) { + ((ps.reproject_ibuf->rect || ps.reproject_ibuf->rect_float) == false)) + { BKE_report(op->reports, RPT_ERROR, "Image data could not be found"); return OPERATOR_CANCELLED; } @@ -6133,7 +6163,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) /* type check to make sure its ok */ if (view_data != nullptr && - (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT)) { + (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT)) + { BKE_report(op->reports, RPT_ERROR, "Image project data invalid"); return OPERATOR_CANCELLED; } @@ -6415,7 +6446,8 @@ bool ED_paint_proj_mesh_data_check( if (ma->texpaintslot != nullptr && (ma->texpaintslot[ma->paint_active_slot].ima == nullptr || !ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima) || - !ID_IS_OVERRIDE_LIBRARY(ma->texpaintslot[ma->paint_active_slot].ima))) { + !ID_IS_OVERRIDE_LIBRARY(ma->texpaintslot[ma->paint_active_slot].ima))) + { hastex = true; break; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index 124250c44c9..99e5a84f93a 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -362,7 +362,8 @@ static bool palette_poll(bContext *C) Paint *paint = BKE_paint_get_active_from_context(C); if (paint && paint->palette != nullptr && !ID_IS_LINKED(paint->palette) && - !ID_IS_OVERRIDE_LIBRARY(paint->palette)) { + !ID_IS_OVERRIDE_LIBRARY(paint->palette)) + { return true; } @@ -811,7 +812,8 @@ static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, con brush = first_brush; do { if ((brush->ob_mode & paint->runtime.ob_mode) && - (brush_tool(brush, paint->runtime.tool_offset) == tool)) { + (brush_tool(brush, paint->runtime.tool_offset) == tool)) + { return brush; } @@ -892,7 +894,8 @@ static bool brush_generic_tool_set(bContext *C, } if (((brush == nullptr) && create_missing) && - ((brush_orig == nullptr) || brush_tool(brush_orig, paint->runtime.tool_offset) != tool)) { + ((brush_orig == nullptr) || brush_tool(brush_orig, paint->runtime.tool_offset) != tool)) + { brush = BKE_brush_add(bmain, tool_name, eObjectMode(paint->runtime.ob_mode)); id_us_min(&brush->id); /* fake user only */ brush_tool_set(brush, paint->runtime.tool_offset, tool); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc b/source/blender/editors/sculpt_paint/paint_stroke.cc index e042abbf1e1..6015f39fede 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.cc +++ b/source/blender/editors/sculpt_paint/paint_stroke.cc @@ -220,7 +220,8 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode) SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, - SCULPT_TOOL_THUMB)) { + SCULPT_TOOL_THUMB)) + { return false; } else if (SCULPT_is_cloth_deform_brush(brush)) { @@ -268,7 +269,8 @@ static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode m SCULPT_TOOL_ELASTIC_DEFORM, SCULPT_TOOL_CLOTH, SCULPT_TOOL_BOUNDARY, - SCULPT_TOOL_POSE)) { + SCULPT_TOOL_POSE)) + { return false; } else { @@ -372,7 +374,8 @@ static bool paint_brush_update(bContext *C, if (ELEM(brush->mask_mtex.brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_AREA, - MTEX_MAP_MODE_RANDOM)) { + MTEX_MAP_MODE_RANDOM)) + { do_random_mask = true; } @@ -562,7 +565,8 @@ static void paint_brush_stroke_add_step( float world_space_position[3]; if (SCULPT_stroke_get_location( - C, world_space_position, stroke->last_mouse_position, stroke->original)) { + C, world_space_position, stroke->last_mouse_position, stroke->original)) + { copy_v3_v3(stroke->last_world_space_position, world_space_position); mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); } @@ -1041,7 +1045,8 @@ bool paint_space_stroke_enabled(Brush *br, ePaintMode mode) } if (mode == PAINT_MODE_SCULPT_CURVES && - !curves_sculpt_brush_uses_spacing(eBrushCurvesSculptTool(br->curves_sculpt_tool))) { + !curves_sculpt_brush_uses_spacing(eBrushCurvesSculptTool(br->curves_sculpt_tool))) + { return false; } @@ -1093,7 +1098,8 @@ bool paint_supports_dynamic_size(Brush *br, ePaintMode mode) bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode) { if (!(br->flag & BRUSH_SMOOTH_STROKE) || - (br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE))) { + (br->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE))) + { return false; } @@ -1341,7 +1347,8 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str } if ((br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || - (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { + (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) + { do_rake = true; for (j = 0; j < 2; j++) { BKE_curve_forward_diff_tangent_bezier(pcp->bez.vec[1][j], @@ -1559,7 +1566,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS if (stroke->stroke_started && (first_modal || ISMOUSE_MOTION(event->type))) { if ((br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || - (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { + (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) + { copy_v2_v2(stroke->ups->last_rake, stroke->last_mouse_position); } paint_calculate_rake_rotation(stroke->ups, br, mouse, mode); @@ -1570,7 +1578,8 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS (!(br->flag & BRUSH_AIRBRUSH) && ISMOUSE_MOTION(event->type)) || /* airbrush */ ((br->flag & BRUSH_AIRBRUSH) && event->type == TIMER && - event->customdata == stroke->timer)) { + event->customdata == stroke->timer)) + { if (paint_smooth_stroke(stroke, &sample_average, mode, mouse, &pressure)) { if (stroke->stroke_started) { if (paint_space_stroke_enabled(br, mode)) { @@ -1695,7 +1704,8 @@ bool PAINT_brush_tool_poll(bContext *C) if (p && ob && BKE_paint_brush(p) && (area && ELEM(area->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) && - (region && region->regiontype == RGN_TYPE_WINDOW)) { + (region && region->regiontype == RGN_TYPE_WINDOW)) + { /* Check the current tool is a brush. */ bToolRef *tref = area->runtime.tool; if (tref && tref->runtime && tref->runtime->data_block[0]) { diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 4be49922fe5..e8f81c736aa 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -315,7 +315,8 @@ static void imapaint_pick_uv( if (!(slot && slot->uvname && (mloopuv = CustomData_get_layer_named( - &me_eval->ldata, CD_PROP_FLOAT2, slot->uvname)))) { + &me_eval->ldata, CD_PROP_FLOAT2, slot->uvname)))) + { mloopuv = CustomData_get_layer(&me_eval->ldata, CD_PROP_FLOAT2); } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 0f313aa6029..a5ceea014ed 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -291,7 +291,8 @@ static bool weight_paint_poll_ex(bContext *C, bool check_tool) if ((ob != nullptr) && (ob->mode & OB_MODE_WEIGHT_PAINT) && (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != nullptr) && - (area = CTX_wm_area(C)) && (area->spacetype == SPACE_VIEW3D)) { + (area = CTX_wm_area(C)) && (area->spacetype == SPACE_VIEW3D)) + { ARegion *region = CTX_wm_region(C); if (ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_HUD)) { if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) { @@ -382,8 +383,8 @@ static Color vpaint_blend(const VPaint *vp, } } - if ((brush->flag & BRUSH_LOCK_ALPHA) && - !ELEM(blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA)) { + if ((brush->flag & BRUSH_LOCK_ALPHA) && !ELEM(blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA)) + { Value *cp, *cc; cp = (Value *)&color_blend; cc = (Value *)&color_curr; @@ -450,7 +451,8 @@ static void paint_and_tex_color_alpha_intern(VPaint *vp, vc->region, co, co_ss, - (eV3DProjTest)(V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR)) == V3D_PROJ_RET_OK) { + (eV3DProjTest)(V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR)) == V3D_PROJ_RET_OK) + { const float co_ss_3d[3] = {co_ss[0], co_ss[1], 0.0f}; /* we need a 3rd empty value */ BKE_brush_sample_tex_3d(vc->scene, brush, mtex, co_ss_3d, r_rgba, 0, nullptr); } @@ -1655,6 +1657,8 @@ static void vwpaint_update_cache_invariants( copy_v3_v3(cache->view_normal, cache->true_view_normal); cache->bstrength = BKE_brush_alpha_get(scene, brush); cache->is_last_valid = false; + + cache->accum = true; } /* Initialize the stroke cache variants from operator properties */ @@ -1689,8 +1693,8 @@ static void vwpaint_update_cache_variants(bContext *C, VPaint *vp, Object *ob, P BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); } - if (BKE_brush_use_size_pressure(brush) && - paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT)) { + if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT)) + { cache->radius = cache->initial_radius * cache->pressure; } else { @@ -1797,7 +1801,8 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo BKE_object_defgroup_check_lock_relative( wpd->lock_flags, wpd->vgroup_validmap, wpd->active.index) && (!wpd->do_multipaint || BKE_object_defgroup_check_lock_relative_multi( - defbase_tot, wpd->lock_flags, defbase_sel, defbase_tot_sel))) { + defbase_tot, wpd->lock_flags, defbase_sel, defbase_tot_sel))) + { wpd->do_lock_relative = true; } @@ -1990,7 +1995,8 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); const float final_alpha = brush_fade * brush_strength * grid_alpha * @@ -2074,7 +2080,8 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) + { bool do_color = false; /* Minimum dot product between brush direction and current * to neighbor direction is 0.0, meaning orthogonal. */ @@ -2180,7 +2187,8 @@ static void do_wpaint_brush_draw_task_cb_ex(void *__restrict userdata, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &data->wpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); const float final_alpha = brush_fade * brush_strength * grid_alpha * @@ -2239,7 +2247,8 @@ static void do_wpaint_brush_calc_average_weight_cb_ex(void *__restrict userdata, const float angle_cos = (use_normal && vd.no) ? dot_v3v3(sculpt_normal_frontface, vd.no) : 1.0f; if (angle_cos > 0.0 && - BKE_brush_curve_strength(data->brush, sqrtf(test.dist), cache->radius) > 0.0) { + BKE_brush_curve_strength(data->brush, sqrtf(test.dist), cache->radius) > 0.0) + { const int v_index = has_grids ? ss->corner_verts[vd.grid_indices[vd.g]] : vd.vert_indices[vd.i]; @@ -3003,7 +3012,8 @@ static void do_vpaint_brush_blur_loops(bContext *C, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &vpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &vpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); @@ -3146,7 +3156,8 @@ static void do_vpaint_brush_blur_verts(bContext *C, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &vpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &vpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); @@ -3299,7 +3310,8 @@ static void do_vpaint_brush_smear(bContext *C, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &vpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &vpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); @@ -3582,7 +3594,8 @@ static void vpaint_do_draw(bContext *C, if (((brush->flag & BRUSH_FRONTFACE) == 0 || (angle_cos > 0.0f)) && ((brush->flag & BRUSH_FRONTFACE_FALLOFF) == 0 || view_angle_limits_apply_falloff( - &vpd->normal_angle_precalc, angle_cos, &brush_strength))) { + &vpd->normal_angle_precalc, angle_cos, &brush_strength))) + { const float brush_fade = BKE_brush_curve_strength( brush, sqrtf(test.dist), cache->radius); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc index 53172b0bd13..d1615cb3499 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc @@ -200,8 +200,8 @@ static void face_corner_color_equalize_verts(Mesh &mesh, const IndexMask selecti static bool vertex_color_smooth(Object *ob) { Mesh *me; - if (((me = BKE_mesh_from_object(ob)) == nullptr) || - (ED_mesh_color_ensure(me, nullptr) == false)) { + if (((me = BKE_mesh_from_object(ob)) == nullptr) || (ED_mesh_color_ensure(me, nullptr) == false)) + { return false; } @@ -346,7 +346,8 @@ static int vertex_color_brightness_contrast_exec(bContext *C, wmOperator *op) Mesh *me; if (((me = BKE_mesh_from_object(obact)) == nullptr) || - (ED_mesh_color_ensure(me, nullptr) == false)) { + (ED_mesh_color_ensure(me, nullptr) == false)) + { return OPERATOR_CANCELLED; } @@ -392,7 +393,8 @@ static int vertex_color_hsv_exec(bContext *C, wmOperator *op) Mesh *me; if (((me = BKE_mesh_from_object(obact)) == nullptr) || - (ED_mesh_color_ensure(me, nullptr) == false)) { + (ED_mesh_color_ensure(me, nullptr) == false)) + { return OPERATOR_CANCELLED; } @@ -442,7 +444,8 @@ static int vertex_color_invert_exec(bContext *C, wmOperator *op) Mesh *me; if (((me = BKE_mesh_from_object(obact)) == nullptr) || - (ED_mesh_color_ensure(me, nullptr) == false)) { + (ED_mesh_color_ensure(me, nullptr) == false)) + { return OPERATOR_CANCELLED; } @@ -479,7 +482,8 @@ static int vertex_color_levels_exec(bContext *C, wmOperator *op) Mesh *me; if (((me = BKE_mesh_from_object(obact)) == nullptr) || - (ED_mesh_color_ensure(me, nullptr) == false)) { + (ED_mesh_color_ensure(me, nullptr) == false)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index d5a7a704cb1..49bb00a5c2e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -113,7 +113,8 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, if (ED_view3d_project_float_object( vp_update->region, co, co_ss, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { const float dist_sq = len_squared_v2v2(vp_update->mval_fl, co_ss); if (dist_sq > vp_handle->dists_sq[index]) { /* bail out! */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc index 10f9cb9a722..bce9e489361 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc @@ -19,6 +19,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" +#include "BKE_attribute.hh" #include "BKE_brush.h" #include "BKE_colortools.h" #include "BKE_context.h" @@ -185,12 +186,12 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even } } else { - if (ED_mesh_pick_face_vert( - C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { + if (ED_mesh_pick_face_vert(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) + { v_idx_best = index; } - else if (ED_mesh_pick_face( - C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { + else if (ED_mesh_pick_face(C, vc.obact, event->mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) + { /* This relies on knowing the internal workings of #ED_mesh_pick_face_vert() */ BKE_report( op->reports, RPT_WARNING, "The modifier used does not support deformed locations"); @@ -364,7 +365,8 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, bDeformGroup *dg; for (dg = static_cast(me->vertex_group_names.first); dg && i < defbase_tot; - i++, dg = dg->next) { + i++, dg = dg->next) + { if (groups[i]) { item_tmp.identifier = item_tmp.name = dg->name; item_tmp.value = i; @@ -592,6 +594,7 @@ struct WPGradient_userData { Mesh *me; MDeformVert *dvert; const bool *select_vert; + blender::VArray hide_vert; Brush *brush; const float *sco_start; /* [2] */ const float *sco_end; /* [2] */ @@ -615,7 +618,8 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index) /* Optionally restrict to assigned vertices only. */ if (grad_data->use_vgroup_restrict && - ((vs->flag & WPGradient_vertStore::VGRAD_STORE_DW_EXIST) == 0)) { + ((vs->flag & WPGradient_vertStore::VGRAD_STORE_DW_EXIST) == 0)) + { /* In this case the vertex will never have been touched. */ BLI_assert((vs->flag & WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED) == 0); return; @@ -678,6 +682,10 @@ static void gradientVertUpdate__mapFunc(void *userData, return; } + if (grad_data->hide_vert[index]) { + return; + } + gradientVert_update(grad_data, index); } @@ -705,7 +713,8 @@ static void gradientVertInit__mapFunc(void *userData, if (ED_view3d_project_float_object( grad_data->region, co, vs->sco, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { copy_v2_fl(vs->sco, FLT_MAX); return; } @@ -815,12 +824,15 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) __func__)); } + const blender::bke::AttributeAccessor attributes = me->attributes(); + data.region = region; data.scene = scene; data.me = me; data.dvert = dverts; data.select_vert = (const bool *)CustomData_get_layer_named( &me->vdata, CD_PROP_BOOL, ".select_vert"); + data.hide_vert = *attributes.lookup_or_default(".hide_vert", ATTR_DOMAIN_POINT, false); data.sco_start = sco_start; data.sco_end = sco_end; data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 576dcaced74..ca8f1f86ac0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -1074,7 +1074,8 @@ static void do_nearest_vertex_get_task_cb(void *__restrict userdata, BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { float distance_squared = len_squared_v3v3(vd.co, data->nearest_vertex_search_co); if (distance_squared < nvtd->nearest_vertex_distance_squared && - distance_squared < data->max_distance_squared) { + distance_squared < data->max_distance_squared) + { nvtd->nearest_vertex = vd.vertex; nvtd->nearest_vertex_distance_squared = distance_squared; } @@ -2075,7 +2076,8 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata, /* Layer brush produces artifacts with normal and area radius */ /* Enable area radius control only on Scrape for now */ if (ELEM(data->brush->sculpt_tool, SCULPT_TOOL_SCRAPE, SCULPT_TOOL_FILL) && - data->brush->area_radius_factor > 0.0f) { + data->brush->area_radius_factor > 0.0f) + { test_radius *= data->brush->area_radius_factor; if (ss->cache && data->brush->flag2 & BRUSH_AREA_RADIUS_PRESSURE) { test_radius *= ss->cache->pressure; @@ -2953,7 +2955,8 @@ static void update_sculpt_normal(Sculpt *sd, Object *ob, Span nodes) !(brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK && cache->normal_weight > 0.0f); if (cache->mirror_symmetry_pass == 0 && cache->radial_symmetry_pass == 0 && - (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(cache) || update_normal)) { + (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(cache) || update_normal)) + { calc_sculpt_normal(sd, ob, nodes, cache->sculpt_normal); if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { project_plane_v3_v3v3(cache->sculpt_normal, cache->sculpt_normal, cache->view_normal); @@ -3203,7 +3206,8 @@ void SCULPT_calc_brush_plane( if (SCULPT_stroke_is_main_symmetry_pass(ss->cache) && (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || - !(brush->flag & BRUSH_ORIGINAL_PLANE) || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) { + !(brush->flag & BRUSH_ORIGINAL_PLANE) || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) + { switch (brush->sculpt_plane) { case SCULPT_DISP_DIR_VIEW: copy_v3_v3(r_area_no, ss->cache->true_view_normal); @@ -3241,7 +3245,8 @@ void SCULPT_calc_brush_plane( /* For area normal. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) && - (brush->flag & BRUSH_ORIGINAL_NORMAL)) { + (brush->flag & BRUSH_ORIGINAL_NORMAL)) + { copy_v3_v3(r_area_no, ss->cache->sculpt_normal); } else { @@ -3250,7 +3255,8 @@ void SCULPT_calc_brush_plane( /* For flatten center. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) && - (brush->flag & BRUSH_ORIGINAL_PLANE)) { + (brush->flag & BRUSH_ORIGINAL_PLANE)) + { copy_v3_v3(r_area_co, ss->cache->last_center); } else { @@ -3590,7 +3596,8 @@ static void do_brush_action(Sculpt *sd, /* It also assigns the paint_face_set here as it needs to be done regardless of the stroke type * and the number of nodes under the brush influence. */ if (brush->sculpt_tool == SCULPT_TOOL_DRAW_FACE_SETS && - SCULPT_stroke_is_first_brush_step(ss->cache) && !ss->cache->alt_smooth) { + SCULPT_stroke_is_first_brush_step(ss->cache) && !ss->cache->alt_smooth) + { if (ss->cache->invert) { /* When inverting the brush, pick the paint face mask ID from the mesh. */ ss->cache->paint_face_set = SCULPT_active_face_set_get(ss); @@ -3604,7 +3611,8 @@ static void do_brush_action(Sculpt *sd, /* For anchored brushes with spherical falloff, we start off with zero radius, thus we have no * PBVH nodes on the first brush step. */ if (!nodes.is_empty() || - ((brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) && (brush->flag & BRUSH_ANCHORED))) { + ((brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) && (brush->flag & BRUSH_ANCHORED))) + { if (SCULPT_stroke_is_first_brush_step(ss->cache)) { /* Initialize auto-masking cache. */ if (SCULPT_is_automasking_enabled(sd, ss, brush)) { @@ -3614,7 +3622,8 @@ static void do_brush_action(Sculpt *sd, } /* Initialize surface smooth cache. */ if ((brush->sculpt_tool == SCULPT_TOOL_SMOOTH) && - (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_SURFACE)) { + (brush->smooth_deform_type == BRUSH_SMOOTH_DEFORM_SURFACE)) + { BLI_assert(ss->cache->surface_smooth_laplacian_disp == nullptr); ss->cache->surface_smooth_laplacian_disp = static_cast( MEM_callocN(sizeof(float[3]) * SCULPT_vertex_count_get(ss), "HC smooth laplacian b")); @@ -3776,7 +3785,8 @@ static void do_brush_action(Sculpt *sd, } if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) && - brush->autosmooth_factor > 0) { + brush->autosmooth_factor > 0) + { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { SCULPT_smooth(sd, ob, nodes, brush->autosmooth_factor * (1.0f - ss->cache->pressure), false); } @@ -3790,16 +3800,17 @@ static void do_brush_action(Sculpt *sd, } if (!SCULPT_tool_can_reuse_automask(brush->sculpt_tool) || - (ss->cache->supports_gravity && sd->gravity_factor > 0.0f)) { + (ss->cache->supports_gravity && sd->gravity_factor > 0.0f)) + { /* Clear cavity mask cache. */ ss->last_automasking_settings_hash = 0; } /* The cloth brush adds the gravity as a regular force and it is processed in the solver. */ - if (ss->cache->supports_gravity && !ELEM(brush->sculpt_tool, - SCULPT_TOOL_CLOTH, - SCULPT_TOOL_DRAW_FACE_SETS, - SCULPT_TOOL_BOUNDARY)) { + if (ss->cache->supports_gravity && + !ELEM( + brush->sculpt_tool, SCULPT_TOOL_CLOTH, SCULPT_TOOL_DRAW_FACE_SETS, SCULPT_TOOL_BOUNDARY)) + { do_gravity(sd, ob, nodes, sd->gravity_factor); } @@ -4381,7 +4392,8 @@ static void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache SCULPT_TOOL_SLIDE_RELAX, SCULPT_TOOL_DRAW_FACE_SETS, SCULPT_TOOL_PAINT, - SCULPT_TOOL_SMEAR)) { + SCULPT_TOOL_SMEAR)) + { /* Do nothing, this tool has its own smooth mode. */ } else { @@ -4415,7 +4427,8 @@ static void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache SCULPT_TOOL_SLIDE_RELAX, SCULPT_TOOL_DRAW_FACE_SETS, SCULPT_TOOL_PAINT, - SCULPT_TOOL_SMEAR)) { + SCULPT_TOOL_SMEAR)) + { /* Do nothing. */ } else { @@ -4571,7 +4584,8 @@ static void sculpt_update_cache_invariants( /* Original coordinates require the sculpt undo system, which isn't used * for image brushes. It's also not necessary, just disable it. */ if (brush && brush->sculpt_tool == SCULPT_TOOL_PAINT && - SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) { + SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) + { cache->accum = true; } @@ -4614,7 +4628,8 @@ static bool sculpt_needs_delta_from_anchored_origin(Brush *brush) SCULPT_TOOL_POSE, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_THUMB, - SCULPT_TOOL_ELASTIC_DEFORM)) { + SCULPT_TOOL_ELASTIC_DEFORM)) + { return true; } if (brush->sculpt_tool == SCULPT_TOOL_CLOTH && @@ -4665,7 +4680,8 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_SMEAR, SCULPT_TOOL_THUMB) && - !sculpt_brush_use_topology_rake(ss, brush)) { + !sculpt_brush_use_topology_rake(ss, brush)) + { return; } float grab_location[3], imat[4][4], delta[3], loc[3]; @@ -4681,7 +4697,8 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru } else if (tool == SCULPT_TOOL_SNAKE_HOOK || (tool == SCULPT_TOOL_CLOTH && - brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) { + brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_SNAKE_HOOK)) + { add_v3_v3(cache->true_location, cache->grab_delta); } @@ -4853,7 +4870,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || !((brush->flag & BRUSH_ANCHORED) || (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK) || - (brush->sculpt_tool == SCULPT_TOOL_ROTATE) || SCULPT_is_cloth_deform_brush(brush))) { + (brush->sculpt_tool == SCULPT_TOOL_ROTATE) || SCULPT_is_cloth_deform_brush(brush))) + { RNA_float_get_array(ptr, "location", cache->true_location); } @@ -4898,8 +4916,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po } } - if (BKE_brush_use_size_pressure(brush) && - paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT)) { + if (BKE_brush_use_size_pressure(brush) && paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT)) + { cache->radius = sculpt_brush_dynamic_size_get(brush, cache, cache->initial_radius); cache->dyntopo_pixel_radius = sculpt_brush_dynamic_size_get( brush, cache, ups->initial_pixel_radius); @@ -4978,7 +4996,8 @@ void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *b bool need_pmap = sculpt_needs_connectivity_info(sd, brush, ss, 0); if (ss->shapekey_active || ss->deform_modifiers_active || - (!BKE_sculptsession_use_pbvh_draw(ob, rv3d) && need_pmap)) { + (!BKE_sculptsession_use_pbvh_draw(ob, rv3d) && need_pmap)) + { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); BKE_sculpt_update_object_for_edit( depsgraph, ob, need_pmap, false, SCULPT_tool_is_paint(brush->sculpt_tool)); @@ -5016,7 +5035,8 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin) &srd->depth, &srd->active_vertex, &srd->active_face_grid_index, - srd->face_normal)) { + srd->face_normal)) + { srd->hit = true; *tmin = srd->depth; } @@ -5050,7 +5070,8 @@ static void sculpt_find_nearest_to_ray_cb(PBVHNode *node, void *data_v, float *t srd->ray_start, srd->ray_normal, &srd->depth, - &srd->dist_sq_to_ray)) { + &srd->dist_sq_to_ray)) + { srd->hit = true; *tmin = srd->dist_sq_to_ray; } @@ -5082,7 +5103,8 @@ float SCULPT_raycast_init(ViewContext *vc, if ((rv3d->is_persp == false) && /* If the ray is clipped, don't adjust its start/end. */ - !RV3D_CLIPPING_ENABLED(v3d, rv3d)) { + !RV3D_CLIPPING_ENABLED(v3d, rv3d)) + { BKE_pbvh_raycast_project_ray_root(ob->sculpt->pbvh, original, ray_start, ray_end, ray_normal); /* rRecalculate the normal. */ @@ -5348,7 +5370,8 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) } if (brush->sculpt_tool == SCULPT_TOOL_CLOTH || - brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM) { + brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM) + { need_mask = true; } @@ -5387,7 +5410,8 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob) if ((brush->flag & BRUSH_ANCHORED) || (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ELASTIC_DEFORM) && BKE_brush_use_size_pressure(brush)) || - (brush->flag & BRUSH_DRAG_DOT)) { + (brush->flag & BRUSH_DRAG_DOT)) + { paint_mesh_restore_co(sd, ob); @@ -5597,7 +5621,8 @@ static void sculpt_stroke_undo_begin(const bContext *C, wmOperator *op) /* Setup the correct undo system. Image painting and sculpting are mutual exclusive. * Color attributes are part of the sculpting undo system. */ if (brush && brush->sculpt_tool == SCULPT_TOOL_PAINT && - SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) { + SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) + { ED_image_undo_push_begin(op->type->name, PAINT_MODE_SCULPT); } else { @@ -5611,7 +5636,8 @@ static void sculpt_stroke_undo_end(const bContext *C, Brush *brush) ToolSettings *tool_settings = CTX_data_tool_settings(C); if (brush && brush->sculpt_tool == SCULPT_TOOL_PAINT && - SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) { + SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) + { ED_image_undo_push_end(); } else { @@ -5653,7 +5679,8 @@ static bool sculpt_stroke_test_start(bContext *C, wmOperator *op, const float mv /* NOTE: This should be removed when paint mode is available. Paint mode can force based on the * canvas it is painting on. (ref. use_sculpt_texture_paint). */ if (brush && SCULPT_tool_is_paint(brush->sculpt_tool) && - !SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) { + !SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) + { View3D *v3d = CTX_wm_view3d(C); if (v3d->shading.type == OB_SOLID) { v3d->shading.color_type = V3D_SHADING_VERTEX_COLOR; @@ -5849,7 +5876,8 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent SculptSession *ss = ob->sculpt; if (SCULPT_tool_is_paint(brush->sculpt_tool) && - !SCULPT_handles_colors_report(ob->sculpt, op->reports)) { + !SCULPT_handles_colors_report(ob->sculpt, op->reports)) + { return OPERATOR_CANCELLED; } if (SCULPT_tool_is_mask(brush->sculpt_tool)) { @@ -6046,10 +6074,12 @@ static void do_fake_neighbor_search_task_cb(void *__restrict userdata, BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { int vd_topology_id = SCULPT_vertex_island_get(ss, vd.vertex); if (vd_topology_id != nvtd->current_topology_id && - ss->fake_neighbors.fake_neighbor_index[vd.index] == FAKE_NEIGHBOR_NONE) { + ss->fake_neighbors.fake_neighbor_index[vd.index] == FAKE_NEIGHBOR_NONE) + { float distance_squared = len_squared_v3v3(vd.co, data->nearest_vertex_search_co); if (distance_squared < nvtd->nearest_vertex_distance_squared && - distance_squared < data->max_distance_squared) { + distance_squared < data->max_distance_squared) + { nvtd->nearest_vertex = vd.vertex; nvtd->nearest_vertex_distance_squared = distance_squared; } @@ -6341,8 +6371,8 @@ void SCULPT_topology_islands_ensure(Object *ob) { SculptSession *ss = ob->sculpt; - if (ss->attrs.topology_island_key && ss->islands_valid && - BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) { + if (ss->attrs.topology_island_key && ss->islands_valid && BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) + { return; } diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index 5dd24d01728..01583af78ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -200,12 +200,14 @@ static bool SCULPT_automasking_needs_factors_cache(const Sculpt *sd, const Brush const int automasking_flags = sculpt_automasking_mode_effective_bits(sd, brush); if (automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY && brush && - sculpt_automasking_is_constrained_by_radius(brush)) { + sculpt_automasking_is_constrained_by_radius(brush)) + { return true; } if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES | - BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | BRUSH_AUTOMASKING_VIEW_NORMAL)) { + BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | BRUSH_AUTOMASKING_VIEW_NORMAL)) + { return brush && brush->automasking_boundary_edges_propagation_steps != 1; } return false; @@ -507,7 +509,8 @@ static float sculpt_automasking_cavity_factor(AutomaskingCache *automasking, bool inverted = automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_INVERTED; if ((automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_ALL) && - (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_USE_CURVE)) { + (automasking->settings.flags & BRUSH_AUTOMASKING_CAVITY_USE_CURVE)) + { factor = inverted ? 1.0f - factor : factor; factor = BKE_curvemapping_evaluateF(automasking->settings.cavity_curve, 0, factor); factor = inverted ? 1.0f - factor : factor; @@ -530,7 +533,8 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking, /* Since brush normal mode depends on the current mirror symmetry pass * it is not folded into the factor cache (when it exists). */ if ((ss->cache || ss->filter_cache) && - (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) { + (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) + { mask *= automasking_brush_normal_factor(automasking, ss, vert, automask_data); } @@ -555,13 +559,15 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking, (BRUSH_AUTOMASKING_VIEW_OCCLUSION | BRUSH_AUTOMASKING_VIEW_NORMAL)) == (BRUSH_AUTOMASKING_VIEW_OCCLUSION | BRUSH_AUTOMASKING_VIEW_NORMAL); if (do_occlusion && - automasking_view_occlusion_factor(automasking, ss, vert, stroke_id, automask_data)) { + automasking_view_occlusion_factor(automasking, ss, vert, stroke_id, automask_data)) + { return automasking_factor_end(ss, automasking, vert, 0.0f); } if (!automasking->settings.topology_use_brush_limit && automasking->settings.flags & BRUSH_AUTOMASKING_TOPOLOGY && - SCULPT_vertex_island_get(ss, vert) != automasking->settings.initial_island_nr) { + SCULPT_vertex_island_get(ss, vert) != automasking->settings.initial_island_nr) + { return 0.0f; } @@ -588,7 +594,8 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking, } if ((ss->cache || ss->filter_cache) && - (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) { + (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) + { mask *= automasking_view_normal_factor(automasking, ss, vert, automask_data); } diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index ce47e6c97cf..d5aa6910bd6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -267,11 +267,13 @@ static void sculpt_boundary_indices_init(SculptSession *ss, /* Check if the boundary loops into itself and add the extra preview edge to close the loop. */ if (fdata.last_visited_vertex.i != BOUNDARY_VERTEX_NONE && - sculpt_boundary_is_vertex_in_editable_boundary(ss, fdata.last_visited_vertex)) { + sculpt_boundary_is_vertex_in_editable_boundary(ss, fdata.last_visited_vertex)) + { SculptVertexNeighborIter ni; SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, fdata.last_visited_vertex, ni) { if (BLI_gset_haskey(included_verts, POINTER_FROM_INT(ni.index)) && - sculpt_boundary_is_vertex_in_editable_boundary(ss, ni.vertex)) { + sculpt_boundary_is_vertex_in_editable_boundary(ss, ni.vertex)) + { sculpt_boundary_preview_edge_add(boundary, fdata.last_visited_vertex, ni.vertex); boundary->forms_loop = true; } @@ -394,7 +396,8 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss, /* Check the distance using the vertex that was propagated from the initial vertex that * was used to initialize the boundary. */ if (boundary->edit_info[from_v_i].original_vertex_i == - BKE_pbvh_vertex_to_index(ss->pbvh, initial_vertex)) { + BKE_pbvh_vertex_to_index(ss->pbvh, initial_vertex)) + { boundary->pivot_vertex = ni.vertex; copy_v3_v3(boundary->initial_pivot_position, SCULPT_vertex_co_get(ss, ni.vertex)); accum_distance += len_v3v3(SCULPT_vertex_co_get(ss, from_v), @@ -439,7 +442,8 @@ static void sculpt_boundary_falloff_factor_init(SculptSession *ss, } if (boundary->edit_info[i].original_vertex_i == - BKE_pbvh_vertex_to_index(ss->pbvh, boundary->initial_vertex)) { + BKE_pbvh_vertex_to_index(ss->pbvh, boundary->initial_vertex)) + { /* All vertices that are propagated from the original vertex won't be affected by the * boundary falloff, so there is no need to calculate anything else. */ continue; @@ -679,8 +683,8 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata, SCULPT_automasking_node_update(ss, &automask_data, &vd); SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } @@ -732,8 +736,8 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata, SCULPT_automasking_node_update(ss, &automask_data, &vd); SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } @@ -783,8 +787,8 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata, SCULPT_automasking_node_update(ss, &automask_data, &vd); SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } @@ -832,8 +836,8 @@ static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata, SCULPT_automasking_node_update(ss, &automask_data, &vd); SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } @@ -888,8 +892,8 @@ static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata, SCULPT_automasking_node_update(ss, &automask_data, &vd); SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } @@ -935,8 +939,8 @@ static void do_boundary_brush_smooth_task_cb_ex(void *__restrict userdata, } SCULPT_orig_vert_data_update(&orig_data, &vd); - if (!SCULPT_check_vertex_pivot_symmetry( - orig_data.co, boundary->initial_vertex_position, symm)) { + if (!SCULPT_check_vertex_pivot_symmetry(orig_data.co, boundary->initial_vertex_position, symm)) + { continue; } diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc index 457f7e0a62e..de494130a6e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc @@ -96,7 +96,8 @@ static void calc_sculpt_plane( if (SCULPT_stroke_is_main_symmetry_pass(ss->cache) && (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || - !(brush->flag & BRUSH_ORIGINAL_PLANE) || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) { + !(brush->flag & BRUSH_ORIGINAL_PLANE) || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) + { switch (brush->sculpt_plane) { case SCULPT_DISP_DIR_VIEW: copy_v3_v3(r_area_no, ss->cache->true_view_normal); @@ -134,7 +135,8 @@ static void calc_sculpt_plane( /* For area normal. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) && - (brush->flag & BRUSH_ORIGINAL_NORMAL)) { + (brush->flag & BRUSH_ORIGINAL_NORMAL)) + { copy_v3_v3(r_area_no, ss->cache->sculpt_normal); } else { @@ -143,7 +145,8 @@ static void calc_sculpt_plane( /* For flatten center. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) && - (brush->flag & BRUSH_ORIGINAL_PLANE)) { + (brush->flag & BRUSH_ORIGINAL_PLANE)) + { copy_v3_v3(r_area_co, ss->cache->last_center); } else { @@ -269,7 +272,8 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata, /* Offset vertex. */ if (ss->cache->brush->flag2 & BRUSH_USE_COLOR_AS_DISPLACEMENT && - (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA)) { + (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA)) + { float r_rgba[4]; SCULPT_brush_strength_color(ss, brush, @@ -2421,7 +2425,8 @@ void SCULPT_relax_vertex(SculptSession *ss, SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd->vertex, ni) { neighbor_count++; if (!filter_boundary_face_sets || - (filter_boundary_face_sets && !SCULPT_vertex_has_unique_face_set(ss, ni.vertex))) { + (filter_boundary_face_sets && !SCULPT_vertex_has_unique_face_set(ss, ni.vertex))) + { /* When the vertex to relax is boundary, use only connected boundary vertices for the average * position. */ diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index c2da182d45b..ba5ead18feb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -356,7 +356,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(void *__restrict userdat for (int c_i = 0; c_i < tot_indices; c_i++) { for (int c_j = 0; c_j < tot_indices; c_j++) { if (c_i != c_j && !cloth_brush_sim_has_length_constraint( - data->cloth_sim, build_indices[c_i], build_indices[c_j])) { + data->cloth_sim, build_indices[c_i], build_indices[c_j])) + { cloth_brush_add_length_constraint(ss, data->cloth_sim, node_index, @@ -670,7 +671,8 @@ static void cloth_brush_solve_collision(Object *object, for (collider_cache = static_cast(cloth_sim->collider_list->first); collider_cache; - collider_cache = collider_cache->next) { + collider_cache = collider_cache->next) + { float ray_start[3], ray_normal[3]; float pos_world_space[3], prev_pos_world_space[3]; @@ -974,7 +976,8 @@ static void cloth_brush_apply_brush_foces(Sculpt *sd, Object *ob, Spancloth_deform_type == BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR || - brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_PLANE) { + brush->cloth_force_falloff_type == BRUSH_CLOTH_FORCE_FALLOFF_PLANE) + { SCULPT_calc_brush_plane(sd, ob, nodes, area_no, area_co); /* Initialize stroke local space matrix. */ diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index 1fb308850d8..9bfed87380a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -108,7 +108,8 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op) SCULPT_undo_push_node(ob, nullptr, SCULPT_UNDO_COORDS); while (BKE_pbvh_bmesh_update_topology( - ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, nullptr, size, false, false)) { + ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, nullptr, size, false, false)) + { for (PBVHNode *node : nodes) { BKE_pbvh_node_mark_topology_update(node); } @@ -191,7 +192,8 @@ static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin) if (BKE_pbvh_node_get_tmin(node) < *tmin) { SculptDetailRaycastData *srd = static_cast(data_v); if (BKE_pbvh_bmesh_node_raycast_detail( - node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) { + node, srd->ray_start, &srd->isect_precalc, &srd->depth, &srd->edge_length)) + { srd->hit = true; *tmin = srd->depth; } @@ -635,7 +637,8 @@ static int dyntopo_detail_size_edit_modal(bContext *C, wmOperator *op, const wmE /* Cancel modal operator */ if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || - (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { + (event->type == RIGHTMOUSE && event->val == KM_PRESS)) + { dyntopo_detail_size_edit_cancel(C, op); ED_region_tag_redraw(region); return OPERATOR_FINISHED; @@ -644,7 +647,8 @@ static int dyntopo_detail_size_edit_modal(bContext *C, wmOperator *op, const wmE /* Finish modal operator */ if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || (event->type == EVT_RETKEY && event->val == KM_PRESS) || - (event->type == EVT_PADENTER && event->val == KM_PRESS)) { + (event->type == EVT_PADENTER && event->val == KM_PRESS)) + { ED_region_draw_cb_exit(region->type, cd->draw_handle); sd->constant_detail = cd->detail_size; ss->draw_faded_cursor = false; diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index 523fcbae2c5..59e735a077d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -1008,7 +1008,8 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob, PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); if (!(SCULPT_vertex_has_face_set(ss, vertex, active_face_set) && - SCULPT_vertex_has_unique_face_set(ss, vertex))) { + SCULPT_vertex_has_unique_face_set(ss, vertex))) + { continue; } expand_cache->vert_falloff[i] *= -1.0f; @@ -1278,7 +1279,8 @@ static void sculpt_expand_mask_update_task_cb(void *__restrict userdata, const bool enabled = sculpt_expand_state_get(ss, expand_cache, vd.vertex); if (expand_cache->check_islands && - !sculpt_expand_is_vert_in_active_component(ss, expand_cache, vd.vertex)) { + !sculpt_expand_is_vert_in_active_component(ss, expand_cache, vd.vertex)) + { continue; } @@ -1844,7 +1846,8 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event copy_v2_v2(expand_cache->initial_mouse_move, mval_fl); copy_v2_v2(expand_cache->original_mouse_move, expand_cache->initial_mouse); if (expand_cache->falloff_type == SCULPT_EXPAND_FALLOFF_GEODESIC && - SCULPT_vertex_count_get(ss) > expand_cache->max_geodesic_move_preview) { + SCULPT_vertex_count_get(ss) > expand_cache->max_geodesic_move_preview) + { /* Set to spherical falloff for preview in high poly meshes as it is the fastest one. * In most cases it should match closely the preview from geodesic. */ expand_cache->move_preview_falloff_type = SCULPT_EXPAND_FALLOFF_SPHERICAL; @@ -2201,7 +2204,8 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even /* Face Set operations are not supported in dyntopo. */ if (ss->expand_cache->target == SCULPT_EXPAND_TARGET_FACE_SETS && - BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { + BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) + { sculpt_expand_cache_free(ss); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index fb635f3ed5a..aa5b88a03f2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -370,8 +370,8 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) for (int i = 0; i < tot_vert; i++) { PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); - if (SCULPT_vertex_mask_get(ss, vertex) >= threshold && - SCULPT_vertex_visible_get(ss, vertex)) { + if (SCULPT_vertex_mask_get(ss, vertex) >= threshold && SCULPT_vertex_visible_get(ss, vertex)) + { SCULPT_vertex_face_set_set(ss, vertex, next_face_set); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index ef512c55641..b7f73d07a57 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -205,7 +205,8 @@ void SCULPT_filter_cache_init(bContext *C, nodes = blender::bke::pbvh::search_gather(pbvh, SCULPT_search_sphere_cb, &search_data2); if (BKE_paint_brush(&sd->paint) && - SCULPT_pbvh_calc_area_normal(brush, ob, nodes, true, ss->filter_cache->initial_normal)) { + SCULPT_pbvh_calc_area_normal(brush, ob, nodes, true, ss->filter_cache->initial_normal)) + { copy_v3_v3(ss->last_normal, ss->filter_cache->initial_normal); } else { @@ -353,11 +354,11 @@ static bool sculpt_mesh_filter_needs_pmap(eSculptMeshFilterType filter_type) static bool sculpt_mesh_filter_is_continuous(eSculptMeshFilterType type) { - return (ELEM(type, - MESH_FILTER_SHARPEN, - MESH_FILTER_SMOOTH, - MESH_FILTER_RELAX, - MESH_FILTER_RELAX_FACE_SETS)); + return ELEM(type, + MESH_FILTER_SHARPEN, + MESH_FILTER_SMOOTH, + MESH_FILTER_RELAX, + MESH_FILTER_RELAX_FACE_SETS); } static void mesh_filter_task_cb(void *__restrict userdata, @@ -402,7 +403,8 @@ static void mesh_filter_task_cb(void *__restrict userdata, } if (ELEM(filter_type, MESH_FILTER_RELAX, MESH_FILTER_RELAX_FACE_SETS) || - ss->filter_cache->no_orig_co) { + ss->filter_cache->no_orig_co) + { copy_v3_v3(orig_co, vd.co); } else { @@ -645,7 +647,8 @@ static void mesh_filter_sharpen_init(SculptSession *ss, /* Smooth the calculated factors and directions to remove high frequency detail. */ for (int smooth_iterations = 0; smooth_iterations < filter_cache->sharpen_curvature_smooth_iterations; - smooth_iterations++) { + smooth_iterations++) + { for (int i = 0; i < totvert; i++) { PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i); diff --git a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc index 0c9a0a01ad8..537abb5ef0a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_geodesic.cc +++ b/source/blender/editors/sculpt_paint/sculpt_geodesic.cc @@ -195,7 +195,8 @@ static float *SCULPT_geodesic_mesh_create(Object *ob, } if (e_other != e && !BLI_BITMAP_TEST(edge_tag, e_other) && - (ss->epmap[e_other].count == 0 || dists[ev_other] != FLT_MAX)) { + (ss->epmap[e_other].count == 0 || dists[ev_other] != FLT_MAX)) + { if (BLI_BITMAP_TEST(affected_vertex, v_other) || BLI_BITMAP_TEST(affected_vertex, ev_other)) { BLI_BITMAP_ENABLE(edge_tag, e_other); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.hh b/source/blender/editors/sculpt_paint/sculpt_intern.hh index fa5a16b36d7..63fd2b77fb1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/sculpt_intern.hh @@ -1026,7 +1026,8 @@ void SCULPT_vertex_neighbors_get(SculptSession *ss, #define SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator) \ SCULPT_vertex_neighbors_get(ss, v_index, true, &neighbor_iterator); \ for (neighbor_iterator.i = neighbor_iterator.size - 1; neighbor_iterator.i >= 0; \ - neighbor_iterator.i--) { \ + neighbor_iterator.i--) \ + { \ neighbor_iterator.vertex = neighbor_iterator.neighbors[neighbor_iterator.i]; \ neighbor_iterator.index = neighbor_iterator.neighbor_indices[neighbor_iterator.i]; \ neighbor_iterator.is_duplicate = (neighbor_iterator.i >= \ @@ -1168,7 +1169,8 @@ BLI_INLINE bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush) } if (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK && - brush->snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC) { + brush->snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC) + { /* Snake hook in elastic deform type has same requirements as the elastic deform tool. */ return true; } diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.cc b/source/blender/editors/sculpt_paint/sculpt_mask_expand.cc index 303c9b5937b..edbded835c7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.cc @@ -175,7 +175,8 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * } if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) || - (event->type == RIGHTMOUSE && event->val == KM_PRESS)) { + (event->type == RIGHTMOUSE && event->val == KM_PRESS)) + { /* Returning OPERATOR_CANCELLED will leak memory due to not finishing * undo. Better solution could be to make paint_mesh_restore_co work * for this case. */ @@ -185,7 +186,8 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) || (event->type == EVT_RETKEY && event->val == KM_PRESS) || - (event->type == EVT_PADENTER && event->val == KM_PRESS)) { + (event->type == EVT_PADENTER && event->val == KM_PRESS)) + { /* Smooth iterations. */ BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index e7acc968524..d590b73fcff 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -349,8 +349,8 @@ void ED_object_sculptmode_enter_ex(Main *bmain, sculpt_init_session(bmain, depsgraph, scene, ob); - if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && - fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) { + if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) + { BKE_report( reports, RPT_WARNING, "Object has non-uniform scale, sculpting may be unpredictable"); } diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.cc b/source/blender/editors/sculpt_paint/sculpt_pose.cc index e3ccddd7e40..bb4f3a5494a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.cc +++ b/source/blender/editors/sculpt_paint/sculpt_pose.cc @@ -404,12 +404,14 @@ static bool pose_topology_floodfill_cb( } if (len_squared_v3v3(data->pose_initial_co, data->fallback_floodfill_origin) < - len_squared_v3v3(data->pose_initial_co, co)) { + len_squared_v3v3(data->pose_initial_co, co)) + { copy_v3_v3(data->fallback_floodfill_origin, co); } if (sculpt_pose_brush_is_vertex_inside_brush_radius( - co, data->pose_initial_co, data->radius, data->symm)) { + co, data->pose_initial_co, data->radius, data->symm)) + { return true; } if (SCULPT_check_vertex_pivot_symmetry(co, data->pose_initial_co, data->symm)) { @@ -444,7 +446,8 @@ static bool pose_face_sets_floodfill_cb( BLI_BITMAP_ENABLE(data->is_weighted, index); if (sculpt_pose_brush_is_vertex_inside_brush_radius( - co, data->pose_initial_co, data->radius, data->symm)) { + co, data->pose_initial_co, data->radius, data->symm)) + { const int visited_face_set = SCULPT_vertex_face_set_get(ss, vertex); BLI_gset_add(data->visited_face_sets, POINTER_FROM_INT(visited_face_set)); } @@ -500,7 +503,8 @@ static bool pose_face_sets_floodfill_cb( /* Check if we can get a valid face set for the next iteration from this neighbor. */ if (SCULPT_vertex_has_unique_face_set(ss, ni.vertex) && - !BLI_gset_haskey(data->visited_face_sets, POINTER_FROM_INT(next_face_set_candidate))) { + !BLI_gset_haskey(data->visited_face_sets, POINTER_FROM_INT(next_face_set_candidate))) + { if (!data->next_face_set_found) { data->next_face_set = next_face_set_candidate; data->next_vertex = ni.vertex; @@ -638,7 +642,8 @@ static int pose_brush_num_effective_segments(const Brush *brush) * artifacts in the areas affected by multiple segments. */ if (ELEM(brush->pose_deform_type, BRUSH_POSE_DEFORM_SCALE_TRASLATE, - BRUSH_POSE_DEFORM_SQUASH_STRETCH)) { + BRUSH_POSE_DEFORM_SQUASH_STRETCH)) + { return 1; } return brush->pose_ik_segments; @@ -815,7 +820,8 @@ static bool pose_face_sets_fk_find_masked_floodfill_cb( if (!BLI_gset_haskey(data->visited_face_sets, POINTER_FROM_INT(to_face_set))) { if (SCULPT_vertex_has_unique_face_set(ss, to_v) && !SCULPT_vertex_has_unique_face_set(ss, from_v) && - SCULPT_vertex_has_face_set(ss, from_v, to_face_set)) { + SCULPT_vertex_has_face_set(ss, from_v, to_face_set)) + { BLI_gset_add(data->visited_face_sets, POINTER_FROM_INT(to_face_set)); @@ -881,7 +887,8 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk( if (fdata.floodfill_it[i] != 0 && SCULPT_vertex_has_face_set(ss, vertex, fdata.initial_face_set) && - SCULPT_vertex_has_face_set(ss, vertex, fdata.masked_face_set)) { + SCULPT_vertex_has_face_set(ss, vertex, fdata.masked_face_set)) + { add_v3_v3(origin_acc, SCULPT_vertex_co_get(ss, vertex)); origin_count++; } @@ -895,7 +902,8 @@ static SculptPoseIKChain *pose_ik_chain_init_face_sets_fk( if (fdata.floodfill_it[i] != 0 && SCULPT_vertex_has_face_set(ss, vertex, fdata.initial_face_set) && - SCULPT_vertex_has_face_set(ss, vertex, fdata.target_face_set)) { + SCULPT_vertex_has_face_set(ss, vertex, fdata.target_face_set)) + { add_v3_v3(target_acc, SCULPT_vertex_co_get(ss, vertex)); target_count++; } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 9b9c66540ee..b42d8a71c31 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -947,8 +947,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } } else if (unode->maxgrid && subdiv_ccg != nullptr) { - if ((subdiv_ccg->num_grids != unode->maxgrid) || - (subdiv_ccg->grid_size != unode->gridsize)) { + if ((subdiv_ccg->num_grids != unode->maxgrid) || (subdiv_ccg->grid_size != unode->gridsize)) + { continue; } @@ -1742,7 +1742,8 @@ static void sculpt_save_active_attribute(Object *ob, SculptAttrRef *attr) return; } if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) || - !(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) { + !(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) + { return; } attr->domain = meta_data->domain; @@ -1854,7 +1855,8 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr layer = BKE_id_attribute_search(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL); if (layer) { if (ED_geometry_attribute_convert( - me, attr->name, eCustomDataType(attr->type), attr->domain, nullptr)) { + me, attr->name, eCustomDataType(attr->type), attr->domain, nullptr)) + { layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain); } } diff --git a/source/blender/editors/space_action/action_draw.cc b/source/blender/editors/space_action/action_draw.cc index 8b5d49549ae..37ba92045d2 100644 --- a/source/blender/editors/space_action/action_draw.cc +++ b/source/blender/editors/space_action/action_draw.cc @@ -75,7 +75,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) float ymax = ANIM_UI_get_first_channel_top(v2d); for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step, channel_index++) { + ale = ale->next, ymax -= channel_step, channel_index++) + { const float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ @@ -92,7 +93,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) float ymax = ANIM_UI_get_first_channel_top(v2d); for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step, channel_index++) { + ale = ale->next, ymax -= channel_step, channel_index++) + { const float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ @@ -136,7 +138,8 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d) float ymin = ymax - ystep; for (bAnimListElem *ale = static_cast(anim_data->first); ale; - ale = ale->next, ymax = ymin, ymin -= ystep) { + ale = ale->next, ymax = ymin, ymin -= ystep) + { bAction *action = nullptr; AnimData *adt = nullptr; @@ -226,7 +229,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region float ymax = ANIM_UI_get_first_channel_top(v2d); const float channel_step = ANIM_UI_get_channel_step(); for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step) { + ale = ale->next, ymax -= channel_step) + { const float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ @@ -386,7 +390,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region const float scale_factor = ANIM_UI_get_keyframe_scale_factor(); for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step) { + ale = ale->next, ymax -= channel_step) + { const float ymin = ymax - ANIM_UI_get_channel_height(); float ycenter = (ymin + ymax) / 2.0f; diff --git a/source/blender/editors/space_action/action_edit.cc b/source/blender/editors/space_action/action_edit.cc index ddaaf217b1f..82bf3d1fc4e 100644 --- a/source/blender/editors/space_action/action_edit.cc +++ b/source/blender/editors/space_action/action_edit.cc @@ -192,7 +192,8 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const /* Find mask layer which is less than or equal to current-frame. */ for (masklay_shape = static_cast(masklay->splines_shapes.first); masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { const float framenum = float(masklay_shape->frame); *min = min_ff(*min, framenum); *max = max_ff(*max, framenum); @@ -327,12 +328,14 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min float ymax = ANIM_UI_get_first_channel_top(&ac->region->v2d); const float channel_step = ANIM_UI_get_channel_step(); for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step) { + ale = ale->next, ymax -= channel_step) + { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && - ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { + ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) + { /* update best estimate */ *r_min = ymax - ANIM_UI_get_channel_height(); *r_max = ymax; @@ -547,7 +550,8 @@ static eKeyPasteError paste_action_keys(bAnimContext *ac, ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS); if (ANIM_animdata_filter( - ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, eAnimCont_Types(ac->datatype)) == 0) { + ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, eAnimCont_Types(ac->datatype)) == 0) + { ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype)); } diff --git a/source/blender/editors/space_action/action_select.cc b/source/blender/editors/space_action/action_select.cc index abed2e4aa43..0db2363fdb6 100644 --- a/source/blender/editors/space_action/action_select.cc +++ b/source/blender/editors/space_action/action_select.cc @@ -274,7 +274,8 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) } else { if (ANIM_fcurve_keyframes_loop( - &ked, static_cast(ale->key_data), nullptr, test_cb, nullptr)) { + &ked, static_cast(ale->key_data), nullptr, test_cb, nullptr)) + { sel = SELECT_SUBTRACT; break; } @@ -493,7 +494,8 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho /* loop over data, doing box select */ for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step) { + ale = ale->next, ymax -= channel_step) + { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ @@ -759,7 +761,8 @@ static void region_select_action_keys( /* loop over data, doing region select */ for (ale = static_cast(anim_data.first); ale; - ale = ale->next, ymax -= channel_step) { + ale = ale->next, ymax -= channel_step) + { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ @@ -1472,7 +1475,8 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se for (marker = static_cast(markers->first); marker; marker = marker->next) { if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < scene->r.cfra)) || - ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= scene->r.cfra))) { + ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= scene->r.cfra))) + { marker->flag |= SELECT; } else { diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index d67bd5670ee..57d074e7051 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -549,7 +549,8 @@ static void action_listener(const wmSpaceTypeListenerParams *params) * (assume for now that if just adding these works, that will be fine). */ else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) || - ((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED))) { + ((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED))) + { ED_area_tag_refresh(area); } /* for simple edits to the curve data though (or just plain selections), diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index d275c8b9fce..f9bdd02d6f7 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -232,7 +232,8 @@ static bool buttons_context_path_data(ButsContextPath *path, int type) return true; } if (RNA_struct_is_a(ptr->type, &RNA_Curve) && - (type == -1 || ELEM(type, OB_CURVES_LEGACY, OB_SURF, OB_FONT))) { + (type == -1 || ELEM(type, OB_CURVES_LEGACY, OB_SURF, OB_FONT))) + { return true; } if (RNA_struct_is_a(ptr->type, &RNA_Armature) && ELEM(type, -1, OB_ARMATURE)) { @@ -300,7 +301,8 @@ static bool buttons_context_path_modifier(ButsContextPath *path) OB_GPENCIL_LEGACY, OB_CURVES, OB_POINTCLOUD, - OB_VOLUME)) { + OB_VOLUME)) + { ModifierData *md = BKE_object_active_modifier(ob); if (md != NULL) { RNA_pointer_create(&ob->id, &RNA_Modifier, md, &path->ptr[path->len]); @@ -565,7 +567,8 @@ static bool buttons_context_path( BCONTEXT_RENDER, BCONTEXT_OUTPUT, BCONTEXT_VIEW_LAYER, - BCONTEXT_WORLD)) { + BCONTEXT_WORLD)) + { RNA_pointer_create(NULL, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); path->len++; } @@ -1194,7 +1197,8 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel) BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && - ptr->type == &RNA_Scene) { + ptr->type == &RNA_Scene) + { continue; } if (!ELEM(sbuts->mainb, @@ -1203,7 +1207,8 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel) BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD) && - ptr->type == &RNA_ViewLayer) { + ptr->type == &RNA_ViewLayer) + { continue; } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 8e14c85587c..9c793253095 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -860,7 +860,8 @@ static void buttons_id_remap(ScrArea *UNUSED(area), SpaceProperties *sbuts = (SpaceProperties *)slink; if (BKE_id_remapper_apply(mappings, &sbuts->pinid, ID_REMAP_APPLY_DEFAULT) == - ID_REMAP_RESULT_SOURCE_UNASSIGNED) { + ID_REMAP_RESULT_SOURCE_UNASSIGNED) + { sbuts->flag &= ~SB_PIN_CONTEXT; } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.cc b/source/blender/editors/space_clip/clip_dopesheet_draw.cc index fbd20f5be63..42a43271446 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.cc +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.cc @@ -73,7 +73,8 @@ static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, uin MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; LISTBASE_FOREACH ( - MovieTrackingDopesheetCoverageSegment *, coverage_segment, &dopesheet->coverage_segments) { + MovieTrackingDopesheetCoverageSegment *, coverage_segment, &dopesheet->coverage_segments) + { if (coverage_segment->coverage < TRACKING_COVERAGE_OK) { int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->start_frame); diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index a321dc1bebd..cb9a93b064b 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -165,7 +165,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip } if (a < markersnr - 1 && - generic_track_get_marker_framenr(active_track, active_plane_track, a + 1) > i) { + generic_track_get_marker_framenr(active_track, active_plane_track, a + 1) > i) + { break; } @@ -322,7 +323,8 @@ static void draw_movieclip_buffer(const bContext *C, /* non-scaled proxy shouldn't use filtering */ if ((clip->flag & MCLIP_USE_PROXY) == 0 || - ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) { + ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) + { use_filter = false; } @@ -602,7 +604,8 @@ static void draw_marker_outline(SpaceClip *sc, marker->pattern_corners[0], marker->pattern_corners[1], marker->pattern_corners[2], - marker->pattern_corners[3])) { + marker->pattern_corners[3])) + { GPU_point_size(tiny ? 3.0f : 4.0f); immBegin(GPU_PRIM_POINTS, 1); @@ -776,7 +779,8 @@ static void draw_marker_areas(SpaceClip *sc, marker->pattern_corners[0], marker->pattern_corners[1], marker->pattern_corners[2], - marker->pattern_corners[3])) { + marker->pattern_corners[3])) + { GPU_point_size(tiny ? 1.0f : 2.0f); immUniform1f("udash_factor", 2.0f); /* Solid "line" */ @@ -1054,7 +1058,8 @@ static void draw_marker_texts(SpaceClip *sc, } if ((sc->flag & SC_SHOW_MARKER_SEARCH) && - ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) { + ((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) + { dx = marker->search_min[0]; dy = marker->search_min[1]; } diff --git a/source/blender/editors/space_clip/clip_editor.cc b/source/blender/editors/space_clip/clip_editor.cc index 36dbf8d4dfe..3febebe043e 100644 --- a/source/blender/editors/space_clip/clip_editor.cc +++ b/source/blender/editors/space_clip/clip_editor.cc @@ -779,7 +779,8 @@ static uchar *prefetch_thread_next_frame(PrefetchQueue *queue, BLI_spin_lock(&queue->spin); if (!*queue->stop && !check_prefetch_break() && - IN_RANGE_INCL(queue->current_frame, queue->start_frame, queue->end_frame)) { + IN_RANGE_INCL(queue->current_frame, queue->start_frame, queue->end_frame)) + { int current_frame; if (queue->forward) { @@ -1163,7 +1164,8 @@ void ED_clip_view_lock_state_store(const bContext *C, ClipViewLockState *state) } if (!clip_view_calculate_view_selection( - C, false, &state->offset_x, &state->offset_y, &state->zoom)) { + C, false, &state->offset_x, &state->offset_y, &state->zoom)) + { return; } diff --git a/source/blender/editors/space_clip/clip_graph_ops.cc b/source/blender/editors/space_clip/clip_graph_ops.cc index 96ed093fce8..cab428b584a 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.cc +++ b/source/blender/editors/space_clip/clip_graph_ops.cc @@ -184,7 +184,8 @@ static bool mouse_select_knot(bContext *C, const float co[2], bool extend) if (UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1) && UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2) && - (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta)) { + (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta)) + { if (!extend) { SelectUserData selectdata = {SEL_DESELECT}; diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index 4400149527f..89476e8dd73 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -527,7 +527,7 @@ static void clip_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) PointerRNA itemptr; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(WM_drag_get_path(drag), dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(WM_drag_get_path(drag), dir, sizeof(dir), file, sizeof(file)); RNA_string_set(drop->ptr, "directory", dir); diff --git a/source/blender/editors/space_clip/tracking_ops.cc b/source/blender/editors/space_clip/tracking_ops.cc index 48782a51145..7085b3df5cd 100644 --- a/source/blender/editors/space_clip/tracking_ops.cc +++ b/source/blender/editors/space_clip/tracking_ops.cc @@ -219,8 +219,8 @@ static int delete_track_exec(bContext *C, wmOperator * /*op*/) bool changed = false; /* Delete selected plane tracks. */ - LISTBASE_FOREACH_MUTABLE ( - MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) { + LISTBASE_FOREACH_MUTABLE (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) + { if (PLANE_TRACK_VIEW_SELECTED(plane_track)) { clip_delete_plane_track(C, clip, plane_track); changed = true; @@ -282,8 +282,8 @@ static int delete_marker_exec(bContext *C, wmOperator * /*op*/) } } - LISTBASE_FOREACH_MUTABLE ( - MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) { + LISTBASE_FOREACH_MUTABLE (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) + { if (PLANE_TRACK_VIEW_SELECTED(plane_track)) { MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get_exact(plane_track, framenr); @@ -462,7 +462,8 @@ static MovieTrackingTrack *tracking_marker_check_slide( const PointTrackPick track_pick = ed_tracking_pick_point_track(&options, C, co); if (ed_tracking_point_track_pick_empty(&track_pick) || - !ed_tracking_point_track_pick_can_slide(space_clip, &track_pick)) { + !ed_tracking_point_track_pick_can_slide(space_clip, &track_pick)) + { return nullptr; } @@ -1103,8 +1104,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op) } delta = pos == 1 ? 1 : -1; - while (sc->user.framenr + delta >= scene->r.sfra && - sc->user.framenr + delta <= scene->r.efra) { + while (sc->user.framenr + delta >= scene->r.sfra && sc->user.framenr + delta <= scene->r.efra) + { int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr + delta); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(active_track, framenr); @@ -2130,7 +2131,8 @@ static bool update_image_from_plane_marker_poll(bContext *C) MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); if (tracking_object->active_plane_track == nullptr || - tracking_object->active_plane_track->image == nullptr) { + tracking_object->active_plane_track->image == nullptr) + { return false; } diff --git a/source/blender/editors/space_clip/tracking_ops_plane.cc b/source/blender/editors/space_clip/tracking_ops_plane.cc index 2cacab4c81b..dcf70c4ff83 100644 --- a/source/blender/editors/space_clip/tracking_ops_plane.cc +++ b/source/blender/editors/space_clip/tracking_ops_plane.cc @@ -110,7 +110,8 @@ static MovieTrackingPlaneTrack *tracking_plane_marker_check_slide(bContext *C, const PlaneTrackPick track_pick = ed_tracking_pick_plane_track(&options, C, co); if (ed_tracking_plane_track_pick_empty(&track_pick) || - !ed_tracking_plane_track_pick_can_slide(&track_pick)) { + !ed_tracking_plane_track_pick_can_slide(&track_pick)) + { return nullptr; } diff --git a/source/blender/editors/space_clip/tracking_ops_solve.cc b/source/blender/editors/space_clip/tracking_ops_solve.cc index 8e1acbc3af5..64379b8cf7a 100644 --- a/source/blender/editors/space_clip/tracking_ops_solve.cc +++ b/source/blender/editors/space_clip/tracking_ops_solve.cc @@ -146,7 +146,8 @@ static void solve_camera_freejob(void *scv) /* Set blender camera focal length so result would look fine there. */ if (scene->camera != nullptr && scene->camera->data && - GS(((ID *)scene->camera->data)->name) == ID_CA) { + GS(((ID *)scene->camera->data)->name) == ID_CA) + { Camera *camera = (Camera *)scene->camera->data; int width, height; BKE_movieclip_get_size(clip, &scj->user, &width, &height); diff --git a/source/blender/editors/space_clip/tracking_select.cc b/source/blender/editors/space_clip/tracking_select.cc index 0484ddbec0f..19110034fa3 100644 --- a/source/blender/editors/space_clip/tracking_select.cc +++ b/source/blender/editors/space_clip/tracking_select.cc @@ -868,7 +868,8 @@ static int do_lasso_select_marker(bContext *C, if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside( - mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) { + mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) + { if (select) { BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); } @@ -897,7 +898,8 @@ static int do_lasso_select_marker(bContext *C, if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside( - mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) { + mcoords, mcoords_len, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) + { if (select) { plane_track->flag |= SELECT; } @@ -1030,7 +1032,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (ED_space_clip_marker_is_visible(sc, tracking_object, track, marker) && - marker_inside_ellipse(marker, offset, ellipse)) { + marker_inside_ellipse(marker, offset, ellipse)) + { if (select) { BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT); } diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index 052c6b22332..94189841747 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -718,7 +718,8 @@ bool file_set_asset_catalog_filter_settings( } if (filter_settings->asset_catalog_visibility == FILE_SHOW_ASSETS_FROM_CATALOG && - !BLI_uuid_equal(filter_settings->asset_catalog_id, catalog_id)) { + !BLI_uuid_equal(filter_settings->asset_catalog_id, catalog_id)) + { filter_settings->asset_catalog_id = catalog_id; needs_update = true; } diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index bf2c7e7cb39..1202959b125 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -217,7 +217,7 @@ static void file_draw_string(int sx, { uiFontStyle fs; rcti rect; - char fname[FILE_MAXFILE]; + char filename[FILE_MAXFILE]; if (string[0] == '\0' || width < 1) { return; @@ -226,8 +226,8 @@ static void file_draw_string(int sx, const uiStyle *style = UI_style_get(); fs = style->widget; - BLI_strncpy(fname, string, FILE_MAXFILE); - UI_text_clip_middle_ex(&fs, fname, width, UI_ICON_SIZE, sizeof(fname), '\0'); + BLI_strncpy(filename, string, FILE_MAXFILE); + UI_text_clip_middle_ex(&fs, filename, width, UI_ICON_SIZE, sizeof(filename), '\0'); /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict * (for buttons it works) */ @@ -239,7 +239,7 @@ static void file_draw_string(int sx, uiFontStyleDraw_Params font_style_params{}; font_style_params.align = align; - UI_fontstyle_draw(&fs, &rect, fname, sizeof(fname), col, &font_style_params); + UI_fontstyle_draw(&fs, &rect, filename, sizeof(filename), col, &font_style_params); } /** @@ -373,7 +373,8 @@ static void file_draw_preview(const FileDirEntry *file, ui_imby = imb->y * UI_SCALE_FAC; /* Unlike thumbnails, icons are not scaled up. */ if (((ui_imbx > layout->prv_w) || (ui_imby > layout->prv_h)) || - (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) { + (!is_icon && ((ui_imbx < layout->prv_w) || (ui_imby < layout->prv_h)))) + { if (imb->x > imb->y) { scaledx = float(layout->prv_w); scaledy = (float(imb->y) / float(imb->x)) * layout->prv_w; @@ -599,7 +600,7 @@ static void renamebutton_cb(bContext *C, void * /*arg1*/, char *oldname) BLI_path_join(orgname, sizeof(orgname), params->dir, oldname); BLI_strncpy(filename, params->renamefile, sizeof(filename)); - BLI_filename_make_safe(filename); + BLI_path_make_safe_filename(filename); BLI_path_join(newname, sizeof(newname), params->dir, filename); if (!STREQ(orgname, newname)) { @@ -826,7 +827,8 @@ static const char *filelist_get_details_column_string( break; case COLUMN_SIZE: if ((file->typeflag & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) || - !(file->typeflag & (FILE_TYPE_DIR | FILE_TYPE_BLENDERLIB))) { + !(file->typeflag & (FILE_TYPE_DIR | FILE_TYPE_BLENDERLIB))) + { if ((file->draw_data.size_str[0] == '\0') || update_stat_strings) { BLI_filelist_entry_size_to_string( nullptr, file->size, small_size, file->draw_data.size_str); @@ -1007,7 +1009,8 @@ void file_draw_list(const bContext *C, ARegion *region) if (!(file_selflag & FILE_SEL_EDITING)) { if ((params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) || - (file_selflag & FILE_SEL_SELECTED)) { + (file_selflag & FILE_SEL_SELECTED)) + { int colorid = (file_selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK; int shade = (params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0; @@ -1240,7 +1243,8 @@ bool file_draw_hint_if_invalid(const bContext *C, const SpaceFile *sfile, ARegio } /* Check if the library exists. */ if ((asset_params->asset_library_ref.type == ASSET_LIBRARY_LOCAL) || - filelist_is_dir(sfile->files, asset_params->base_params.dir)) { + filelist_is_dir(sfile->files, asset_params->base_params.dir)) + { return false; } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index baafd46ae32..cd7de03292e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -171,7 +171,8 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) /* make the selected file active */ if ((selected_idx >= 0) && (selected_idx < numfiles) && - (file = filelist_file(sfile->files, selected_idx))) { + (file = filelist_file(sfile->files, selected_idx))) + { params->highlight_file = selected_idx; params->active_file = selected_idx; @@ -314,7 +315,8 @@ static void file_ensure_selection_inside_viewbounds(ARegion *region, const FileLayout *layout = ED_fileselect_get_layout(sfile, region); if (((layout->flag & FILE_LAYOUT_HOR) && region->winx <= (1.2f * layout->tile_w)) && - ((layout->flag & FILE_LAYOUT_VER) && region->winy <= (2.0f * layout->tile_h))) { + ((layout->flag & FILE_LAYOUT_VER) && region->winy <= (2.0f * layout->tile_h))) + { return; } @@ -421,7 +423,8 @@ static int file_box_select_find_last_selected(SpaceFile *sfile, /* are first and last in the same column (horizontal layout)/row (vertical layout)? */ if ((layout->flag & FILE_LAYOUT_HOR && bounds_first.xmin == bounds_last.xmin) || - (layout->flag & FILE_LAYOUT_VER && bounds_first.ymin != bounds_last.ymin)) { + (layout->flag & FILE_LAYOUT_VER && bounds_first.ymin != bounds_last.ymin)) + { /* use vertical distance */ const int my_loc = (int)mouseco_view[1]; dist_first = BLI_rcti_length_y(&bounds_first, my_loc); @@ -731,7 +734,8 @@ static bool file_walk_select_selection_set(struct bContext *C, if (has_selection) { if (extend && filelist_entry_select_index_get(files, active_old, CHECK_ALL) && - filelist_entry_select_index_get(files, active_new, CHECK_ALL)) { + filelist_entry_select_index_get(files, active_new, CHECK_ALL)) + { /* conditions for deselecting: initial file is selected, new file is * selected and either other_side isn't selected/found or we use fill */ deselect = (fill || other_site == -1 || @@ -850,22 +854,26 @@ static bool file_walk_select_do(bContext *C, const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->flow_columns; if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_UP) || - (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_LEFT)) { + (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_LEFT)) + { active_new = active_old - 1; other_site = active_old + 1; } else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_DOWN) || - (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_RIGHT)) { + (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_RIGHT)) + { active_new = active_old + 1; other_site = active_old - 1; } else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_LEFT) || - (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_UP)) { + (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_UP)) + { active_new = active_old - idx_shift; other_site = active_old + idx_shift; } else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_RIGHT) || - (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_DOWN)) { + (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_DOWN)) + { active_new = active_old + idx_shift; other_site = active_old - idx_shift; @@ -1481,7 +1489,8 @@ static int file_column_sort_ui_context_invoke(bContext *C, SpaceFile *sfile = CTX_wm_space_file(C); if (file_attribute_column_header_is_inside( - ®ion->v2d, sfile->layout, event->mval[0], event->mval[1])) { + ®ion->v2d, sfile->layout, event->mval[0], event->mval[1])) + { FileSelectParams *params = ED_fileselect_get_active_params(sfile); const FileAttributeColumnType column_type = file_attribute_column_type_find_isect( ®ion->v2d, params, sfile->layout, event->mval[0]); @@ -1681,8 +1690,8 @@ void file_operator_to_sfile(Main *bmain, SpaceFile *sfile, wmOperator *op) if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { char filepath[FILE_MAX]; RNA_property_string_get(op->ptr, prop, filepath); - BLI_split_dirfile( - filepath, params->dir, params->file, sizeof(params->dir), sizeof(params->file)); + BLI_path_split_dir_file( + filepath, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } else { if ((prop = RNA_struct_find_property(op->ptr, "filename"))) { @@ -1710,11 +1719,11 @@ void file_sfile_filepath_set(SpaceFile *sfile, const char *filepath) } else { if ((params->flag & FILE_DIRSEL_ONLY) == 0) { - BLI_split_dirfile( - filepath, params->dir, params->file, sizeof(params->dir), sizeof(params->file)); + BLI_path_split_dir_file( + filepath, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } else { - BLI_split_dir_part(filepath, params->dir, sizeof(params->dir)); + BLI_path_split_dir_part(filepath, params->dir, sizeof(params->dir)); } } } @@ -1826,8 +1835,8 @@ static int file_external_operation_exec(bContext *C, wmOperator *op) PointerRNA op_props; WM_operator_properties_create_ptr(&op_props, ot); RNA_string_set(&op_props, "filepath", filepath); - if (WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_props, NULL) == - OPERATOR_FINISHED) { + if (WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_props, NULL) == OPERATOR_FINISHED) + { WM_cursor_set(CTX_wm_window(C), WM_CURSOR_DEFAULT); return OPERATOR_FINISHED; } @@ -2039,11 +2048,11 @@ static bool file_execute(bContext *C, SpaceFile *sfile) if (file && file->redirection_path) { /* redirection_path is an absolute path that takes precedence * over using params->dir + params->file. */ - BLI_split_dirfile(file->redirection_path, - params->dir, - params->file, - sizeof(params->dir), - sizeof(params->file)); + BLI_path_split_dir_file(file->redirection_path, + params->dir, + sizeof(params->dir), + params->file, + sizeof(params->file)); /* Update relpath with redirected filename as well so that the alternative * combination of params->dir + relpath remains valid as well. */ MEM_freeN(file->relpath); @@ -2140,7 +2149,8 @@ static int file_execute_mouse_invoke(bContext *C, wmOperator *UNUSED(op), const SpaceFile *sfile = CTX_wm_space_file(C); if (!ED_fileselect_layout_is_inside_pt( - sfile->layout, ®ion->v2d, event->mval[0], event->mval[1])) { + sfile->layout, ®ion->v2d, event->mval[0], event->mval[1])) + { return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } @@ -2353,7 +2363,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w * so we also have to handle switching to rename mode here. */ FileSelectParams *params = ED_fileselect_get_active_params(sfile); if ((params->rename_flag & - (FILE_PARAMS_RENAME_PENDING | FILE_PARAMS_RENAME_POSTSCROLL_PENDING)) != 0) { + (FILE_PARAMS_RENAME_PENDING | FILE_PARAMS_RENAME_POSTSCROLL_PENDING)) != 0) + { file_params_renamefile_activate(sfile, params); } @@ -2361,7 +2372,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w int edit_idx = -1; for (i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL) & - (FILE_SEL_EDITING | FILE_SEL_HIGHLIGHTED)) { + (FILE_SEL_EDITING | FILE_SEL_HIGHLIGHTED)) + { edit_idx = i; break; } @@ -2571,24 +2583,26 @@ void FILE_OT_filepath_drop(wmOperatorType *ot) * \{ */ /** - * Create a new, non-existing folder name, returns true if successful, + * Create a new, non-existing folder `dirname`, returns true if successful, * false if name couldn't be created. - * The actual name is returned in 'name', 'folder' contains the complete path, + * The actual name is returned in `r_dirpath`, `r_dirpath_full` contains the complete path, * including the new folder name. */ -static bool new_folder_path(const char *parent, char folder[FILE_MAX], char name[FILE_MAXFILE]) +static bool new_folder_path(const char *parent, + char r_dirpath_full[FILE_MAX], + char r_dirname[FILE_MAXFILE]) { int i = 1; int len = 0; - BLI_strncpy(name, "New Folder", FILE_MAXFILE); - BLI_path_join(folder, FILE_MAX, parent, name); - /* check whether folder with the name already exists, in this case + BLI_strncpy(r_dirname, "New Folder", FILE_MAXFILE); + BLI_path_join(r_dirpath_full, FILE_MAX, parent, r_dirname); + /* check whether r_dirpath_full with the name already exists, in this case * add number to the name. Check length of generated name to avoid * crazy case of huge number of folders each named 'New Folder (x)' */ - while (BLI_exists(folder) && (len < FILE_MAXFILE)) { - len = BLI_snprintf(name, FILE_MAXFILE, "New Folder(%d)", i); - BLI_path_join(folder, FILE_MAX, parent, name); + while (BLI_exists(r_dirpath_full) && (len < FILE_MAXFILE)) { + len = BLI_snprintf(r_dirname, FILE_MAXFILE, "New Folder(%d)", i); + BLI_path_join(r_dirpath_full, FILE_MAX, parent, r_dirname); i++; } @@ -2597,7 +2611,7 @@ static bool new_folder_path(const char *parent, char folder[FILE_MAX], char name static int file_directory_new_exec(bContext *C, wmOperator *op) { - char name[FILE_MAXFILE]; + char dirname[FILE_MAXFILE]; char path[FILE_MAX]; bool generate_name = true; @@ -2623,7 +2637,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) if (generate_name) { /* create a new, non-existing folder name */ - if (!new_folder_path(params->dir, path, name)) { + if (!new_folder_path(params->dir, path, dirname)) { BKE_report(op->reports, RPT_ERROR, "Could not create new folder name"); return OPERATOR_CANCELLED; } @@ -2646,7 +2660,8 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) if (!BLI_dir_create_recursive(path) || /* Should no more be needed, * now that BLI_dir_create_recursive returns a success state - but kept just in case. */ - !BLI_exists(path)) { + !BLI_exists(path)) + { BKE_reportf(op->reports, RPT_ERROR, "Could not create new folder: %s", @@ -2661,7 +2676,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) BLI_assert_msg(params->rename_id == NULL, "File rename handling should immediately clear rename_id when done, " "because otherwise it will keep taking precedence over renamefile."); - BLI_strncpy(params->renamefile, name, FILE_MAXFILE); + BLI_strncpy(params->renamefile, dirname, FILE_MAXFILE); rename_flag = FILE_PARAMS_RENAME_PENDING; } @@ -2792,8 +2807,8 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN if (BLI_is_file(params->dir)) { char path[sizeof(params->dir)]; BLI_strncpy(path, params->dir, sizeof(path)); - BLI_split_dirfile( - path, params->dir, params->file, sizeof(params->dir), sizeof(params->file)); + BLI_path_split_dir_file( + path, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } else if (BKE_blendfile_library_path_explode(params->dir, tdir, &group, &name)) { if (group) { @@ -2882,7 +2897,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg /* *After* file_select_match! */ const bool allow_tokens = (params->flag & FILE_PATH_TOKENS_ALLOW) != 0; - BLI_filename_make_safe_ex(params->file, allow_tokens); + BLI_path_make_safe_filename_ex(params->file, allow_tokens); if (matches) { /* replace the pattern (or filename that the user typed in, @@ -2966,16 +2981,17 @@ static bool file_filenum_poll(bContext *C) } /** - * Looks for a string of digits within name (using BLI_path_sequence_decode) and adjusts it by add. + * Looks for a string of digits within filename (using BLI_path_sequence_decode) and adjusts it by + * add. */ -static void filenum_newname(char *name, size_t name_size, int add) +static void filenum_newname(char *filename, size_t filename_size, int add) { char head[FILE_MAXFILE], tail[FILE_MAXFILE]; - char name_temp[FILE_MAXFILE]; + char filename_temp[FILE_MAXFILE]; int pic; ushort digits; - pic = BLI_path_sequence_decode(name, head, sizeof(head), tail, sizeof(tail), &digits); + pic = BLI_path_sequence_decode(filename, head, sizeof(head), tail, sizeof(tail), &digits); /* are we going from 100 -> 99 or from 10 -> 9 */ if (add < 0 && digits > 0) { @@ -2993,8 +3009,8 @@ static void filenum_newname(char *name, size_t name_size, int add) if (pic < 0) { pic = 0; } - BLI_path_sequence_encode(name_temp, sizeof(name_temp), head, tail, digits, pic); - BLI_strncpy(name, name_temp, name_size); + BLI_path_sequence_encode(filename_temp, sizeof(filename_temp), head, tail, digits, pic); + BLI_strncpy(filename, filename_temp, filename_size); } static int file_filenum_exec(bContext *C, wmOperator *op) @@ -3043,7 +3059,8 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ FileDirEntry *file = filelist_file(sfile->files, file_idx); if ((require_selected == false) || - (filelist_entry_select_get(sfile->files, file, CHECK_ALL) & FILE_SEL_SELECTED)) { + (filelist_entry_select_get(sfile->files, file, CHECK_ALL) & FILE_SEL_SELECTED)) + { FileSelectParams *params = ED_fileselect_get_active_params(sfile); filelist_entry_select_index_set( diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index c02442f3ad8..2f0b467afc8 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -680,7 +680,8 @@ static bool is_filtered_hidden(const char *filename, #endif /* For data-blocks (but not the group directories), check the asset-only filter. */ if (!(file->typeflag & FILE_TYPE_DIR) && (file->typeflag & FILE_TYPE_BLENDERLIB) && - (filter->flags & FLF_ASSETS_ONLY) && !(file->typeflag & FILE_TYPE_ASSET)) { + (filter->flags & FLF_ASSETS_ONLY) && !(file->typeflag & FILE_TYPE_ASSET)) + { return true; } @@ -836,8 +837,9 @@ static bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter) const AssetMetaData *asset_data = filelist_file_internal_get_asset_data(file); /* Not used yet for the asset view template. */ - if (filter->asset_catalog_filter && !file_is_asset_visible_in_catalog_filter_settings( - filter->asset_catalog_filter, asset_data)) { + if (filter->asset_catalog_filter && + !file_is_asset_visible_in_catalog_filter_settings(filter->asset_catalog_filter, asset_data)) + { return false; } @@ -1200,7 +1202,8 @@ static int filelist_geticon_ex(const FileList *filelist, const eFileSel_File_Types typeflag = (eFileSel_File_Types)file->typeflag; if ((typeflag & FILE_TYPE_DIR) && - !(ignore_libdir && (typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER)))) { + !(ignore_libdir && (typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER)))) + { if (FILENAME_IS_PARENT(file->relpath)) { return is_main ? ICON_FILE_PARENT : ICON_NONE; } @@ -1490,8 +1493,8 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat if (preview->flags & FILE_TYPE_IMAGE) { source = THB_SOURCE_IMAGE; } - else if (preview->flags & - (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB)) { + else if (preview->flags & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB)) + { source = THB_SOURCE_BLEND; } else if (preview->flags & FILE_TYPE_MOVIE) { @@ -1551,7 +1554,8 @@ static void filelist_cache_previews_clear(FileListEntryCache *cache) FileListEntryPreview *preview; while ((preview = static_cast( - BLI_thread_queue_pop_timeout(cache->previews_done, 0)))) { + BLI_thread_queue_pop_timeout(cache->previews_done, 0)))) + { // printf("%s: DONE %d - %s - %p\n", __func__, preview->index, preview->path, // preview->img); if (preview->icon_id) { @@ -1597,7 +1601,8 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry } if (!(entry->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT | - FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB))) { + FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB))) + { return; } @@ -2078,7 +2083,8 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in ret->asset = reinterpret_cast<::AssetRepresentation *>(entry->asset); /* For some file types the preview is already available. */ if (entry->local_data.preview_image && - BKE_previewimg_is_finished(entry->local_data.preview_image, ICON_SIZE_PREVIEW)) { + BKE_previewimg_is_finished(entry->local_data.preview_image, ICON_SIZE_PREVIEW)) + { ImBuf *ibuf = BKE_previewimg_to_imbuf(entry->local_data.preview_image, ICON_SIZE_PREVIEW); if (ibuf) { ret->preview_icon_id = BKE_icon_imbuf_create(ibuf); @@ -2114,7 +2120,8 @@ FileDirEntry *filelist_file_ex(FileList *filelist, const int index, const bool u } if ((ret = static_cast( - BLI_ghash_lookup(cache->misc_entries, POINTER_FROM_INT(index))))) { + BLI_ghash_lookup(cache->misc_entries, POINTER_FROM_INT(index))))) + { return ret; } @@ -2128,7 +2135,8 @@ FileDirEntry *filelist_file_ex(FileList *filelist, const int index, const bool u ret = filelist_file_create_entry(filelist, index); old_index = cache->misc_entries_indices[cache->misc_cursor]; if ((old = static_cast( - BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), nullptr)))) { + BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), nullptr)))) + { BLI_ghash_remove(cache->uids, POINTER_FROM_UINT(old->uid), nullptr, nullptr); filelist_file_release_entry(filelist, old); } @@ -2188,6 +2196,14 @@ int filelist_file_find_id(const FileList *filelist, const ID *id) return -1; } +ID *filelist_entry_get_id(const FileList *filelist, const int index) +{ + BLI_assert(index >= 0 && index < filelist->filelist.entries_filtered_num); + + const FileListInternEntry *intern_entry = filelist->filelist_intern.filtered[index]; + return intern_entry->local_data.id; +} + ID *filelist_file_get_id(const FileDirEntry *file) { return file->id; @@ -2246,7 +2262,8 @@ static bool filelist_file_cache_block_create(FileList *filelist, /* That entry might have already been requested and stored in misc cache... */ if ((entry = static_cast( - BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(idx), nullptr))) == nullptr) { + BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(idx), nullptr))) == nullptr) + { entry = filelist_file_create_entry(filelist, idx); BLI_ghash_insert(cache->uids, POINTER_FROM_UINT(entry->uid), entry); } @@ -2309,9 +2326,11 @@ bool filelist_file_cache_block(FileList *filelist, const int index) /* If we have something to (re)cache... */ if (full_refresh || (start_index != cache->block_start_index) || - (end_index != cache->block_end_index)) { + (end_index != cache->block_end_index)) + { if (full_refresh || (start_index >= cache->block_end_index) || - (end_index <= cache->block_start_index)) { + (end_index <= cache->block_start_index)) + { int size1 = cache->block_end_index - cache->block_start_index; int size2 = 0; int idx1 = cache->block_cursor, idx2 = 0; @@ -2637,7 +2656,8 @@ int ED_path_extension_type(const char *path) ".app", /* Safari in-progress/paused download */ ".download", - nullptr)) { + nullptr)) + { return FILE_TYPE_BUNDLE; } #endif @@ -2654,11 +2674,13 @@ int ED_path_extension_type(const char *path) ".mcr", ".inc", ".fountain", - nullptr)) { + nullptr)) + { return FILE_TYPE_TEXT; } if (BLI_path_extension_check_n( - path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", nullptr)) { + path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", nullptr)) + { return FILE_TYPE_FTFONT; } if (BLI_path_extension_check(path, ".btx")) { @@ -2679,17 +2701,9 @@ int ED_path_extension_type(const char *path) if (BLI_path_extension_check(path, ".zip")) { return FILE_TYPE_ARCHIVE; } - if (BLI_path_extension_check_n(path, - ".obj", - ".mtl", - ".3ds", - ".fbx", - ".glb", - ".gltf", - ".svg", - ".ply", - ".stl", - nullptr)) { + if (BLI_path_extension_check_n( + path, ".obj", ".mtl", ".3ds", ".fbx", ".glb", ".gltf", ".svg", ".ply", ".stl", nullptr)) + { return FILE_TYPE_OBJECT_IO; } if (BLI_path_extension_check_array(path, imb_ext_image)) { @@ -2767,7 +2781,8 @@ uint filelist_entry_select_set(const FileList *filelist, BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL)); if ((check == CHECK_ALL) || ((check == CHECK_DIRS) && (entry->typeflag & FILE_TYPE_DIR)) || - ((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) { + ((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) + { switch (select) { case FILE_SEL_REMOVE: entry_flag &= ~flag; @@ -2821,7 +2836,8 @@ void filelist_entries_select_index_range_set(FileList *filelist, { /* select all valid files between first and last indicated */ if ((sel->first >= 0) && (sel->first < filelist->filelist.entries_filtered_num) && - (sel->last >= 0) && (sel->last < filelist->filelist.entries_filtered_num)) { + (sel->last >= 0) && (sel->last < filelist->filelist.entries_filtered_num)) + { int current_file; for (current_file = sel->first; current_file <= sel->last; current_file++) { filelist_entry_select_index_set(filelist, current_file, select, flag, check); @@ -2837,7 +2853,8 @@ eDirEntry_SelectFlag filelist_entry_select_get(FileList *filelist, BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL)); if ((check == CHECK_ALL) || ((check == CHECK_DIRS) && (entry->typeflag & FILE_TYPE_DIR)) || - ((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) { + ((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) + { /* Default nullptr pointer if not found is fine here! */ return eDirEntry_SelectFlag(POINTER_AS_UINT( BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(entry->uid)))); @@ -3014,7 +3031,8 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params, #ifdef __APPLE__ && !(ED_path_extension_type(full_path) & FILE_TYPE_BUNDLE) #endif - ) { + ) + { entry->typeflag = FILE_TYPE_DIR; } @@ -3545,7 +3563,8 @@ static bool filelist_readjob_should_recurse_into_entry(const int max_recursion, /* Show entries when recursion is set to `Blend file` even when `current_recursion_level` * exceeds `max_recursion`. */ if (!is_lib && (current_recursion_level >= max_recursion) && - ((entry->typeflag & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) == 0)) { + ((entry->typeflag & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) == 0)) + { return false; } if (entry->typeflag & FILE_TYPE_BLENDERLIB) { diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index f42496aa99c..80c2e25bafe 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -130,6 +130,10 @@ int filelist_file_find_id(const struct FileList *filelist, const struct ID *id); * Get the ID a file represents (if any). For #FILE_MAIN, #FILE_MAIN_ASSET. */ struct ID *filelist_file_get_id(const struct FileDirEntry *file); +/** + * Same as #filelist_file_get_id(), but gets the file by index (doesn't require the file to be + * cached, uses #FileListInternEntry only). */ +struct ID *filelist_entry_get_id(const struct FileList *filelist, int index); bool filelist_uid_is_set(const FileUID uid); void filelist_uid_unset(FileUID *r_uid); void filelist_file_cache_slidingwindow_set(struct FileList *filelist, size_t window_size); diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index dd7ce444e64..d9feb3e7267 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -77,7 +77,7 @@ static void fileselect_initialize_params_common(SpaceFile *sfile, FileSelectPara if (!params->dir[0]) { if (blendfile_path[0] != '\0') { - BLI_split_dir_part(blendfile_path, params->dir, sizeof(params->dir)); + BLI_path_split_dir_part(blendfile_path, params->dir, sizeof(params->dir)); } else { const char *doc_path = BKE_appdir_folder_default(); @@ -147,11 +147,11 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) sfile->params = static_cast( MEM_callocN(sizeof(FileSelectParams), "fileselparams")); /* set path to most recently opened .blend */ - BLI_split_dirfile(blendfile_path, - sfile->params->dir, - sfile->params->file, - sizeof(sfile->params->dir), - sizeof(sfile->params->file)); + BLI_path_split_dir_file(blendfile_path, + sfile->params->dir, + sizeof(sfile->params->dir), + sfile->params->file, + sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; sfile->params->thumbnail_size = U_default.file_space_data.thumbnail_size; sfile->params->details_flags = U_default.file_space_data.details_flags; @@ -180,15 +180,15 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) } if (is_filepath && RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { - char name[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", name); + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); if (params->type == FILE_LOADLIB) { - BLI_strncpy(params->dir, name, sizeof(params->dir)); + BLI_strncpy(params->dir, filepath, sizeof(params->dir)); params->file[0] = '\0'; } else { - BLI_split_dirfile( - name, params->dir, params->file, sizeof(params->dir), sizeof(params->file)); + BLI_path_split_dir_file( + filepath, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } } else { @@ -208,8 +208,8 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) } params->flag = 0; - if (is_directory == true && is_filename == false && is_filepath == false && - is_files == false) { + if (is_directory == true && is_filename == false && is_filepath == false && is_files == false) + { params->flag |= FILE_DIRSEL_ONLY; } if ((prop = RNA_struct_find_property(op->ptr, "check_existing"))) { @@ -783,7 +783,8 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r rowmax = (rect->ymax - layout->offset_top) / (layout->tile_h + 2 * layout->tile_border_y); if (is_inside(colmin, rowmin, layout->flow_columns, layout->rows) || - is_inside(colmax, rowmax, layout->flow_columns, layout->rows)) { + is_inside(colmax, rowmax, layout->flow_columns, layout->rows)) + { CLAMP(colmin, 0, layout->flow_columns - 1); CLAMP(rowmin, 0, layout->rows - 1); CLAMP(colmax, 0, layout->flow_columns - 1); @@ -931,7 +932,8 @@ FileAttributeColumnType file_attribute_column_type_find_isect(const View2D *v2d, for (FileAttributeColumnType column = FileAttributeColumnType(0); column < ATTRIBUTE_COLUMN_MAX; - column = FileAttributeColumnType(int(column) + 1)) { + column = FileAttributeColumnType(int(column) + 1)) + { if (!file_attribute_column_type_enabled(params, column)) { continue; } @@ -995,9 +997,10 @@ static void file_attribute_columns_widths(const FileSelectParams *params, FileLa for (FileAttributeColumnType column_type = FileAttributeColumnType(int(ATTRIBUTE_COLUMN_MAX) - 1); column_type >= 0; - column_type = FileAttributeColumnType(int(column_type) - 1)) { - if ((column_type == COLUMN_NAME) || - !file_attribute_column_type_enabled(params, column_type)) { + column_type = FileAttributeColumnType(int(column_type) - 1)) + { + if ((column_type == COLUMN_NAME) || !file_attribute_column_type_enabled(params, column_type)) + { continue; } remwidth -= columns[column_type].width; @@ -1218,7 +1221,7 @@ int autocomplete_directory(struct bContext *C, char *str, void * /*arg_v*/) DIR *dir; struct dirent *de; - BLI_split_dir_part(str, dirname, sizeof(dirname)); + BLI_path_split_dir_part(str, dirname, sizeof(dirname)); dir = opendir(dirname); @@ -1377,7 +1380,8 @@ void file_params_renamefile_activate(SpaceFile *sfile, FileSelectParams *params) BLI_assert(params->rename_flag != 0); if ((params->rename_flag & (FILE_PARAMS_RENAME_ACTIVE | FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE)) != - 0) { + 0) + { return; } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 41b78ff3562..823777b66ed 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -233,7 +233,8 @@ FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, FSMenuEntry *fsm_iter; for (fsm_iter = ED_fsmenu_get_category(fsmenu, category); fsm_iter && idx; - fsm_iter = fsm_iter->next) { + fsm_iter = fsm_iter->next) + { idx--; } @@ -356,7 +357,8 @@ short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int idx) FSMenuEntry *fsm_iter; for (fsm_iter = ED_fsmenu_get_category(fsmenu, category); fsm_iter && idx; - fsm_iter = fsm_iter->next) { + fsm_iter = fsm_iter->next) + { idx--; } @@ -533,7 +535,8 @@ bool fsmenu_write_file(struct FSMenu *fsmenu, const char *filepath) bool has_error = false; has_error |= (fprintf(fp, "[Bookmarks]\n") < 0); for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter; - fsm_iter = fsm_iter->next) { + fsm_iter = fsm_iter->next) + { if (fsm_iter->path && fsm_iter->save) { fsmenu_entry_generate_name(fsm_iter, fsm_name, sizeof(fsm_name)); if (fsm_iter->name[0] && !STREQ(fsm_iter->name, fsm_name)) { @@ -545,7 +548,8 @@ bool fsmenu_write_file(struct FSMenu *fsmenu, const char *filepath) has_error = (fprintf(fp, "[Recent]\n") < 0); for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); - fsm_iter = fsm_iter->next, nwritten++) { + fsm_iter = fsm_iter->next, nwritten++) + { if (fsm_iter->path && fsm_iter->save) { fsmenu_entry_generate_name(fsm_iter, fsm_name, sizeof(fsm_name)); if (fsm_iter->name[0] && !STREQ(fsm_iter->name, fsm_name)) { @@ -825,11 +829,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); /* Get name of the volume. */ - char name[FILE_MAXFILE] = ""; + char display_name[FILE_MAXFILE] = ""; CFStringRef nameString = NULL; CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeLocalizedNameKey, &nameString, NULL); if (nameString != NULL) { - CFStringGetCString(nameString, name, sizeof(name), kCFStringEncodingUTF8); + CFStringGetCString(nameString, display_name, sizeof(display_name), kCFStringEncodingUTF8); CFRelease(nameString); } @@ -854,8 +858,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFRelease(localKey); } - fsmenu_insert_entry( - fsmenu, FS_CATEGORY_SYSTEM, defPath, name[0] ? name : NULL, icon, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, + FS_CATEGORY_SYSTEM, + defPath, + display_name[0] ? display_name : NULL, + icon, + FS_INSERT_SORTED); } CFRelease(volEnum); @@ -889,7 +897,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); if (pathString == NULL || - !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) { + !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) + { continue; } @@ -982,9 +991,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *const xdg_runtime_dir = BLI_getenv("XDG_RUNTIME_DIR"); if (xdg_runtime_dir != NULL) { struct direntry *dirs; - char name[FILE_MAX]; - BLI_path_join(name, sizeof(name), xdg_runtime_dir, "gvfs/"); - const uint dirs_num = BLI_filelist_dir_contents(name, &dirs); + char filepath[FILE_MAX]; + BLI_path_join(filepath, sizeof(filepath), xdg_runtime_dir, "gvfs/"); + const uint dirs_num = BLI_filelist_dir_contents(filepath, &dirs); for (uint i = 0; i < dirs_num; i++) { if (dirs[i].type & S_IFDIR) { const char *dirname = dirs[i].relname; @@ -998,7 +1007,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *label_test = label + 6; label = *label_test ? label_test : dirname; } - BLI_snprintf(line, sizeof(line), "%s%s", name, dirname); + BLI_snprintf(line, sizeof(line), "%s%s", filepath, dirname); fsmenu_insert_entry( fsmenu, FS_CATEGORY_SYSTEM, line, label, ICON_NETWORK_DRIVE, FS_INSERT_SORTED); found = 1; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 4f606387bc0..29f6adbfbb5 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -204,7 +204,8 @@ static void file_refresh(const bContext *C, ScrArea *area) folder_history_list_ensure_for_active_browse_mode(sfile); if (sfile->files && (sfile->tags & FILE_TAG_REBUILD_MAIN_FILES) && - filelist_needs_reset_on_main_changes(sfile->files)) { + filelist_needs_reset_on_main_changes(sfile->files)) + { filelist_tag_force_reset_mainfiles(sfile->files); } sfile->tags &= ~FILE_TAG_REBUILD_MAIN_FILES; @@ -508,7 +509,8 @@ static bool file_main_region_needs_refresh_before_draw(SpaceFile *sfile) /* File reading tagged the space because main data changed that may require a filelist reset. */ if (filelist_needs_reset_on_main_changes(sfile->files) && - (sfile->tags & FILE_TAG_REBUILD_MAIN_FILES)) { + (sfile->tags & FILE_TAG_REBUILD_MAIN_FILES)) + { return true; } @@ -823,6 +825,7 @@ const char *file_context_dir[] = { "asset_library_ref", "selected_asset_files", "id", + "selected_ids", NULL, }; @@ -911,6 +914,24 @@ static int /*eContextResult*/ file_context(const bContext *C, CTX_data_id_pointer_set(result, id); return CTX_RESULT_OK; } + if (CTX_data_equals(member, "selected_ids")) { + const int num_files_filtered = filelist_files_ensure(sfile->files); + + for (int file_index = 0; file_index < num_files_filtered; file_index++) { + if (!filelist_entry_is_selected(sfile->files, file_index)) { + continue; + } + ID *id = filelist_entry_get_id(sfile->files, file_index); + if (!id) { + continue; + } + + CTX_data_id_list_add(result, id); + } + + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); + return CTX_RESULT_OK; + } return CTX_RESULT_MEMBER_NOT_FOUND; } @@ -1098,8 +1119,8 @@ void ED_file_read_bookmarks(void) fsmenu_read_system(ED_fsmenu_get(), true); if (cfgdir) { - char name[FILE_MAX]; - BLI_path_join(name, sizeof(name), cfgdir, BLENDER_BOOKMARK_FILE); - fsmenu_read_bookmarks(ED_fsmenu_get(), name); + char filepath[FILE_MAX]; + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_BOOKMARK_FILE); + fsmenu_read_bookmarks(ED_fsmenu_get(), filepath); } } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 3ebebceb9e8..48e9d13853f 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -895,7 +895,8 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ, - DTAR_TRANSCHAN_ROTW)) { + DTAR_TRANSCHAN_ROTW)) + { uiItemR(sub, &dtar_ptr, "rotation_mode", 0, IFACE_("Mode"), ICON_NONE); } @@ -1256,7 +1257,8 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ, DTAR_TRANSCHAN_ROTW) && - dvar->targets[0].rotation_mode != DTAR_ROTMODE_QUATERNION)) { + dvar->targets[0].rotation_mode != DTAR_ROTMODE_QUATERNION)) + { BLI_snprintf( valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval)); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 791f08e66d7..4d099fb1c61 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -273,14 +273,16 @@ static void draw_fcurve_selected_handle_vertices( if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { if ((bezt->f1 & SELECT) == sel - /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax) */) { + /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax) */) + { immVertex2fv(pos, bezt->vec[0]); } } if (bezt->ipo == BEZT_IPO_BEZ) { if ((bezt->f3 & SELECT) == sel - /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax) */) { + /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax) */) + { immVertex2fv(pos, bezt->vec[2]); } } @@ -389,7 +391,8 @@ static bool draw_fcurve_handles_check(SpaceGraph *sipo, FCurve *fcu) (fcu->flag & FCURVE_INT_VALUES) || #endif /* group that curve belongs to is not editable */ - ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))) { + ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED))) + { return false; } return true; @@ -457,7 +460,8 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu) else { /* only draw first handle if previous segment was had handles, and selection is ok */ if (((bezt->f1 & SELECT) == sel) && ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || - (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))) { + (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)))) + { UI_GetThemeColor3ubv(basecol + bezt->h1, col); col[3] = fcurve_display_alpha(fcu) * 255; immAttr4ubv(color, col); @@ -739,7 +743,8 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || - (fcu->totvert == 1)) { + (fcu->totvert == 1)) + { /* just extend across the first keyframe's value */ v[1] = prevfpt->vec[1]; } @@ -773,7 +778,8 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || - (fcu->totvert == 1)) { + (fcu->totvert == 1)) + { /* based on last keyframe's value */ v[1] = prevfpt->vec[1]; } @@ -848,7 +854,8 @@ static void draw_fcurve_curve_bezts( /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || - (prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) { + (prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) + { /* just extend across the first keyframe's value */ v1[1] = prevbezt->vec[1][1]; } @@ -967,8 +974,8 @@ static void draw_fcurve_curve_bezts( /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || - (prevbezt->ipo == BEZT_IPO_CONST) || - (prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) { + (prevbezt->ipo == BEZT_IPO_CONST) || (prevbezt->ipo == BEZT_IPO_LIN && fcu->totvert == 1)) + { /* based on last keyframe's value */ v1[1] = prevbezt->vec[1][1]; } @@ -1018,7 +1025,8 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn /* 1) draw curve line */ if (((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) || - (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert))) { + (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert))) + { /* set color/drawing style for curve itself */ /* draw active F-Curve thicker than the rest to make it stand out */ if (fcu->flag & FCURVE_ACTIVE) { diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index df3b572442d..19f6d6bf807 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -115,7 +115,8 @@ static void nearest_fcurve_vert_store(ListBase *matches, &screen_co[0], &screen_co[1]) && /* check if distance from mouse cursor to vert in screen space is within tolerance */ - ((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL)) { + ((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL)) + { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; bool replace = false; @@ -172,9 +173,8 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY); - if (U.animation_flag & - USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) { /* FIXME: this should really be check for by the - * filtering code. */ + /* FIXME: this should really be check for by the filtering code. */ + if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) { filter |= ANIMFILTER_SEL; } mapping_flag |= ANIM_get_normalization_flags(ac); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index f5d26e1fd17..87ae62f3033 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -679,7 +679,7 @@ void GRAPH_OT_blend_to_neighbor(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* Flags. */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X; RNA_def_float_factor(ot->srna, "factor", @@ -764,7 +764,7 @@ void GRAPH_OT_breakdown(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* Flags. */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X; RNA_def_float_factor(ot->srna, "factor", @@ -869,7 +869,7 @@ void GRAPH_OT_blend_to_default(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* Flags. */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X; RNA_def_float_factor(ot->srna, "factor", @@ -954,7 +954,7 @@ void GRAPH_OT_ease(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* Flags. */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X; RNA_def_float_factor(ot->srna, "factor", diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 5678b4c89fe..2805b87f169 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -617,7 +617,8 @@ static void graph_listener(const wmSpaceTypeListenerParams *params) break; case NC_WINDOW: if (sipo->runtime.flag & - (SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC | SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR)) { + (SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC | SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR)) + { /* force redraw/refresh after undo/redo - prevents "black curve" problem */ ED_area_tag_refresh(area); } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index db795b254e1..0fe4b13ebef 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -654,7 +654,8 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, /* view */ if (BLI_listbase_count_at_most(&rr->views, 2) > 1 && - ((!show_stereo) || !RE_RenderResult_is_stereo(rr))) { + ((!show_stereo) || !RE_RenderResult_is_stereo(rr))) + { rview = BLI_findlink(&rr->views, iuser->view); display_name = rview ? rview->name : ""; @@ -676,7 +677,8 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, /* stereo image */ else if ((BKE_image_is_stereo(image) && (!show_stereo)) || - (BKE_image_is_multiview(image) && !BKE_image_is_stereo(image))) { + (BKE_image_is_multiview(image) && !BKE_image_is_stereo(image))) + { ImageView *iv; int nr = 0; @@ -994,7 +996,8 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_ma R_IMF_CHAN_DEPTH_12, R_IMF_CHAN_DEPTH_16, R_IMF_CHAN_DEPTH_24, - R_IMF_CHAN_DEPTH_32) == 0) { + R_IMF_CHAN_DEPTH_32) == 0) + { uiItemR(uiLayoutRow(col, true), imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1250,8 +1253,8 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i } else if (ima->source == IMA_SRC_SEQUENCE && ibuf) { /* Image sequence frame number + filename */ - const char *filename = BLI_path_slash_rfind(ibuf->name); - filename = (filename == NULL) ? ibuf->name : filename + 1; + const char *filename = BLI_path_slash_rfind(ibuf->filepath); + filename = (filename == NULL) ? ibuf->filepath : filename + 1; BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d: %s"), framenr, filename); } else { diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 3d4f9fab69d..8f702a0049c 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -82,7 +82,8 @@ void ED_space_image_sync(struct Main *bmain, struct Image *image, bool ignore_re continue; } if (ignore_render_viewer && sima->image && - ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) + { continue; } ED_space_image_set(bmain, sima, image, true); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index e1d2e317c07..e38d5073f22 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2174,7 +2174,8 @@ static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* Not writable formats or images without a file-path will go to "Save As". */ if (!BKE_image_has_packedfile(ima) && - (!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser))) { + (!BKE_image_has_filepath(ima) || !image_file_format_writable(ima, iuser))) + { WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL, event); return OPERATOR_CANCELLED; } @@ -2249,7 +2250,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) } /* get a filename for menu */ - BLI_split_dir_part(first_ibuf->name, di, sizeof(di)); + BLI_path_split_dir_part(first_ibuf->filepath, di, sizeof(di)); BKE_reportf(op->reports, RPT_INFO, "%d image(s) will be saved in %s", tot, di); iter = IMB_moviecacheIter_new(image->cache); @@ -2257,17 +2258,17 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) ibuf = IMB_moviecacheIter_getImBuf(iter); if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) { - char name[FILE_MAX]; - BLI_strncpy(name, ibuf->name, sizeof(name)); + char filepath[FILE_MAX]; + BLI_strncpy(filepath, ibuf->filepath, sizeof(filepath)); - BLI_path_abs(name, BKE_main_blendfile_path(bmain)); + BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); - if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { + if (0 == IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat)) { BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); break; } - BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name); + BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->filepath); ibuf->userflags &= ~IB_BITMAPDIRTY; } @@ -2307,7 +2308,8 @@ static bool image_should_be_saved_when_modified(Image *ima) static bool image_should_be_saved(Image *ima, bool *is_format_writable) { if (BKE_image_is_dirty_writable(ima, is_format_writable) && - ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED, IMA_SRC_TILED)) { + ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED, IMA_SRC_TILED)) + { return image_should_be_saved_when_modified(ima); } return false; @@ -3901,7 +3903,8 @@ static int render_border_exec(bContext *C, wmOperator *op) /* Drawing a border surrounding the entire camera view switches off border rendering * or the border covers no pixels. */ if ((border.xmin <= 0.0f && border.xmax >= 1.0f && border.ymin <= 0.0f && border.ymax >= 1.0f) || - (border.xmin == border.xmax || border.ymin == border.ymax)) { + (border.xmin == border.xmax || border.ymin == border.ymax)) + { scene->r.mode &= ~R_BORDER; } else { diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c index a7976eeecbe..5bf71c6a4cc 100644 --- a/source/blender/editors/space_image/image_sequence.c +++ b/source/blender/editors/space_image/image_sequence.c @@ -60,7 +60,8 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges) /* still in the same sequence */ if (do_frame_range && (range != NULL) && STREQLEN(base_head, head, FILE_MAX) && - STREQLEN(base_tail, tail, FILE_MAX)) { + STREQLEN(base_tail, tail, FILE_MAX)) + { /* Set filepath to first frame in the range. */ if (frame->framenr < range_first_frame) { BLI_path_join(range->filepath, sizeof(range->filepath), dir, filename); @@ -149,7 +150,8 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo /* File browser. */ if (RNA_struct_property_is_set(op->ptr, "directory") && - RNA_struct_property_is_set(op->ptr, "files")) { + RNA_struct_property_is_set(op->ptr, "files")) + { const bool was_relative = BLI_path_is_rel(filepath); image_sequence_get_frame_ranges(op, &ranges); diff --git a/source/blender/editors/space_image/image_undo.cc b/source/blender/editors/space_image/image_undo.cc index db78ef857dc..90cb5695602 100644 --- a/source/blender/editors/space_image/image_undo.cc +++ b/source/blender/editors/space_image/image_undo.cc @@ -440,7 +440,7 @@ struct UndoImageBuf { */ struct UndoImageBuf *post; - char ibuf_name[IMB_FILENAME_SIZE]; + char ibuf_filepath[IMB_FILEPATH_SIZE]; UndoImageTile **tiles; @@ -471,7 +471,7 @@ static UndoImageBuf *ubuf_from_image_no_tiles(Image *image, const ImBuf *ibuf) ubuf->tiles = static_cast( MEM_callocN(sizeof(*ubuf->tiles) * ubuf->tiles_len, __func__)); - BLI_strncpy(ubuf->ibuf_name, ibuf->name, sizeof(ubuf->ibuf_name)); + BLI_strncpy(ubuf->ibuf_filepath, ibuf->filepath, sizeof(ubuf->ibuf_filepath)); ubuf->image_state.source = image->source; ubuf->image_state.use_float = ibuf->rect_float != nullptr; @@ -514,7 +514,8 @@ static void ubuf_ensure_compat_ibuf(const UndoImageBuf *ubuf, ImBuf *ibuf) } if (ibuf->x == ubuf->image_dims[0] && ibuf->y == ubuf->image_dims[1] && - (ubuf->image_state.use_float ? (void *)ibuf->rect_float : (void *)ibuf->rect)) { + (ubuf->image_state.use_float ? (void *)ibuf->rect_float : (void *)ibuf->rect)) + { return; } @@ -638,10 +639,10 @@ static void uhandle_free_list(ListBase *undo_handles) static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh, const Image * /*image*/, - const char *ibuf_name) + const char *ibuf_filepath) { LISTBASE_FOREACH (UndoImageBuf *, ubuf, &uh->buffers) { - if (STREQ(ubuf->ibuf_name, ibuf_name)) { + if (STREQ(ubuf->ibuf_filepath, ibuf_filepath)) { return ubuf; } } @@ -650,7 +651,7 @@ static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh, static UndoImageBuf *uhandle_add_ubuf(UndoImageHandle *uh, Image *image, ImBuf *ibuf) { - BLI_assert(uhandle_lookup_ubuf(uh, image, ibuf->name) == nullptr); + BLI_assert(uhandle_lookup_ubuf(uh, image, ibuf->filepath) == nullptr); UndoImageBuf *ubuf = ubuf_from_image_no_tiles(image, ibuf); BLI_addtail(&uh->buffers, ubuf); @@ -661,7 +662,7 @@ static UndoImageBuf *uhandle_add_ubuf(UndoImageHandle *uh, Image *image, ImBuf * static UndoImageBuf *uhandle_ensure_ubuf(UndoImageHandle *uh, Image *image, ImBuf *ibuf) { - UndoImageBuf *ubuf = uhandle_lookup_ubuf(uh, image, ibuf->name); + UndoImageBuf *ubuf = uhandle_lookup_ubuf(uh, image, ibuf->filepath); if (ubuf == nullptr) { ubuf = uhandle_add_ubuf(uh, image, ibuf); } @@ -744,11 +745,12 @@ static UndoImageBuf *ubuf_lookup_from_reference(ImageUndoStep *us_prev, /* Use name lookup because the pointer is cleared for previous steps. */ UndoImageHandle *uh_prev = uhandle_lookup_by_name(&us_prev->handles, image, tile_number); if (uh_prev != nullptr) { - UndoImageBuf *ubuf_reference = uhandle_lookup_ubuf(uh_prev, image, ubuf->ibuf_name); + UndoImageBuf *ubuf_reference = uhandle_lookup_ubuf(uh_prev, image, ubuf->ibuf_filepath); if (ubuf_reference) { ubuf_reference = ubuf_reference->post; if ((ubuf_reference->image_dims[0] == ubuf->image_dims[0]) && - (ubuf_reference->image_dims[1] == ubuf->image_dims[1])) { + (ubuf_reference->image_dims[1] == ubuf->image_dims[1])) + { return ubuf_reference; } } @@ -837,7 +839,8 @@ static bool image_undosys_step_encode(struct bContext *C, struct Main * /*bmain* UndoImageBuf *ubuf_post = ubuf_pre->post; if (ubuf_pre->image_dims[0] != ubuf_post->image_dims[0] || - ubuf_pre->image_dims[1] != ubuf_post->image_dims[1]) { + ubuf_pre->image_dims[1] != ubuf_post->image_dims[1]) + { ubuf_from_image_all_tiles(ubuf_post, ibuf); } else { @@ -857,7 +860,8 @@ static bool image_undosys_step_encode(struct bContext *C, struct Main * /*bmain* ((ubuf_pre->tiles[i] == nullptr) || /* In this case the paint stroke as has added a tile * which we have a duplicate reference available. */ - (ubuf_pre->tiles[i]->users == 1))) { + (ubuf_pre->tiles[i]->users == 1))) + { if (ubuf_pre->tiles[i] != nullptr) { /* If we have a reference, re-use this single use tile for the post state. */ BLI_assert(ubuf_pre->tiles[i]->users == 1); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 43c57227b2f..f62149523ad 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -574,9 +574,9 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co /* escape if not our timer */ if ((reports->reporttimer == NULL) || (reports->reporttimer != event->customdata) || - ((report = BKE_reports_last_displayable(reports)) == NULL) - /* may have been deleted */ - ) { + ((report = BKE_reports_last_displayable(reports)) == NULL)) + { + /* May have been deleted. */ return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 56e98aa7625..f62af1191f3 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -231,7 +231,8 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) /* if this is a connected child and its parent is being moved, remove our root */ if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && ebo->parent && - (ebo->parent->flag & BONE_TIPSEL)) { + (ebo->parent->flag & BONE_TIPSEL)) + { stats->totvertsel--; } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index d49cd4af6a8..47b51657831 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -488,7 +488,8 @@ static void nla_draw_strip(SpaceNla *snla, /* draw 'inside' of strip itself */ if (solo && is_nlastrip_enabled(adt, nlt, strip) && - !(strip->flag & NLASTRIP_FLAG_INVALID_LOCATION)) { + !(strip->flag & NLASTRIP_FLAG_INVALID_LOCATION)) + { immUnbindProgram(); /* strip is in normal track */ @@ -761,14 +762,16 @@ static ListBase get_visible_nla_strips(NlaTrack *nlt, View2D *v2d) NlaStrip *first_strip = nlt->strips.first; NlaStrip *last_strip = nlt->strips.last; if (first_strip && v2d->cur.xmax < first_strip->start && - first_strip->extendmode == NLASTRIP_EXTEND_HOLD) { + first_strip->extendmode == NLASTRIP_EXTEND_HOLD) + { /* The view is to the left of all strips and the first strip has an * extendmode that should be drawn. */ first = last = first_strip; } else if (last_strip && v2d->cur.xmin > last_strip->end && - last_strip->extendmode != NLASTRIP_EXTEND_NOTHING) { + last_strip->extendmode != NLASTRIP_EXTEND_NOTHING) + { /* The view is to the right of all strips and the last strip has an * extendmode that should be drawn. */ diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index aa8f079bc5a..230e1b94ef9 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -450,7 +450,8 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *r_min, fl /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && - ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { + ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) + { /* update best estimate */ *r_min = ymax - NLACHANNEL_HEIGHT(snla); *r_max = ymax; @@ -1634,7 +1635,8 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) NlaStrip *mstrip = (NlaStrip *)nlt->strips.first; if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) && - (BLI_listbase_count_at_most(&mstrip->strips, 3) == 2)) { + (BLI_listbase_count_at_most(&mstrip->strips, 3) == 2)) + { /* remove this temp meta, so that we can see the strips inside */ BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } @@ -1701,7 +1703,8 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) /* check if the track has room for the strips to be swapped */ if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && - BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) { + BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) + { /* set new extents for strips then */ area->start = nsa[0]; area->end = nsa[1]; @@ -1809,7 +1812,8 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) } if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt) || - BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nltn)) { + BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nltn)) + { /* No moving of strips in non-local tracks of override data. */ continue; } @@ -1901,7 +1905,8 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) } if (BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nlt) || - BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nltp)) { + BKE_nlatrack_is_nonlocal_in_liboverride(ale->id, nltp)) + { /* No moving of strips in non-local tracks of override data. */ continue; } diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index a0bab859025..68f2f988bcb 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -212,8 +212,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) for (NodeClipboardItem &item : clipboard.nodes) { const bNode &node = *item.node; const char *disabled_hint = nullptr; - if (node.typeinfo->poll_instance && - node.typeinfo->poll_instance(&node, &tree, &disabled_hint)) { + if (node.typeinfo->poll_instance && node.typeinfo->poll_instance(&node, &tree, &disabled_hint)) + { bNode *new_node = bke::node_copy_with_mapping( &tree, node, LIB_ID_COPY_DEFAULT, true, socket_map); node_map.add_new(&node, new_node); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 4eb1dffd880..7c8de13ca69 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -345,7 +345,8 @@ static void node_buts_image_user(uiLayout *layout, } if (show_layer_selection && RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER && - RNA_boolean_get(ptr, "has_layers")) { + RNA_boolean_get(ptr, "has_layers")) + { col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "layer", DEFAULT_FLAGS, nullptr, ICON_NONE); } @@ -1564,7 +1565,8 @@ void draw_nodespace_back_pix(const bContext &C, } if ((snode.nodetree->flag & NTREE_VIEWER_BORDER) && - viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax) { + viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax) + { rcti pixel_border; BLI_rcti_init(&pixel_border, x + snode.zoom * viewer_border->xmin * ibuf->x, @@ -2057,7 +2059,8 @@ static NodeLinkDrawConfig nodelink_get_draw_config(const bContext &C, UI_GetThemeColor4fv(th_col3, draw_config.outline_color); if (snode.overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && - snode.overlay.flag & SN_OVERLAY_SHOW_WIRE_COLORS) { + snode.overlay.flag & SN_OVERLAY_SHOW_WIRE_COLORS) + { PointerRNA from_node_ptr, to_node_ptr; RNA_pointer_create((ID *)&node_tree, &RNA_Node, link.fromnode, &from_node_ptr); RNA_pointer_create((ID *)&node_tree, &RNA_Node, link.tonode, &to_node_ptr); @@ -2208,7 +2211,8 @@ void node_draw_link(const bContext &C, /* Links from field to non-field sockets are not allowed. */ if (snode.edittree->type == NTREE_GEOMETRY) { if ((link.fromsock && link.fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) && - (link.tosock && link.tosock->display_shape == SOCK_DISPLAY_SHAPE_CIRCLE)) { + (link.tosock && link.tosock->display_shape == SOCK_DISPLAY_SHAPE_CIRCLE)) + { th_col1 = th_col2 = th_col3 = TH_REDALERT; } } diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 6ff47505e1d..72bd8940dac 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -746,7 +746,8 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even snode->runtime->cursor[1] /= UI_SCALE_FAC; if (WM_operator_properties_id_lookup_is_set(op->ptr) || - RNA_struct_property_is_set(op->ptr, "filepath")) { + RNA_struct_property_is_set(op->ptr, "filepath")) + { return node_add_file_exec(C, op); } return WM_operator_filesel(C, op, event); diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index f1d9200ef6f..34ab80edb5d 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -745,7 +745,8 @@ static void node_socket_draw(const bNodeSocket &sock, if (ELEM(sock.display_shape, SOCK_DISPLAY_SHAPE_DIAMOND_DOT, SOCK_DISPLAY_SHAPE_SQUARE_DOT, - SOCK_DISPLAY_SHAPE_CIRCLE_DOT)) { + SOCK_DISPLAY_SHAPE_CIRCLE_DOT)) + { flags |= GPU_KEYFRAME_SHAPE_INNER_DOT; } @@ -1078,20 +1079,24 @@ static std::optional create_socket_inspection_string(TreeDrawContex ValueLog *value_log = tree_draw_ctx.geo_tree_log->find_socket_value_log(socket); std::stringstream ss; if (const geo_log::GenericValueLog *generic_value_log = - dynamic_cast(value_log)) { + dynamic_cast(value_log)) + { create_inspection_string_for_generic_value(socket, generic_value_log->value, ss); } else if (const geo_log::FieldInfoLog *gfield_value_log = - dynamic_cast(value_log)) { + dynamic_cast(value_log)) + { create_inspection_string_for_field_info(socket, *gfield_value_log, ss); } else if (const geo_log::GeometryInfoLog *geo_value_log = - dynamic_cast(value_log)) { + dynamic_cast(value_log)) + { create_inspection_string_for_geometry_info(*geo_value_log, ss); } if (const nodes::decl::Geometry *socket_decl = dynamic_cast( - socket.runtime->declaration)) { + socket.runtime->declaration)) + { const bool after_log = value_log != nullptr; create_inspection_string_for_geometry_socket(ss, socket_decl, after_log); } @@ -1725,7 +1730,8 @@ static void node_add_error_message_button(const TreeDrawContext &tree_draw_ctx, float &icon_offset) { if (tree_draw_ctx.used_by_realtime_compositor && - node.typeinfo->realtime_compositor_unsupported_message) { + node.typeinfo->realtime_compositor_unsupported_message) + { node_add_unsupported_compositor_operation_error_message_button(node, block, rect, icon_offset); return; } @@ -1792,8 +1798,8 @@ static std::optional node_get_execution_time( } } else { - if (const geo_log::GeoNodeLog *node_log = tree_log->nodes.lookup_ptr_as( - tnode->identifier)) { + if (const geo_log::GeoNodeLog *node_log = tree_log->nodes.lookup_ptr_as(tnode->identifier)) + { found_node = true; run_time += node_log->run_time; } @@ -1934,7 +1940,8 @@ static std::optional node_get_accessed_attributes_row( if (ELEM(node.type, GEO_NODE_STORE_NAMED_ATTRIBUTE, GEO_NODE_REMOVE_ATTRIBUTE, - GEO_NODE_INPUT_NAMED_ATTRIBUTE)) { + GEO_NODE_INPUT_NAMED_ATTRIBUTE)) + { /* Only show the overlay when the name is passed in from somewhere else. */ for (const bNodeSocket *socket : node.input_sockets()) { if (STREQ(socket->name, "Name")) { @@ -1965,7 +1972,8 @@ static Vector node_get_extra_info(TreeDrawContext &tree_draw_c } if (snode.overlay.flag & SN_OVERLAY_SHOW_NAMED_ATTRIBUTES && - snode.edittree->type == NTREE_GEOMETRY) { + snode.edittree->type == NTREE_GEOMETRY) + { if (std::optional row = node_get_accessed_attributes_row(tree_draw_ctx, node)) { rows.append(std::move(*row)); @@ -1974,7 +1982,8 @@ static Vector node_get_extra_info(TreeDrawContext &tree_draw_c if (snode.overlay.flag & SN_OVERLAY_SHOW_TIMINGS && snode.edittree->type == NTREE_GEOMETRY && (ELEM(node.typeinfo->nclass, NODE_CLASS_GEOMETRY, NODE_CLASS_GROUP, NODE_CLASS_ATTRIBUTE) || - ELEM(node.type, NODE_FRAME, NODE_GROUP_OUTPUT))) { + ELEM(node.type, NODE_FRAME, NODE_GROUP_OUTPUT))) + { NodeExtraInfoRow row; row.text = node_get_execution_time_label(tree_draw_ctx, snode, node); if (!row.text.empty()) { @@ -2961,7 +2970,8 @@ static void reroute_node_draw( /* Skip if out of view. */ const rctf &rct = node.runtime->totr; if (rct.xmax < region.v2d.cur.xmin || rct.xmin > region.v2d.cur.xmax || - rct.ymax < region.v2d.cur.ymin || node.runtime->totr.ymin > region.v2d.cur.ymax) { + rct.ymax < region.v2d.cur.ymin || node.runtime->totr.ymin > region.v2d.cur.ymax) + { UI_block_end(&C, &block); return; } diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index ab4c6680173..30a0fabe672 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -656,7 +656,8 @@ void snode_set_context(const bContext &C) } if (snode->nodetree != ntree || snode->id != id || snode->from != from || - (snode->treepath.last == nullptr && ntree)) { + (snode->treepath.last == nullptr && ntree)) + { ED_node_tree_start(snode, ntree, id, from); } } @@ -700,7 +701,8 @@ void ED_node_set_active( SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, - SH_NODE_OUTPUT_LINESTYLE)) { + SH_NODE_OUTPUT_LINESTYLE)) + { for (bNode *node_iter : ntree->all_nodes()) { if (node_iter->type == node->type) { node_iter->flag &= ~NODE_DO_OUTPUT; @@ -1291,7 +1293,8 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) /* This creates new links between copied nodes. If keep_inputs is set, also copies input links * from unselected (when fromnode is null)! */ if (link->tonode && (link->tonode->flag & NODE_SELECT) && - (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) { + (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) + { bNodeLink *newlink = MEM_cnew("bNodeLink"); newlink->flag = link->flag; newlink->tonode = node_map.lookup(link->tonode); @@ -1389,7 +1392,8 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator * /*op*/) for (bNode *node : edit_tree.all_nodes()) { if ((node->type == CMP_NODE_R_LAYERS) || - (node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) { + (node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) + { ID *id = node->id; if (id == nullptr) { continue; @@ -1491,7 +1495,8 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) continue; } if (toggle_flag == NODE_OPTIONS && - !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) { + !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) + { continue; } @@ -1510,7 +1515,8 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) continue; } if (toggle_flag == NODE_OPTIONS && - !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) { + !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) + { continue; } @@ -2031,6 +2037,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) nimf->active_input++; } + BKE_ntree_update_tag_node_property(snode->edittree, node); ED_node_tree_propagate_change(C, CTX_data_main(C), snode->edittree); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 50cabb412a9..be31abb57df 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -75,7 +75,8 @@ static bool node_group_operator_active_poll(bContext *C) "ShaderNodeTree", "CompositorNodeTree", "TextureNodeTree", - "GeometryNodeTree")) { + "GeometryNodeTree")) + { return true; } } @@ -91,7 +92,8 @@ static bool node_group_operator_editable(bContext *C) * Disabled otherwise to allow python-nodes define their own operators * with same key-map. */ if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) || - ED_node_is_geometry(snode)) { + ED_node_is_geometry(snode)) + { return true; } } @@ -322,7 +324,8 @@ static bool node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) /* find external links to this input */ for (bNodeLink *tlink = (bNodeLink *)ntree->links.first; tlink != glinks_first->next; - tlink = tlink->next) { + tlink = tlink->next) + { if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) { nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock); num_external_links++; @@ -349,7 +352,8 @@ static bool node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) /* output links */ for (bNodeLink *link = (bNodeLink *)ntree->links.first; link != glinks_first->next; - link = link->next) { + link = link->next) + { if (link->fromnode == gnode) { const char *identifier = link->fromsock->identifier; int num_internal_links = 0; @@ -694,7 +698,8 @@ static bool node_group_make_test_selected(bNodeTree &ntree, return false; }; if (sockets_connected_to_group(node->input_sockets()) && - sockets_connected_to_group(node->output_sockets())) { + sockets_connected_to_group(node->output_sockets())) + { return false; } } diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 7d65292ae90..dd4de20fb82 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -2066,12 +2066,14 @@ static bNode *get_selected_node_for_insertion(bNodeTree &node_tree) } if (std::any_of(selected_node->input_sockets().begin(), selected_node->input_sockets().end(), - [&](const bNodeSocket *socket) { return socket->is_directly_linked(); })) { + [&](const bNodeSocket *socket) { return socket->is_directly_linked(); })) + { return nullptr; } if (std::any_of(selected_node->output_sockets().begin(), selected_node->output_sockets().end(), - [&](const bNodeSocket *socket) { return socket->is_directly_linked(); })) { + [&](const bNodeSocket *socket) { return socket->is_directly_linked(); })) + { return nullptr; }; return selected_node; @@ -2166,12 +2168,14 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode) /* Ignore main sockets when the types don't match. */ if (best_input != nullptr && ntree.typeinfo->validate_link != nullptr && !ntree.typeinfo->validate_link(static_cast(old_link->fromsock->type), - static_cast(best_input->type))) { + static_cast(best_input->type))) + { best_input = nullptr; } if (best_output != nullptr && ntree.typeinfo->validate_link != nullptr && !ntree.typeinfo->validate_link(static_cast(best_output->type), - static_cast(old_link->tosock->type))) { + static_cast(old_link->tosock->type))) + { best_output = nullptr; } } @@ -2443,7 +2447,8 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, * without actually making it a part of the frame (because mouse isn't intersecting it) * - logic here is similar to node_find_frame_to_attach. */ if (!insert.parent || - (prev->parent && (prev->parent == next->parent) && (prev->parent != insert.parent))) { + (prev->parent && (prev->parent == next->parent) && (prev->parent != insert.parent))) + { bNode *frame; rctf totr_frame; @@ -2458,9 +2463,11 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, node_to_updated_rect(*frame, totr_frame); if (BLI_rctf_isect_x(&totr_frame, totr_insert.xmin) && - BLI_rctf_isect_x(&totr_frame, totr_insert.xmax)) { + BLI_rctf_isect_x(&totr_frame, totr_insert.xmax)) + { if (BLI_rctf_isect_y(&totr_frame, totr_insert.ymin) || - BLI_rctf_isect_y(&totr_frame, totr_insert.ymax)) { + BLI_rctf_isect_y(&totr_frame, totr_insert.ymax)) + { /* frame isn't insert.parent actually, but this is needed to make offsetting * nodes work correctly for above checked cases (it is restored later) */ insert.parent = frame; @@ -2495,7 +2502,8 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd, if (needs_alignment) { bNode *offs_node = right_alignment ? next : prev; if (!offs_node->parent || offs_node->parent == insert.parent || - nodeIsParentAndChild(offs_node->parent, &insert)) { + nodeIsParentAndChild(offs_node->parent, &insert)) + { node_offset_apply(*offs_node, addval); } else if (!insert.parent && offs_node->parent) { @@ -2536,8 +2544,8 @@ static int node_insert_offset_modal(bContext *C, wmOperator *op, const wmEvent * NodeInsertOfsData *iofsd = static_cast(op->customdata); bool redraw = false; - if (!snode || event->type != TIMER || iofsd == nullptr || - iofsd->anim_timer != event->customdata) { + if (!snode || event->type != TIMER || iofsd == nullptr || iofsd->anim_timer != event->customdata) + { return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index b6b009550eb..e07aadbe57d 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -114,7 +114,8 @@ static bool node_frame_select_isect_mouse(const bNode &node, const float2 &mouse * would prevent e.g. box selection of nodes inside that frame). */ const rctf frame_inside = node_frame_rect_inside(node); if (BLI_rctf_isect_pt(&node.runtime->totr, mouse.x, mouse.y) && - !BLI_rctf_isect_pt(&frame_inside, mouse.x, mouse.y)) { + !BLI_rctf_isect_pt(&frame_inside, mouse.x, mouse.y)) + { return true; } @@ -386,7 +387,8 @@ static bool node_select_grouped_name(bNodeTree &node_tree, bNode &node_act, cons if ((from_right && STREQ(suf_act, suf_curr)) || (!from_right && (pref_len_act == pref_len_curr) && - STREQLEN(node_act.name, node->name, pref_len_act))) { + STREQLEN(node_act.name, node->name, pref_len_act))) + { nodeSetSelected(node, true); changed = true; } @@ -667,7 +669,8 @@ static bool node_mouse_select(bContext *C, ED_node_set_active_viewer_key(&snode); node_sort(node_tree); if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) || - viewer_node_changed) { + viewer_node_changed) + { DEG_id_tag_update(&snode.edittree->id, ID_RECALC_COPY_ON_WRITE); } @@ -777,7 +780,8 @@ static int node_box_select_exec(bContext *C, wmOperator *op) * nodes - would prevent selection of other nodes inside that frame. */ const rctf frame_inside = node_frame_rect_inside(*node); if (BLI_rctf_isect(&rectf, &node->runtime->totr, nullptr) && - !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) + { nodeSetSelected(node, select); is_inside = true; } @@ -882,7 +886,8 @@ static int node_circleselect_exec(bContext *C, wmOperator *op) const float radius_adjusted = float(radius) / zoom; BLI_rctf_pad(&frame_inside, -2.0f * radius_adjusted, -2.0f * radius_adjusted); if (BLI_rctf_isect_circle(&node->runtime->totr, offset, radius_adjusted) && - !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted)) { + !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted)) + { nodeSetSelected(node, select); } break; @@ -976,7 +981,8 @@ static bool do_lasso_select_node(bContext *C, UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf); const rctf frame_inside = node_frame_rect_inside(*node); if (BLI_rctf_isect(&rectf, &node->runtime->totr, nullptr) && - !BLI_rctf_inside_rctf(&frame_inside, &rectf)) { + !BLI_rctf_inside_rctf(&frame_inside, &rectf)) + { nodeSetSelected(node, select); changed = true; } @@ -991,7 +997,8 @@ static bool do_lasso_select_node(bContext *C, if (UI_view2d_view_to_region_clip( ®ion->v2d, center.x, center.y, &screen_co.x, &screen_co.y) && BLI_rcti_isect_pt(&rect, screen_co.x, screen_co.y) && - BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co.x, screen_co.y, INT_MAX)) { + BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co.x, screen_co.y, INT_MAX)) + { nodeSetSelected(node, select); changed = true; } diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index cb69800e515..a9dae4612f5 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -214,7 +214,8 @@ static void node_socket_add_replace(const bContext *C, if (node_from) { if (node_from->inputs.first || node_from->typeinfo->draw_buttons || - node_from->typeinfo->draw_buttons_ex) { + node_from->typeinfo->draw_buttons_ex) + { node_from = nullptr; } } @@ -277,7 +278,8 @@ static void node_socket_add_replace(const bContext *C, if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE && node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE && /* White noise texture node does not have NodeTexBase. */ - node_from->storage != nullptr && node_prev->storage != nullptr) { + node_from->storage != nullptr && node_prev->storage != nullptr) + { memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase)); } @@ -321,20 +323,22 @@ static Vector ui_node_link_items(NodeLinkArg *arg, int i; for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup; - ngroup = (bNodeTree *)ngroup->id.next) { + ngroup = (bNodeTree *)ngroup->id.next) + { const char *disabled_hint; - if ((ngroup->type != arg->ntree->type) || - !nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) { + if ((ngroup->type != arg->ntree->type) || !nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) + { continue; } } i = 0; for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup; - ngroup = (bNodeTree *)ngroup->id.next) { + ngroup = (bNodeTree *)ngroup->id.next) + { const char *disabled_hint; - if ((ngroup->type != arg->ntree->type) || - !nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) { + if ((ngroup->type != arg->ntree->type) || !nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) + { continue; } diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 80f08fda3e5..3185e723177 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -198,7 +198,8 @@ void ED_node_set_active_viewer_key(SpaceNode *snode) /* A change in active viewer may result in the change of the output node used by the * compositor, so we need to get notified about such changes. */ if (snode->nodetree->active_viewer_key.value != path->parent_key.value && - snode->nodetree->type == NTREE_COMPOSIT) { + snode->nodetree->type == NTREE_COMPOSIT) + { DEG_id_tag_update(&snode->nodetree->id, ID_RECALC_NTREE_OUTPUT); WM_main_add_notifier(NC_NODE, nullptr); } diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc index 9a557627abb..0e214d2cdf4 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -52,10 +52,9 @@ bool outliner_is_collection_tree_element(const TreeElement *te) return false; } - if (ELEM(tselem->type, - TSE_LAYER_COLLECTION, - TSE_SCENE_COLLECTION_BASE, - TSE_VIEW_COLLECTION_BASE)) { + if (ELEM( + tselem->type, TSE_LAYER_COLLECTION, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) + { return true; } if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_GR) { @@ -114,8 +113,8 @@ TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *cus return TRAVERSE_CONTINUE; } - if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || - (GS(tselem->id->name) != ID_OB)) { + if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || (GS(tselem->id->name) != ID_OB)) + { return TRAVERSE_SKIP_CHILDS; } @@ -239,7 +238,8 @@ static int collection_new_exec(bContext *C, wmOperator *op) } if (data.collection == nullptr || ID_IS_LINKED(data.collection) || - ID_IS_OVERRIDE_LIBRARY(data.collection)) { + ID_IS_OVERRIDE_LIBRARY(data.collection)) + { data.collection = scene->master_collection; } @@ -699,7 +699,8 @@ static int collection_link_exec(bContext *C, wmOperator *op) if ((ID_IS_LINKED(active_collection) || ID_IS_OVERRIDE_LIBRARY(active_collection)) || ((active_collection->flag & COLLECTION_IS_MASTER) && - (ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene)))) { + (ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene)))) + { BKE_report( op->reports, RPT_ERROR, "Cannot add a collection to a linked/override collection/scene"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 2569670a8d3..06cab393097 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -139,7 +139,8 @@ static TreeElement *outliner_drop_insert_find(bContext *C, if (view_mval[1] < (te_hovered->ys + margin)) { if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner) && - !BLI_listbase_is_empty(&te_hovered->subtree)) { + !BLI_listbase_is_empty(&te_hovered->subtree)) + { /* inserting after a open item means we insert into it, but as first child */ if (BLI_listbase_is_empty(&te_hovered->subtree)) { *r_insert_type = TE_INSERT_INTO; @@ -385,7 +386,8 @@ static void parent_drop_set_parents(bContext *C, } if (ED_object_parent_set( - reports, C, scene, object, parent, parent_type, false, keep_transform, nullptr)) { + reports, C, scene, object, parent, parent_type, false, keep_transform, nullptr)) + { parent_set = true; } } @@ -724,7 +726,8 @@ static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData TSE_CONSTRAINT, TSE_CONSTRAINT_BASE, TSE_GPENCIL_EFFECT, - TSE_GPENCIL_EFFECT_BASE)) { + TSE_GPENCIL_EFFECT_BASE)) + { return false; } @@ -762,7 +765,8 @@ static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData if (ELEM(drop_data->drag_tselem->type, TSE_MODIFIER_BASE, TSE_CONSTRAINT_BASE, - TSE_GPENCIL_EFFECT_BASE)) { + TSE_GPENCIL_EFFECT_BASE)) + { drop_data->insert_type = TE_INSERT_INTO; drop_data->drop_action = DATA_STACK_DROP_LINK; @@ -821,7 +825,8 @@ static bool datastack_drop_are_types_valid(StackDropData *drop_data) if (tselem->type == TSE_CONSTRAINT) { } else if ((drop_data->pchan_parent && tselem->type != TSE_POSE_CHANNEL) || - (!drop_data->pchan_parent && tselem->type == TSE_POSE_CHANNEL)) { + (!drop_data->pchan_parent && tselem->type == TSE_POSE_CHANNEL)) + { return false; } diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 3f2f466a1e5..4ff90cf011f 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -277,7 +277,8 @@ static void outliner_object_set_flag_recursive_fn(bContext *C, Object *ob_parent = ob ? ob : base->object; for (Object *ob_iter = static_cast(bmain->objects.first); ob_iter; - ob_iter = static_cast(ob_iter->id.next)) { + ob_iter = static_cast(ob_iter->id.next)) + { if (BKE_object_is_child_recursive(ob_parent, ob_iter)) { if (ob) { RNA_id_pointer_create(&ob_iter->id, &ptr); @@ -438,7 +439,8 @@ static bool outliner_collection_is_isolated(Scene *scene, else if (collection_ensure == collection_ensure_cmp) { } else if (BKE_collection_has_collection(collection_ensure, (Collection *)collection_ensure_cmp) || - BKE_collection_has_collection((Collection *)collection_ensure_cmp, collection_ensure)) { + BKE_collection_has_collection((Collection *)collection_ensure_cmp, collection_ensure)) + { /* This collection is either a parent or a child of the collection. * We expect it to be set "visible" already. */ if (value != value_cmp) { @@ -469,7 +471,8 @@ static bool outliner_collection_is_isolated(Scene *scene, value_cmp, layer_or_collection_prop, layer_collection_iter, - collection_iter)) { + collection_iter)) + { return false; } } @@ -1097,7 +1100,8 @@ static void outliner_draw_restrictbuts(uiBlock *block, restrict_offsets.select = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH; } if (space_outliner->outlinevis == SO_VIEW_LAYER && - space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE) { + space_outliner->show_restrict_flags & SO_RESTRICT_ENABLE) + { restrict_offsets.enable = (++restrict_column_offset) * UI_UNIT_X + V2D_SCROLL_WIDTH; } @@ -1139,7 +1143,8 @@ static void outliner_draw_restrictbuts(uiBlock *block, } } else if (((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) && - (te->flag & TE_CHILD_NOT_IN_COLLECTION)) { + (te->flag & TE_CHILD_NOT_IN_COLLECTION)) + { /* Don't show restrict columns for children that are not directly inside the collection. */ } else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) { @@ -1488,7 +1493,8 @@ static void outliner_draw_restrictbuts(uiBlock *block, PointerRNA layer_collection_ptr; if (outliner_restrict_properties_collection_set( - scene, te, &collection_ptr, &layer_collection_ptr, &props, &props_active)) { + scene, te, &collection_ptr, &layer_collection_ptr, &props, &props_active)) + { LayerCollection *layer_collection = (tselem->type == TSE_LAYER_COLLECTION) ? static_cast(te->directdata) : @@ -1843,7 +1849,8 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, } if (const TreeElementOverridesPropertyOperation *override_op_elem = - tree_element_cast(te)) { + tree_element_cast(te)) + { StringRefNull op_label = override_op_elem->getOverrideOperationLabel(); uiDefBut(block, UI_BTYPE_LABEL, @@ -2034,7 +2041,8 @@ static void outliner_draw_rnabuts(uiBlock *block, } } else if (TreeElementRNAArrayElement *te_rna_array_elem = - tree_element_cast(te)) { + tree_element_cast(te)) + { ptr = te_rna_array_elem->getPointerRNA(); prop = te_rna_array_elem->getPropertyRNA(); @@ -2068,13 +2076,13 @@ static void outliner_buttons(const bContext *C, /* If we add support to rename Sequence, need change this. */ if (tselem->type == TSE_EBONE) { - len = sizeof(((EditBone *)nullptr)->name); + len = sizeof(EditBone::name); } else if (tselem->type == TSE_MODIFIER) { - len = sizeof(((ModifierData *)nullptr)->name); + len = sizeof(ModifierData::name); } else if (tselem->id && GS(tselem->id->name) == ID_LI) { - len = sizeof(((Library *)nullptr)->filepath); + len = sizeof(Library::filepath); } else { len = MAX_ID_NAME - 2; @@ -2203,7 +2211,8 @@ static void outliner_draw_mode_column_toggle(uiBlock *block, if (ID_IS_LINKED(&ob->id) || (ID_IS_OVERRIDE_LIBRARY_REAL(ob) && - (ob->id.override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) != 0)) { + (ob->id.override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) != 0)) + { UI_but_disable(but, TIP_("Can't edit library or non-editable override data")); } } @@ -3070,7 +3079,8 @@ static void outliner_draw_iconrow(bContext *C, * collection). */ const bool is_bone = ELEM(tselem->type, TSE_BONE, TSE_EBONE, TSE_POSE_CHANNEL); if ((level < 1) || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) || - (in_bone_hierarchy && is_bone)) { + (in_bone_hierarchy && is_bone)) + { /* active blocks get white circle */ if (tselem->type == TSE_SOME_ID) { if (te->idcode == ID_OB) { @@ -3100,7 +3110,8 @@ static void outliner_draw_iconrow(bContext *C, TSE_EBONE, TSE_POSE_CHANNEL, TSE_POSEGRP, - TSE_DEFGROUP)) { + TSE_DEFGROUP)) + { outliner_draw_iconrow_doit(block, te, xmax, offsx, ys, alpha_fac, active, 1); } else { @@ -3308,7 +3319,8 @@ static void outliner_draw_tree_element(bContext *C, /* Scene collection in view layer can't expand/collapse. */ } else if (te->subtree.first || ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_SCE)) || - (te->flag & TE_PRETEND_HAS_CHILDREN)) { + (te->flag & TE_PRETEND_HAS_CHILDREN)) + { /* Open/close icon, only when sub-levels, except for scene. */ int icon_x = startx; @@ -3338,7 +3350,8 @@ static void outliner_draw_tree_element(bContext *C, te, (tselem->flag & TSE_HIGHLIGHTED_ICON) ? alpha_fac + 0.5f : alpha_fac, true, - 1)) { + 1)) + { offsx += UI_UNIT_X + 4 * ufac; } else { @@ -3347,7 +3360,8 @@ static void outliner_draw_tree_element(bContext *C, const TreeElementRNAStruct *te_rna_struct = tree_element_cast(te); if (ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION) || - (te_rna_struct && RNA_struct_is_ID(te_rna_struct->getPointerRNA().type))) { + (te_rna_struct && RNA_struct_is_ID(te_rna_struct->getPointerRNA().type))) + { const BIFIconID lib_icon = (BIFIconID)UI_icon_from_library(tselem->id); if (lib_icon != ICON_NONE) { UI_icon_draw_alpha( @@ -3868,7 +3882,8 @@ void draw_outliner(const bContext *C) SO_OVERRIDES_LIBRARY, SO_DATA_API, SO_ID_ORPHANS) && - space_outliner->flag & SO_SYNC_SELECT) { + space_outliner->flag & SO_SYNC_SELECT) + { outliner_sync_selection(C, space_outliner); } diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 4ea83f4720c..6b0f1669e8a 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -110,7 +110,8 @@ static int outliner_highlight_update(bContext *C, wmOperator * /*op*/, const wmE bool changed = false; if (!hovered_te || !is_over_icon || !(hovered_te->store_elem->flag & TSE_HIGHLIGHTED) || - !(icon_te->store_elem->flag & TSE_HIGHLIGHTED_ICON)) { + !(icon_te->store_elem->flag & TSE_HIGHLIGHTED_ICON)) + { /* Clear highlights when nothing is hovered or when a new item is hovered. */ changed = outliner_flag_set(*space_outliner, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false); if (hovered_te) { @@ -298,7 +299,8 @@ static void do_item_rename(ARegion *region, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE, - TSE_SCENE_OBJECTS_BASE)) { + TSE_SCENE_OBJECTS_BASE)) + { /* do nothing */ } else if (ELEM(tselem->type, @@ -313,7 +315,8 @@ static void do_item_rename(ARegion *region, TSE_R_LAYER_BASE, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE, - TSE_LIBRARY_OVERRIDE_BASE)) { + TSE_LIBRARY_OVERRIDE_BASE)) + { BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); } else if (ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { @@ -423,6 +426,8 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even void OUTLINER_OT_item_rename(wmOperatorType *ot) { + PropertyRNA *prop; + ot->name = "Rename"; ot->idname = "OUTLINER_OT_item_rename"; ot->description = "Rename the active element"; @@ -434,11 +439,12 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, - "use_active", - false, - "Use Active", - "Rename the active item, rather than the one the mouse is over"); + prop = RNA_def_boolean(ot->srna, + "use_active", + false, + "Use Active", + "Rename the active item, rather than the one the mouse is over"); + RNA_def_property_flag(prop, PropertyFlag(PROP_SKIP_SAVE | PROP_HIDDEN)); } /** \} */ @@ -459,7 +465,8 @@ static void id_delete_tag(bContext *C, ReportList *reports, TreeElement *te, Tre if (ID_IS_OVERRIDE_LIBRARY(id)) { if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || - (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) == 0) { + (id->override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) == 0) + { BKE_reportf(reports, RPT_WARNING, "Cannot delete library override id '%s', it is part of an override hierarchy", @@ -896,7 +903,7 @@ static int lib_relocate( Library *lib = (Library *)tselem->id; char dir[FILE_MAXDIR], filename[FILE_MAX]; - BLI_split_dirfile(lib->filepath_abs, dir, filename, sizeof(dir), sizeof(filename)); + BLI_path_split_dir_file(lib->filepath_abs, dir, sizeof(dir), filename, sizeof(filename)); printf("%s, %s\n", tselem->id->name, lib->filepath_abs); @@ -1521,7 +1528,8 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *space_outli TSE_SOME_ID, TSE_SCENE_OBJECTS_BASE, TSE_VIEW_COLLECTION_BASE, - TSE_LAYER_COLLECTION)) { + TSE_LAYER_COLLECTION)) + { if (te->idcode == ID_SCE) { if (tselem->id != (ID *)scene) { tselem->flag |= TSE_CLOSED; diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index f77272f79f5..3dac091f055 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -194,7 +194,8 @@ void outliner_item_mode_toggle(bContext *C, /* Hidden objects can be removed from the mode. */ if (!base || (!(base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) && - (ob->mode != tvc->obact->mode))) { + (ob->mode != tvc->obact->mode))) + { return; } @@ -245,7 +246,8 @@ static void do_outliner_object_select_recursive(const Scene *scene, LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { Object *ob = base->object; if (((base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) != 0) && - BKE_object_is_child_recursive(ob_parent, ob)) { + BKE_object_is_child_recursive(ob_parent, ob)) + { ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); } } @@ -366,7 +368,8 @@ static void tree_element_object_activate(bContext *C, * see #55246. */ if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? (ob->mode == OB_MODE_OBJECT) : - true) { + true) + { BKE_view_layer_base_deselect_all(scene, view_layer); } ED_object_base_select(base, BA_SELECT); @@ -564,7 +567,8 @@ static void tree_element_bone_activate(bContext *C, if (set != OL_SETSEL_EXTEND) { /* single select forces all other bones to get unselected */ for (Bone *bone_iter = static_cast(arm->bonebase.first); bone_iter != nullptr; - bone_iter = bone_iter->next) { + bone_iter = bone_iter->next) + { bone_iter->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); do_outliner_bone_select_recursive(arm, bone_iter, false); } @@ -1400,7 +1404,8 @@ static void do_outliner_item_activate_tree_element(bContext *C, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, TSE_EBONE, - TSE_LAYER_COLLECTION)) { + TSE_LAYER_COLLECTION)) + { /* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several * objects, we do not want to switch out of edit mode (see #48328 for details). */ } @@ -1641,7 +1646,8 @@ static int outliner_item_do_activate_from_cursor(bContext *C, } /* Don't allow toggle on scene collection */ else if ((TREESTORE(te)->type != TSE_VIEW_COLLECTION_BASE) && - outliner_item_is_co_within_close_toggle(te, view_mval[0])) { + outliner_item_is_co_within_close_toggle(te, view_mval[0])) + { return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } else { diff --git a/source/blender/editors/space_outliner/outliner_sync.cc b/source/blender/editors/space_outliner/outliner_sync.cc index a1991c6a762..c594559f7db 100644 --- a/source/blender/editors/space_outliner/outliner_sync.cc +++ b/source/blender/editors/space_outliner/outliner_sync.cc @@ -78,7 +78,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C) wmWindowManager *wm = CTX_wm_manager(C); for (bScreen *screen = static_cast(bmain->screens.first); screen; - screen = static_cast(screen->id.next)) { + screen = static_cast(screen->id.next)) + { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_OUTLINER) { @@ -351,7 +352,8 @@ void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_out SO_LIBRARIES, SO_OVERRIDES_LIBRARY, SO_DATA_API, - SO_ID_ORPHANS)) { + SO_ID_ORPHANS)) + { return; } diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 608a32ffef6..3d92e7f8d1c 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -571,7 +571,8 @@ static void outliner_do_libdata_operation_selection_set(bContext *C, bool is_selected = tselem->flag & TSE_SELECTED; if ((is_selected && do_selected) || (has_parent_selected && do_content)) { if (((tselem->type == TSE_SOME_ID) && (element->idcode != 0)) || - tselem->type == TSE_LAYER_COLLECTION) { + tselem->type == TSE_LAYER_COLLECTION) + { TreeStoreElem *tsep = element->parent ? TREESTORE(element->parent) : nullptr; operation_fn(C, reports, scene, element, tsep, tselem, user_data); } @@ -906,7 +907,8 @@ static void outliner_object_delete_fn(bContext *C, ReportList *reports, Scene *s return; } if (ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0 && - BKE_library_ID_is_indirectly_used(bmain, ob)) { + BKE_library_ID_is_indirectly_used(bmain, ob)) + { BKE_reportf(reports, RPT_WARNING, "Cannot delete object '%s' from scene '%s', indirectly used objects need at " @@ -1036,7 +1038,8 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, ID *id_root_reference = tselem->id; if (!BKE_idtype_idcode_is_linkable(GS(id_root_reference->name)) || - (id_root_reference->flag & (LIB_EMBEDDED_DATA | LIB_EMBEDDED_DATA_LIB_OVERRIDE)) != 0) { + (id_root_reference->flag & (LIB_EMBEDDED_DATA | LIB_EMBEDDED_DATA_LIB_OVERRIDE)) != 0) + { return; } @@ -1046,7 +1049,7 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, data->selected_id_uid.add(id_root_reference->session_uuid); if (ID_IS_OVERRIDE_LIBRARY_REAL(id_root_reference) && !ID_IS_LINKED(id_root_reference)) { - id_root_reference->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id_root_reference->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; return; } @@ -1065,7 +1068,8 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, ID *id_instance_hint = nullptr; bool is_override_instancing_object = false; if (tsep != nullptr && tsep->type == TSE_SOME_ID && tsep->id != nullptr && - GS(tsep->id->name) == ID_OB && !ID_IS_OVERRIDE_LIBRARY(tsep->id)) { + GS(tsep->id->name) == ID_OB && !ID_IS_OVERRIDE_LIBRARY(tsep->id)) + { Object *ob = reinterpret_cast(tsep->id); if (ob->type == OB_EMPTY && &ob->instance_collection->id == id_root_reference) { BLI_assert(GS(id_root_reference->name) == ID_GR); @@ -1077,7 +1081,8 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, } if (!ID_IS_OVERRIDABLE_LIBRARY(id_root_reference) && - !(ID_IS_LINKED(id_root_reference) && do_hierarchy)) { + !(ID_IS_LINKED(id_root_reference) && do_hierarchy)) + { return; } @@ -1107,8 +1112,8 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, * access its hierarchy root directly. */ if (!ID_IS_LINKED(id_current_hierarchy_root) && ID_IS_OVERRIDE_LIBRARY_REAL(id_current_hierarchy_root) && - id_current_hierarchy_root->override_library->reference->lib == - id_root_reference->lib) { + id_current_hierarchy_root->override_library->reference->lib == id_root_reference->lib) + { id_hierarchy_root_reference = id_current_hierarchy_root->override_library->hierarchy_root; BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root_reference)); @@ -1157,7 +1162,8 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C, (!ID_IS_LINKED(id_hierarchy_root_reference) && ID_IS_OVERRIDE_LIBRARY_REAL(id_hierarchy_root_reference) && id_hierarchy_root_reference->override_library->reference->lib == - id_root_reference->lib))) { + id_root_reference->lib))) + { BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); BKE_reportf(reports, RPT_WARNING, @@ -1263,7 +1269,7 @@ static void id_override_library_create_hierarchy( success = id_root_override != nullptr; if (success) { BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root_override)); - id_root_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id_root_override->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } /* Cleanup. */ BKE_main_id_newptr_and_tag_clear(&bmain); @@ -1322,8 +1328,9 @@ static void id_override_library_create_hierarchy_process(bContext *C, continue; } if (data.selected_id_uid.contains(id_iter->override_library->reference->session_uuid) || - data.selected_id_uid.contains(id_iter->session_uuid)) { - id_iter->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + data.selected_id_uid.contains(id_iter->session_uuid)) + { + id_iter->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } } FOREACH_MAIN_ID_END; @@ -2180,7 +2187,8 @@ static void outliner_batch_delete_object_tag(ReportList *reports, /* FIXME: This code checking object user-count won't work as expected if a same object belongs to * more than one collection in the scene. */ if (ID_REAL_USERS(object) <= 1 && ID_EXTRA_USERS(object) == 0 && - BKE_library_ID_is_indirectly_used(bmain, object)) { + BKE_library_ID_is_indirectly_used(bmain, object)) + { BKE_reportf(reports, RPT_WARNING, "Cannot delete object '%s' from scene '%s', indirectly used objects need at least " @@ -2205,12 +2213,14 @@ static void outliner_batch_delete_object_hierarchy_tag( * deletable. */ for (Base *base_iter = static_cast(BKE_view_layer_object_bases_get(view_layer)->first); base_iter != nullptr; - base_iter = base_iter->next) { + base_iter = base_iter->next) + { Object *parent_ob_iter; for (parent_ob_iter = base_iter->object->parent; (parent_ob_iter != nullptr && parent_ob_iter != object && (parent_ob_iter->id.tag & LIB_TAG_DOIT) == 0); - parent_ob_iter = parent_ob_iter->parent) { + parent_ob_iter = parent_ob_iter->parent) + { /* pass */ } if (parent_ob_iter != nullptr) { @@ -2223,7 +2233,8 @@ static void outliner_batch_delete_object_hierarchy_tag( for (parent_ob_iter = base_iter->object; (parent_ob_iter != nullptr && parent_ob_iter != object && (parent_ob_iter->id.tag & LIB_TAG_DOIT) == 0); - parent_ob_iter = parent_ob_iter->parent) { + parent_ob_iter = parent_ob_iter->parent) + { outliner_batch_delete_object_tag(reports, bmain, scene, parent_ob_iter); } } @@ -2454,8 +2465,8 @@ static TreeTraversalAction outliner_collect_objects_to_delete(TreeElement *te, v return TRAVERSE_CONTINUE; } - if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || - (GS(tselem->id->name) != ID_OB)) { + if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || (GS(tselem->id->name) != ID_OB)) + { return TRAVERSE_SKIP_CHILDS; } diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index d363ec4e8ea..c98fdfdfe92 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -701,7 +701,8 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, /* do not extend Armature when we have posemode */ tselem = TREESTORE(te->parent); if (TSE_IS_REAL_ID(tselem) && GS(tselem->id->name) == ID_OB && - ((Object *)tselem->id)->mode & OB_MODE_POSE) { + ((Object *)tselem->id)->mode & OB_MODE_POSE) + { /* pass */ } else { @@ -869,7 +870,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (ELEM(type, TSE_LIBRARY_OVERRIDE_BASE, TSE_LIBRARY_OVERRIDE, - TSE_LIBRARY_OVERRIDE_OPERATION)) { + TSE_LIBRARY_OVERRIDE_OPERATION)) + { if (!te->abstract_element) { BLI_assert_msg(0, "Expected override types to be ported to new Outliner tree-element design"); @@ -912,7 +914,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP, - TSE_GENERIC_LABEL)) { + TSE_GENERIC_LABEL)) + { BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design"); } @@ -992,8 +995,8 @@ static int treesort_alpha_ob(const void *v1, const void *v2) if (comp == 3) { /* Among objects first come the ones in the collection, followed by the ones not on it. * This way we can have the dashed lines in a separate style connecting the former. */ - if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != - (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { + if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) + { return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } @@ -1093,7 +1096,8 @@ static void outliner_sort(ListBase *lb) /* Sorting rules; only object lists, ID lists, or deform-groups. */ if (ELEM(last_tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || - ((last_tselem->type == TSE_SOME_ID) && (last_te->idcode == ID_OB))) { + ((last_tselem->type == TSE_SOME_ID) && (last_te->idcode == ID_OB))) + { int totelem = BLI_listbase_count(lb); if (totelem > 1) { @@ -1288,7 +1292,8 @@ static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner bool (*callback_test)(TreeElement *); if ((space_outliner->outlinevis == SO_VIEW_LAYER) && - (space_outliner->filter & SO_FILTER_NO_COLLECTION)) { + (space_outliner->filter & SO_FILTER_NO_COLLECTION)) + { callback_test = test_object_callback; } else { @@ -1493,14 +1498,16 @@ static bool outliner_element_visible_get(const Scene *scene, } if ((te->parent != nullptr) && (TREESTORE(te->parent)->type == TSE_SOME_ID) && - (te->parent->idcode == ID_OB)) { + (te->parent->idcode == ID_OB)) + { if (exclude_filter & SO_FILTER_NO_CHILDREN) { return false; } } } else if ((te->parent != nullptr) && (TREESTORE(te->parent)->type == TSE_SOME_ID) && - (te->parent->idcode == ID_OB)) { + (te->parent->idcode == ID_OB)) + { if (exclude_filter & SO_FILTER_NO_OB_CONTENT) { return false; } @@ -1602,8 +1609,8 @@ static int outliner_filter_subtree(SpaceOutliner *space_outliner, if (!TSELEM_OPEN(tselem, space_outliner) || outliner_filter_subtree( - space_outliner, scene, view_layer, &te->subtree, search_string, exclude_filter) == - 0) { + space_outliner, scene, view_layer, &te->subtree, search_string, exclude_filter) == 0) + { outliner_free_tree_element(te, lb); } } @@ -1627,7 +1634,7 @@ static void outliner_filter_tree(SpaceOutliner *space_outliner, const Scene *scene, ViewLayer *view_layer) { - char search_buff[sizeof(((struct SpaceOutliner *)nullptr)->search_string) + 2]; + char search_buff[sizeof(SpaceOutliner::search_string) + 2]; char *search_string; const int exclude_filter = outliner_exclude_filter_get(space_outliner); @@ -1681,7 +1688,8 @@ void outliner_build_tree(Main *mainvar, } if (space_outliner->runtime->tree_hash && (space_outliner->storeflag & SO_TREESTORE_REBUILD) && - space_outliner->treestore) { + space_outliner->treestore) + { space_outliner->runtime->tree_hash->rebuild_from_treestore(*space_outliner->treestore); } space_outliner->storeflag &= ~SO_TREESTORE_REBUILD; diff --git a/source/blender/editors/space_outliner/outliner_utils.cc b/source/blender/editors/space_outliner/outliner_utils.cc index 73ace155033..3b3e451f055 100644 --- a/source/blender/editors/space_outliner/outliner_utils.cc +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -52,7 +52,8 @@ void outliner_viewcontext_init(const bContext *C, TreeViewContext *tvc) if ((tvc->obact->type == OB_ARMATURE) || /* This could be made into its own function. */ - ((tvc->obact->type == OB_MESH) && tvc->obact->mode & OB_MODE_WEIGHT_PAINT)) { + ((tvc->obact->type == OB_MESH) && tvc->obact->mode & OB_MODE_WEIGHT_PAINT)) + { tvc->ob_pose = BKE_object_pose_armature_get(tvc->obact); } } @@ -294,7 +295,8 @@ bool outliner_tree_traverse(const SpaceOutliner *space_outliner, /* skip */ } else if (!outliner_tree_traverse( - space_outliner, &subtree, filter_te_flag, filter_tselem_flag, func, customdata)) { + space_outliner, &subtree, filter_te_flag, filter_tselem_flag, func, customdata)) + { return false; } } diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index 3fddd96c004..54a9fc506a4 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -261,7 +261,8 @@ static void outliner_main_region_listener(const wmRegionListenerParams *params) break; case NC_NODE: if (ELEM(wmn->action, NA_ADDED, NA_REMOVED) && - ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API)) { + ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API)) + { ED_region_tag_redraw(region); } break; diff --git a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc index 2150d2b211a..73537d736bc 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc @@ -55,7 +55,8 @@ ListBase TreeDisplayOverrideLibraryHierarchies::buildTree(const TreeSourceData & /* Second step: Build hierarchies for external libraries. */ for (Library *lib = (Library *)source_data.bmain->libraries.first; lib; - lib = (Library *)lib->id.next) { + lib = (Library *)lib->id.next) + { TreeElement *tenlib = outliner_add_element( &space_outliner_, &tree, lib, nullptr, TSE_SOME_ID, 0); build_hierarchy_for_lib_or_main(source_data.bmain, *tenlib, lib); @@ -264,7 +265,8 @@ static void foreach_natural_hierarchy_child(const MainIDRelations &id_relations, /* Iterate over all IDs used by the parent ID (e.g. the child-collections of a collection). */ for (MainIDRelationsEntryItem *to_id_entry = relations_of_id->to_ids; to_id_entry; - to_id_entry = to_id_entry->next) { + to_id_entry = to_id_entry->next) + { /* An ID pointed to (used) by the ID to recurse into. */ ID &target_id = **to_id_entry->id_pointer.to; @@ -293,7 +295,8 @@ static void foreach_natural_hierarchy_child(const MainIDRelations &id_relations, /* If the ID is an object, find and iterate over any child objects. */ if (GS(parent_id.name) == ID_OB) { for (MainIDRelationsEntryItem *from_id_entry = relations_of_id->from_ids; from_id_entry; - from_id_entry = from_id_entry->next) { + from_id_entry = from_id_entry->next) + { ID &potential_child_id = *from_id_entry->id_pointer.from; if (GS(potential_child_id.name) != ID_OB) { diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc index 441ba3c85d0..29ebdb0c4d1 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc @@ -261,7 +261,8 @@ void ObjectsChildrenBuilder::make_object_parent_hierarchy_collections() parent_ob_collection_tree_element = parent_ob_tree_element->parent; while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, TSE_VIEW_COLLECTION_BASE, - TSE_LAYER_COLLECTION)) { + TSE_LAYER_COLLECTION)) + { parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index 11067d37966..69c8e45bea8 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -60,7 +60,8 @@ TreeElementOverridesBase::TreeElementOverridesBase(TreeElement &legacy_te, ID &i { BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE_BASE); if (legacy_te.parent != nullptr && - ELEM(legacy_te.parent->store_elem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) { + ELEM(legacy_te.parent->store_elem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) + { legacy_te.name = IFACE_("Library Overrides"); } else { @@ -92,7 +93,8 @@ static void iterate_properties_to_display(ID &id, RNA_id_pointer_create(&id, &idpoin); for (IDOverrideLibraryProperty *override_prop : - ListBaseWrapper(id.override_library->properties)) { + ListBaseWrapper(id.override_library->properties)) + { int rnaprop_index = 0; const bool is_rna_path_valid = BKE_lib_override_rna_property_find( &idpoin, override_prop, &override_rna_ptr, &override_rna_prop, &rnaprop_index); @@ -105,10 +107,12 @@ static void iterate_properties_to_display(ID &id, /* Matching ID pointers are considered as system overrides. */ if (ELEM(override_prop->rna_prop_type, PROP_POINTER, PROP_COLLECTION) && - RNA_struct_is_ID(RNA_property_pointer_type(&override_rna_ptr, override_rna_prop))) { + RNA_struct_is_ID(RNA_property_pointer_type(&override_rna_ptr, override_rna_prop))) + { for (IDOverrideLibraryPropertyOperation *override_prop_op : - ListBaseWrapper(override_prop->operations)) { - if ((override_prop_op->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { + ListBaseWrapper(override_prop->operations)) + { + if ((override_prop_op->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { do_skip = false; break; } @@ -118,7 +122,8 @@ static void iterate_properties_to_display(ID &id, /* Animated/driven properties are considered as system overrides. */ if (!is_system_override && !BKE_lib_override_library_property_is_animated( - &id, override_prop, override_rna_prop, rnaprop_index)) { + &id, override_prop, override_rna_prop, rnaprop_index)) + { do_skip = false; } @@ -223,9 +228,7 @@ TreeElementOverridesPropertyOperation::TreeElementOverridesPropertyOperation( StringRefNull TreeElementOverridesPropertyOperation::getOverrideOperationLabel() const { - if (ELEM(operation_->operation, - IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, - IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) { + if (ELEM(operation_->operation, LIBOVERRIDE_OP_INSERT_AFTER, LIBOVERRIDE_OP_INSERT_BEFORE)) { return TIP_("Added through override"); } @@ -248,7 +251,8 @@ std::optional TreeElementOverridesPropertyOperation::get_collection_ if (RNA_property_collection_lookup_int(const_cast(&override_rna_ptr), &override_rna_prop, operation_->subitem_local_index, - &col_item_ptr)) { + &col_item_ptr)) + { return col_item_ptr; } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 87b733168bf..9bf4a4361a7 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -202,7 +202,8 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) for (seq = ed->seqbasep->first; seq; seq = seq->next) { const int strip_end = SEQ_time_right_handle_frame_get(scene, seq); if (ELEM(type, -1, seq->type) && (strip_end <= timeline_frame) && - (timeline_frame - strip_end < proximity)) { + (timeline_frame - strip_end < proximity)) + { tgt = seq; proximity = timeline_frame - strip_end; } @@ -303,17 +304,20 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm } if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && - RNA_property_boolean_get(op->ptr, prop)) { + RNA_property_boolean_get(op->ptr, prop)) + { load_data->flags |= SEQ_LOAD_MOVIE_SYNC_FPS; } if ((prop = RNA_struct_find_property(op->ptr, "set_view_transform")) && - RNA_property_boolean_get(op->ptr, prop)) { + RNA_property_boolean_get(op->ptr, prop)) + { load_data->flags |= SEQ_LOAD_SET_VIEW_TRANSFORM; } if ((prop = RNA_struct_find_property(op->ptr, "use_multiview")) && - RNA_property_boolean_get(op->ptr, prop)) { + RNA_property_boolean_get(op->ptr, prop)) + { if (op->customdata) { SequencerAddData *sad = op->customdata; ImageFormatData *imf = &sad->im_format; @@ -340,7 +344,8 @@ static void seq_load_apply_generic_options(bContext *C, wmOperator *op, Sequence } if (RNA_boolean_get(op->ptr, "overlap") == true || - !SEQ_transform_test_overlap(scene, ed->seqbasep, seq)) { + !SEQ_transform_test_overlap(scene, ed->seqbasep, seq)) + { /* No overlap should be handled or the strip is not overlapping, exit early. */ return; } @@ -996,7 +1001,8 @@ static int sequencer_add_movie_strip_invoke(bContext *C, /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) || - RNA_struct_property_is_set(op->ptr, "filepath")) { + RNA_struct_property_is_set(op->ptr, "filepath")) + { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); return sequencer_add_movie_strip_exec(C, op); } @@ -1153,7 +1159,8 @@ static int sequencer_add_sound_strip_invoke(bContext *C, /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) || - RNA_struct_property_is_set(op->ptr, "filepath")) { + RNA_struct_property_is_set(op->ptr, "filepath")) + { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); return sequencer_add_sound_strip_exec(C, op); } @@ -1239,14 +1246,14 @@ void sequencer_image_seq_reserve_frames( RNA_END; if (filename) { - char ext[PATH_MAX]; - char filename_stripped[PATH_MAX]; + char ext[FILE_MAX]; + char filename_stripped[FILE_MAX]; /* Strip the frame from filename and substitute with `#`. */ BLI_path_frame_strip(filename, ext, sizeof(ext)); for (int i = 0; i < len; i++, se++) { BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped)); - BLI_path_frame(filename_stripped, minframe + i, numdigits); + BLI_path_frame(filename_stripped, sizeof(filename_stripped), minframe + i, numdigits); BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext); } @@ -1277,7 +1284,7 @@ static void sequencer_add_image_strip_load_files(wmOperator *op, const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); /* size of Strip->dir. */ char directory[768]; - BLI_split_dir_part(load_data->path, directory, sizeof(directory)); + BLI_path_split_dir_part(load_data->path, directory, sizeof(directory)); SEQ_add_image_set_directory(seq, directory); if (use_placeholders) { diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c b/source/blender/editors/space_sequencer/sequencer_drag_drop.c index 3f3737c5c6e..4fd796e52dc 100644 --- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c +++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c @@ -227,7 +227,7 @@ static void sequencer_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop) Image *ima = (Image *)id; PointerRNA itemptr; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(ima->filepath, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(ima->filepath, dir, sizeof(dir), file, sizeof(file)); RNA_string_set(drop->ptr, "directory", dir); RNA_collection_clear(drop->ptr, "files"); RNA_collection_add(drop->ptr, "files", &itemptr); @@ -257,7 +257,7 @@ static void sequencer_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop) PointerRNA itemptr; char dir[FILE_MAX], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); RNA_string_set(drop->ptr, "directory", dir); @@ -457,7 +457,7 @@ static void draw_seq_in_view(bContext *C, wmWindow *UNUSED(win), wmDrag *drag, c get_drag_path(drag, path); if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_NAME) { - BLI_split_file_part(path, filename, FILE_MAX); + BLI_path_split_file_part(path, filename, FILE_MAX); text_array[len_text_arr++] = filename; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index c650ebf27f7..b9c9bd6423f 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -100,7 +100,8 @@ void color3ubv_from_seq(const Scene *curscene, ListBase *channels = SEQ_channels_displayed_get(ed); if (show_strip_color_tag && (uint)seq->color_tag < SEQUENCE_COLOR_TOT && - seq->color_tag != SEQUENCE_COLOR_NONE) { + seq->color_tag != SEQUENCE_COLOR_NONE) + { bTheme *btheme = UI_GetTheme(); const ThemeStripColor *strip_color = &btheme->strip_color[seq->color_tag]; copy_v3_v3_uchar(r_col, strip_color->color); @@ -693,7 +694,8 @@ static void draw_seq_handle(const Scene *scene, /* Draw numbers for start and end of the strip next to its handles. */ if (y_threshold && - (((seq->flag & SELECT) && (G.moving & G_TRANSFORM_SEQ)) || (seq->flag & whichsel))) { + (((seq->flag & SELECT) && (G.moving & G_TRANSFORM_SEQ)) || (seq->flag & whichsel))) + { char numstr[64]; size_t numstr_len; @@ -1253,8 +1255,8 @@ static void draw_seq_fcurve_overlay( float prev_val = INT_MIN; bool skip = false; - for (int timeline_frame = eval_start; timeline_frame <= eval_end; - timeline_frame += eval_step) { + for (int timeline_frame = eval_start; timeline_frame <= eval_end; timeline_frame += eval_step) + { curve_val = evaluate_fcurve(fcu, timeline_frame); CLAMP(curve_val, 0.0f, 1.0f); @@ -1330,7 +1332,8 @@ static void draw_seq_strip(const bContext *C, bool y_threshold; if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_NAME) || (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_SOURCE) || - (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION)) { + (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION)) + { /* Calculate height needed for drawing text on strip. */ text_margin_y = y2 - min_ff(0.40f, 20 * UI_SCALE_FAC * pixely); @@ -1368,19 +1371,21 @@ static void draw_seq_strip(const bContext *C, x2 = SEQ_time_right_handle_frame_get(scene, seq); if ((seq->type == SEQ_TYPE_META) || - ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) { + ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) + { drawmeta_contents(scene, seq, x1, y1, x2, y2, show_strip_color_tag); } if ((sseq->flag & SEQ_SHOW_OVERLAY) && (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS) && - ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { + ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) + { draw_seq_strip_thumbnail( v2d, C, scene, seq, y1, y_threshold ? text_margin_y : y2, pixelx, pixely); } - if ((sseq->flag & SEQ_SHOW_OVERLAY) && - (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_FCURVES)) { + if ((sseq->flag & SEQ_SHOW_OVERLAY) && (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_FCURVES)) + { draw_seq_fcurve_overlay(scene, v2d, seq, x1, y1, x2, y2, pixelx); } @@ -1419,7 +1424,8 @@ static void draw_seq_strip(const bContext *C, if (seq->type == SEQ_TYPE_SOUND_RAM) { if (!y_threshold && (sseq->timeline_overlay.flag & SEQ_TIMELINE_NO_WAVEFORMS) == 0 && ((sseq->timeline_overlay.flag & SEQ_TIMELINE_ALL_WAVEFORMS) || - (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) { + (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) + { return; } } @@ -2079,7 +2085,8 @@ static void seq_draw_image_origin_and_outline(const bContext *C, Sequence *seq, return; } if ((sseq->flag & SEQ_SHOW_OVERLAY) == 0 || - (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_OUTLINE_SELECTED) == 0) { + (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_OUTLINE_SELECTED) == 0) + { return; } if (ELEM(sseq->mainb, SEQ_DRAW_IMG_WAVEFORM, SEQ_DRAW_IMG_VECTORSCOPE, SEQ_DRAW_IMG_HISTOGRAM)) { @@ -2184,7 +2191,8 @@ void sequencer_draw_preview(const bContext *C, /* Draw background. */ if (!draw_backdrop && - (!draw_overlay || (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_REFERENCE))) { + (!draw_overlay || (sseq->overlay_frame_type == SEQ_OVERLAY_FRAME_TYPE_REFERENCE))) + { sequencer_preview_clear(); if (sseq->flag & SEQ_USE_ALPHA) { @@ -2286,11 +2294,13 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region) continue; } if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) > - v2d->cur.xmax) { + v2d->cur.xmax) + { continue; } if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), - SEQ_time_content_end_frame_get(scene, seq)) < v2d->cur.xmin) { + SEQ_time_content_end_frame_get(scene, seq)) < v2d->cur.xmin) + { continue; } if (seq->machine + 1.0f < v2d->cur.ymin) { @@ -2488,7 +2498,8 @@ static bool draw_cache_view_iter_fn(void *userdata, vert_count = &drawdata->raw_vert_count; } else if ((cache_type & SEQ_CACHE_STORE_PREPROCESSED) && - (drawdata->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED)) { + (drawdata->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED)) + { stripe_ofs_y = drawdata->stripe_ofs_y; stripe_ht = drawdata->stripe_ht; stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + (stripe_ofs_y + stripe_ht) + stripe_ofs_y; @@ -2497,7 +2508,8 @@ static bool draw_cache_view_iter_fn(void *userdata, vert_count = &drawdata->preprocessed_vert_count; } else if ((cache_type & SEQ_CACHE_STORE_COMPOSITE) && - (drawdata->cache_flag & SEQ_CACHE_VIEW_COMPOSITE)) { + (drawdata->cache_flag & SEQ_CACHE_VIEW_COMPOSITE)) + { stripe_ofs_y = drawdata->stripe_ofs_y; stripe_ht = drawdata->stripe_ht; stripe_top = seq->machine + SEQ_STRIP_OFSTOP - stripe_ofs_y; @@ -2575,7 +2587,8 @@ static void draw_cache_view(const bContext *C) } if (SEQ_time_left_handle_frame_get(scene, seq) > v2d->cur.xmax || - SEQ_time_right_handle_frame_get(scene, seq) < v2d->cur.xmin) { + SEQ_time_right_handle_frame_get(scene, seq) < v2d->cur.xmin) + { continue; } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index feccd21cf79..db05e572911 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -219,7 +219,8 @@ bool sequencer_view_has_preview_poll(bContext *C) return false; } if (!(ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW) && - (sseq->mainb == SEQ_DRAW_IMG_IMBUF))) { + (sseq->mainb == SEQ_DRAW_IMG_IMBUF))) + { return false; } ARegion *region = CTX_wm_region(C); @@ -372,7 +373,8 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) /* Check meta-strips. */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !SEQ_transform_is_locked(channels, seq) && - SEQ_transform_sequence_can_be_translated(seq)) { + SEQ_transform_sequence_can_be_translated(seq)) + { if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) { SEQ_transform_translate_sequence(scene, seq, (snap_frame - seq->startofs) - seq->start); } @@ -1256,14 +1258,16 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) if (!seq_effect_find_selected( scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg) || - SEQ_effect_get_num_inputs(last_seq->type) == 0) { + SEQ_effect_get_num_inputs(last_seq->type) == 0) + { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } /* Check if reassigning would create recursivity. */ if (SEQ_relations_render_loop_check(seq1, last_seq) || SEQ_relations_render_loop_check(seq2, last_seq) || - SEQ_relations_render_loop_check(seq3, last_seq)) { + SEQ_relations_render_loop_check(seq3, last_seq)) + { BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: recursion detected"); return OPERATOR_CANCELLED; } @@ -2220,7 +2224,8 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i seq = ed->seqbasep->first; while (seq) { if ((seq != test) && (test->machine == seq->machine) && - ((sel == -1) || (sel == (seq->flag & SELECT)))) { + ((sel == -1) || (sel == (seq->flag & SELECT)))) + { dist = MAXFRAME * 2; switch (lr) { @@ -2278,11 +2283,13 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) /* Disallow effect strips. */ if (SEQ_effect_get_num_inputs(seq->type) >= 1 && - (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) { + (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) + { return OPERATOR_CANCELLED; } if ((SEQ_effect_get_num_inputs(active_seq->type) >= 1) && - (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) { + (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) + { return OPERATOR_CANCELLED; } @@ -2298,7 +2305,8 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) /* Do this in a new loop since both effects need to be calculated first. */ for (iseq = seqbase->first; iseq; iseq = iseq->next) { if ((iseq->type & SEQ_TYPE_EFFECT) && - (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { + (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) + { /* This may now overlap. */ if (SEQ_transform_test_overlap(scene, seqbase, iseq)) { SEQ_transform_seqbase_shuffle(seqbase, iseq, scene); @@ -3152,7 +3160,8 @@ static bool seq_get_text_strip_cb(Sequence *seq, void *user_data) ListBase *channels = SEQ_channels_displayed_get(ed); /* Only text strips that are not muted and don't end with negative frame. */ if ((seq->type == SEQ_TYPE_TEXT) && !SEQ_render_is_muted(channels, seq) && - (SEQ_time_right_handle_frame_get(cd->scene, seq) > cd->scene->r.sfra)) { + (SEQ_time_right_handle_frame_get(cd->scene, seq) > cd->scene->r.sfra)) + { BLI_addtail(cd->text_seq, MEM_dupallocN(seq)); } return true; @@ -3178,7 +3187,7 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op) /* Avoid File write exceptions. */ if (!BLI_exists(filepath)) { - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); if (!BLI_file_touch(filepath)) { BKE_report(op->reports, RPT_ERROR, "Can't create subtitle file"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc index d622b624fa8..ece8557782e 100644 --- a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc +++ b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc @@ -380,7 +380,8 @@ static void retime_speed_text_draw(const bContext *C, int next_handle_index = SEQ_retiming_handle_index_get(seq, handle) + 1; const SeqRetimingHandle *next_handle = &SEQ_retiming_handles_get(seq)[next_handle_index]; if (handle_x_get(scene, seq, next_handle) < start_frame || - handle_x_get(scene, seq, handle) > end_frame) { + handle_x_get(scene, seq, handle) > end_frame) + { return; /* Label out of strip bounds. */ } @@ -456,7 +457,8 @@ static int gizmo_retime_handle_test_select(bContext *C, wmGizmo *gz, const int m } if (handle_x_get(scene, seq, handle) == SEQ_time_left_handle_frame_get(scene, seq) || - handle_index == 0) { + handle_index == 0) + { return -1; } @@ -532,7 +534,8 @@ static int gizmo_retime_remove_test_select(bContext *C, wmGizmo *gz, const int m } if (handle_x_get(scene, seq, handle) == SEQ_time_left_handle_frame_get(scene, seq) || - handle_index == 0) { + handle_index == 0) + { return -1; /* Ignore first handle. */ } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 6971d8dd06b..036afc4f428 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -271,8 +271,8 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq != test) && (test->machine == seq->machine) && - ((sel == -1) || (sel && (seq->flag & SELECT)) || - (sel == 0 && (seq->flag & SELECT) == 0))) { + ((sel == -1) || (sel && (seq->flag & SELECT)) || (sel == 0 && (seq->flag & SELECT) == 0))) + { switch (lr) { case SEQ_SIDE_LEFT: if (SEQ_time_left_handle_frame_get(scene, test) == @@ -322,7 +322,8 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ ((SEQ_time_left_handle_frame_get(scene, seq) > SEQ_time_right_handle_frame_get(scene, seq)) && (SEQ_time_left_handle_frame_get(scene, seq) >= x && - SEQ_time_right_handle_frame_get(scene, seq) <= x))) { + SEQ_time_right_handle_frame_get(scene, seq) <= x))) + { if (SEQ_transform_sequence_can_be_translated(seq)) { /* Clamp handles to defined size in pixel space. */ @@ -592,7 +593,8 @@ static void sequencer_select_side_of_frame(const bContext *C, if (((x < scene->r.cfra) && (SEQ_time_right_handle_frame_get(scene, seq_iter) <= scene->r.cfra)) || ((x >= scene->r.cfra) && - (SEQ_time_left_handle_frame_get(scene, seq_iter) >= scene->r.cfra))) { + (SEQ_time_left_handle_frame_get(scene, seq_iter) >= scene->r.cfra))) + { /* Select left or right. */ seq_iter->flag |= SELECT; recurs_sel_seq(seq_iter); @@ -606,7 +608,8 @@ static void sequencer_select_side_of_frame(const bContext *C, for (tmarker = scene->markers.first; tmarker; tmarker = tmarker->next) { if (((x < scene->r.cfra) && (tmarker->frame <= scene->r.cfra)) || - ((x >= scene->r.cfra) && (tmarker->frame >= scene->r.cfra))) { + ((x >= scene->r.cfra) && (tmarker->frame >= scene->r.cfra))) + { tmarker->flag |= SELECT; } else { @@ -1874,8 +1877,8 @@ static bool select_grouped_type_effect(SeqCollection *strips, Sequence *seq; SEQ_ITERATOR_FOREACH (seq, strips) { - if (SEQ_CHANNEL_CHECK(seq, channel) && - (is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) { + if (SEQ_CHANNEL_CHECK(seq, channel) && (is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) + { seq->flag |= SELECT; changed = true; } @@ -1901,7 +1904,8 @@ static bool select_grouped_data(SeqCollection *strips, if (SEQ_HAS_PATH(actseq) && dir) { SEQ_ITERATOR_FOREACH (seq, strips) { if (SEQ_CHANNEL_CHECK(seq, channel) && SEQ_HAS_PATH(seq) && seq->strip && - STREQ(seq->strip->dir, dir)) { + STREQ(seq->strip->dir, dir)) + { seq->flag |= SELECT; changed = true; } @@ -1919,8 +1923,8 @@ static bool select_grouped_data(SeqCollection *strips, else if (actseq->type == SEQ_TYPE_MOVIECLIP) { MovieClip *clip = actseq->clip; SEQ_ITERATOR_FOREACH (seq, strips) { - if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP && - seq->clip == clip) { + if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP && seq->clip == clip) + { seq->flag |= SELECT; changed = true; } @@ -1954,7 +1958,8 @@ static bool select_grouped_effect(SeqCollection *strips, Sequence *seq; SEQ_ITERATOR_FOREACH (seq, strips) { if (SEQ_CHANNEL_CHECK(seq, channel) && (seq->type & SEQ_TYPE_EFFECT) && - SEQ_relation_is_effect_of_strip(seq, actseq)) { + SEQ_relation_is_effect_of_strip(seq, actseq)) + { effects[seq->type] = true; } } @@ -1989,7 +1994,8 @@ static bool select_grouped_time_overlap(const Scene *scene, if (SEQ_time_left_handle_frame_get(scene, seq) < SEQ_time_right_handle_frame_get(scene, actseq) && SEQ_time_right_handle_frame_get(scene, seq) > - SEQ_time_left_handle_frame_get(scene, actseq)) { + SEQ_time_left_handle_frame_get(scene, actseq)) + { seq->flag |= SELECT; changed = true; } @@ -2011,7 +2017,8 @@ static void query_lower_channel_strips(const Scene *scene, if (SEQ_time_right_handle_frame_get(scene, seq_test) <= SEQ_time_left_handle_frame_get(scene, seq_reference) || SEQ_time_left_handle_frame_get(scene, seq_test) >= - SEQ_time_right_handle_frame_get(scene, seq_reference)) { + SEQ_time_right_handle_frame_get(scene, seq_reference)) + { continue; /* Not intersecting in time. */ } SEQ_collection_append_strip(seq_test, collection); diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c b/source/blender/editors/space_sequencer/sequencer_thumbnails.c index 954465e590d..c20717dd386 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c @@ -75,11 +75,13 @@ static bool check_seq_need_thumbnails(const Scene *scene, Sequence *seq, rctf *v return false; } if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) > - view_area->xmax) { + view_area->xmax) + { return false; } if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), - SEQ_time_content_end_frame_get(scene, seq)) < view_area->xmin) { + SEQ_time_content_end_frame_get(scene, seq)) < view_area->xmin) + { return false; } if (seq->machine + 1.0f < view_area->ymin) { @@ -293,13 +295,15 @@ static void sequencer_thumbnail_start_job_if_necessary( /* Job start requested, but over area which has been processed. Unless `thumbnail_is_missing` is * true, ignore this request as all images are in view. */ if (v2d->cur.xmax == sseq->runtime.last_thumbnail_area.xmax && - v2d->cur.ymax == sseq->runtime.last_thumbnail_area.ymax && !thumbnail_is_missing) { + v2d->cur.ymax == sseq->runtime.last_thumbnail_area.ymax && !thumbnail_is_missing) + { return; } /* Stop the job first as view has changed. Pointless to continue old job. */ if (v2d->cur.xmax != sseq->runtime.last_thumbnail_area.xmax || - v2d->cur.ymax != sseq->runtime.last_thumbnail_area.ymax) { + v2d->cur.ymax != sseq->runtime.last_thumbnail_area.ymax) + { WM_jobs_stop(CTX_wm_manager(C), NULL, thumbnail_start_job); } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 25d1313f1a0..15d2e557957 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -274,7 +274,8 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) } /* Final check that both preview and main height are reasonable. */ if (region_preview->sizey < 10 || region_main->sizey < 10 || - region_preview->sizey + region_main->sizey > height) { + region_preview->sizey + region_main->sizey > height) + { region_preview->sizey = roundf(height * 0.4f); region_main->sizey = (int)(height - region_preview->sizey); view_changed = true; @@ -751,7 +752,8 @@ static bool is_cursor_visible(const SpaceSeq *sseq) } if ((sseq->flag & SEQ_SHOW_OVERLAY) && - (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_2D_CURSOR) != 0) { + (sseq->preview_overlay.flag & SEQ_PREVIEW_SHOW_2D_CURSOR) != 0) + { return true; } return false; @@ -783,8 +785,8 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *region) over_cfra = scene->r.cfra + scene->ed->overlay_frame_ofs; } - if ((over_cfra != scene->r.cfra) || - (sseq->overlay_frame_type != SEQ_OVERLAY_FRAME_TYPE_RECT)) { + if ((over_cfra != scene->r.cfra) || (sseq->overlay_frame_type != SEQ_OVERLAY_FRAME_TYPE_RECT)) + { sequencer_draw_preview( C, scene, region, sseq, scene->r.cfra, over_cfra - scene->r.cfra, true, false); } diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 7b39b39c78b..5ea179dcd9a 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -297,7 +297,8 @@ Object *spreadsheet_get_object_eval(const SpaceSpreadsheet *sspreadsheet, OB_VOLUME, OB_CURVES_LEGACY, OB_FONT, - OB_CURVES)) { + OB_CURVES)) + { return nullptr; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index c20f6ac2f6a..24542f0c833 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -235,7 +235,8 @@ std::unique_ptr GeometryDataSource::get_column_values( if (component_->type() == GEO_COMPONENT_TYPE_INSTANCES) { if (const bke::Instances *instances = - static_cast(*component_).get_for_read()) { + static_cast(*component_).get_for_read()) + { if (STREQ(column_id.name, "Name")) { Span reference_handles = instances->reference_handles(); Span references = instances->references(); @@ -265,7 +266,8 @@ std::unique_ptr GeometryDataSource::get_column_values( const MeshComponent &component = static_cast(*component_); if (const Mesh *mesh = component.get_for_read()) { if (std::unique_ptr values = build_mesh_debug_columns( - *mesh, domain_, column_id.name)) { + *mesh, domain_, column_id.name)) + { return values; } } @@ -525,7 +527,8 @@ GeometrySet spreadsheet_get_display_geometry_set(const SpaceSpreadsheet *sspread else { if (const ViewerNodeLog *viewer_log = nodes::geo_eval_log::GeoModifierLog::find_viewer_node_log_for_path( - sspreadsheet->viewer_path)) { + sspreadsheet->viewer_path)) + { geometry_set = viewer_log->geometry; } } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index 5007e859a0f..7d1dfc50cd2 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -134,7 +134,8 @@ static void spreadsheet_filter_panel_draw_header(const bContext *C, Panel *panel const SpreadsheetColumn *column = lookup_visible_column_for_filter(*sspreadsheet, column_name); if (!(sspreadsheet->filter_flag & SPREADSHEET_FILTER_ENABLE) || - (column == nullptr && !column_name.is_empty())) { + (column == nullptr && !column_name.is_empty())) + { uiLayoutSetActive(layout, false); } @@ -180,7 +181,8 @@ static void spreadsheet_filter_panel_draw(const bContext *C, Panel *panel) const SpreadsheetColumn *column = lookup_visible_column_for_filter(*sspreadsheet, column_name); if (!(sspreadsheet->filter_flag & SPREADSHEET_FILTER_ENABLE) || !(filter->flag & SPREADSHEET_ROW_FILTER_ENABLED) || - (column == nullptr && !column_name.is_empty())) { + (column == nullptr && !column_name.is_empty())) + { uiLayoutSetActive(layout, false); } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 9fc856c6d5a..fd939965531 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -289,7 +289,8 @@ static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region) if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle, win->eventstate->xy[0] - region->winrct.xmin, - st->runtime.scroll_region_handle.ymin)) { + st->runtime.scroll_region_handle.ymin)) + { wmcursor = WM_CURSOR_DEFAULT; } diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index f6cf5bb771e..c37a1f86119 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -163,12 +163,14 @@ static GHash *text_autocomplete_build(Text *text) i_pos = i_start; while ((i_start < linep->len) && !text_check_identifier_nodigit_unicode( - BLI_str_utf8_as_unicode_step(linep->line, linep->len, &i_pos))) { + BLI_str_utf8_as_unicode_step(linep->line, linep->len, &i_pos))) + { i_start = i_pos; } i_pos = i_end = i_start; while ((i_end < linep->len) && text_check_identifier_unicode(BLI_str_utf8_as_unicode_step( - linep->line, linep->len, &i_pos))) { + linep->line, linep->len, &i_pos))) + { i_end = i_pos; } @@ -176,12 +178,14 @@ static GHash *text_autocomplete_build(Text *text) /* Check we're at the beginning of a line or that the previous char is not an * identifier this prevents digits from being added. */ ((i_start < 1) || - !text_check_identifier_unicode(BLI_str_utf8_as_unicode(&linep->line[i_start - 1])))) { + !text_check_identifier_unicode(BLI_str_utf8_as_unicode(&linep->line[i_start - 1])))) + { char *str_sub = &linep->line[i_start]; const int choice_len = i_end - i_start; if ((choice_len > seek_len) && (seek_len == 0 || STREQLEN(seek, str_sub, seek_len)) && - (seek != str_sub)) { + (seek != str_sub)) + { // printf("Adding: %s\n", s); char str_sub_last = str_sub[choice_len]; str_sub[choice_len] = '\0'; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 5d3cd03ebb1..f43ab6ed56b 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -933,7 +933,8 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b (pix_bardiff * (lhlstart - st->top) / st->runtime.viewlines); } else if (lhlstart > st->top + st->runtime.viewlines && hlstart < barstart + barheight && - hlstart > barstart) { + hlstart > barstart) + { /* push hl start down */ hlstart = barstart + barheight; } @@ -947,8 +948,8 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b } /* the end of the highlight is in the current viewport */ - if (st->runtime.viewlines && lhlend >= st->top && - lhlend <= st->top + st->runtime.viewlines) { + if (st->runtime.viewlines && lhlend >= st->top && lhlend <= st->top + st->runtime.viewlines) + { /* Speed the progression of the end of the highlight through the scroll-bar. */ hlend = (((pix_available - pix_bardiff) * lhlend) / ltexth) + (pix_bardiff * (lhlend - st->top) / st->runtime.viewlines); @@ -958,7 +959,8 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b hlend = barstart; } else if (lhlend > st->top + st->runtime.viewlines && - lhlstart < st->top + st->runtime.viewlines && hlend < barstart + barheight) { + lhlstart < st->top + st->runtime.viewlines && hlend < barstart + barheight) + { /* fill out end */ hlend = barstart + barheight; } @@ -1453,7 +1455,8 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi /* Don't highlight brackets if syntax HL is off or bracket in string or comment. */ if (!linep->format || linep->format[fc] == FMT_TYPE_STRING || - linep->format[fc] == FMT_TYPE_COMMENT) { + linep->format[fc] == FMT_TYPE_COMMENT) + { return; } diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index f2dff82306d..bfa6552d0e9 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -270,7 +270,8 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Numbers (digits not part of an identifier and periods followed by digits) */ else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) || - (*str == '.' && text_check_digit(*(str + 1)))) { + (*str == '.' && text_check_digit(*(str + 1)))) + { *fmt = FMT_TYPE_NUMERAL; } /* Booleans */ diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index fa041697f01..2bef924ed95 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -291,7 +291,8 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Numbers (digits not part of an identifier and periods followed by digits) */ else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) || - (*str == '.' && text_check_digit(*(str + 1)))) { + (*str == '.' && text_check_digit(*(str + 1)))) + { *fmt = FMT_TYPE_NUMERAL; } /* Punctuation */ diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 746e939752b..70e8fb5c8b6 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -863,7 +863,8 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ } /* Numbers (digits not part of an identifier and periods followed by digits) */ else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) || - (*str == '.' && text_check_digit(*(str + 1)))) { + (*str == '.' && text_check_digit(*(str + 1)))) + { *fmt = FMT_TYPE_NUMERAL; } /* Booleans */ diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index 60e37700efe..cdc0cd8d0ef 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -441,7 +441,8 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool } /* Numbers (digits not part of an identifier and periods followed by digits) */ else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) || - (*str == '.' && text_check_digit(*(str + 1)))) { + (*str == '.' && text_check_digit(*(str + 1)))) + { *fmt = FMT_TYPE_NUMERAL; } /* Booleans */ diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 9237e831da9..0b6ab32236f 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -302,7 +302,8 @@ static int txtfmt_py_literal_numeral(const char *string, char prev_fmt) } } else if ((prev_fmt != FMT_TYPE_DEFAULT) && - (text_check_digit(first) || (first == '.' && text_check_digit(second)))) { + (text_check_digit(first) || (first == '.' && text_check_digit(second)))) + { /* New numeral, starting with a digit or a decimal point followed by a digit. */ return txtfmt_py_find_numeral_inner(string); } @@ -446,7 +447,8 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n } else if (((ELEM(*str, 'f', 'F') && ELEM(*(str + 1), 'r', 'R')) || (ELEM(*str, 'r', 'R') && ELEM(*(str + 1), 'f', 'F'))) && - ELEM(*(str + 2), '"', '\'')) { + ELEM(*(str + 2), '"', '\'')) + { /* Strings with two letter prefixes (raw f-strings). * Format the prefix as part of the string. */ *fmt = FMT_TYPE_STRING; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 7239d2b73b4..fa6a7469141 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2445,7 +2445,8 @@ static int text_delete_exec(bContext *C, wmOperator *op) if (*curr != '\0') { const char *prev = BLI_str_find_prev_char_utf8(curr, text->curl->line); if ((curr != prev) && /* When back-spacing from the start of the line. */ - (*curr == text_closing_character_pair_get(*prev))) { + (*curr == text_closing_character_pair_get(*prev))) + { txt_move_right(text, false); txt_backspace_char(text); } @@ -2711,7 +2712,8 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event) if (scroll_ofs_new[0] != st->left || scroll_ofs_new[1] != st->top || /* Horizontal sub-pixel offset currently isn't used. */ /* scroll_ofs_px_new[0] != st->scroll_ofs_px[0] || */ - scroll_ofs_px_new[1] != st->runtime.scroll_ofs_px[1]) { + scroll_ofs_px_new[1] != st->runtime.scroll_ofs_px[1]) + { st->left = scroll_ofs_new[0]; st->top = scroll_ofs_new[1]; @@ -2882,9 +2884,11 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev /* verify we are in the right zone */ if (mval[0] > st->runtime.scroll_region_handle.xmin && - mval[0] < st->runtime.scroll_region_handle.xmax) { + mval[0] < st->runtime.scroll_region_handle.xmax) + { if (mval[1] >= st->runtime.scroll_region_handle.ymin && - mval[1] <= st->runtime.scroll_region_handle.ymax) { + mval[1] <= st->runtime.scroll_region_handle.ymax) + { /* mouse inside scroll handle */ zone = SCROLLHANDLE_BAR; } @@ -3042,7 +3046,8 @@ static void text_cursor_set_to_pos_wrapped( char ch; for (j = 0; !found && ((ch = linep->line[j]) != '\0'); - j += BLI_str_utf8_size_safe(linep->line + j)) { + j += BLI_str_utf8_size_safe(linep->line + j)) + { int chars; int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab */ @@ -3419,7 +3424,8 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm if (!(mval[0] > 2 && mval[0] < (TXT_NUMCOL_WIDTH(st) + (TXT_BODY_LPAD * st->runtime.cwidth_px)) && - mval[1] > 2 && mval[1] < region->winy - 2)) { + mval[1] > 2 && mval[1] < region->winy - 2)) + { return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index feb1850e27b..b863bf9044c 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -131,7 +131,7 @@ static int preferences_asset_library_add_exec(bContext *UNUSED(C), wmOperator *o char dirname[FILE_MAXFILE]; BLI_path_slash_rstrip(path); - BLI_split_file_part(path, dirname, sizeof(dirname)); + BLI_path_split_file_part(path, dirname, sizeof(dirname)); /* NULL is a valid directory path here. A library without path will be created then. */ const bUserAssetLibrary *new_library = BKE_preferences_asset_library_add(&U, dirname, path); diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 3e1d3566506..e5c9ab67b80 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -119,7 +119,8 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_regi RegionView3D *rv3d; if ((region->regiontype == RGN_TYPE_WINDOW) && (rv3d = static_cast(region->regiondata)) && - (rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) { + (rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) + { *r_v3d = v3d; *r_region = region; return true; @@ -2004,7 +2005,8 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes static void view3d_id_remap_v3d_ob_centers(View3D *v3d, const struct IDRemapper *mappings) { if (BKE_id_remapper_apply(mappings, (ID **)&v3d->ob_center, ID_REMAP_APPLY_DEFAULT) == - ID_REMAP_RESULT_SOURCE_UNASSIGNED) { + ID_REMAP_RESULT_SOURCE_UNASSIGNED) + { /* Otherwise, bone-name may remain valid... * We could be smart and check this, too? */ v3d->ob_center_bone[0] = '\0'; @@ -2019,7 +2021,8 @@ static void view3d_id_remap_v3d(ScrArea *area, { ARegion *region; if (BKE_id_remapper_apply(mappings, (ID **)&v3d->camera, ID_REMAP_APPLY_DEFAULT) == - ID_REMAP_RESULT_SOURCE_UNASSIGNED) { + ID_REMAP_RESULT_SOURCE_UNASSIGNED) + { /* 3D view might be inactive, in that case needs to use slink->regionbase */ ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase : &slink->regionbase; @@ -2038,8 +2041,9 @@ static void view3d_id_remap_v3d(ScrArea *area, static void view3d_id_remap(ScrArea *area, SpaceLink *slink, const struct IDRemapper *mappings) { - if (!BKE_id_remapper_has_mapping_for( - mappings, FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_IM | FILTER_ID_MC)) { + if (!BKE_id_remapper_has_mapping_for(mappings, + FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_IM | FILTER_ID_MC)) + { return; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index badb6f65397..921ade101c7 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -117,7 +117,8 @@ static void *editmesh_partial_update_begin_fn(struct bContext *UNUSED(C), { const int retval_test = B_TRANSFORM_PANEL_MEDIAN; if (BLI_array_findindex( - params->unique_retval_ids, params->unique_retval_ids_len, &retval_test) == -1) { + params->unique_retval_ids, params->unique_retval_ids_len, &retval_test) == -1) + { return NULL; } @@ -969,7 +970,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if ((ob->type == OB_MESH) && (apply_vcos || median_basis.mesh.bv_weight || median_basis.mesh.v_crease || median_basis.mesh.skin[0] || median_basis.mesh.skin[1] || median_basis.mesh.be_weight || - median_basis.mesh.e_crease)) { + median_basis.mesh.e_crease)) + { const TransformMedian_Mesh *median = &median_basis.mesh, *ve_median = &ve_median_basis.mesh; Mesh *me = ob->data; BMEditMesh *em = me->edit_mesh; @@ -1101,7 +1103,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF) && (apply_vcos || median_basis.curve.b_weight || median_basis.curve.weight || - median_basis.curve.radius || median_basis.curve.tilt)) { + median_basis.curve.radius || median_basis.curve.tilt)) + { const TransformMedian_Curve *median = &median_basis.curve, *ve_median = &ve_median_basis.curve; Curve *cu = ob->data; @@ -1769,8 +1772,8 @@ static void view3d_panel_transform(const bContext *C, Panel *panel) v3d_transform_butsR(col, &obptr); /* Dimensions and editmode are mostly the same check. */ - if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || - ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) { + if (OB_TYPE_SUPPORT_EDITMODE(ob->type) || ELEM(ob->type, OB_VOLUME, OB_CURVES, OB_POINTCLOUD)) + { View3D *v3d = CTX_wm_view3d(C); v3d_object_dimension_buts(NULL, col, v3d, ob); } diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index cf3841f2b1c..141222c746c 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -533,7 +533,8 @@ static bool v3d_cursor_is_snap_invert(SnapCursorDataIntern *data_intern, const w if ((ELEM(kmi->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY) && (event->modifier & KM_CTRL)) || (ELEM(kmi->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY) && (event->modifier & KM_SHIFT)) || (ELEM(kmi->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY) && (event->modifier & KM_ALT)) || - ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) { + ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) + { return true; } } @@ -769,7 +770,8 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state, snap_elem_index[0] = index; } else if (snap_elem & - (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { + (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) + { snap_elem_index[1] = index; } else if (snap_elem == SCE_SNAP_MODE_FACE_RAYCAST) { diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index ae4598f649e..c2d718641d9 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -233,7 +233,8 @@ static bool view3d_stereo3d_active(wmWindow *win, return false; } if (((scene->r.views_format & SCE_VIEWS_FORMAT_MULTIVIEW) != 0) && - !BKE_scene_multiview_is_stereo3d(&scene->r)) { + !BKE_scene_multiview_is_stereo3d(&scene->r)) + { return false; } break; @@ -359,7 +360,8 @@ void ED_view3d_draw_setup_view(const wmWindowManager *wm, } else #endif - if (view3d_stereo3d_active(win, scene, v3d, rv3d)) { + if (view3d_stereo3d_active(win, scene, v3d, rv3d)) + { view3d_stereo3d_setup(depsgraph, scene, v3d, region, rect); } else { @@ -1475,7 +1477,8 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) #ifdef WITH_INPUT_NDOF if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) && - (rv3d->persp != RV3D_CAMOB)) { + (rv3d->persp != RV3D_CAMOB)) + { /* TODO: draw something else (but not this) during fly mode */ draw_rotation_guide(rv3d); } @@ -1712,7 +1715,8 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, GPU_matrix_identity_set(); if ((viewname != nullptr && viewname[0] != '\0') && (viewmat == nullptr) && - rv3d->persp == RV3D_CAMOB && v3d->camera) { + rv3d->persp == RV3D_CAMOB && v3d->camera) + { view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, region, winmat, viewname); } else { @@ -2175,7 +2179,8 @@ static void validate_object_select_id(struct Depsgraph *depsgraph, UNUSED_VARS_NDEBUG(region); if (obact_eval && (obact_eval->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) || - BKE_paint_select_face_test(obact_eval))) { + BKE_paint_select_face_test(obact_eval))) + { /* do nothing */ } /* texture paint mode sampling */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 39b6dcd385f..74ba05dd837 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -925,7 +925,8 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, NULL, &ob_dummy, obmat, - NULL) != 0) { + NULL) != 0) + { if (use_depth) { copy_v3_v3(cursor_co, ray_co); } @@ -1025,7 +1026,8 @@ void ED_view3d_cursor3d_update(bContext *C, if ((ED_view3d_project_float_global( region, cursor_prev.location, co_2d_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && (ED_view3d_project_float_global( - region, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { + region, cursor_curr->location, co_2d_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) + { rv3d->ofs_lock[0] += (co_2d_curr[0] - co_2d_prev[0]) / (region->winx * 0.5f); rv3d->ofs_lock[1] += (co_2d_curr[1] - co_2d_prev[1]) / (region->winy * 0.5f); } @@ -1198,7 +1200,8 @@ static int toggle_xray_exec(bContext *C, wmOperator *op) Object *obact = CTX_data_active_object(C); if (obact && ((obact->mode & OB_MODE_POSE) || - ((obact->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))) { + ((obact->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(obact)))) + { v3d->overlay.flag ^= V3D_OVERLAY_BONE_SELECT; } else { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index db201466e51..bf26aeda95e 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -51,7 +51,8 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED( return false; } if ((v3d->gizmo_show_camera & V3D_GIZMO_SHOW_CAMERA_LENS) == 0 && - (v3d->gizmo_show_camera & V3D_GIZMO_SHOW_CAMERA_DOF_DIST) == 0) { + (v3d->gizmo_show_camera & V3D_GIZMO_SHOW_CAMERA_DOF_DIST) == 0) + { return false; } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index f58f39d87a2..7ea80ef3d9b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -113,7 +113,8 @@ static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSE View3D *v3d = CTX_wm_view3d(C); if ((((U.uiflag & USER_SHOW_GIZMO_NAVIGATE) == 0) && (U.mini_axis_type != USER_MINI_AXIS_TYPE_GIZMO)) || - (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) { + (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) + { return false; } return true; @@ -239,7 +240,8 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g (navgroup->state.rect_visible.ymax == rect_visible->ymax) && (navgroup->state.rv3d.is_persp == rv3d->is_persp) && (navgroup->state.rv3d.is_camera == (rv3d->persp == RV3D_CAMOB)) && - (navgroup->state.rv3d.viewlock == RV3D_LOCK_FLAGS(rv3d))) { + (navgroup->state.rv3d.viewlock == RV3D_LOCK_FLAGS(rv3d))) + { return; } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc index d912f279b59..d4a7d87d7de 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc @@ -161,7 +161,8 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int &base_index_face, &eve_test, &eed_test, - &efa_test)) { + &efa_test)) + { if (EDBM_preselect_action_get(gz_ele->psel) == PRESELECT_ACTION_DELETE) { /* Delete action */ if (efa_test) { @@ -193,7 +194,8 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int best.base_index = base_index_vert; } if (!BM_vert_is_boundary(vert) && - EDBM_preselect_action_get(gz_ele->psel) != PRESELECT_ACTION_DELETE) { + EDBM_preselect_action_get(gz_ele->psel) != PRESELECT_ACTION_DELETE) + { best.ele = (BMElem *)eve_test; best.base_index = base_index_vert; } @@ -358,7 +360,8 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const View3D *v3d = CTX_wm_view3d(C); BKE_view_layer_synced_ensure(scene, view_layer); if ((gz_ring->bases) == nullptr || - (gz_ring->bases[0] != BKE_view_layer_active_base_get(view_layer))) { + (gz_ring->bases[0] != BKE_view_layer_active_base_get(view_layer))) + { MEM_SAFE_FREE(gz_ring->bases); gz_ring->bases = BKE_view_layer_array_from_bases_in_edit_mode( scene, view_layer, v3d, &gz_ring->bases_len); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc index 8851c662cbe..010fe1ff4c9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc @@ -532,7 +532,8 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup) BKE_gpencil_free_strokes(gpf); for (ruler_item = gzgroup_ruler_item_first_get(gzgroup); ruler_item; - ruler_item = (RulerItem *)ruler_item->gz.next) { + ruler_item = (RulerItem *)ruler_item->gz.next) + { bGPDspoint *pt; int j; @@ -865,7 +866,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) float rot_90_vec[2] = {-dir_ruler[1], dir_ruler[0]}; normalize_v2(rot_90_vec); posit[1] += rot_90_vec[0] * numstr_size[1]; - posit[0] += ((rot_90_vec[1] < 0)) ? numstr_size[0] : -numstr_size[0]; + posit[0] += (rot_90_vec[1] < 0) ? numstr_size[0] : -numstr_size[0]; /* draw text (bg) */ if (proj_ok[1]) { @@ -946,7 +947,8 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) const float len = len_v2v2(co_ss[0], co_ss[2]); if ((len < (numstr_size[1] * 2.5f)) || - ((len < (numstr_size[0] + bg_margin + bg_margin)) && (fabs(rot_90_vec[0]) < 0.5f))) { + ((len < (numstr_size[0] + bg_margin + bg_margin)) && (fabs(rot_90_vec[0]) < 0.5f))) + { /* Super short, or quite short and also shallow angle. Position below line.*/ posit[1] = MIN2(co_ss[0][1], co_ss[2][1]) - numstr_size[1] - bg_margin - bg_margin; } @@ -1066,7 +1068,8 @@ static int gizmo_ruler_modal(bContext *C, if (ruler_info->state == RULER_STATE_DRAG) { struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (view3d_ruler_item_mousemove( - C, depsgraph, ruler_info, ruler_item, event->mval, do_thickness, do_snap)) { + C, depsgraph, ruler_info, ruler_item, event->mval, do_thickness, do_snap)) + { do_draw = true; } } @@ -1282,7 +1285,8 @@ static bool view3d_ruler_poll(bContext *C) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == nullptr) || !STREQ(view3d_gzgt_ruler_id, tref_rt->gizmo_group) || - CTX_wm_region_view3d(C) == nullptr) { + CTX_wm_region_view3d(C) == nullptr) + { return false; } return true; @@ -1316,7 +1320,8 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e WM_gizmo_highlight_set(gzmap, &ruler_item->gz); if (WM_operator_name_call( C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_REGION_WIN, nullptr, event) == - OPERATOR_RUNNING_MODAL) { + OPERATOR_RUNNING_MODAL) + { RulerInfo *ruler_info = static_cast(gzgroup->customdata); RulerInteraction *inter = static_cast(ruler_item->gz.interaction_data); struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); diff --git a/source/blender/editors/space_view3d/view3d_iterators.cc b/source/blender/editors/space_view3d/view3d_iterators.cc index 3cd9d3c9d52..fd2eb73c717 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.cc +++ b/source/blender/editors/space_view3d/view3d_iterators.cc @@ -144,15 +144,16 @@ static bool view3d_project_segment_to_screen_with_content_clip_planes( /* Simple cases have been ruled out, clip by viewport planes, then re-project. */ float v_a_clip[3], v_b_clip[3]; - if (!clip_segment_v3_plane_n( - v_a, v_b, content_planes, content_planes_len, v_a_clip, v_b_clip)) { + if (!clip_segment_v3_plane_n(v_a, v_b, content_planes, content_planes_len, v_a_clip, v_b_clip)) + { return false; } if ((ED_view3d_project_float_object(region, v_a_clip, r_screen_co_a, clip_flag_nowin) != V3D_PROJ_RET_OK) || (ED_view3d_project_float_object(region, v_b_clip, r_screen_co_b, clip_flag_nowin) != - V3D_PROJ_RET_OK)) { + V3D_PROJ_RET_OK)) + { return false; } @@ -272,7 +273,8 @@ static void meshobject_foreachScreenVert__mapFunc(void *userData, float screen_co[2]; if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return; } @@ -324,7 +326,8 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, float screen_co[2]; if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return; } @@ -385,7 +388,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, data->content_planes, data->content_planes_len, screen_co_a, - screen_co_b)) { + screen_co_b)) + { return; } @@ -474,7 +478,8 @@ static void mesh_foreachScreenEdge_clip_bb_segment__mapFunc(void *userData, data->content_planes, data->content_planes_len, screen_co_a, - screen_co_b)) { + screen_co_b)) + { return; } @@ -549,7 +554,8 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, float screen_co[2]; if (ED_view3d_project_float_object(data->vc.region, cent, screen_co, data->clip_flag) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { return; } @@ -633,8 +639,8 @@ void nurbs_foreachScreenVert(ViewContext *vc, vc->region, bezt->vec[1], screen_co, - eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == - V3D_PROJ_RET_OK) { + eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) + { func(userData, nu, nullptr, bezt, 1, false, screen_co); } } @@ -643,24 +649,24 @@ void nurbs_foreachScreenVert(ViewContext *vc, vc->region, bezt->vec[0], screen_co, - eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == - V3D_PROJ_RET_OK) { + eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) + { func(userData, nu, nullptr, bezt, 0, true, screen_co); } if (ED_view3d_project_float_object( vc->region, bezt->vec[1], screen_co, - eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == - V3D_PROJ_RET_OK) { + eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) + { func(userData, nu, nullptr, bezt, 1, true, screen_co); } if (ED_view3d_project_float_object( vc->region, bezt->vec[2], screen_co, - eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == - V3D_PROJ_RET_OK) { + eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) + { func(userData, nu, nullptr, bezt, 2, true, screen_co); } } @@ -677,7 +683,8 @@ void nurbs_foreachScreenVert(ViewContext *vc, vc->region, bp->vec, screen_co, - eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) { + eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) + { func(userData, nu, bp, nullptr, -1, false, screen_co); } } @@ -742,7 +749,8 @@ void lattice_foreachScreenVert(ViewContext *vc, if (bp->hide == 0) { float screen_co[2]; if (ED_view3d_project_float_object(vc->region, dl ? co : bp->vec, screen_co, clip_flag) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { func(userData, bp, screen_co); } } @@ -800,13 +808,15 @@ void armature_foreachScreenBone(ViewContext *vc, content_planes, content_planes_len, screen_co_a, - screen_co_b)) { + screen_co_b)) + { continue; } } else { if (!view3d_project_segment_to_screen_with_clip_tag( - vc->region, v_a, v_b, clip_flag, screen_co_a, screen_co_b)) { + vc->region, v_a, v_b, clip_flag, screen_co_a, screen_co_b)) + { continue; } } @@ -871,13 +881,15 @@ void pose_foreachScreenBone(ViewContext *vc, content_planes, content_planes_len, screen_co_a, - screen_co_b)) { + screen_co_b)) + { continue; } } else { if (!view3d_project_segment_to_screen_with_clip_tag( - vc->region, v_a, v_b, clip_flag, screen_co_a, screen_co_b)) { + vc->region, v_a, v_b, clip_flag, screen_co_a, screen_co_b)) + { continue; } } diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index a7f8486ae9a..c57c6b9bb2a 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -432,7 +432,8 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) && /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ - ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) { + ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0) + { BKE_paint_stroke_get_average(scene, ob_act_eval, lastofs); is_set = true; } @@ -936,7 +937,8 @@ static bool view3d_object_skip_minmax(const View3D *v3d, } if ((ob->type == OB_EMPTY) && (ob->empty_drawtype == OB_EMPTY_IMAGE) && - !BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) { + !BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) + { *r_only_center = true; return false; } @@ -1209,7 +1211,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) * active/selection callback interface once... */ Base *base_eval; for (base_eval = (Base *)BKE_view_layer_object_bases_get(view_layer_eval)->first; base_eval; - base_eval = base_eval->next) { + base_eval = base_eval->next) + { if (BASE_SELECTED_EDITABLE(v3d, base_eval)) { if (base_eval->object->type == OB_ARMATURE) { if (base_eval->object->mode & OB_MODE_POSE) { @@ -1260,14 +1263,16 @@ static int viewselected_exec(bContext *C, wmOperator *op) else if (obedit) { /* only selected */ FOREACH_OBJECT_IN_MODE_BEGIN ( - scene_eval, view_layer_eval, v3d, obedit->type, obedit->mode, ob_eval_iter) { + scene_eval, view_layer_eval, v3d, obedit->type, obedit->mode, ob_eval_iter) + { ok |= ED_view3d_minmax_verts(ob_eval_iter, min, max); } FOREACH_OBJECT_IN_MODE_END; } else if (ob_eval && (ob_eval->mode & OB_MODE_POSE)) { FOREACH_OBJECT_IN_MODE_BEGIN ( - scene_eval, view_layer_eval, v3d, ob_eval->type, ob_eval->mode, ob_eval_iter) { + scene_eval, view_layer_eval, v3d, ob_eval->type, ob_eval->mode, ob_eval_iter) + { ok |= BKE_pose_minmax(ob_eval_iter, min, max, true, true); } FOREACH_OBJECT_IN_MODE_END; @@ -1279,7 +1284,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) ok = PE_minmax(depsgraph, scene, CTX_data_view_layer(C), min, max); } else if (ob_eval && (ob_eval->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | - OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { + OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) + { BKE_paint_stroke_get_average(scene, ob_eval, min); copy_v3_v3(max, min); ok = true; diff --git a/source/blender/editors/space_view3d/view3d_navigate_fly.c b/source/blender/editors/space_view3d/view3d_navigate_fly.c index 3e83f8085c7..b9420275aff 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_fly.c +++ b/source/blender/editors/space_view3d/view3d_navigate_fly.c @@ -817,7 +817,8 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) /* Should we redraw? */ if ((fly->speed != 0.0f) || moffset[0] || moffset[1] || (fly->zlock != FLY_AXISLOCK_STATE_OFF) || (fly->xlock != FLY_AXISLOCK_STATE_OFF) || - dvec[0] || dvec[1] || dvec[2]) { + dvec[0] || dvec[1] || dvec[2]) + { float dvec_tmp[3]; /* time how fast it takes for us to redraw, @@ -1095,7 +1096,8 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) } else #endif /* WITH_INPUT_NDOF */ - if (event->type == TIMER && event->customdata == fly->timer) { + if (event->type == TIMER && event->customdata == fly->timer) + { flyApply(C, fly, false); } diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c index 9b4e652ad63..d3dead3011f 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c +++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c @@ -270,7 +270,8 @@ void ED_view3d_smooth_view_ex( (sms.dst.lens == v3d->lens) && /* Lens. */ equals_v3v3(sms.dst.ofs, rv3d->ofs) && /* Offset. */ equals_v4v4(sms.dst.quat, rv3d->viewquat) /* Rotation. */ - ) { + ) + { /* Early return if nothing changed. */ return; } diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.c b/source/blender/editors/space_view3d/view3d_navigate_walk.c index 9aa8328287b..28b38c062a4 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_walk.c +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c @@ -499,7 +499,8 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int } if (walk->rv3d->persp == RV3D_CAMOB && - !BKE_id_is_editable(CTX_data_main(C), &walk->v3d->camera->id)) { + !BKE_id_is_editable(CTX_data_main(C), &walk->v3d->camera->id)) + { BKE_report(op->reports, RPT_ERROR, "Cannot navigate a camera from an external library or non-editable override"); @@ -820,7 +821,8 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event) case WALK_MODAL_JUMP: if ((walk->navigation_mode == WALK_MODE_GRAVITY) && (walk->gravity_state == WALK_GRAVITY_STATE_OFF) && - (walk->teleport.state == WALK_TELEPORT_STATE_OFF)) { + (walk->teleport.state == WALK_TELEPORT_STATE_OFF)) + { /* no need to check for ground, * walk->gravity wouldn't be off * if we were over a hole */ @@ -968,7 +970,8 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) if ((walk->active_directions) || moffset[0] || moffset[1] || walk->zlock == WALK_AXISLOCK_STATE_ACTIVE || walk->gravity_state != WALK_GRAVITY_STATE_OFF || - walk->teleport.state == WALK_TELEPORT_STATE_ON || is_confirm) { + walk->teleport.state == WALK_TELEPORT_STATE_ON || is_confirm) + { float dvec_tmp[3]; /* time how fast it takes for us to redraw, @@ -1181,7 +1184,8 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) /* stick to the floor */ if (walk->navigation_mode == WALK_MODE_GRAVITY && - ELEM(walk->gravity_state, WALK_GRAVITY_STATE_OFF, WALK_GRAVITY_STATE_START)) { + ELEM(walk->gravity_state, WALK_GRAVITY_STATE_OFF, WALK_GRAVITY_STATE_START)) + { bool ret; float ray_distance; @@ -1404,7 +1408,8 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) } else #endif /* WITH_INPUT_NDOF */ - if (event->type == TIMER && event->customdata == walk->timer) { + if (event->type == TIMER && event->customdata == walk->timer) + { walkApply(C, walk, false); } diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom.c b/source/blender/editors/space_view3d/view3d_navigate_zoom.c index b6a1769ebf2..4168f0cd90b 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom.c @@ -336,7 +336,8 @@ static void viewzoom_apply(ViewOpsData *vod, const bool zoom_to_pos = (vod->viewops_flag & VIEWOPS_FLAG_ZOOM_TO_MOUSE) != 0; if ((vod->rv3d->persp == RV3D_CAMOB) && - (vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) == 0) { + (vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) == 0) + { viewzoom_apply_camera(vod, xy, viewzoom, zoom_invert, zoom_to_pos); } else { diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c index fe83bbb7c59..d70c5a1ea1e 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.c @@ -97,7 +97,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } /* convert border to 3d coordinates */ if (!ED_view3d_unproject_v3(region, cent[0], cent[1], depth_close, p) || - !ED_view3d_unproject_v3(region, rect.xmin, rect.ymin, depth_close, p_corner)) { + !ED_view3d_unproject_v3(region, rect.xmin, rect.ymin, depth_close, p_corner)) + { return OPERATOR_CANCELLED; } @@ -120,8 +121,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_dist = rv3d->dist; /* convert the drawn rectangle into 3d space */ - if (depth_close != FLT_MAX && - ED_view3d_unproject_v3(region, cent[0], cent[1], depth_close, p)) { + if (depth_close != FLT_MAX && ED_view3d_unproject_v3(region, cent[0], cent[1], depth_close, p)) + { negate_v3_v3(new_ofs, p); } else { diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index 23b5ff58175..a62364e41d3 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -470,7 +470,8 @@ static bool calc_bbox(struct InteractivePlaceData *ipd, BoundBox *bounds) } if ((ipd->step_index == STEP_DEPTH) && - (compare_v3v3(ipd->step[0].co_dst, ipd->step[1].co_dst, FLT_EPSILON) == false)) { + (compare_v3v3(ipd->step[0].co_dst, ipd->step[1].co_dst, FLT_EPSILON) == false)) + { for (int i = 0; i < ARRAY_SIZE(quad_base); i++) { add_v3_v3v3(quad_secondary[i], quad_base[i], delta_local); @@ -605,7 +606,8 @@ static void draw_primitive_view_impl(const struct bContext *C, } else if (ELEM(ipd->primitive_type, PLACE_PRIMITIVE_TYPE_SPHERE_UV, - PLACE_PRIMITIVE_TYPE_SPHERE_ICO)) { + PLACE_PRIMITIVE_TYPE_SPHERE_ICO)) + { /* See bound-box diagram for reference. */ /* Primary Side. */ @@ -783,7 +785,8 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv } if (ipd->step[STEP_BASE].is_degenerate_view_align || - ipd->step[STEP_DEPTH].is_degenerate_view_align) { + ipd->step[STEP_DEPTH].is_degenerate_view_align) + { RegionView3D *rv3d = ipd->region->regiondata; float axis_view[3]; add_v3_v3v3(axis_view, rv3d->viewinv[0], rv3d->viewinv[1]); @@ -1148,11 +1151,12 @@ static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEve if (ELEM(ipd->primitive_type, PLACE_PRIMITIVE_TYPE_CYLINDER, PLACE_PRIMITIVE_TYPE_SPHERE_UV, - PLACE_PRIMITIVE_TYPE_SPHERE_ICO)) { + PLACE_PRIMITIVE_TYPE_SPHERE_ICO)) + { RNA_float_set(&op_props, "radius", 1.0f); } - if (ELEM( - ipd->primitive_type, PLACE_PRIMITIVE_TYPE_CYLINDER, PLACE_PRIMITIVE_TYPE_CONE)) { + if (ELEM(ipd->primitive_type, PLACE_PRIMITIVE_TYPE_CYLINDER, PLACE_PRIMITIVE_TYPE_CONE)) + { RNA_float_set(&op_props, "depth", 2.0f); } if (ipd->primitive_type == PLACE_PRIMITIVE_TYPE_CONE) { @@ -1198,13 +1202,15 @@ static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEve ipd->step[STEP_BASE].plane, mval_fl, ipd->step[STEP_BASE].is_degenerate_view_align ? ipd->view_plane : NULL, - ipd->step[STEP_BASE].co_dst)) { + ipd->step[STEP_BASE].co_dst)) + { /* pass */ } if (ipd->use_snap && (ipd->snap_to == PLACE_SNAP_TO_DEFAULT)) { if (idp_snap_calc_incremental( - ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_BASE].co_dst)) { + ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_BASE].co_dst)) + { } } } @@ -1220,13 +1226,15 @@ static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEve ipd->step[STEP_DEPTH].plane, mval_fl, ipd->step[STEP_DEPTH].is_degenerate_view_align ? ipd->view_plane : NULL, - ipd->step[STEP_DEPTH].co_dst)) { + ipd->step[STEP_DEPTH].co_dst)) + { /* pass */ } if (ipd->use_snap && (ipd->snap_to == PLACE_SNAP_TO_DEFAULT)) { if (idp_snap_calc_incremental( - ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_DEPTH].co_dst)) { + ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_DEPTH].co_dst)) + { } } } diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 1a9a80ba764..84247b07ba4 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -139,7 +139,8 @@ static eV3DProjStatus ed_view3d_project__internal(const ARegion *region, const float fy = ((float)region->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); if ((flag & V3D_PROJ_TEST_CLIP_WIN) && - (fx <= 0.0f || fy <= 0.0f || fx >= (float)region->winx || fy >= (float)region->winy)) { + (fx <= 0.0f || fy <= 0.0f || fx >= (float)region->winx || fy >= (float)region->winy)) + { return V3D_PROJ_RET_CLIP_WIN; } @@ -159,8 +160,8 @@ eV3DProjStatus ED_view3d_project_short_ex(const ARegion *region, float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(region, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { - if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && - (tvec[1] > -32700.0f && tvec[1] < 32700.0f)) { + if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && (tvec[1] > -32700.0f && tvec[1] < 32700.0f)) + { r_co[0] = (short)floorf(tvec[0]); r_co[1] = (short)floorf(tvec[1]); } @@ -182,7 +183,8 @@ eV3DProjStatus ED_view3d_project_int_ex(const ARegion *region, eV3DProjStatus ret = ed_view3d_project__internal(region, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) && - (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f)) { + (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f)) + { r_co[0] = (int)floorf(tvec[0]); r_co[1] = (int)floorf(tvec[1]); } @@ -357,7 +359,8 @@ static void view3d_win_to_ray_segment(const struct Depsgraph *depsgraph, bool ED_view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float ray_end[3]) { if ((rv3d->rflag & RV3D_CLIPPING) && - (clip_segment_v3_plane_n(ray_start, ray_end, rv3d->clip, 6, ray_start, ray_end) == false)) { + (clip_segment_v3_plane_n(ray_start, ray_end, rv3d->clip, 6, ray_start, ray_end) == false)) + { return false; } return true; diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index 4828ef03679..d195884ee62 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -461,7 +461,8 @@ static bool view3d_selectable_data(bContext *C) } else { if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && - !BKE_paint_select_elem_test(ob)) { + !BKE_paint_select_elem_test(ob)) + { return false; } } @@ -528,7 +529,8 @@ static void do_lasso_select_pose__do_tag(void *userData, if (BLI_rctf_isect_segment(data->rect_fl, screen_co_a, screen_co_b) && BLI_lasso_is_edge_inside( - data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX)) { + data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX)) + { pchan->bone->flag |= BONE_DONE; data->is_changed = true; } @@ -610,7 +612,8 @@ static blender::Vector do_pose_tag_select_op_prepare(ViewContext *vc) blender::Vector bases; FOREACH_BASE_IN_MODE_BEGIN ( - vc->scene, vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) { + vc->scene, vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) + { Object *ob_iter = base_iter->object; bArmature *arm = static_cast(ob_iter->data); LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) { @@ -1021,8 +1024,8 @@ static void do_lasso_select_armature__doSelectBone(void *userData, if (screen_co_a[0] != IS_CLIPPED) { if (BLI_rcti_isect_pt(data->rect, UNPACK2(screen_co_a)) && - BLI_lasso_is_point_inside( - data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), INT_MAX)) { + BLI_lasso_is_point_inside(data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), INT_MAX)) + { is_inside_flag |= BONESEL_ROOT; } } @@ -1032,8 +1035,8 @@ static void do_lasso_select_armature__doSelectBone(void *userData, if (screen_co_b[0] != IS_CLIPPED) { if (BLI_rcti_isect_pt(data->rect, UNPACK2(screen_co_b)) && - BLI_lasso_is_point_inside( - data->mcoords, data->mcoords_len, UNPACK2(screen_co_b), INT_MAX)) { + BLI_lasso_is_point_inside(data->mcoords, data->mcoords_len, UNPACK2(screen_co_b), INT_MAX)) + { is_inside_flag |= BONESEL_TIP; } } @@ -1043,11 +1046,9 @@ static void do_lasso_select_armature__doSelectBone(void *userData, if (is_ignore_flag == 0) { if (is_inside_flag == (BONE_ROOTSEL | BONE_TIPSEL) || - BLI_lasso_is_edge_inside(data->mcoords, - data->mcoords_len, - UNPACK2(screen_co_a), - UNPACK2(screen_co_b), - INT_MAX)) { + BLI_lasso_is_edge_inside( + data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX)) + { is_inside_flag |= BONESEL_BONE; } } @@ -1076,7 +1077,8 @@ static void do_lasso_select_armature__doSelectBone_clip_content(void *userData, } if (BLI_lasso_is_edge_inside( - data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX)) { + data->mcoords, data->mcoords_len, UNPACK2(screen_co_a), UNPACK2(screen_co_b), INT_MAX)) + { is_inside_flag |= BONESEL_BONE; } @@ -1339,8 +1341,8 @@ static bool view3d_lasso_select(bContext *C, } } else { /* Edit Mode */ - FOREACH_OBJECT_IN_MODE_BEGIN ( - vc->scene, vc->view_layer, vc->v3d, ob->type, ob->mode, ob_iter) { + FOREACH_OBJECT_IN_MODE_BEGIN (vc->scene, vc->view_layer, vc->v3d, ob->type, ob->mode, ob_iter) + { ED_view3d_viewcontext_init_object(vc, ob_iter); bool changed = false; @@ -2259,7 +2261,8 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, const int select_id_active = base->object->runtime.select_id; for (int i_next = 0, i_prev = hits - 1; i_next < hits; i_prev = i_next++) { if ((select_id_active == (buffer[i_prev].id & 0xFFFF)) && - (select_id_active != (buffer[i_next].id & 0xFFFF))) { + (select_id_active != (buffer[i_next].id & 0xFFFF))) + { hit_index = i_next; break; } @@ -2323,7 +2326,8 @@ static Base *mouse_select_object_center(ViewContext *vc, Base *startbase, const float screen_co[2]; if (ED_view3d_project_float_global( region, base->object->object_to_world[3], screen_co, V3D_PROJ_TEST_CLIP_DEFAULT) == - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { float dist_test = len_manhattan_v2v2(mval_fl, screen_co); if (base == oldbasact) { dist_test += penalty_dist; @@ -2689,7 +2693,8 @@ static bool ed_object_select_pick(bContext *C, /* Select pose-bones or camera-tracks. */ if (((gpu->hits > 0) && gpu->has_bones) || /* Special case, even when there are no hits, pose logic may de-select all bones. */ - ((gpu->hits == 0) && has_pose_old)) { + ((gpu->hits == 0) && has_pose_old)) + { if (basact && (gpu->has_bones && (basact->object->type == OB_CAMERA))) { MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, false); @@ -2717,7 +2722,8 @@ static bool ed_object_select_pick(bContext *C, gpu->buffer, gpu->hits, params, - gpu->do_nearest)) { + gpu->do_nearest)) + { changed_pose = true; @@ -2794,7 +2800,8 @@ static bool ed_object_select_pick(bContext *C, * special exception for edit-mode - vertex-parent operator. */ if (basact && oldbasact) { if ((oldbasact->object->mode != basact->object->mode) && - (oldbasact->object->mode & basact->object->mode) == 0) { + (oldbasact->object->mode & basact->object->mode) == 0) + { basact = nullptr; } } @@ -3089,7 +3096,8 @@ static int view3d_select_exec(bContext *C, wmOperator *op) Object *obact = CTX_data_active_object(C); if (obact && obact->type == OB_GPENCIL_LEGACY && GPENCIL_ANY_MODE((bGPdata *)obact->data) && - (BKE_object_pose_armature_get_with_wpaint_check(obact) == nullptr)) { + (BKE_object_pose_armature_get_with_wpaint_check(obact) == nullptr)) + { /* Prevent acting on Grease Pencil (when not in object mode -- or not in weight-paint + pose * selection), it implements its own selection operator in other modes. We might still fall * trough to here (because that operator uses OPERATOR_PASS_THROUGH to make tweak work) but if @@ -3900,7 +3908,8 @@ static bool do_object_box_select(bContext *C, qsort(buffer, hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp); for (const GPUSelectResult *buf_iter = buffer, *buf_end = buf_iter + hits; buf_iter < buf_end; - buf_iter++) { + buf_iter++) + { bPoseChannel *pchan_dummy; Base *base = ED_armature_base_and_pchan_from_select_buffer( bases.data(), bases.size(), buf_iter->id, &pchan_dummy); @@ -3963,7 +3972,8 @@ static bool do_pose_box_select(bContext *C, qsort(buffer, hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp); for (const GPUSelectResult *buf_iter = buffer, *buf_end = buf_iter + hits; buf_iter < buf_end; - buf_iter++) { + buf_iter++) + { Bone *bone; Base *base = ED_armature_base_and_bone_from_select_buffer( bases.data(), bases.size(), buf_iter->id, &bone); @@ -4033,7 +4043,8 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op) if (vc.obedit) { FOREACH_OBJECT_IN_MODE_BEGIN ( - vc.scene, vc.view_layer, vc.v3d, vc.obedit->type, vc.obedit->mode, ob_iter) { + vc.scene, vc.view_layer, vc.v3d, vc.obedit->type, vc.obedit->mode, ob_iter) + { ED_view3d_viewcontext_init_object(&vc, ob_iter); bool changed = false; @@ -4587,7 +4598,8 @@ static void do_circle_select_pose__doSelectBone(void *userData, * It works nicer to only do this if the head or tail are not in the circle, * otherwise there is no way to circle select joints alone */ if ((is_point_done == false) && (points_proj_tot == 2) && - edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { + edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) + { if (data->select) { pchan->bone->flag |= BONE_SELECTED; } @@ -4701,7 +4713,8 @@ static void do_circle_select_armature__doSelectBone(void *userData, * It works nicer to only do this if the head or tail are not in the circle, * otherwise there is no way to circle select joints alone */ if ((is_point_done == false) && (points_proj_tot == 2) && - edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { + edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) + { SET_FLAG_FROM_TEST(ebone->flag, data->select, BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); is_edge_done = true; data->is_changed = true; @@ -4896,7 +4909,8 @@ static bool object_circle_select(ViewContext *vc, if (ED_view3d_project_float_global(vc->region, base->object->object_to_world[3], screen_co, - V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) { + V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) + { if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT); changed = true; @@ -4920,7 +4934,8 @@ static void view3d_circle_select_recalc(void *user_data) ViewContext vc; em_setup_viewcontext(C, &vc); FOREACH_OBJECT_IN_MODE_BEGIN ( - vc.scene, vc.view_layer, vc.v3d, vc.obact->type, vc.obact->mode, ob_iter) { + vc.scene, vc.view_layer, vc.v3d, vc.obact->type, vc.obact->mode, ob_iter) + { ED_view3d_viewcontext_init_object(&vc, ob_iter); BM_mesh_select_mode_flush_ex( vc.em->bm, vc.em->selectmode, BM_SELECT_LEN_FLUSH_RECALC_ALL); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index c1f8ac1fd6c..585ceb4b547 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -395,7 +395,8 @@ static bool snap_selected_to_location(bContext *C, /* if the bone has a parent and is connected to the parent, * don't do anything - will break chain unless we do auto-ik. */ - (pchan->bone->flag & BONE_CONNECTED) == 0) { + (pchan->bone->flag & BONE_CONNECTED) == 0) + { pchan->bone->flag |= BONE_TRANSFORM; } else { @@ -407,7 +408,8 @@ static bool snap_selected_to_location(bContext *C, if ((pchan->bone->flag & BONE_TRANSFORM) && /* check that our parents not transformed (if we have one) */ ((pchan->bone->parent && - BKE_armature_bone_flag_test_recursive(pchan->bone->parent, BONE_TRANSFORM)) == 0)) { + BKE_armature_bone_flag_test_recursive(pchan->bone->parent, BONE_TRANSFORM)) == 0)) + { /* Get position in pchan (pose) space. */ float cursor_pose[3]; diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index ed5d962b837..4a06f78b427 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -346,7 +346,8 @@ bool ED_view3d_clipping_clamp_minmax(const RegionView3D *rv3d, float min[3], flo const float eps_coplanar = 1e-4f; const float eps_isect = 1e-6f; if (isect_planes_v3_fn( - planes, planes_len, eps_coplanar, eps_isect, points_in_planes_minmax_fn, &user_data)) { + planes, planes_len, eps_coplanar, eps_isect, points_in_planes_minmax_fn, &user_data)) + { copy_v3_v3(min, user_data.min); copy_v3_v3(max, user_data.max); return true; @@ -577,7 +578,8 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV Object *root_parent; if (v3d->camera->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK && - (root_parent = v3d->camera->parent)) { + (root_parent = v3d->camera->parent)) + { Object *ob_update; float tmat[4][4]; float imat[4][4]; @@ -675,7 +677,8 @@ bool ED_view3d_camera_lock_autokey(View3D *v3d, ID *id_key; Object *root_parent; if (v3d->camera->transflag & OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK && - (root_parent = v3d->camera->parent)) { + (root_parent = v3d->camera->parent)) + { while (root_parent->parent) { root_parent = root_parent->parent; } @@ -871,7 +874,8 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_ /* we could use rv3d->viewinv, but better not depend on view matrix being updated */ if (UNLIKELY(ED_view3d_quat_from_axis_view(rv3d_src->view, rv3d_src->view_axis_roll, viewinv) == - false)) { + false)) + { return; } invert_qt_normalized(viewinv); @@ -879,7 +883,8 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_ mul_qt_v3(viewinv, view_src_y); if (UNLIKELY(ED_view3d_quat_from_axis_view(rv3d_dst->view, rv3d_dst->view_axis_roll, viewinv) == - false)) { + false)) + { return; } invert_qt_normalized(viewinv); @@ -889,7 +894,8 @@ static void view3d_boxview_sync_axis(RegionView3D *rv3d_dst, RegionView3D *rv3d_ /* check source and dest have a matching axis */ for (i = 0; i < 3; i++) { if (((fabsf(view_src_x[i]) > axis_eps) || (fabsf(view_src_y[i]) > axis_eps)) && - ((fabsf(view_dst_x[i]) > axis_eps) || (fabsf(view_dst_y[i]) > axis_eps))) { + ((fabsf(view_dst_x[i]) > axis_eps) || (fabsf(view_dst_y[i]) > axis_eps))) + { rv3d_dst->ofs[i] = rv3d_src->ofs[i]; } } @@ -1450,9 +1456,11 @@ bool ED_view3d_quat_to_axis_view(const float quat[4], /* Under 45 degrees, just pick the closest value. */ for (int view = RV3D_VIEW_FRONT; view <= RV3D_VIEW_BOTTOM; view++) { for (int view_axis_roll = RV3D_VIEW_AXIS_ROLL_0; view_axis_roll <= RV3D_VIEW_AXIS_ROLL_270; - view_axis_roll++) { + view_axis_roll++) + { if (fabsf(angle_signed_qtqt( - quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll])) < epsilon) { + quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll])) < epsilon) + { *r_view = view; *r_view_axis_roll = view_axis_roll; return true; @@ -1465,7 +1473,8 @@ bool ED_view3d_quat_to_axis_view(const float quat[4], float delta_best = FLT_MAX; for (int view = RV3D_VIEW_FRONT; view <= RV3D_VIEW_BOTTOM; view++) { for (int view_axis_roll = RV3D_VIEW_AXIS_ROLL_0; view_axis_roll <= RV3D_VIEW_AXIS_ROLL_270; - view_axis_roll++) { + view_axis_roll++) + { const float delta_test = fabsf( angle_signed_qtqt(quat, view3d_quat_axis[view - RV3D_VIEW_FRONT][view_axis_roll])); if (delta_best > delta_test) { @@ -1616,7 +1625,8 @@ static bool view3d_camera_to_view_selected_impl(struct Main *bmain, float scale; /* only for ortho cameras */ if (BKE_camera_view_frame_fit_to_scene( - depsgraph, scene, camera_ob_eval, co, &scale, r_clip_start, r_clip_end)) { + depsgraph, scene, camera_ob_eval, co, &scale, r_clip_start, r_clip_end)) + { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; bool is_ortho_camera = false; @@ -1663,7 +1673,8 @@ bool ED_view3d_camera_to_view_selected_with_set_clipping(struct Main *bmain, float clip_start; float clip_end; if (view3d_camera_to_view_selected_impl( - bmain, depsgraph, scene, camera_ob, &clip_start, &clip_end)) { + bmain, depsgraph, scene, camera_ob, &clip_start, &clip_end)) + { ((Camera *)camera_ob->data)->clip_start = clip_start; ((Camera *)camera_ob->data)->clip_end = clip_end; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index bd17c673dc8..74ba3c7794e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -170,7 +170,8 @@ static void sync_viewport_camera_smoothview(bContext *C, for (bScreen *screen = bmain->screens.first; screen != NULL; screen = screen->id.next) { for (ScrArea *area = screen->areabase.first; area != NULL; area = area->next) { for (SpaceLink *space_link = area->spacedata.first; space_link != NULL; - space_link = space_link->next) { + space_link = space_link->next) + { if (space_link->spacetype == SPACE_VIEW3D) { View3D *other_v3d = (View3D *)space_link; if (other_v3d == v3d) { @@ -513,7 +514,8 @@ eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, con { if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { if (obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT) && - BKE_object_pose_armature_get((Object *)obact)) { + BKE_object_pose_armature_get((Object *)obact)) + { return VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK; } return VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b584eacce0a..77ed865159c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -75,7 +75,8 @@ bool transdata_check_local_islands(TransInfo *t, short around) void setTransformViewMatrices(TransInfo *t) { if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && t->region && - (t->region->regiontype == RGN_TYPE_WINDOW)) { + (t->region->regiontype == RGN_TYPE_WINDOW)) + { RegionView3D *rv3d = t->region->regiondata; copy_m4_m4(t->viewmat, rv3d->viewmat); @@ -372,7 +373,8 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) void applyAspectRatio(TransInfo *t, float vec[2]) { if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION) && - !(t->options & CTX_PAINT_CURVE)) { + !(t->options & CTX_PAINT_CURVE)) + { SpaceImage *sima = t->area->spacedata.first; if ((sima->flag & SI_COORDFLOATS) == 0) { @@ -647,7 +649,8 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) * `Move` operation. * * Ideally we should check if it really uses the same key. */ - t->mode != TFM_TRANSLATION)) { + t->mode != TFM_TRANSLATION)) + { return false; } if (value == TFM_MODAL_TRACKBALL && @@ -660,7 +663,8 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) * `Rotate` operation. * * Ideally we should check if it really uses the same key. */ - t->mode != TFM_ROTATION) { + t->mode != TFM_ROTATION) + { return false; } if (value == TFM_MODAL_ROTATE_NORMALS) { @@ -925,7 +929,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) /* Handle modal numinput events first, if already activated. */ if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) && - handleNumInput(t->context, &(t->num), event)) { + handleNumInput(t->context, &(t->num), event)) + { t->redraw |= TREDRAW_HARD; handled = true; } @@ -970,7 +975,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) } if ((event->val == TFM_MODAL_TRANSLATE && t->mode == TFM_TRANSLATION) || - (event->val == TFM_MODAL_RESIZE && t->mode == TFM_RESIZE)) { + (event->val == TFM_MODAL_RESIZE && t->mode == TFM_RESIZE)) + { if (t->data_type == &TransConvertType_Tracking) { restoreTransObjects(t); @@ -985,7 +991,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) (event->val == TFM_MODAL_TRACKBALL && t->mode == TFM_TRACKBALL) || (event->val == TFM_MODAL_ROTATE_NORMALS && t->mode == TFM_NORMAL_ROTATION) || (event->val == TFM_MODAL_VERT_EDGE_SLIDE && - ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE))) { + ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE))) + { break; } @@ -1177,7 +1184,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) case TFM_MODAL_AUTOCONSTRAINT: case TFM_MODAL_AUTOCONSTRAINTPLANE: if ((t->flag & T_RELEASE_CONFIRM) && (event->prev_val == KM_RELEASE) && - event->prev_type == t->launch_event) { + event->prev_type == t->launch_event) + { /* Confirm transform if launch key is released after mouse move. */ t->state = TRANS_CONFIRM; } @@ -1326,13 +1334,15 @@ int transformEvent(TransInfo *t, const wmEvent *event) /* Per transform event, if present */ if (t->handleEvent && (!handled || /* Needed for vertex slide, see #38756. */ - (event->type == MOUSEMOVE))) { + (event->type == MOUSEMOVE))) + { t->redraw |= t->handleEvent(t, event); } /* Try to init modal numinput now, if possible. */ if (!(handled || t->redraw) && ((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && - handleNumInput(t->context, &(t->num), event)) { + handleNumInput(t->context, &(t->num), event)) + { t->redraw |= TREDRAW_HARD; handled = true; } @@ -1507,34 +1517,17 @@ static void drawTransformPixel(const struct bContext *C, ARegion *region, void * void saveTransform(bContext *C, TransInfo *t, wmOperator *op) { - if (t->state == TRANS_CANCEL) { - /* No need to edit operator properties or tool settings if we are canceling the operation. - * These properties must match the original ones. */ - return; - } - ToolSettings *ts = CTX_data_tool_settings(C); PropertyRNA *prop; - /* Save back mode in case we're in the generic operator */ - if ((prop = RNA_struct_find_property(op->ptr, "mode"))) { - RNA_property_enum_set(op->ptr, prop, t->mode); - } - - if ((prop = RNA_struct_find_property(op->ptr, "value"))) { - if (RNA_property_array_check(prop)) { - RNA_property_float_set_array(op->ptr, prop, t->values_final); - } - else { - RNA_property_float_set(op->ptr, prop, t->values_final[0]); - } - } + bool use_prop_edit = false; + int prop_edit_flag = 0; /* Save proportional edit settings. - * Skip saving proportional edit if it was not actually used. */ + * Skip saving proportional edit if it was not actually used. + * Note that this value is being saved even if the operation is cancelled. This is to maintain a + * behavior already used by users. */ if (!(t->options & CTX_NO_PET)) { - bool use_prop_edit = false; - int prop_edit_flag = 0; if (t->flag & T_PROP_EDIT_ALL) { if (t->flag & T_PROP_EDIT) { use_prop_edit = true; @@ -1551,7 +1544,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) { /* save settings if not set in operator */ if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) && - !RNA_property_is_set(op->ptr, prop)) { + !RNA_property_is_set(op->ptr, prop)) + { BKE_view_layer_synced_ensure(t->scene, t->view_layer); const Object *obact = BKE_view_layer_active_object_get(t->view_layer); @@ -1584,11 +1578,20 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && - !RNA_property_is_set(op->ptr, prop)) { + !RNA_property_is_set(op->ptr, prop)) + { ts->prop_mode = t->prop_mode; } } + } + if (t->state == TRANS_CANCEL) { + /* No need to edit operator properties or tool settings if we are canceling the operation. + * These properties must match the original ones. */ + return; + } + + if (!(t->options & CTX_NO_PET)) { if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { RNA_property_boolean_set(op->ptr, prop, use_prop_edit); RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & PROP_EDIT_CONNECTED); @@ -1598,6 +1601,20 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } + /* Save back mode in case we're in the generic operator */ + if ((prop = RNA_struct_find_property(op->ptr, "mode"))) { + RNA_property_enum_set(op->ptr, prop, t->mode); + } + + if ((prop = RNA_struct_find_property(op->ptr, "value"))) { + if (RNA_property_array_check(prop)) { + RNA_property_float_set_array(op->ptr, prop, t->values_final); + } + else { + RNA_property_float_set(op->ptr, prop, t->values_final[0]); + } + } + /* Save snapping settings. */ if ((prop = RNA_struct_find_property(op->ptr, "snap"))) { RNA_property_boolean_set(op->ptr, prop, (t->modifiers & MOD_SNAP) != 0); @@ -1690,7 +1707,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) && - !RNA_property_is_set(op->ptr, prop)) { + !RNA_property_is_set(op->ptr, prop)) + { /* Set the first time to register on redo. */ RNA_property_enum_set(op->ptr, prop, orient_type_set); RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]); @@ -1786,28 +1804,32 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->state = TRANS_STARTING; if ((prop = RNA_struct_find_property(op->ptr, "cursor_transform")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_CURSOR; } } if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_TEXTURE_SPACE; } } if ((prop = RNA_struct_find_property(op->ptr, "gpencil_strokes")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_GPENCIL_STROKES; } } if ((prop = RNA_struct_find_property(op->ptr, "view2d_edge_pan")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_VIEW2D_EDGE_PAN; } @@ -1839,7 +1861,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve SPACE_NODE, SPACE_GRAPH, SPACE_ACTION, - SPACE_SEQ)) { + SPACE_SEQ)) + { t->draw_handle_view = ED_region_draw_cb_activate( t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->draw_handle_cursor = WM_paint_cursor_activate( @@ -1896,7 +1919,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve (ELEM(kmi->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY) && (event->modifier & KM_SHIFT)) || (ELEM(kmi->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY) && (event->modifier & KM_ALT)) || - ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) { + ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) + { t->modifiers |= MOD_SNAP_INVERT; } break; @@ -1918,7 +1942,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve (ELEM(kmi->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY) && (event->modifier & KM_SHIFT)) || (ELEM(kmi->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY) && (event->modifier & KM_ALT)) || - ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) { + ((kmi->type == EVT_OSKEY) && (event->modifier & KM_OSKEY))) + { t->modifiers &= ~MOD_NODE_ATTACH; } break; @@ -1947,7 +1972,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* Initialize accurate transform to settings requested by keymap. */ bool use_accurate = false; if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { use_accurate = true; } @@ -1972,11 +1998,13 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* Transformation axis from operator */ if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { t->orient_axis = RNA_property_enum_get(op->ptr, prop); } if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); } @@ -2103,7 +2131,8 @@ bool checkUseAxisMatrix(TransInfo *t) /* currently only checks for editmode */ if (t->flag & T_EDIT) { if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && - ELEM(t->obedit_type, OB_MESH, OB_CURVES_LEGACY, OB_MBALL, OB_ARMATURE)) { + ELEM(t->obedit_type, OB_MESH, OB_CURVES_LEGACY, OB_MBALL, OB_ARMATURE)) + { /* not all editmode supports axis-matrix */ return true; } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 25034e0bb08..3b94adc3bb8 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -304,7 +304,8 @@ void transform_constraint_snap_axis_to_edge(const TransInfo *t, const float *edge_dir = t->tsnap.snapNormal; bool is_aligned = fabsf(dot_v3v3(axis, edge_dir)) > (1.0f - CONSTRAIN_EPSILON); if (!is_aligned && - isect_ray_ray_v3(t->tsnap.snap_source, axis, edge_snap_point, edge_dir, &lambda, NULL)) { + isect_ray_ray_v3(t->tsnap.snap_source, axis, edge_snap_point, edge_dir, &lambda, NULL)) + { mul_v3_v3fl(r_out, axis, lambda); } } @@ -576,7 +577,8 @@ static void constraints_rotation_impl(const TransInfo *t, } /* don't flip axis if asked to or if num input */ if (r_angle && - !((mode & CON_NOFLIP) || hasNumInput(&t->num) || (t->flag & T_INPUT_IS_VALUES_FINAL))) { + !((mode & CON_NOFLIP) || hasNumInput(&t->num) || (t->flag & T_INPUT_IS_VALUES_FINAL))) + { float view_vector[3]; view_vector_calc(t, t->center_global, view_vector); if (dot_v3v3(r_axis, view_vector) > 0.0f) { diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 889895148ad..7ce18b1fa74 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -560,7 +560,8 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list) CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_ARMATURE, CONSTRAINT_TYPE_OBJECTSOLVER, - CONSTRAINT_TYPE_FOLLOWTRACK)) { + CONSTRAINT_TYPE_FOLLOWTRACK)) + { return true; } @@ -588,7 +589,8 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list) bTransLikeConstraint *data = (bTransLikeConstraint *)con->data; if (ELEM(data->mix_mode, TRANSLIKE_MIX_BEFORE, TRANSLIKE_MIX_BEFORE_FULL) && - ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION)) { + ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION)) + { return true; } if (ELEM(data->mix_mode, TRANSLIKE_MIX_BEFORE_SPLIT) && ELEM(t->mode, TFM_ROTATION)) { @@ -600,7 +602,8 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list) bActionConstraint *data = (bActionConstraint *)con->data; if (ELEM(data->mix_mode, ACTCON_MIX_BEFORE, ACTCON_MIX_BEFORE_FULL) && - ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION)) { + ELEM(t->mode, TFM_ROTATION, TFM_TRANSLATION)) + { return true; } if (ELEM(data->mix_mode, ACTCON_MIX_BEFORE_SPLIT) && ELEM(t->mode, TFM_ROTATION)) { @@ -686,7 +689,8 @@ static int countAndCleanTransDataContainer(TransInfo *t) for (TransDataContainer *th_end = t->data_container - 1, *tc = &t->data_container[t->data_container_len - 1]; tc != th_end; - tc--) { + tc--) + { if (tc->data_len == 0) { uint index = tc - t->data_container; if (index + 1 != t->data_container_len) { @@ -726,7 +730,8 @@ static void init_proportional_edit(TransInfo *t) &TransConvertType_MeshVertCData, &TransConvertType_Node, &TransConvertType_Object, - &TransConvertType_Particle)) { + &TransConvertType_Particle)) + { /* Disable proportional editing */ t->options |= CTX_NO_PET; t->flag &= ~T_PROP_EDIT_ALL; @@ -747,7 +752,8 @@ static void init_proportional_edit(TransInfo *t) else if (ELEM(t->data_type, &TransConvertType_Mesh, &TransConvertType_MeshSkin, - &TransConvertType_MeshVertCData)) { + &TransConvertType_MeshVertCData)) + { if (t->flag & T_PROP_CONNECTED) { /* Already calculated by transform_convert_mesh_connectivity_distance. */ } @@ -793,7 +799,8 @@ static void init_TransDataContainers(TransInfo *t, &TransConvertType_MeshEdge, &TransConvertType_MeshSkin, &TransConvertType_MeshUV, - &TransConvertType_MeshVertCData)) { + &TransConvertType_MeshVertCData)) + { /* Does not support Multi object editing. */ return; } @@ -802,7 +809,8 @@ static void init_TransDataContainers(TransInfo *t, const short object_type = obact ? obact->type : -1; if ((object_mode & OB_MODE_EDIT) || (t->data_type == &TransConvertType_GPencil) || - ((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE))) { + ((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE))) + { if (t->data_container) { MEM_freeN(t->data_container); } @@ -886,7 +894,8 @@ static TransConvertTypeInfo *convert_type_get(const TransInfo *t, Object **r_obj return &TransConvertType_Cursor3D; } if (!(t->options & CTX_PAINT_CURVE) && (t->spacetype == SPACE_VIEW3D) && ob && - (ob->mode == OB_MODE_SCULPT) && ob->sculpt) { + (ob->mode == OB_MODE_SCULPT) && ob->sculpt) + { return &TransConvertType_Sculpt; } if (t->options & CTX_TEXTURE_SPACE) { @@ -981,7 +990,8 @@ static TransConvertTypeInfo *convert_type_get(const TransInfo *t, Object **r_obj return NULL; } if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && - PE_start_edit(PE_get_current(t->depsgraph, t->scene, ob))) { + PE_start_edit(PE_get_current(t->depsgraph, t->scene, ob))) + { return &TransConvertType_Particle; } if (ob && ((ob->mode & OB_MODE_ALL_PAINT) || (ob->mode & OB_MODE_SCULPT_CURVES))) { @@ -1170,7 +1180,8 @@ void animrecord_check_state(TransInfo *t, struct ID *id) * - the option to add new actions for each round is not enabled */ if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL) == 0 && - (scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA)) { + (scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA)) + { /* if playback has just looped around, * we need to add a new NLA track+strip to allow a clean pass to occur */ if ((sad) && (sad->flag & ANIMPLAY_FLAG_JUMPED)) { diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c index 6afe4c62aa7..4b01d087bdc 100644 --- a/source/blender/editors/transform/transform_convert_action.c +++ b/source/blender/editors/transform/transform_convert_action.c @@ -115,7 +115,8 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo /* only include points that occur on the right side of cfra */ for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape; - masklayer_shape = masklayer_shape->next) { + masklayer_shape = masklayer_shape->next) + { if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra)) { if (masklayer_shape->flag & MASK_SHAPE_SELECT) { count++; @@ -268,7 +269,8 @@ static int MaskLayerToTransData(TransData *td, /* check for select frames on right side of current frame */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (is_prop_edit || (masklay_shape->flag & MASK_SHAPE_SELECT)) { if (FrameOnMouseSide(side, (float)masklay_shape->frame, cfra)) { tfd->val = (float)masklay_shape->frame; @@ -486,7 +488,8 @@ static void createTransActionData(bContext *C, TransInfo *t) MaskLayerShape *masklay_shape; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { if (FrameOnMouseSide(t->frame_side, (float)masklay_shape->frame, cfra)) { if (masklay_shape->flag & MASK_SHAPE_SELECT) { td->dist = td->rdist = 0.0f; @@ -674,7 +677,8 @@ static void posttrans_mask_clean(Mask *mask) if (is_double) { for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape_next) { + masklay_shape = masklay_shape_next) + { masklay_shape_next = masklay_shape->next; if (masklay_shape_next && masklay_shape->frame == masklay_shape_next->frame) { BKE_mask_layer_shape_unlink(masklay, masklay_shape); @@ -684,7 +688,8 @@ static void posttrans_mask_clean(Mask *mask) #ifdef DEBUG for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { + masklay_shape = masklay_shape->next) + { BLI_assert(!masklay_shape->next || masklay_shape->frame < masklay_shape->next->frame); } #endif diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c index 7d191969c47..74f126e293e 100644 --- a/source/blender/editors/transform/transform_convert_armature.c +++ b/source/blender/editors/transform/transform_convert_armature.c @@ -111,7 +111,8 @@ static void autokeyframe_pose( for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone->flag & BONE_TRANSFORM) == 0 && - !((pose->flag & POSE_MIRROR_EDIT) && (pchan->bone->flag & BONE_TRANSFORM_MIRROR))) { + !((pose->flag & POSE_MIRROR_EDIT) && (pchan->bone->flag & BONE_TRANSFORM_MIRROR))) + { continue; } @@ -170,9 +171,8 @@ static void autokeyframe_pose( } } else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) { - if (ELEM(scene->toolsettings->transform_pivot_point, - V3D_AROUND_CURSOR, - V3D_AROUND_ACTIVE)) { + if (ELEM(scene->toolsettings->transform_pivot_point, V3D_AROUND_CURSOR, V3D_AROUND_ACTIVE)) + { do_loc = true; } @@ -181,9 +181,8 @@ static void autokeyframe_pose( } } else if (tmode == TFM_RESIZE) { - if (ELEM(scene->toolsettings->transform_pivot_point, - V3D_AROUND_CURSOR, - V3D_AROUND_ACTIVE)) { + if (ELEM(scene->toolsettings->transform_pivot_point, V3D_AROUND_CURSOR, V3D_AROUND_ACTIVE)) + { do_loc = true; } @@ -263,7 +262,8 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan) for (; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->flag & CONSTRAINT_OFF) == 0 && - (con->enforce != 0.0f)) { + (con->enforce != 0.0f)) + { bKinematicConstraint *data = con->data; if (data->tar == NULL) { @@ -632,8 +632,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* exceptional case: rotate the pose bone which also applies transformation * when a parentless bone has BONE_NO_LOCAL_LOCATION [] */ - if (!ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE) && - (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) { + if (!ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) + { if (pchan->parent) { /* same as td->smtx but without pchan->bone->bone_mat */ td->flag |= TD_PBONE_LOCAL_MTX_C; @@ -1056,7 +1056,8 @@ static void createTransArmatureVerts(bContext *UNUSED(C), TransInfo *t) * However, in rotation mode, we want to keep that 'rotate bone around root with * only its tip selected' behavior (see #46325). */ if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && - ((t->mode == TFM_ROTATION) || (ebo->flag & BONE_ROOTSEL))) { + ((t->mode == TFM_ROTATION) || (ebo->flag & BONE_ROOTSEL))) + { copy_v3_v3(td->center, ebo->head); } else { @@ -1509,7 +1510,8 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb) bone->flag |= BONE_HINGE_CHILD_TRANSFORM; } else if ((bone->flag & BONE_TRANSFORM) && ELEM(mode, TFM_ROTATION, TFM_TRACKBALL) && - (around == V3D_AROUND_LOCAL_ORIGINS)) { + (around == V3D_AROUND_LOCAL_ORIGINS)) + { bone->flag |= BONE_TRANSFORM_CHILD; } else { diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c index 68c3479fb5d..42c78951869 100644 --- a/source/blender/editors/transform/transform_convert_graph.c +++ b/source/blender/editors/transform/transform_convert_graph.c @@ -538,7 +538,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * - If so, change them auto-handles to aligned handles so that handles get affected too */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && - ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) + { if (hdata && (sel_left) && (sel_right)) { bezt->h1 = HD_ALIGN; bezt->h2 = HD_ALIGN; @@ -654,7 +655,8 @@ static void flushTransGraphData(TransInfo *t) /* flush to 2d vector from internally used 3d vector */ for (a = 0, td = tc->data, td2d = tc->data_2d, tdg = tc->custom.type.data; a < tc->data_len; - a++, td++, td2d++, tdg++) { + a++, td++, td2d++, tdg++) + { /* pointers to relevant AnimData blocks are stored in the td->extra pointers */ AnimData *adt = (AnimData *)td->extra; @@ -758,7 +760,8 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert) */ if (bezm->swapHs == 0) { if ((bezm->bezt->vec[0][0] > bezm->bezt->vec[1][0]) && - (bezm->bezt->vec[2][0] < bezm->bezt->vec[1][0])) { + (bezm->bezt->vec[2][0] < bezm->bezt->vec[1][0])) + { /* handles need to be swapped */ bezm->swapHs = 1; } diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 902b995680f..3ea7048f9f0 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -193,7 +193,8 @@ static BMFace *tc_mesh_customdatacorrect_find_best_face_substitute(BMFace *f) /* Check the loops edge isn't selected. */ if (!BM_elem_flag_test(l_radial_next->v, BM_ELEM_SELECT) && - !BM_elem_flag_test(l_radial_next->next->v, BM_ELEM_SELECT)) { + !BM_elem_flag_test(l_radial_next->next->v, BM_ELEM_SELECT)) + { /* Prefer edges with unselected vertices. * Useful for extrude. */ best_face = f_test; @@ -273,7 +274,8 @@ static void tc_mesh_customdatacorrect_init_vert(struct TransCustomDataLayer *tcl if (tcld->use_merge_group) { if ((l_prev = BM_loop_find_prev_nodouble(l, l->next, FLT_EPSILON)) && - (l_next = BM_loop_find_next_nodouble(l, l_prev, FLT_EPSILON))) { + (l_next = BM_loop_find_next_nodouble(l, l_prev, FLT_EPSILON))) + { loop_weights[j] = angle_v3v3v3(l_prev->v->co, l->v->co, l_next->v->co); } else { @@ -456,7 +458,8 @@ void transform_convert_mesh_customdatacorrect_init(TransInfo *t) TFM_SHRINKFATTEN, TFM_TRACKBALL, TFM_PUSHPULL, - TFM_ALIGN)) { + TFM_ALIGN)) + { { if (!(t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) { /* No custom-data correction. */ @@ -559,13 +562,15 @@ static void tc_mesh_customdatacorrect_apply_vert(struct TransCustomDataLayer *tc * 'sv->co_orig_3d', see: #45096. */ project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis); while (UNLIKELY(((co_prev_ok = (len_squared_v3v3(v_proj[1], v_proj[0]) > eps)) == false) && - ((l_prev = l_prev->prev) != l->next))) { + ((l_prev = l_prev->prev) != l->next))) + { co_prev = tc_mesh_vert_orig_co_get(tcld, l_prev->v); project_plane_normalized_v3_v3v3(v_proj[0], co_prev, v_proj_axis); } project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis); while (UNLIKELY(((co_next_ok = (len_squared_v3v3(v_proj[1], v_proj[2]) > eps)) == false) && - ((l_next = l_next->next) != l->prev))) { + ((l_next = l_next->next) != l->prev))) + { co_next = tc_mesh_vert_orig_co_get(tcld, l_next->v); project_plane_normalized_v3_v3v3(v_proj[2], co_next, v_proj_axis); } @@ -919,8 +924,8 @@ static bool bmesh_test_dist_add(BMVert *v0, int *index, const float mtx[3][3]) { - if ((BM_elem_flag_test(v0, BM_ELEM_SELECT) == 0) && - (BM_elem_flag_test(v0, BM_ELEM_HIDDEN) == 0)) { + if ((BM_elem_flag_test(v0, BM_ELEM_SELECT) == 0) && (BM_elem_flag_test(v0, BM_ELEM_HIDDEN) == 0)) + { const int i0 = BM_elem_index_get(v0); const int i1 = BM_elem_index_get(v1); @@ -1079,7 +1084,8 @@ void transform_convert_mesh_connectivity_distance(struct BMesh *bm, BM_ITER_ELEM (e_other, &eiter, v2, BM_EDGES_OF_VERT) { if (e_other != e && BM_elem_flag_test(e_other, tag_queued) == 0 && !BM_elem_flag_test(e_other, BM_ELEM_HIDDEN) && - (BM_elem_flag_test(e, tag_loose) || BM_elem_flag_test(e_other, tag_loose))) { + (BM_elem_flag_test(e, tag_loose) || BM_elem_flag_test(e_other, tag_loose))) + { BM_elem_flag_enable(e_other, tag_queued); BLI_LINKSTACK_PUSH(queue_next, e_other); } @@ -1111,7 +1117,8 @@ void transform_convert_mesh_connectivity_distance(struct BMesh *bm, if (e_other != e && BM_elem_flag_test(e_other, tag_queued) == 0 && !BM_elem_flag_test(e_other, BM_ELEM_HIDDEN) && (BM_elem_flag_test(e_other, tag_loose) || - dists[BM_elem_index_get(BM_edge_other_vert(e_other, v_other))] != FLT_MAX)) { + dists[BM_elem_index_get(BM_edge_other_vert(e_other, v_other))] != FLT_MAX)) + { BM_elem_flag_enable(e_other, tag_queued); BLI_LINKSTACK_PUSH(queue_next, e_other); } @@ -1430,7 +1437,8 @@ static void VertsToTransData(TransInfo *t, copy_v3_v3(td->iloc, td->loc); if ((t->mode == TFM_SHRINKFATTEN) && (em->selectmode & SCE_SELECT_FACE) && - BM_elem_flag_test(eve, BM_ELEM_SELECT) && BM_vert_calc_normal_ex(eve, BM_ELEM_SELECT, _no)) { + BM_elem_flag_test(eve, BM_ELEM_SELECT) && BM_vert_calc_normal_ex(eve, BM_ELEM_SELECT, _no)) + { no = _no; } else { @@ -1747,8 +1755,8 @@ static BMPartialUpdate *tc_mesh_partial_ensure(TransInfo *t, BLI_bitmap *verts_mask = NULL; int verts_mask_count = 0; /* Number of elements enabled in `verts_mask`. */ - if ((partial_type == PARTIAL_TYPE_GROUP) && - ((t->flag & T_PROP_EDIT) || tc->use_mirror_axis_any)) { + if ((partial_type == PARTIAL_TYPE_GROUP) && ((t->flag & T_PROP_EDIT) || tc->use_mirror_axis_any)) + { verts_group = MEM_callocN(sizeof(*verts_group) * em->bm->totvert, __func__); int i; TransData *td; @@ -1823,7 +1831,8 @@ static BMPartialUpdate *tc_mesh_partial_ensure(TransInfo *t, for (i = 0; i < tc->data_mirror_len; i++, td_mirror++) { BMVert *v_mirr = (BMVert *)POINTER_OFFSET(td_mirror->loc_src, -offsetof(BMVert, co)); if (!BLI_BITMAP_TEST(verts_mask, BM_elem_index_get(v_mirr)) && - equals_v3v3(td_mirror->loc, td_mirror->iloc)) { + equals_v3v3(td_mirror->loc, td_mirror->iloc)) + { continue; } @@ -1913,7 +1922,8 @@ static void tc_mesh_partial_types_calc(TransInfo *t, struct PartialTypeState *r_ * Uniform negative scale can keep normals as-is since the faces are flipped, * normals remain unchanged. */ if ((t->con.mode & CON_APPLY) || - (t->values_final[0] != t->values_final[1] || t->values_final[0] != t->values_final[2])) { + (t->values_final[0] != t->values_final[1] || t->values_final[0] != t->values_final[2])) + { partial_for_normals = PARTIAL_TYPE_ALL; } break; @@ -1958,7 +1968,8 @@ static void tc_mesh_partial_update(TransInfo *t, partial_state_prev->for_normals); if ((partial_for_looptri == PARTIAL_TYPE_ALL) && (partial_for_normals == PARTIAL_TYPE_ALL) && - (em->bm->totvert == em->bm->totvertsel)) { + (em->bm->totvert == em->bm->totvertsel)) + { /* The additional cost of generating the partial connectivity data isn't justified * when all data needs to be updated. * diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.c b/source/blender/editors/transform/transform_convert_mesh_edge.c index e5c2c90f957..6ad5c260b85 100644 --- a/source/blender/editors/transform/transform_convert_mesh_edge.c +++ b/source/blender/editors/transform/transform_convert_mesh_edge.c @@ -84,7 +84,8 @@ static void createTransEdge(bContext *UNUSED(C), TransInfo *t) BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && - (BM_elem_flag_test(eed, BM_ELEM_SELECT) || is_prop_edit)) { + (BM_elem_flag_test(eed, BM_ELEM_SELECT) || is_prop_edit)) + { float *fl_ptr; /* need to set center for center calculations */ mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co); diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c index 532e1edc825..c7ba989f37b 100644 --- a/source/blender/editors/transform/transform_convert_nla.c +++ b/source/blender/editors/transform/transform_convert_nla.c @@ -184,12 +184,14 @@ static void nlastrip_flag_overlaps(NlaStrip *strip) NlaStrip *adj_strip = strip->prev; if (adj_strip != NULL && !(adj_strip->flag & NLASTRIP_FLAG_SELECT) && - nlastrip_is_overlap(strip, 0, adj_strip, 0)) { + nlastrip_is_overlap(strip, 0, adj_strip, 0)) + { strip->flag |= NLASTRIP_FLAG_INVALID_LOCATION; } adj_strip = strip->next; if (adj_strip != NULL && !(adj_strip->flag & NLASTRIP_FLAG_SELECT) && - nlastrip_is_overlap(strip, 0, adj_strip, 0)) { + nlastrip_is_overlap(strip, 0, adj_strip, 0)) + { strip->flag |= NLASTRIP_FLAG_INVALID_LOCATION; } } @@ -590,7 +592,8 @@ static void recalcData_nla(TransInfo *t) for (track = tdn->nlt->next, n = 0; (track) && (n < delta); track = track->next, n++) { /* check if space in this track for the strip */ if (BKE_nlatrack_has_space(track, strip->start, strip->end) && - !BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) { + !BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) + { /* move strip to this track */ BKE_nlatrack_remove_strip(tdn->nlt, strip); BKE_nlatrack_add_strip(track, strip, is_liboverride); @@ -610,7 +613,8 @@ static void recalcData_nla(TransInfo *t) for (track = tdn->nlt->prev, n = 0; (track) && (n < delta); track = track->prev, n++) { /* check if space in this track for the strip */ if (BKE_nlatrack_has_space(track, strip->start, strip->end) && - !BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) { + !BKE_nlatrack_is_nonlocal_in_liboverride(tdn->id, track)) + { /* move strip to this track */ BKE_nlatrack_remove_strip(tdn->nlt, strip); BKE_nlatrack_add_strip(track, strip, is_liboverride); diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 65ad2579af9..196873b3926 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -161,7 +161,8 @@ static void node_snap_grid_apply(TransInfo *t) using namespace blender; if (!(transform_snap_is_active(t) && - (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) { + (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) + { return; } diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c index 5945ebc2860..4abd8535b45 100644 --- a/source/blender/editors/transform/transform_convert_object.c +++ b/source/blender/editors/transform/transform_convert_object.c @@ -382,8 +382,8 @@ static void set_trans_object_base_flags(TransInfo *t) } if (parsel != NULL) { /* Rotation around local centers are allowed to propagate. */ - if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && - ELEM(t->mode, TFM_ROTATION, TFM_TRACKBALL)) { + if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && ELEM(t->mode, TFM_ROTATION, TFM_TRACKBALL)) + { base->flag_legacy |= BA_TRANSFORM_CHILD; } else { @@ -444,7 +444,8 @@ static int count_proportional_objects(TransInfo *t) /* all base not already selected or marked that is editable */ if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && (base->flag & BASE_SELECTED) == 0 && - (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { + (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) + { mark_children(base->object); } } @@ -457,7 +458,8 @@ static int count_proportional_objects(TransInfo *t) */ if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && (base->flag & BASE_SELECTED) == 0 && - (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) { + (BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base))) + { flush_trans_object_base_deps_flag(depsgraph, ob); total += 1; } @@ -577,7 +579,8 @@ static void createTransObject(bContext *C, TransInfo *t) * or not a child of selection and it is editable and selectable */ if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && (base->flag & BASE_SELECTED) == 0 && BASE_EDITABLE(v3d, base) && - BASE_SELECTABLE(v3d, base)) { + BASE_SELECTABLE(v3d, base)) + { td->protectflag = ob->protectflag; td->ext = tx; td->ext->rotOrder = ob->rotmode; @@ -610,7 +613,8 @@ static void createTransObject(bContext *C, TransInfo *t) /* if base is not selected, not a parent of selection * or not a child of selection and it is editable and selectable */ if ((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0 && - BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { + BASE_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) + { Object *ob_parent = ob->parent; if (ob_parent != NULL) { @@ -657,7 +661,8 @@ static void createTransObject(bContext *C, TransInfo *t) Object *ob = base->object; if (ob->parent != NULL) { if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) && - !BLI_gset_haskey(objects_in_transdata, ob)) { + !BLI_gset_haskey(objects_in_transdata, ob)) + { if ((base->flag_legacy & BA_WAS_SEL) && (base->flag & BASE_SELECTED) == 0) { Base *base_parent = BKE_view_layer_base_find(view_layer, ob->parent); if (base_parent && !BASE_XFORM_INDIRECT(base_parent)) { diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c index 8a42ac8a73d..eae733a9044 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.c +++ b/source/blender/editors/transform/transform_convert_sequencer.c @@ -376,7 +376,8 @@ static Sequence *effect_input_get(const Scene *scene, Sequence *effect, SeqInput if (effect->seq2 && (SEQ_time_left_handle_frame_get(scene, effect->seq2) - SEQ_time_left_handle_frame_get(scene, effect->seq1)) * side > - 0) { + 0) + { input = effect->seq2; } return input; diff --git a/source/blender/editors/transform/transform_convert_tracking.c b/source/blender/editors/transform/transform_convert_tracking.c index deb39e8c092..1d9ec136ae1 100644 --- a/source/blender/editors/transform/transform_convert_tracking.c +++ b/source/blender/editors/transform/transform_convert_tracking.c @@ -461,7 +461,8 @@ static void flushTransTracking(TransInfo *t) /* flush to 2d vector from internally used 3d vector */ for (td_index = 0, td = tc->data, td2d = tc->data_2d, tdt = tc->custom.type.data; td_index < tc->data_len; - td_index++, td2d++, td++, tdt++) { + td_index++, td2d++, td++, tdt++) + { if (tdt->mode == transDataTracking_ModeTracks) { float loc2d[2]; diff --git a/source/blender/editors/transform/transform_convert_tracking_curves.c b/source/blender/editors/transform/transform_convert_tracking_curves.c index d11487c4e22..ebc20c4616b 100644 --- a/source/blender/editors/transform/transform_convert_tracking_curves.c +++ b/source/blender/editors/transform/transform_convert_tracking_curves.c @@ -247,7 +247,8 @@ static void flushTransTrackingCurves(TransInfo *t) /* flush to 2d vector from internally used 3d vector */ for (td_index = 0, td = tc->data, td2d = tc->data_2d, tdt = tc->custom.type.data; td_index < tc->data_len; - td_index++, td2d++, td++, tdt++) { + td_index++, td2d++, td++, tdt++) + { { td2d->loc2d[tdt->coord] = tdt->prev_pos[tdt->coord] + td2d->loc[1] * tdt->scale; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c13eca2532e..f7238eac67e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -147,7 +147,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag = 0; if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) && - ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) { + ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) + { t->obedit_type = obact->type; } else { @@ -210,7 +211,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->remove_on_cancel = false; if (op && (prop = RNA_struct_find_property(op->ptr, "remove_on_cancel")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { t->remove_on_cancel = true; } @@ -316,7 +318,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve setTransformViewAspect(t, t->aspect); if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { RNA_property_float_get_array(op->ptr, prop, t->center_global); mul_v3_v3(t->center_global, t->aspect); t->flag |= T_OVERRIDE_CENTER; @@ -339,7 +342,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve bool t_values_set_is_array = false; if (op && (prop = RNA_struct_find_property(op->ptr, "value")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory. */ if (RNA_property_array_check(prop)) { RNA_property_float_get_array(op->ptr, prop, values); @@ -405,7 +409,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) && - RNA_property_is_set(op->ptr, prop))) { + RNA_property_is_set(op->ptr, prop))) + { orient_type_set = RNA_property_enum_get(op->ptr, prop); if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) { orient_type_set = V3D_ORIENT_GLOBAL; @@ -429,11 +434,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve * changes. */ if (op && !(op->flag & OP_IS_REPEAT_LAST) && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) && - RNA_property_is_set(op->ptr, prop))) { + RNA_property_is_set(op->ptr, prop))) + { RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]); if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop); } else if (orient_type_set == -1) { @@ -515,7 +522,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) && - RNA_property_is_set(op->ptr, prop))) { + RNA_property_is_set(op->ptr, prop))) + { if (RNA_property_boolean_get(op->ptr, prop)) { t->flag |= T_RELEASE_CONFIRM; } @@ -523,14 +531,16 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve else { /* Release confirms preference should not affect node editor (#69288, #70504). */ if (ISMOUSE_BUTTON(t->launch_event) && - ((U.flag & USER_RELEASECONFIRM) || (t->spacetype == SPACE_NODE))) { + ((U.flag & USER_RELEASECONFIRM) || (t->spacetype == SPACE_NODE))) + { /* Global "release confirm" on mouse bindings */ t->flag |= T_RELEASE_CONFIRM; } } - if (op && ((prop = RNA_struct_find_property(op->ptr, "mirror")) && - RNA_property_is_set(op->ptr, prop))) { + if (op && + ((prop = RNA_struct_find_property(op->ptr, "mirror")) && RNA_property_is_set(op->ptr, prop))) + { if (!RNA_property_boolean_get(op->ptr, prop)) { t->flag |= T_NO_MIRROR; } @@ -592,7 +602,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) && - RNA_property_is_set(op->ptr, prop))) { + RNA_property_is_set(op->ptr, prop))) + { t->prop_size = RNA_property_float_get(op->ptr, prop); } else { @@ -606,7 +617,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && - RNA_property_is_set(op->ptr, prop))) { + RNA_property_is_set(op->ptr, prop))) + { t->prop_mode = RNA_property_enum_get(op->ptr, prop); } else { @@ -619,7 +631,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve if (t->obedit_type == OB_MESH) { if (op && (prop = RNA_struct_find_property(op->ptr, "use_automerge_and_split")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { if (RNA_property_boolean_get(op->ptr, prop)) { t->flag |= T_AUTOMERGE | T_AUTOSPLIT; } @@ -714,7 +727,8 @@ void postTrans(bContext *C, TransInfo *t) FOREACH_TRANS_DATA_CONTAINER (t, tc) { /* free data malloced per trans-data */ if (ELEM(t->obedit_type, OB_CURVES_LEGACY, OB_SURF, OB_GPENCIL_LEGACY) || - (t->spacetype == SPACE_GRAPH)) { + (t->spacetype == SPACE_GRAPH)) + { TransData *td = tc->data; for (int a = 0; a < tc->data_len; a++, td++) { if (td->flag & TD_BEZTRIPLE) { @@ -880,7 +894,8 @@ void calculateCenterCursor(TransInfo *t, float r_center[3]) /* If edit or pose mode, move cursor in local space */ if (t->options & CTX_PAINT_CURVE) { if (ED_view3d_project_float_global(t->region, cursor, r_center, V3D_PROJ_TEST_NOP) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { r_center[0] = t->region->winx / 2.0f; r_center[1] = t->region->winy / 2.0f; } @@ -1221,7 +1236,8 @@ void calculatePropRatio(TransInfo *t) td->factor = 1.0f; } else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) || - (connected == 0 && td->rdist > t->prop_size)) { + (connected == 0 && td->rdist > t->prop_size)) + { td->factor = 0.0f; restoreElement(td); } diff --git a/source/blender/editors/transform/transform_gizmo_3d.cc b/source/blender/editors/transform/transform_gizmo_3d.cc index 76dd627c9ba..8b5780ab91b 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_3d.cc @@ -250,7 +250,8 @@ static bool gizmo_is_axis_visible(const RegionView3D *rv3d, if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_GIZMO_SHOW_OBJECT_TRANSLATE)) || (axis_type == MAN_AXES_ROTATE && !(twtype & V3D_GIZMO_SHOW_OBJECT_ROTATE)) || - (axis_type == MAN_AXES_SCALE && !(twtype & V3D_GIZMO_SHOW_OBJECT_SCALE))) { + (axis_type == MAN_AXES_SCALE && !(twtype & V3D_GIZMO_SHOW_OBJECT_SCALE))) + { return false; } @@ -649,7 +650,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, if ((ebo->flag & BONE_ROOTSEL) && /* don't include same point multiple times */ ((ebo->flag & BONE_CONNECTED) && (ebo->parent != nullptr) && - (ebo->parent->flag & BONE_TIPSEL) && EBONE_VISIBLE(arm, ebo->parent)) == 0) { + (ebo->parent->flag & BONE_TIPSEL) && EBONE_VISIBLE(arm, ebo->parent)) == 0) + { run_coord_with_matrix(ebo->head, use_mat_local, mat_local); totsel++; @@ -872,7 +874,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, } for (base = static_cast(BKE_view_layer_object_bases_get(view_layer)->first); base; - base = base->next) { + base = base->next) + { if (!BASE_SELECTED_EDITABLE(v3d, base)) { continue; } @@ -1192,8 +1195,8 @@ void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup, } } - if ((ts->transform_pivot_point == V3D_AROUND_CURSOR) || - (orient_slot->type == V3D_ORIENT_CURSOR)) { + if ((ts->transform_pivot_point == V3D_AROUND_CURSOR) || (orient_slot->type == V3D_ORIENT_CURSOR)) + { /* We could be more specific here, for now subscribe to any cursor change. */ PointerRNA cursor_ptr; RNA_pointer_create(&scene->id, &RNA_View3DCursor, &scene->cursor, &cursor_ptr); @@ -2130,7 +2133,8 @@ static void WIDGETGROUP_gizmo_invoke_prepare(const bContext *C, const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag( scene, ggd->twtype_init); if ((gz == ggd->gizmos[MAN_AXIS_ROT_C]) || - (orient_slot == &scene->orientation_slots[SCE_ORIENT_DEFAULT])) { + (orient_slot == &scene->orientation_slots[SCE_ORIENT_DEFAULT])) + { /* #MAN_AXIS_ROT_C always uses the #V3D_ORIENT_VIEW orientation, * optionally we could set this orientation instead of unset the property. */ RNA_property_unset(ptr, prop_orient_type); @@ -2204,7 +2208,8 @@ static bool WIDGETGROUP_gizmo_poll_context(const bContext *C, wmGizmoGroupType * return false; } if ((v3d->gizmo_show_object & (V3D_GIZMO_SHOW_OBJECT_TRANSLATE | V3D_GIZMO_SHOW_OBJECT_ROTATE | - V3D_GIZMO_SHOW_OBJECT_SCALE)) == 0) { + V3D_GIZMO_SHOW_OBJECT_SCALE)) == 0) + { return false; } @@ -2332,7 +2337,8 @@ void transform_gizmo_3d_model_from_constraint_and_mode_init(TransInfo *t) nullptr; if (!gizmo_modal_current || !ELEM(gizmo_modal_current->parent_gzgroup->type, g_GGT_xform_gizmo, - g_GGT_xform_gizmo_context)) { + g_GGT_xform_gizmo_context)) + { t->flag |= T_NO_GIZMO; } } diff --git a/source/blender/editors/transform/transform_gizmo_3d_cage.cc b/source/blender/editors/transform/transform_gizmo_3d_cage.cc index 67e7fcfb922..3619a2904e1 100644 --- a/source/blender/editors/transform/transform_gizmo_3d_cage.cc +++ b/source/blender/editors/transform/transform_gizmo_3d_cage.cc @@ -112,7 +112,8 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgr calc_params.use_local_axis = true; calc_params.orientation_index = orient_index + 1; if ((ED_transform_calc_gizmo_stats(C, &calc_params, &tbounds, rv3d) == 0) || - equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) { + equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) + { WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } else { diff --git a/source/blender/editors/transform/transform_gizmo_extrude_3d.c b/source/blender/editors/transform/transform_gizmo_extrude_3d.c index a622ea365d3..643500cb837 100644 --- a/source/blender/editors/transform/transform_gizmo_extrude_3d.c +++ b/source/blender/editors/transform/transform_gizmo_extrude_3d.c @@ -257,7 +257,8 @@ static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *gzgroup) .orientation_index = V3D_ORIENT_NORMAL + 1, }, &tbounds_normal, - rv3d)) { + rv3d)) + { unit_m3(tbounds_normal.axis); } copy_m3_m3(ggd->data.normal_mat3, tbounds_normal.axis); @@ -269,7 +270,8 @@ static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *gzgroup) .orientation_index = ggd->data.orientation_index + 1, }, &tbounds, - rv3d)) { + rv3d)) + { return; } diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 1295486550a..bba57ff9602 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -57,8 +57,8 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, const double mval[2], /* flip scale */ /* values can become really big when zoomed in so use longs #26598. */ if (((int64_t)((int)mi->center[0] - mval[0]) * (int64_t)((int)mi->center[0] - mi->imval[0]) + - (int64_t)((int)mi->center[1] - mval[1]) * (int64_t)((int)mi->center[1] - mi->imval[1])) < - 0) { + (int64_t)((int)mi->center[1] - mval[1]) * (int64_t)((int)mi->center[1] - mi->imval[1])) < 0) + { output[0] *= -1.0f; } } diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c index 1fa00aaed5b..1ced9904179 100644 --- a/source/blender/editors/transform/transform_mode.c +++ b/source/blender/editors/transform/transform_mode.c @@ -951,7 +951,8 @@ void ElementResize(const TransInfo *t, &TransConvertType_Sculpt, &TransConvertType_Object, &TransConvertType_ObjectTexSpace, - &TransConvertType_Pose)) { + &TransConvertType_Pose)) + { float obsizemat[3][3]; /* Reorient the size mat to fit the oriented object. */ mul_m3_m3m3(obsizemat, tmat, td->axismtx); @@ -1245,7 +1246,8 @@ void transform_mode_default_modal_orientation_set(TransInfo *t, int type) View3D *v3d = NULL; RegionView3D *rv3d = NULL; if ((type == V3D_ORIENT_VIEW) && (t->spacetype == SPACE_VIEW3D) && t->region && - (t->region->regiontype == RGN_TYPE_WINDOW)) { + (t->region->regiontype == RGN_TYPE_WINDOW)) + { v3d = t->view; rv3d = t->region->regiondata; } diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c index 276827d1b4c..ce411ec25b6 100644 --- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c @@ -104,7 +104,8 @@ void initCurveShrinkFatten(TransInfo *t) float scale_factor = 0.0f; if (((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW) && (t->data_len_all == 1)) || - (t->data_len_all == 3 && TRANS_DATA_CONTAINER_FIRST_OK(t)->data[0].val == NULL)) { + (t->data_len_all == 3 && TRANS_DATA_CONTAINER_FIRST_OK(t)->data[0].val == NULL)) + { /* For cases where only one point on the curve is being transformed and the radius of that * point is zero, use the factor to multiply the offset of the ratio and allow scaling. * Note that for bezier curves, 3 TransData equals 1 point in most cases. */ diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index f54624c1a1b..4f4c75b63e3 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -444,7 +444,8 @@ static void calcEdgeSlide_mval_range(TransInfo *t, if (is_visible) { if ((dist_best_sq == -1.0f) || /* intentionally use 2d size on 3d vector */ - (dist_sq < dist_best_sq && (len_squared_v2v2(sco_b, sco_a) > 0.1f))) { + (dist_sq < dist_best_sq && (len_squared_v2v2(sco_b, sco_a) > 0.1f))) + { dist_best_sq = dist_sq; sub_v3_v3v3(mval_dir, sco_b, sco_a); } @@ -994,7 +995,8 @@ static EdgeSlideData *createEdgeSlideVerts_single_side(TransInfo *t, TransDataCo if ((BM_elem_flag_test(e_step, BM_ELEM_SELECT) && BM_elem_flag_test(v_other, BM_ELEM_SELECT)) && - (endpoint == 0)) { + (endpoint == 0)) + { /* scan down the list */ TransDataEdgeSlideVert *sv; BLI_assert(sv_table[BM_elem_index_get(v_other)] == -1); diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c index 713902f6c62..ca3fd92b3e1 100644 --- a/source/blender/editors/transform/transform_mode_rotate.c +++ b/source/blender/editors/transform/transform_mode_rotate.c @@ -120,7 +120,8 @@ static void transdata_elem_rotate(const TransInfo *t, if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) { copy_v3_v3(td->ext->rot, td->ext->irot); for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final); - angle_progress += angle_step) { + angle_progress += angle_step) + { axis_angle_normalized_to_mat3(rmc->mat, axis_final, angle_progress); ElementRotation(t, tc, td, rmc->mat, t->around); } diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 18812bc9671..1abef353de5 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -622,7 +622,8 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) float incr_dir[3]; copy_v3_v3(incr_dir, global_dir); if (!(transform_snap_is_active(t) && validSnap(t)) && - transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, incr_dir)) { + transform_snap_increment_ex(t, (t->con.mode & CON_APPLY) != 0, incr_dir)) + { /* Test for mixed snap with grid. */ float snap_dist_sq = FLT_MAX; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 64bd87cbf79..34c63b34d8d 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -1177,7 +1177,8 @@ int getTransformOrientation_ex(const Scene *scene, if (flag) { float tvec[3]; if ((around == V3D_AROUND_LOCAL_ORIGINS) || - ELEM(flag, SEL_F2, SEL_F1 | SEL_F3, SEL_F1 | SEL_F2 | SEL_F3)) { + ELEM(flag, SEL_F2, SEL_F1 | SEL_F3, SEL_F1 | SEL_F2 | SEL_F3)) + { BKE_nurb_bezt_calc_normal(nu, bezt, tvec); add_v3_v3(normal, tvec); } @@ -1301,10 +1302,10 @@ int getTransformOrientation_ex(const Scene *scene, add_v3_v3(plane, tmat[1]); ok = true; } - else if ((ok == false) && - ((ebone->flag & BONE_TIPSEL) || - ((ebone->flag & BONE_ROOTSEL) && - (ebone->parent && ebone->flag & BONE_CONNECTED) == false))) { + else if ((ok == false) && ((ebone->flag & BONE_TIPSEL) || + ((ebone->flag & BONE_ROOTSEL) && + (ebone->parent && ebone->flag & BONE_CONNECTED) == false))) + { ED_armature_ebone_to_mat3(ebone, tmat); add_v3_v3(fallback_normal, tmat[2]); add_v3_v3(fallback_plane, tmat[1]); diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc index be900cf41b8..a1fc4ba75f2 100644 --- a/source/blender/editors/transform/transform_snap.cc +++ b/source/blender/editors/transform/transform_snap.cc @@ -101,7 +101,8 @@ static bool snap_use_backface_culling(const TransInfo *t) } if (v3d->shading.type == OB_RENDER && (t->scene->display.shading.flag & V3D_SHADING_BACKFACE_CULLING) && - BKE_scene_uses_blender_workbench(t->scene)) { + BKE_scene_uses_blender_workbench(t->scene)) + { return true; } if (t->settings->snap_flag & SCE_SNAP_BACKFACE_CULLING) { @@ -584,7 +585,8 @@ bool validSnappingNormal(const TransInfo *t) static bool bm_edge_is_snap_target(BMEdge *e, void * /*user_data*/) { if (BM_elem_flag_test(e, BM_ELEM_SELECT | BM_ELEM_HIDDEN) || - BM_elem_flag_test(e->v1, BM_ELEM_SELECT) || BM_elem_flag_test(e->v2, BM_ELEM_SELECT)) { + BM_elem_flag_test(e->v1, BM_ELEM_SELECT) || BM_elem_flag_test(e->v2, BM_ELEM_SELECT)) + { return false; } @@ -643,7 +645,8 @@ static eSnapMode snap_mode_from_spacetype(TransInfo *t) if (t->spacetype == SPACE_IMAGE) { eSnapMode snap_mode = eSnapMode(ts->snap_uv_mode); if ((snap_mode & SCE_SNAP_MODE_INCREMENT) && (ts->snap_uv_flag & SCE_SNAP_ABS_GRID) && - (t->mode == TFM_TRANSLATION)) { + (t->mode == TFM_TRANSLATION)) + { snap_mode &= ~SCE_SNAP_MODE_INCREMENT; snap_mode |= SCE_SNAP_MODE_GRID; } @@ -661,7 +664,8 @@ static eSnapMode snap_mode_from_spacetype(TransInfo *t) eSnapMode snap_mode = eSnapMode(ts->snap_mode); if ((snap_mode & SCE_SNAP_MODE_INCREMENT) && (ts->snap_flag & SCE_SNAP_ABS_GRID) && - (t->mode == TFM_TRANSLATION)) { + (t->mode == TFM_TRANSLATION)) + { /* Special case in which snap to increments is transformed to snap to grid. */ snap_mode &= ~SCE_SNAP_MODE_INCREMENT; snap_mode |= SCE_SNAP_MODE_GRID; @@ -742,7 +746,8 @@ static void initSnappingMode(TransInfo *t) if ((t->spacetype != SPACE_VIEW3D) || !(t->tsnap.mode & (SCE_SNAP_MODE_FACE_RAYCAST | SCE_SNAP_MODE_FACE_NEAREST)) || - (t->flag & T_NO_PROJECT)) { + (t->flag & T_NO_PROJECT)) + { /* Force project off when not supported. */ t->tsnap.flag &= ~SCE_SNAP_PROJECT; } @@ -805,7 +810,8 @@ void initSnapping(TransInfo *t, wmOperator *op) t->modifiers |= MOD_SNAP; if ((prop = RNA_struct_find_property(op->ptr, "snap_elements")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { t->tsnap.mode = eSnapMode(RNA_property_enum_get(op->ptr, prop)); } @@ -813,7 +819,8 @@ void initSnapping(TransInfo *t, wmOperator *op) * "target" (now, "source" is geometry to be moved and "target" is geometry to which moved * geometry is snapped). */ if ((prop = RNA_struct_find_property(op->ptr, "snap_target")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { snap_source = eSnapSourceOP(RNA_property_enum_get(op->ptr, prop)); } @@ -835,35 +842,40 @@ void initSnapping(TransInfo *t, wmOperator *op) } if ((prop = RNA_struct_find_property(op->ptr, "use_snap_project")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { SET_FLAG_FROM_TEST( t->tsnap.flag, RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_PROJECT); } /* use_snap_self is misnamed and should be use_snap_active */ if ((prop = RNA_struct_find_property(op->ptr, "use_snap_self")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { SET_FLAG_FROM_TEST(t->tsnap.target_operation, !RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_TARGET_NOT_ACTIVE); } if ((prop = RNA_struct_find_property(op->ptr, "use_snap_edit")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { SET_FLAG_FROM_TEST(t->tsnap.target_operation, !RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_TARGET_NOT_EDITED); } if ((prop = RNA_struct_find_property(op->ptr, "use_snap_nonedit")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { SET_FLAG_FROM_TEST(t->tsnap.target_operation, !RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_TARGET_NOT_NONEDITED); } if ((prop = RNA_struct_find_property(op->ptr, "use_snap_selectable")) && - RNA_property_is_set(op->ptr, prop)) { + RNA_property_is_set(op->ptr, prop)) + { SET_FLAG_FROM_TEST(t->tsnap.target_operation, RNA_property_boolean_get(op->ptr, prop), SCE_SNAP_TARGET_ONLY_SELECTABLE); @@ -997,7 +1009,8 @@ eRedrawFlag updateSelectedSnapPoint(TransInfo *t) float dist_sq; if (ED_view3d_project_float_global(t->region, p->co, screen_loc, V3D_PROJ_TEST_NOP) != - V3D_PROJ_RET_OK) { + V3D_PROJ_RET_OK) + { continue; } @@ -1124,7 +1137,8 @@ static void snap_target_uv_fn(TransInfo *t, float * /*vec*/) t->mval, t->tsnap.target_operation & SCE_SNAP_TARGET_NOT_SELECTED, &dist_sq, - t->tsnap.snap_target)) { + t->tsnap.snap_target)) + { t->tsnap.snap_target[0] *= t->aspect[0]; t->tsnap.snap_target[1] *= t->aspect[1]; @@ -1431,7 +1445,8 @@ bool peelObjectsTransform(TransInfo *t, /* if peeling objects, take the first and last from each object */ hit_max = hit_min; for (SnapObjectHitDepth *iter = static_cast(depths_peel.first); iter; - iter = iter->next) { + iter = iter->next) + { if ((iter->depth > hit_max->depth) && (iter->ob_uuid == hit_min->ob_uuid)) { hit_max = iter; } @@ -1440,7 +1455,8 @@ bool peelObjectsTransform(TransInfo *t, else { /* otherwise, pair first with second and so on */ for (SnapObjectHitDepth *iter = static_cast(depths_peel.first); iter; - iter = iter->next) { + iter = iter->next) + { if ((iter != hit_min) && (iter->ob_uuid == hit_min->ob_uuid)) { if (hit_max == nullptr) { hit_max = iter; @@ -1689,7 +1705,8 @@ bool transform_snap_increment(const TransInfo *t, float *r_val) float transform_snap_increment_get(const TransInfo *t) { if (transform_snap_is_active(t) && - (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))) { + (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))) + { return (t->modifiers & MOD_PRECISION) ? t->snap[1] : t->snap[0]; } diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 146acc78c81..87872227936 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -228,7 +228,8 @@ static void snap_editmesh_minmax(SnapObjectContext *sctx, BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (sctx->callbacks.edit_mesh.test_vert_fn && - !sctx->callbacks.edit_mesh.test_vert_fn(v, sctx->callbacks.edit_mesh.user_data)) { + !sctx->callbacks.edit_mesh.test_vert_fn(v, sctx->callbacks.edit_mesh.user_data)) + { continue; } minmax_v3v3_v3(r_min, r_max, v->co); @@ -306,17 +307,20 @@ static SnapData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx, } } else if (sod->treedata_editmesh.tree && sod->treedata_editmesh.cached && - !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->treedata_editmesh.tree)) { + !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->treedata_editmesh.tree)) + { /* The tree is owned by the EditMesh and may have been freed since we last used! */ is_dirty = true; } else if (sod->bvhtree[0] && sod->cached[0] && - !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->bvhtree[0])) { + !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->bvhtree[0])) + { /* The tree is owned by the EditMesh and may have been freed since we last used! */ is_dirty = true; } else if (sod->bvhtree[1] && sod->cached[1] && - !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->bvhtree[1])) { + !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->bvhtree[1])) + { /* The tree is owned by the EditMesh and may have been freed since we last used! */ is_dirty = true; } @@ -413,7 +417,8 @@ static bool snap_object_is_snappable(const SnapObjectContext *sctx, } if ((snap_target_select == SCE_SNAP_TARGET_ALL) || - (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE)) { + (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE)) + { return true; } @@ -493,7 +498,8 @@ static eSnapMode iter_snap_objects(SnapObjectContext *sctx, dupli_ob->mat, is_object_active, false, - data)) != SCE_SNAP_MODE_NONE) { + data)) != SCE_SNAP_MODE_NONE) + { ret = tmp; } } @@ -509,7 +515,8 @@ static eSnapMode iter_snap_objects(SnapObjectContext *sctx, obj_eval->object_to_world, is_object_active, use_hide, - data)) != SCE_SNAP_MODE_NONE) { + data)) != SCE_SNAP_MODE_NONE) + { ret = tmp; } } @@ -719,7 +726,8 @@ static bool raycastMesh(SnapObjectContext *sctx, if (bb) { /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ if (!isect_ray_aabb_v3_simple( - ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, nullptr)) { + ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, nullptr)) + { return retval; } } @@ -781,7 +789,8 @@ static bool raycastMesh(SnapObjectContext *sctx, params->use_backface_culling ? mesh_looptri_raycast_backface_culling_cb : treedata.raycast_callback, - &treedata) != -1) { + &treedata) != -1) + { hit.dist += len_diff; hit.dist /= local_scale; if (hit.dist <= *ray_depth) { @@ -855,7 +864,8 @@ static bool raycastEditMesh(SnapObjectContext *sctx, /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ if (!isect_ray_aabb_v3_simple( - ray_start_local, ray_normal_local, sod->min, sod->max, &len_diff, nullptr)) { + ray_start_local, ray_normal_local, sod->min, sod->max, &len_diff, nullptr)) + { return retval; } @@ -916,7 +926,8 @@ static bool raycastEditMesh(SnapObjectContext *sctx, params->use_backface_culling ? editmesh_looptri_raycast_backface_culling_cb : treedata->raycast_callback, - treedata) != -1) { + treedata) != -1) + { hit.dist += len_diff; hit.dist /= local_scale; if (hit.dist <= *ray_depth) { @@ -1002,7 +1013,8 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx, sctx->ret.loc, sctx->ret.no, &sctx->ret.index, - sctx->ret.hit_list)) { + sctx->ret.hit_list)) + { retval = true; is_edit = true; } @@ -1296,7 +1308,8 @@ static eSnapMode nearest_world_object_fn(SnapObjectContext *sctx, &sctx->ret.dist_sq, sctx->ret.loc, sctx->ret.no, - &sctx->ret.index)) { + &sctx->ret.index)) + { retval = true; is_edit = true; } @@ -1579,13 +1592,9 @@ static void cb_snap_vert(void *userdata, const float *co; data->get_vert_co(index, data, &co); - if (test_projected_vert_dist(precalc, - clip_plane, - clip_plane_len, - data->is_persp, - co, - &nearest->dist_sq, - nearest->co)) { + if (test_projected_vert_dist( + precalc, clip_plane, clip_plane_len, data->is_persp, co, &nearest->dist_sq, nearest->co)) + { data->copy_vert_no(index, data, nearest->no); nearest->index = index; } @@ -1614,7 +1623,8 @@ static void cb_snap_edge(void *userdata, v_pair[0], v_pair[1], &nearest->dist_sq, - nearest->co)) { + nearest->co)) + { sub_v3_v3v3(nearest->no, v_pair[0], v_pair[1]); nearest->index = index; } @@ -1943,7 +1953,8 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, neasrest_precalc.ray_direction, v_pair[0], v_pair[1], - &lambda)) { + &lambda)) + { /* Do nothing. */ } else { @@ -1963,7 +1974,8 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, nearest2d.is_persp, v_pair[v_id], &nearest.dist_sq, - nearest.co)) { + nearest.co)) + { nearest.index = vindex[v_id]; elem = SCE_SNAP_MODE_VERTEX; { @@ -1989,7 +2001,8 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, nearest2d.is_persp, vmid, &nearest.dist_sq, - nearest.co)) { + nearest.co)) + { nearest.index = sctx->ret.index; elem = SCE_SNAP_MODE_EDGE_MIDPOINT; } @@ -2016,7 +2029,8 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, nearest2d.is_persp, v_near, &nearest.dist_sq, - nearest.co)) { + nearest.co)) + { nearest.index = sctx->ret.index; elem = SCE_SNAP_MODE_EDGE_PERPENDICULAR; } @@ -2071,12 +2085,10 @@ static eSnapMode snapArmature(SnapObjectContext *sctx, if (is_editmode == false) { /* Test BoundBox. */ const BoundBox *bb = BKE_armature_boundbox_get(ob_eval); - if (bb && !snap_bound_box_check_dist(bb->vec[0], - bb->vec[6], - lpmat, - sctx->runtime.win_size, - sctx->runtime.mval, - dist_px_sq)) { + if (bb && + !snap_bound_box_check_dist( + bb->vec[0], bb->vec[6], lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) + { return retval; } } @@ -2135,7 +2147,8 @@ static eSnapMode snapArmature(SnapObjectContext *sctx, eBone->head, eBone->tail, &dist_px_sq, - r_loc)) { + r_loc)) + { retval = SCE_SNAP_MODE_EDGE; } } @@ -2187,7 +2200,8 @@ static eSnapMode snapArmature(SnapObjectContext *sctx, head_vec, tail_vec, &dist_px_sq, - r_loc)) { + r_loc)) + { retval = SCE_SNAP_MODE_EDGE; } } @@ -2240,12 +2254,10 @@ static eSnapMode snapCurve(SnapObjectContext *sctx, if (use_obedit == false) { /* Test BoundBox */ BoundBox *bb = BKE_curve_boundbox_get(ob_eval); - if (bb && !snap_bound_box_check_dist(bb->vec[0], - bb->vec[6], - lpmat, - sctx->runtime.win_size, - sctx->runtime.mval, - dist_px_sq)) { + if (bb && + !snap_bound_box_check_dist( + bb->vec[0], bb->vec[6], lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) + { return SCE_SNAP_MODE_NONE; } } @@ -2412,7 +2424,8 @@ static eSnapMode snap_object_center(const SnapObjectContext *sctx, is_persp, obmat[3], &dist_px_sq, - r_loc)) { + r_loc)) + { *dist_px = sqrtf(dist_px_sq); retval = SCE_SNAP_MODE_VERTEX; } @@ -2502,7 +2515,8 @@ static eSnapMode snapCamera(const SnapObjectContext *sctx, is_persp, bundle_pos, &dist_px_sq, - r_loc)) { + r_loc)) + { retval = SCE_SNAP_MODE_VERTEX; } } @@ -2550,12 +2564,9 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, /* Test BoundBox */ if (ob_eval->data == me_eval) { const BoundBox *bb = BKE_object_boundbox_get(ob_eval); - if (!snap_bound_box_check_dist(bb->vec[0], - bb->vec[6], - lpmat, - sctx->runtime.win_size, - sctx->runtime.mval, - dist_px_sq)) { + if (!snap_bound_box_check_dist( + bb->vec[0], bb->vec[6], lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) + { return SCE_SNAP_MODE_NONE; } } @@ -2726,7 +2737,8 @@ static eSnapMode snapEditMesh(SnapObjectContext *sctx, /* Was BKE_boundbox_ray_hit_check, see: cf6ca226fa58. */ if (!snap_bound_box_check_dist( - sod->min, sod->max, lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) { + sod->min, sod->max, lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) + { return SCE_SNAP_MODE_NONE; } @@ -3280,7 +3292,8 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont if ((snap_to_flag & SCE_SNAP_MODE_FACE_RAYCAST) || use_occlusion_test) { float ray_start[3], ray_normal[3]; if (!ED_view3d_win_to_ray_clipped_ex( - depsgraph, region, v3d, mval, nullptr, ray_normal, ray_start, true)) { + depsgraph, region, v3d, mval, nullptr, ray_normal, ray_start, true)) + { return retval; } @@ -3314,7 +3327,8 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont } if (snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | - SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { + SCE_SNAP_MODE_EDGE_PERPENDICULAR)) + { eSnapMode elem_test, elem = SCE_SNAP_MODE_NONE; float dist_px_tmp = *dist_px; @@ -3378,8 +3392,9 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont } if ((elem == SCE_SNAP_MODE_EDGE) && - (snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE_MIDPOINT | - SCE_SNAP_MODE_EDGE_PERPENDICULAR))) { + (snap_to_flag & + (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR))) + { sctx->runtime.snap_to_flag = snap_to_flag; elem = snap_mesh_edge_verts_mixed(sctx, params, *dist_px, prev_co, &dist_px_tmp); } @@ -3487,7 +3502,8 @@ bool ED_transform_snap_object_project_all_view3d_ex(SnapObjectContext *sctx, float ray_start[3], ray_normal[3]; if (!ED_view3d_win_to_ray_clipped_ex( - depsgraph, region, v3d, mval, nullptr, ray_normal, ray_start, true)) { + depsgraph, region, v3d, mval, nullptr, ray_normal, ray_start, true)) + { return false; } diff --git a/source/blender/editors/undo/ed_undo.cc b/source/blender/editors/undo/ed_undo.cc index dfd1f4c6860..8f04d9a924f 100644 --- a/source/blender/editors/undo/ed_undo.cc +++ b/source/blender/editors/undo/ed_undo.cc @@ -683,7 +683,8 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) * (which copy their data), won't stop redo, see #29579. * * NOTE: WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this. */ - (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0)) { + (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0)) + { int retval; if (G.debug & G_DEBUG) { @@ -833,7 +834,8 @@ void ED_undo_object_editmode_restore_helper(struct bContext *C, } Object **ob_p = object_array; for (uint i = 0; i < object_array_len; - i++, ob_p = static_cast(POINTER_OFFSET(ob_p, object_array_stride))) { + i++, ob_p = static_cast(POINTER_OFFSET(ob_p, object_array_stride))) + { Object *obedit = *ob_p; ED_object_editmode_enter_ex(bmain, scene, obedit, EM_NO_CONTEXT); ((ID *)obedit->data)->tag &= ~LIB_TAG_DOIT; @@ -910,7 +912,8 @@ Object **ED_undo_editmode_objects_from_view_layer(const Scene *scene, for (Base *base = baseact, *base_next = static_cast(BKE_view_layer_object_bases_get(view_layer)->first); base; - base = base_next, base_next = base_next ? base_next->next : nullptr) { + base = base_next, base_next = base_next ? base_next->next : nullptr) + { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { ID *id = static_cast(ob->data); @@ -945,7 +948,8 @@ Base **ED_undo_editmode_bases_from_view_layer(const Scene *scene, for (Base *base = BKE_view_layer_active_base_get(view_layer), *base_next = static_cast(BKE_view_layer_object_bases_get(view_layer)->first); base; - base = base_next, base_next = base_next ? base_next->next : nullptr) { + base = base_next, base_next = base_next ? base_next->next : nullptr) + { Object *ob = base->object; if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) { ID *id = static_cast(ob->data); diff --git a/source/blender/editors/util/ed_util.cc b/source/blender/editors/util/ed_util.cc index b04ba65edd0..44fa3500252 100644 --- a/source/blender/editors/util/ed_util.cc +++ b/source/blender/editors/util/ed_util.cc @@ -131,7 +131,8 @@ void ED_editors_init(bContext *C) } /* Object mode is enforced for non-editable data (or their obdata). */ if (!BKE_id_is_editable(bmain, &ob->id) || - (ob_data != nullptr && !BKE_id_is_editable(bmain, ob_data))) { + (ob_data != nullptr && !BKE_id_is_editable(bmain, ob_data))) + { continue; } @@ -146,7 +147,8 @@ void ED_editors_init(bContext *C) * modes like Sculpt. * Ref. #98225. */ if (!BKE_collection_has_object_recursive(scene->master_collection, ob) || - !BKE_scene_has_object(scene, ob) || (ob->visibility_flag & OB_HIDE_VIEWPORT) != 0) { + !BKE_scene_has_object(scene, ob) || (ob->visibility_flag & OB_HIDE_VIEWPORT) != 0) + { continue; } @@ -377,7 +379,7 @@ void unpack_menu(bContext *C, if (blendfile_path[0] != '\0') { char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; - BLI_split_file_part(abs_name, fi, sizeof(fi)); + BLI_path_split_file_part(abs_name, fi, sizeof(fi)); BLI_path_join(local_name, sizeof(local_name), "//", folder, fi); if (!STREQ(abs_name, local_name)) { switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) { diff --git a/source/blender/editors/util/ed_util_ops.cc b/source/blender/editors/util/ed_util_ops.cc index 0b3a8fe463b..202536b06b9 100644 --- a/source/blender/editors/util/ed_util_ops.cc +++ b/source/blender/editors/util/ed_util_ops.cc @@ -229,7 +229,8 @@ static int lib_id_fake_user_toggle_exec(bContext *C, wmOperator *op) ID *id = (ID *)idptr.data; if (!BKE_id_is_editable(CTX_data_main(C), id) || - ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS)) { + ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS)) + { BKE_report(op->reports, RPT_ERROR, "Data-block type does not support fake user"); return OPERATOR_CANCELLED; } @@ -313,7 +314,7 @@ static int lib_id_override_editable_toggle_exec(bContext *C, wmOperator * /*op*/ const bool is_system_override = BKE_lib_override_library_is_system_defined(bmain, id); if (is_system_override) { /* A system override is not editable. Make it an editable (non-system-defined) one. */ - id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED; + id->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED; } else { /* Reset override, which makes it non-editable (i.e. a system define override). */ diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 0e9f6dce6b9..f535b91ec0e 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -323,7 +323,8 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event) #endif { if (((event->modifier & (KM_CTRL | KM_ALT)) == 0) && (event_ascii != '\0') && - strchr("01234567890@%^&*-+/{}()[]<>.|", event_ascii)) { + strchr("01234567890@%^&*-+/{}()[]<>.|", event_ascii)) + { if (!(n->flag & NUM_EDIT_FULL)) { n->flag |= NUM_EDITED; n->flag |= NUM_EDIT_FULL; diff --git a/source/blender/editors/uvedit/uvedit_clipboard.cc b/source/blender/editors/uvedit/uvedit_clipboard.cc index 71ca1d52215..6a43e15b7f2 100644 --- a/source/blender/editors/uvedit/uvedit_clipboard.cc +++ b/source/blender/editors/uvedit/uvedit_clipboard.cc @@ -254,7 +254,8 @@ bool UV_ClipboardBuffer::find_isomorphism(UvElementMap *dest_element_map, graph[source_island_index], cd_loop_uv_offset, r_label, - r_search_abandoned)) { + r_search_abandoned)) + { const int island_total_unique_uvs = dest_element_map->island_total_unique_uvs[dest_island_index]; const int island_offset = offset[source_island_index]; diff --git a/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc b/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc index edf48d9522e..d61a7d914c1 100644 --- a/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc +++ b/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc @@ -191,7 +191,8 @@ static void generate_next_domains(uint8_t domains[][BDS], int bound = 0; uint8_t *bd; for (i = *bd_pos - 1, bd = &domains[i][L]; i >= 0 && bd[P] == cur_pos - 1; - i--, bd = &domains[i][L]) { + i--, bd = &domains[i][L]) + { uint8_t l_len = partition(left, bd[L], bd[LL], adjmat0[v]); uint8_t r_len = partition(right, bd[R], bd[RL], adjmat1[w]); @@ -256,7 +257,8 @@ static void select_bidomain( int best = INT_MAX; uint8_t *bd; for (i = bd_pos - 1, bd = &domains[i][L]; i >= 0 && bd[P] == current_matching_size; - i--, bd = &domains[i][L]) { + i--, bd = &domains[i][L]) + { if (connected && current_matching_size > 0 && !bd[ADJ]) { continue; } diff --git a/source/blender/editors/uvedit/uvedit_path.c b/source/blender/editors/uvedit/uvedit_path.c index 7941d492a78..018f0f17051 100644 --- a/source/blender/editors/uvedit/uvedit_path.c +++ b/source/blender/editors/uvedit/uvedit_path.c @@ -217,7 +217,8 @@ static int mouse_mesh_uv_shortest_path_vert(Scene *scene, node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { verttag_set_cb((BMLoop *)node->link, !all_set, &user_data); if (is_path_ordered) { l_dst_last = node->link; @@ -337,7 +338,8 @@ static int mouse_mesh_uv_shortest_path_edge(Scene *scene, node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { edgetag_set_cb((BMLoop *)node->link, !all_set, &user_data); if (is_path_ordered) { l_dst_last = node->link; @@ -453,7 +455,8 @@ static int mouse_mesh_uv_shortest_path_face(Scene *scene, node = path; do { if ((is_path_ordered == false) || - WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) { + WM_operator_properties_checker_interval_test(&op_params->interval_params, depth)) + { facetag_set_cb((BMFace *)node->link, !all_set, &user_data); if (is_path_ordered) { f_dst_last = node->link; @@ -623,7 +626,8 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve l_src = ED_uvedit_active_edge_loop_get(bm); if (l_src != NULL) { if (!uvedit_uv_select_test(scene, l_src, offsets) && - !uvedit_uv_select_test(scene, l_src->next, offsets)) { + !uvedit_uv_select_test(scene, l_src->next, offsets)) + { l_src = NULL; } ele_src = (BMElem *)l_src; @@ -717,7 +721,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (!(ele_src = (BMElem *)BM_mesh_active_face_get(bm, false, false)) || - !(ele_dst = (BMElem *)BM_face_at_index_find_or_table(bm, index))) { + !(ele_dst = (BMElem *)BM_face_at_index_find_or_table(bm, index))) + { return OPERATOR_CANCELLED; } } @@ -726,7 +731,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (!(ele_src = (BMElem *)ED_uvedit_active_edge_loop_get(bm)) || - !(ele_dst = (BMElem *)BM_loop_at_index_find(bm, index))) { + !(ele_dst = (BMElem *)BM_loop_at_index_find(bm, index))) + { return OPERATOR_CANCELLED; } } @@ -735,7 +741,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (!(ele_src = (BMElem *)ED_uvedit_active_vert_loop_get(bm)) || - !(ele_dst = (BMElem *)BM_loop_at_index_find(bm, index))) { + !(ele_dst = (BMElem *)BM_loop_at_index_find(bm, index))) + { return OPERATOR_CANCELLED; } } @@ -749,7 +756,8 @@ static int uv_shortest_path_pick_exec(bContext *C, wmOperator *op) op_params.track_active = true; if (!uv_shortest_path_pick_ex( - scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, offsets)) { + scene, depsgraph, obedit, &op_params, ele_src, ele_dst, aspect_y, offsets)) + { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/uvedit/uvedit_rip.c b/source/blender/editors/uvedit/uvedit_rip.c index 7517a526722..100f7957dbf 100644 --- a/source/blender/editors/uvedit/uvedit_rip.c +++ b/source/blender/editors/uvedit/uvedit_rip.c @@ -105,7 +105,8 @@ static BMLoop *bm_loop_find_other_radial_loop_with_visible_face(BMLoop *l_src, if (l_iter != l_src) { do { if (BM_elem_flag_test(l_iter->f, BM_ELEM_TAG) && UL(l_iter)->is_select_edge && - BM_loop_uv_share_edge_check(l_src, l_iter, cd_loop_uv_offset)) { + BM_loop_uv_share_edge_check(l_src, l_iter, cd_loop_uv_offset)) + { /* Check UVs are contiguous. */ if (l_other == NULL) { l_other = l_iter; @@ -131,7 +132,8 @@ static BMLoop *bm_loop_find_other_fan_loop_with_visible_face(BMLoop *l_src, if (l_iter != l_src) { do { if (BM_elem_flag_test(l_iter->f, BM_ELEM_TAG) && - BM_loop_uv_share_edge_check(l_src, l_iter, cd_loop_uv_offset)) { + BM_loop_uv_share_edge_check(l_src, l_iter, cd_loop_uv_offset)) + { /* Check UVs are contiguous. */ if (l_other == NULL) { l_other = l_iter; @@ -371,7 +373,8 @@ static UVRipSingle *uv_rip_single_from_loop(BMLoop *l_init_orig, BMEdge *e_prev = i ? l_init->e : l_init->prev->e; BMLoop *l_iter = l_init; while (((l_iter = bm_vert_step_fan_loop_uv(l_iter, &e_prev, cd_loop_uv_offset)) != l_init) && - (l_iter != NULL) && (UL(l_iter)->side == 0)) { + (l_iter != NULL) && (UL(l_iter)->side == 0)) + { uv_fan_count_contiguous += 1; /* Keep. */ UL(l_iter)->side = 1; @@ -621,7 +624,8 @@ static UVRipPairs *uv_rip_pairs_from_loop(BMLoop *l_init, else { if (UL(l_other)->side != side) { if ((UL(l_other)->side_was_swapped == false) && - uv_rip_pairs_loop_change_sides_test(l_other, l_step, aspect_y, cd_loop_uv_offset)) { + uv_rip_pairs_loop_change_sides_test(l_other, l_step, aspect_y, cd_loop_uv_offset)) + { UV_SET_SIDE_AND_REMOVE_FROM_RAIL(l_other, side); } } @@ -651,7 +655,8 @@ static UVRipPairs *uv_rip_pairs_from_loop(BMLoop *l_init, if (UL(l_other)->side != side) { if ((UL(l_other)->side_was_swapped == false) && uv_rip_pairs_loop_change_sides_test( - l_other, l_step, aspect_y, cd_loop_uv_offset)) { + l_other, l_step, aspect_y, cd_loop_uv_offset)) + { UV_SET_SIDE_AND_REMOVE_FROM_RAIL(l_other, side); } } diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index ef8deaf18f3..e12456b014c 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -480,8 +480,8 @@ void uvedit_edge_select_set_noflush(const Scene *scene, BMLoop *l_iter = l; do { if (uvedit_face_visible_test(scene, l_iter->f)) { - if ((sticky_flag == SI_STICKY_VERTEX) || - BM_loop_uv_share_edge_check(l, l_iter, offsets.uv)) { + if ((sticky_flag == SI_STICKY_VERTEX) || BM_loop_uv_share_edge_check(l, l_iter, offsets.uv)) + { BM_ELEM_CD_SET_BOOL(l_iter, offsets.select_edge, select); } } @@ -743,7 +743,8 @@ static BMLoop *uvedit_loop_find_other_radial_loop_with_visible_face(const Scene if (l_iter != l_src) { do { if (uvedit_face_visible_test(scene, l_iter->f) && - BM_loop_uv_share_edge_check(l_src, l_iter, offsets.uv)) { + BM_loop_uv_share_edge_check(l_src, l_iter, offsets.uv)) + { /* Check UVs are contiguous. */ if (l_other == NULL) { l_other = l_iter; @@ -1174,7 +1175,8 @@ bool uvedit_vert_is_edge_select_any_other(const Scene *scene, BMLoop *l, const B * and #l_radial_iter for the actual edge selection test. */ l_other = (l_radial_iter->v != l->v) ? l_radial_iter->next : l_radial_iter; if (BM_loop_uv_share_vert_check(l, l_other, offsets.uv) && - uvedit_edge_select_test(scene, l_radial_iter, offsets)) { + uvedit_edge_select_test(scene, l_radial_iter, offsets)) + { return true; } } @@ -1194,7 +1196,8 @@ bool uvedit_vert_is_face_select_any_other(const Scene *scene, BMLoop *l, const B continue; } if (BM_loop_uv_share_vert_check(l, l_iter, offsets.uv) && - uvedit_face_select_test(scene, l_iter->f, offsets)) { + uvedit_face_select_test(scene, l_iter->f, offsets)) + { return true; } } @@ -1213,7 +1216,8 @@ bool uvedit_vert_is_all_other_faces_selected(const Scene *scene, continue; } if (BM_loop_uv_share_vert_check(l, l_iter, offsets.uv) && - !uvedit_face_select_test(scene, l_iter->f, offsets)) { + !uvedit_face_select_test(scene, l_iter->f, offsets)) + { return false; } } @@ -1302,7 +1306,8 @@ void uvedit_select_flush(const Scene *scene, BMEditMesh *em) } BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (BM_ELEM_CD_GET_BOOL(l, offsets.select_vert) && - BM_ELEM_CD_GET_BOOL(l->next, offsets.select_vert)) { + BM_ELEM_CD_GET_BOOL(l->next, offsets.select_vert)) + { BM_ELEM_CD_SET_BOOL(l, offsets.select_edge, true); } } @@ -1329,7 +1334,8 @@ void uvedit_deselect_flush(const Scene *scene, BMEditMesh *em) } BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (!BM_ELEM_CD_GET_BOOL(l, offsets.select_vert) || - !BM_ELEM_CD_GET_BOOL(l->next, offsets.select_vert)) { + !BM_ELEM_CD_GET_BOOL(l->next, offsets.select_vert)) + { BM_ELEM_CD_SET_BOOL(l, offsets.select_edge, false); } } @@ -1412,7 +1418,8 @@ static void uv_select_edgeloop_double_side_tag(const Scene *scene, !uvedit_face_visible_test(scene, l_step_pair[1]->f) || /* Check loops have not diverged. */ (uvedit_loop_find_other_radial_loop_with_visible_face(scene, l_step_pair[0], offsets) != - l_step_pair[1])) { + l_step_pair[1])) + { break; } @@ -1429,7 +1436,8 @@ static void uv_select_edgeloop_double_side_tag(const Scene *scene, } if ((l_step_pair[0] && BM_elem_flag_test(l_step_pair[0], BM_ELEM_TAG)) || - (l_step_pair[1] && BM_elem_flag_test(l_step_pair[1], BM_ELEM_TAG))) { + (l_step_pair[1] && BM_elem_flag_test(l_step_pair[1], BM_ELEM_TAG))) + { break; } v_from = v_from_next; @@ -1465,7 +1473,8 @@ static void uv_select_edgeloop_single_side_tag(const Scene *scene, if (!uvedit_face_visible_test(scene, l_step->f) || /* Check the boundary is still a boundary. */ - (uvedit_loop_find_other_radial_loop_with_visible_face(scene, l_step, offsets) != NULL)) { + (uvedit_loop_find_other_radial_loop_with_visible_face(scene, l_step, offsets) != NULL)) + { break; } @@ -1834,7 +1843,8 @@ static void uv_select_linked_multi(Scene *scene, BMLoop *l_other; BM_ITER_ELEM (l_other, &liter_other, l->v, BM_LOOPS_OF_VERT) { if ((l != l_other) && !BM_loop_uv_share_vert_check(l, l_other, offsets.uv) && - uvedit_face_select_test(scene, l_other->f, offsets)) { + uvedit_face_select_test(scene, l_other->f, offsets)) + { add_to_stack = false; break; } @@ -3914,8 +3924,8 @@ static bool do_lasso_select_mesh_uv_is_point_inside(const ARegion *region, if (UI_view2d_view_to_region_clip( ®ion->v2d, co_test[0], co_test[1], &co_screen[0], &co_screen[1]) && BLI_rcti_isect_pt_v(clip_rect, co_screen) && - BLI_lasso_is_point_inside( - mcoords, mcoords_len, co_screen[0], co_screen[1], V2D_IS_CLIPPED)) { + BLI_lasso_is_point_inside(mcoords, mcoords_len, co_screen[0], co_screen[1], V2D_IS_CLIPPED)) + { return true; } return false; @@ -3933,7 +3943,8 @@ static bool do_lasso_select_mesh_uv_is_edge_inside(const ARegion *region, ®ion->v2d, co_test_a, co_test_b, co_screen_a, co_screen_b) && BLI_rcti_isect_segment(clip_rect, co_screen_a, co_screen_b) && BLI_lasso_is_edge_inside( - mcoords, mcoords_len, UNPACK2(co_screen_a), UNPACK2(co_screen_b), V2D_IS_CLIPPED)) { + mcoords, mcoords_len, UNPACK2(co_screen_a), UNPACK2(co_screen_b), V2D_IS_CLIPPED)) + { return true; } return false; @@ -4023,7 +4034,8 @@ static bool do_lasso_select_mesh_uv(bContext *C, float *luv = BM_ELEM_CD_GET_FLOAT_P(l, offsets.uv); if (do_lasso_select_mesh_uv_is_point_inside(region, &rect, mcoords, mcoords_len, luv) && do_lasso_select_mesh_uv_is_point_inside( - region, &rect, mcoords, mcoords_len, luv_prev)) { + region, &rect, mcoords, mcoords_len, luv_prev)) + { uvedit_edge_select_set_with_sticky(scene, em, l_prev, select, false, offsets); do_second_pass = false; changed = true; @@ -4067,8 +4079,8 @@ static bool do_lasso_select_mesh_uv(bContext *C, BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (select != uvedit_uv_select_test(scene, l, offsets)) { float *luv = BM_ELEM_CD_GET_FLOAT_P(l, offsets.uv); - if (do_lasso_select_mesh_uv_is_point_inside( - region, &rect, mcoords, mcoords_len, luv)) { + if (do_lasso_select_mesh_uv_is_point_inside(region, &rect, mcoords, mcoords_len, luv)) + { uvedit_uv_select_set(scene, em->bm, l, select, false, offsets); changed = true; BM_elem_flag_enable(l->v, BM_ELEM_TAG); @@ -4277,7 +4289,8 @@ static bool overlap_tri_tri_uv_test(const float t1[3][2], isect_seg_seg_v2_point_ex(t1[1], t1[2], t2[1], t2[2], endpoint_bias, vi) == 1 || isect_seg_seg_v2_point_ex(t1[1], t1[2], t2[2], t2[0], endpoint_bias, vi) == 1 || isect_seg_seg_v2_point_ex(t1[2], t1[0], t2[0], t2[1], endpoint_bias, vi) == 1 || - isect_seg_seg_v2_point_ex(t1[2], t1[0], t2[1], t2[2], endpoint_bias, vi) == 1) { + isect_seg_seg_v2_point_ex(t1[2], t1[0], t2[1], t2[2], endpoint_bias, vi) == 1) + { return true; } @@ -4458,7 +4471,8 @@ static int uv_select_overlap(bContext *C, const bool extend) /* Skip if both faces are already selected. */ if (uvedit_face_select_test(scene, face_a, offsets_a) && - uvedit_face_select_test(scene, face_b, offsets_b)) { + uvedit_face_select_test(scene, face_b, offsets_b)) + { continue; } diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index b5165f4f1de..fe9a182b3e0 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -359,7 +359,8 @@ static bool stitch_check_edges_stitchable(const int cd_loop_uv_offset, float *luv_iter2 = BM_ELEM_CD_GET_FLOAT_P(state->uvs[edge_iter->uv2]->l, cd_loop_uv_offset); if (fabsf(luv_orig1[0] - luv_iter1[0]) < limit && fabsf(luv_orig1[1] - luv_iter1[1]) < limit && - fabsf(luv_orig2[0] - luv_iter2[0]) < limit && fabsf(luv_orig2[1] - luv_iter2[1]) < limit) { + fabsf(luv_orig2[0] - luv_iter2[0]) < limit && fabsf(luv_orig2[1] - luv_iter2[1]) < limit) + { return 1; } return 0; @@ -373,7 +374,8 @@ static bool stitch_check_uvs_state_stitchable(const int cd_loop_uv_offset, StitchStateContainer *ssc) { if ((ssc->snap_islands && element->island == element_iter->island) || - (!ssc->midpoints && element->island == element_iter->island)) { + (!ssc->midpoints && element->island == element_iter->island)) + { return 0; } @@ -387,7 +389,8 @@ static bool stitch_check_edges_state_stitchable(const int cd_loop_uv_offset, StitchState *state) { if ((ssc->snap_islands && edge->element->island == edge_iter->element->island) || - (!ssc->midpoints && edge->element->island == edge_iter->element->island)) { + (!ssc->midpoints && edge->element->island == edge_iter->element->island)) + { return 0; } @@ -432,7 +435,8 @@ static void stitch_calculate_island_snapping(const int cd_loop_uv_offset, island_stitch_data[i].medianPoint[1] /= state->aspect; if ((island_stitch_data[i].rotation + island_stitch_data[i].rotation_neg < (float)M_PI_2) || island_stitch_data[i].num_rot_elements == 0 || - island_stitch_data[i].num_rot_elements_neg == 0) { + island_stitch_data[i].num_rot_elements_neg == 0) + { rotation = (island_stitch_data[i].rotation * island_stitch_data[i].num_rot_elements - island_stitch_data[i].rotation_neg * island_stitch_data[i].num_rot_elements_neg) / @@ -559,7 +563,8 @@ static void stitch_island_calculate_vert_rotation(const int cd_loop_uv_offset, UvElement *element_iter = BM_uv_element_get_head(state->element_map, element); for (; element_iter; element_iter = element_iter->next) { if (element_iter->separate && - stitch_check_uvs_state_stitchable(cd_loop_uv_offset, element, element_iter, ssc)) { + stitch_check_uvs_state_stitchable(cd_loop_uv_offset, element, element_iter, ssc)) + { float normal[2]; /* only calculate rotation against static island uv verts */ @@ -862,7 +867,8 @@ static void stitch_validate_edge_stitchability(const int cd_loop_uv_offset, } if (stitch_check_edges_state_stitchable(cd_loop_uv_offset, edge, edge_iter, ssc, state)) { if ((edge_iter->element->island == ssc->static_island) || - (edge->element->island == ssc->static_island)) { + (edge->element->island == ssc->static_island)) + { edge->flag |= STITCH_STITCHABLE; preview->num_stitchable++; stitch_setup_face_preview_for_uv_group( @@ -1277,14 +1283,14 @@ static int stitch_process_data(StitchStateContainer *ssc, state->uvs[edge->uv1]->flag |= STITCH_STITCHABLE; state->uvs[edge->uv2]->flag |= STITCH_STITCHABLE; - if (ssc->snap_islands && edge->element->island == ssc->static_island && - !stitch_midpoints) { + if (ssc->snap_islands && edge->element->island == ssc->static_island && !stitch_midpoints) + { continue; } for (edge_iter = edge->first; edge_iter; edge_iter = edge_iter->next) { - if (stitch_check_edges_state_stitchable( - cd_loop_uv_offset, edge, edge_iter, ssc, state)) { + if (stitch_check_edges_state_stitchable(cd_loop_uv_offset, edge, edge_iter, ssc, state)) + { l = state->uvs[edge_iter->uv1]->l; luv1 = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset); l = state->uvs[edge_iter->uv2]->l; @@ -1343,7 +1349,8 @@ static int stitch_process_data(StitchStateContainer *ssc, for (i = 0; i < state->total_separate_edges; i++) { UvEdge *edge = state->edges + i; if ((edge->flag & STITCH_BOUNDARY) && (state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && - (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) { + (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) + { stitch_island_calculate_edge_rotation(cd_loop_uv_offset, edge, ssc, @@ -1360,7 +1367,8 @@ static int stitch_process_data(StitchStateContainer *ssc, for (i = 0; i < state->total_separate_edges; i++) { UvEdge *edge = state->edges + i; if ((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && - (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) { + (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) + { BM_elem_flag_disable(edge->element->l->e, BM_ELEM_SEAM); } } @@ -2078,7 +2086,8 @@ static StitchState *stitch_init(bContext *C, BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!(ts->uv_flag & UV_SYNC_SELECTION) && - (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT))) { + (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT))) + { continue; } @@ -2227,7 +2236,8 @@ static int stitch_init_all(bContext *C, wmOperator *op) StitchStateInit *state_init = NULL; if (RNA_struct_property_is_set(op->ptr, "selection") && - RNA_struct_property_is_set(op->ptr, "objects_selection_count")) { + RNA_struct_property_is_set(op->ptr, "objects_selection_count")) + { /* Retrieve list of selected UVs, one list contains all selected UVs * for all objects. */ diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc index bc529760ce6..3f1e3cedeee 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc @@ -668,7 +668,8 @@ static ParamHandle *construct_param_handle_subsurfed(const Scene *scene, } else { if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) || - (options->only_selected_faces && !BM_elem_flag_test(origFace, BM_ELEM_SELECT))) { + (options->only_selected_faces && !BM_elem_flag_test(origFace, BM_ELEM_SELECT))) + { continue; } } @@ -1224,7 +1225,8 @@ static void uvedit_pack_islands_multi(const Scene *scene, if (original_selection) { /* Protect against degenerate source AABB. */ if ((selection_max_co[0] - selection_min_co[0]) * (selection_max_co[1] - selection_min_co[1]) > - 1e-40f) { + 1e-40f) + { params->target_aspect_y = (selection_max_co[0] - selection_min_co[0]) / (selection_max_co[1] - selection_min_co[1]); } @@ -2626,7 +2628,8 @@ static int smart_project_exec(bContext *C, wmOperator *op) /* Remove all zero area faces. */ while ((thick_faces_len > 0) && - !(thick_faces[thick_faces_len - 1].area > smart_uv_project_area_ignore)) { + !(thick_faces[thick_faces_len - 1].area > smart_uv_project_area_ignore)) + { /* Zero UVs so they don't overlap with other faces being unwrapped. */ BMIter liter; diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 424365b3bf3..9b24df6fc18 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -366,7 +366,8 @@ int BlenderFileLoader::testDegenerateTriangle(float v1[3], float v2[3], float v3 } if (dist_squared_to_line_segment_v3(v1, v2, v3) < eps_sq || dist_squared_to_line_segment_v3(v2, v1, v3) < eps_sq || - dist_squared_to_line_segment_v3(v3, v1, v2) < eps_sq) { + dist_squared_to_line_segment_v3(v3, v1, v2) < eps_sq) + { #if 0 if (verbose && G.debug & G_DEBUG_FREESTYLE) { printf("BlenderFileLoader::testDegenerateTriangle = 2\n"); @@ -591,7 +592,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) for (vector::iterator it = meshMaterials.begin(), itend = meshMaterials.end(); it != itend; - it++, i++) { + it++, i++) + { if (*it == mat) { ls.currentMIndex = i; found = true; @@ -650,7 +652,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) uint mindex = 0; for (vector::iterator m = meshFrsMaterials.begin(), mend = meshFrsMaterials.end(); m != mend; - ++m) { + ++m) + { marray[mindex] = new FrsMaterial(*m); ++mindex; } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 3a8b25e5e75..9b8689aa67d 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -452,7 +452,8 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const vector *groups = hasTex ? &self->texturedStrokeGroups : &self->strokeGroups; StrokeGroup *group; if (groups->empty() || !(groups->back()->totvert + totvert < MESH_MAX_VERTS && - groups->back()->materials.size() + 1 < MAXMAT)) { + groups->back()->materials.size() + 1 < MAXMAT)) + { group = new StrokeGroup; groups->push_back(group); } @@ -639,7 +640,8 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) for (vector::const_iterator it = group->strokes.begin(), itend = group->strokes.end(); it != itend; - ++it) { + ++it) + { const int matnr = group->materials.lookup_default((*it)->getMaterial(), 0); vector &strips = (*it)->getStrips(); diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index a3c5cd5f806..a547c201f58 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -45,7 +45,7 @@ using namespace Freestyle; #include "DEG_depsgraph_query.h" -#include "pipeline.h" +#include "pipeline.hh" #include "FRS_freestyle.h" @@ -277,8 +277,8 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) re->i.infostr = TIP_("Freestyle: Mesh loading"); re->stats_draw(re->sdh, &re->i); re->i.infostr = nullptr; - if (controller->LoadMesh( - re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty + if (controller->LoadMesh(re, view_layer, depsgraph)) { + /* Returns if scene cannot be loaded or if empty. */ return; } if (re->test_break(re->tbh)) { @@ -300,7 +300,8 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) } for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig *)config->modules.first; module_conf; - module_conf = module_conf->next) { + module_conf = module_conf->next) + { if (module_conf->script && module_conf->is_displayed) { const char *id_name = module_conf->script->id.name + 2; if (G.debug & G_DEBUG_FREESTYLE) { @@ -345,7 +346,8 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) cout << "Linesets:" << endl; } for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; lineset; - lineset = lineset->next) { + lineset = lineset->next) + { if (lineset->flags & FREESTYLE_LINESET_ENABLED) { if (G.debug & G_DEBUG_FREESTYLE) { cout << " " << layer_count + 1 << ": " << lineset->name << " - " @@ -387,21 +389,21 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph) logical_and = !logical_and; } if (test_edge_type_conditions( - conditions, num_edge_types, logical_and, FREESTYLE_FE_RIDGE_VALLEY, true)) { + conditions, num_edge_types, logical_and, FREESTYLE_FE_RIDGE_VALLEY, true)) + { ++use_ridges_and_valleys; } if (test_edge_type_conditions(conditions, num_edge_types, logical_and, FREESTYLE_FE_SUGGESTIVE_CONTOUR, - true)) { + true)) + { ++use_suggestive_contours; } - if (test_edge_type_conditions(conditions, - num_edge_types, - logical_and, - FREESTYLE_FE_MATERIAL_BOUNDARY, - true)) { + if (test_edge_type_conditions( + conditions, num_edge_types, logical_and, FREESTYLE_FE_MATERIAL_BOUNDARY, true)) + { ++use_material_boundaries; } } @@ -555,7 +557,8 @@ static int displayed_layer_count(ViewLayer *view_layer) for (FreestyleModuleConfig *module = (FreestyleModuleConfig *)view_layer->freestyle_config.modules.first; module; - module = module->next) { + module = module->next) + { if (module->script && module->is_displayed) { count++; } @@ -565,7 +568,8 @@ static int displayed_layer_count(ViewLayer *view_layer) for (FreestyleLineSet *lineset = (FreestyleLineSet *)view_layer->freestyle_config.linesets.first; lineset; - lineset = lineset->next) { + lineset = lineset->next) + { if (lineset->flags & FREESTYLE_LINESET_ENABLED) { count++; } diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index b8beeed5880..a66c94ae52e 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -38,7 +38,8 @@ bool intersect2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, co bool include2dSeg2dArea(const Vec2r &min, const Vec2r &max, const Vec2r &A, const Vec2r &B) { if ((((max[0] > A[0]) && (A[0] > min[0])) && ((max[0] > B[0]) && (B[0] > min[0]))) && - (((max[1] > A[1]) && (A[1] > min[1])) && ((max[1] > B[1]) && (B[1] > min[1])))) { + (((max[1] > A[1]) && (A[1] > min[1])) && ((max[1] > B[1]) && (B[1] > min[1])))) + { return true; } return false; diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp index a2620aa25d7..33d747b992b 100644 --- a/source/blender/freestyle/intern/geometry/Grid.cpp +++ b/source/blender/freestyle/intern/geometry/Grid.cpp @@ -25,7 +25,8 @@ static bool inBox(const Vec3r &inter, const Vec3r &box_min, const Vec3r &box_max { if (((inter.x() >= box_min.x()) && (inter.x() < box_max.x())) && ((inter.y() >= box_min.y()) && (inter.y() < box_max.y())) && - ((inter.z() >= box_min.z()) && (inter.z() < box_max.z()))) { + ((inter.z() >= box_min.z()) && (inter.z() < box_max.z()))) + { return true; } return false; @@ -46,7 +47,8 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ) // Check whether the intersection is in the cell: if (inBox(ray_org_ + tmp_t * ray_dir_ / ray_dir_.norm(), current_cell_->getOrigin(), - current_cell_->getOrigin() + cell_size_)) { + current_cell_->getOrigin() + cell_size_)) + { #if 0 Vec3d bboxdiag(_scene3d->bbox().getMax() - _scene3d->bbox().getMin()); if ((t > 1.0e-06 * (min(min(bboxdiag.x(), bboxdiag.y()), bboxdiag.z()))) && diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h index 06e96ddf6e6..e3d112e6ea7 100644 --- a/source/blender/freestyle/intern/geometry/GridHelpers.h +++ b/source/blender/freestyle/intern/geometry/GridHelpers.h @@ -118,7 +118,8 @@ inline bool insideProscenium(const real proscenium[4], const Polygon3r &polygon) Vec3r bbMin, bbMax; polygon.getBBox(bbMin, bbMax); if (bbMax[0] < proscenium[0] || bbMin[0] > proscenium[1] || bbMax[1] < proscenium[2] || - bbMin[1] > proscenium[3]) { + bbMin[1] > proscenium[3]) + { return false; } @@ -140,7 +141,8 @@ inline vector enumerateVertices(const vector &fedges) vector points; // Iterate over vertices, storing projections in points for (vector::const_iterator woe = fedges.begin(), woend = fedges.end(); woe != woend; - woe++) { + woe++) + { points.push_back((*woe)->GetaVertex()->GetVertex()); } diff --git a/source/blender/freestyle/intern/geometry/Polygon.h b/source/blender/freestyle/intern/geometry/Polygon.h index d9d5ff17b81..7eaef8759b8 100644 --- a/source/blender/freestyle/intern/geometry/Polygon.h +++ b/source/blender/freestyle/intern/geometry/Polygon.h @@ -45,7 +45,8 @@ template class Polygon { Point p; for (typename vector::const_iterator it = poly.getVertices().begin(); it != poly.getVertices().end(); - it++) { + it++) + { p = *it; _vertices.push_back(p); } @@ -103,8 +104,8 @@ template class Polygon { { _vertices.clear(); Point p; - for (typename vector::const_iterator it = vertices.begin(); it != vertices.end(); - it++) { + for (typename vector::const_iterator it = vertices.begin(); it != vertices.end(); it++) + { p = *it; _vertices.push_back(p); } diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h index b5427170cea..69abb513453 100644 --- a/source/blender/freestyle/intern/geometry/SweepLine.h +++ b/source/blender/freestyle/intern/geometry/SweepLine.h @@ -196,7 +196,8 @@ template class SweepLine { for (typename vector> *>::iterator i = _Intersections.begin(), iend = _Intersections.end(); i != iend; - i++) { + i++) + { delete (*i); } } @@ -253,7 +254,8 @@ template class SweepLine { } for (typename std::list *>::iterator s = _set.begin(), send = _set.end(); s != send; - s++) { + s++) + { Segment *currentS = (*s); if (true != binrule(*S, *currentS)) { continue; @@ -276,7 +278,8 @@ template class SweepLine { } if (GeomUtils::intersect2dSeg2dSegParametric(v0, v1, v2, v3, t, u, epsilon) == - GeomUtils::DO_INTERSECT) { + GeomUtils::DO_INTERSECT) + { // create the intersection Intersection> *inter = new Intersection>( S, t, currentS, u); diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp index 3f9e96ffa73..04d5721d4fa 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp @@ -89,14 +89,9 @@ static PyObject *BinaryPredicate0D___call__(BPy_BinaryPredicate0D *self, static const char *kwlist[] = {"inter1", "inter2", nullptr}; BPy_Interface0D *obj1, *obj2; - if (!PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist, - &Interface0D_Type, - &obj1, - &Interface0D_Type, - &obj2)) { + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist, &Interface0D_Type, &obj1, &Interface0D_Type, &obj2)) + { return nullptr; } if (typeid(*(self->bp0D)) == typeid(BinaryPredicate0D)) { diff --git a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp index bf4bf2d099a..38ebb60ab1b 100644 --- a/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp @@ -124,14 +124,9 @@ static PyObject *BinaryPredicate1D___call__(BPy_BinaryPredicate1D *self, static const char *kwlist[] = {"inter1", "inter2", nullptr}; BPy_Interface1D *obj1, *obj2; - if (!PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist, - &Interface1D_Type, - &obj1, - &Interface1D_Type, - &obj2)) { + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist, &Interface1D_Type, &obj1, &Interface1D_Type, &obj2)) + { return nullptr; } if (typeid(*(self->bp1D)) == typeid(BinaryPredicate1D)) { diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp index e076234f429..075c301e37c 100644 --- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp @@ -104,7 +104,8 @@ static PyObject *ContextFunctions_load_map(PyObject * /*self*/, PyObject *args, float sigma = 1.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma)) { + args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma)) + { return nullptr; } ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma); @@ -139,8 +140,8 @@ static PyObject *ContextFunctions_read_map_pixel(PyObject * /*self*/, int level; uint x, y; - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y)) + { return nullptr; } return PyFloat_FromDouble(ContextFunctions::ReadMapPixelCF(mapName, level, x, y)); @@ -206,7 +207,8 @@ static PyObject *ContextFunctions_read_directional_view_map_pixel(PyObject * /*s uint x, y; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y)) { + args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y)) + { return nullptr; } return PyFloat_FromDouble( diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 60b924f0eb3..da0dc8138fd 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -168,7 +168,8 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args) 3, obj1, "argument 2 must be a 3D vector " - "(either a tuple/list of 3 elements or Vector)") == -1) { + "(either a tuple/list of 3 elements or Vector)") == -1) + { return nullptr; } if (mathutils_array_parse(b, @@ -176,7 +177,8 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args) 3, obj2, "argument 4 must be a 3D vector " - "(either a tuple/list of 3 elements or Vector)") == -1) { + "(either a tuple/list of 3 elements or Vector)") == -1) + { return nullptr; } ramp_blend(type, a, fac, b); diff --git a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp index 7bc3f2ea05a..f781d22391c 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsMaterial.cpp @@ -105,7 +105,8 @@ static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwd convert_v4, emission, &shininess, - &priority)) { + &priority)) + { self->m = new FrsMaterial(line, diffuse, ambient, specular, emission, shininess, priority); } else { diff --git a/source/blender/freestyle/intern/python/BPy_Id.cpp b/source/blender/freestyle/intern/python/BPy_Id.cpp index 7745bc11512..4db1c086418 100644 --- a/source/blender/freestyle/intern/python/BPy_Id.cpp +++ b/source/blender/freestyle/intern/python/BPy_Id.cpp @@ -61,7 +61,8 @@ static int Id_init(BPy_Id *self, PyObject *args, PyObject *kwds) self->id = new Id(*(((BPy_Id *)brother)->id)); } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "|ii", (char **)kwlist_2, &first, &second)) { + PyArg_ParseTupleAndKeywords(args, kwds, "|ii", (char **)kwlist_2, &first, &second)) + { self->id = new Id(first, second); } else { diff --git a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp index b70058a0b66..181549ba221 100644 --- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp +++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp @@ -66,7 +66,8 @@ static PyObject *Integrator_integrate(PyObject * /*self*/, PyObject *args, PyObj &Interface0DIterator_Type, &obj3, &IntegrationType_Type, - &obj4)) { + &obj4)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp index 11ac078124a..342cff73f89 100644 --- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp @@ -130,8 +130,8 @@ static PyObject *Interface0D_get_fedge(BPy_Interface0D *self, PyObject *args, Py static const char *kwlist[] = {"inter", nullptr}; PyObject *py_if0D; - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0D_Type, &py_if0D)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0D_Type, &py_if0D)) + { return nullptr; } FEdge *fe = self->if0D->getFEdge(*(((BPy_Interface0D *)py_if0D)->if0D)); diff --git a/source/blender/freestyle/intern/python/BPy_Operators.cpp b/source/blender/freestyle/intern/python/BPy_Operators.cpp index df2312c8680..9d2c3e8b7ab 100644 --- a/source/blender/freestyle/intern/python/BPy_Operators.cpp +++ b/source/blender/freestyle/intern/python/BPy_Operators.cpp @@ -125,7 +125,8 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj &UnaryPredicate1D_Type, &obj2, &UnaryFunction1DVoid_Type, - &obj3)) { + &obj3)) + { return nullptr; } if (!((BPy_ChainingIterator *)obj1)->c_it) { @@ -140,7 +141,8 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj } if (!obj3) { if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it), - *(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) { + *(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed"); } @@ -155,7 +157,8 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj } if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it), *(((BPy_UnaryPredicate1D *)obj2)->up1D), - *(((BPy_UnaryFunction1DVoid *)obj3)->uf1D_void)) < 0) { + *(((BPy_UnaryFunction1DVoid *)obj3)->uf1D_void)) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed"); } @@ -203,7 +206,8 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/, &ChainingIterator_Type, &obj1, &UnaryPredicate1D_Type, - &obj2)) { + &obj2)) + { return nullptr; } if (!((BPy_ChainingIterator *)obj1)->c_it) { @@ -228,7 +232,8 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/, return nullptr; } if (Operators::bidirectionalChain(*(((BPy_ChainingIterator *)obj1)->c_it), - *(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) { + *(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectional_chain() failed"); } @@ -286,7 +291,8 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/, &obj1, &UnaryPredicate0D_Type, &obj2, - &f)) { + &f)) + { if (!((BPy_UnaryPredicate0D *)obj1)->up0D) { PyErr_SetString( PyExc_TypeError, @@ -301,7 +307,8 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/, } if (Operators::sequentialSplit(*(((BPy_UnaryPredicate0D *)obj1)->up0D), *(((BPy_UnaryPredicate0D *)obj2)->up0D), - f) < 0) { + f) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.sequential_split() failed"); } @@ -311,7 +318,8 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/, else if ((void)PyErr_Clear(), (void)(f = 0.0f), PyArg_ParseTupleAndKeywords( - args, kwds, "O!|f", (char **)kwlist_2, &UnaryPredicate0D_Type, &obj1, &f)) { + args, kwds, "O!|f", (char **)kwlist_2, &UnaryPredicate0D_Type, &obj1, &f)) + { if (!((BPy_UnaryPredicate0D *)obj1)->up0D) { PyErr_SetString( PyExc_TypeError, @@ -385,7 +393,8 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/, &obj1, &UnaryPredicate1D_Type, &obj2, - &f)) { + &f)) + { if (!((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double) { PyErr_SetString( PyExc_TypeError, @@ -400,7 +409,8 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/, } if (Operators::recursiveSplit(*(((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double), *(((BPy_UnaryPredicate1D *)obj2)->up1D), - f) < 0) { + f) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed"); } @@ -419,7 +429,8 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/, &obj2, &UnaryPredicate1D_Type, &obj3, - &f)) { + &f)) + { if (!((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double) { PyErr_SetString( PyExc_TypeError, @@ -441,7 +452,8 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/, if (Operators::recursiveSplit(*(((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double), *(((BPy_UnaryPredicate0D *)obj2)->up0D), *(((BPy_UnaryPredicate1D *)obj3)->up1D), - f) < 0) { + f) < 0) + { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed"); } @@ -504,14 +516,9 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb static const char *kwlist[] = {"pred", "shaders", nullptr}; PyObject *obj1 = nullptr, *obj2 = nullptr; - if (!PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist, - &UnaryPredicate1D_Type, - &obj1, - &PyList_Type, - &obj2)) { + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist, &UnaryPredicate1D_Type, &obj1, &PyList_Type, &obj2)) + { return nullptr; } if (!((BPy_UnaryPredicate1D *)obj1)->up1D) { diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index ed2af40545a..c9df1ff8ef7 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -80,7 +80,8 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj float red, green, blue, alpha, thickness_right, thickness_left, t; if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &StrokeAttribute_Type, &obj1)) { + args, kwds, "|O!", (char **)kwlist_1, &StrokeAttribute_Type, &obj1)) + { if (!obj1) { self->sa = new StrokeAttribute(); } @@ -97,7 +98,8 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj &obj1, &StrokeAttribute_Type, &obj2, - &t)) { + &t)) + { self->sa = new StrokeAttribute( *(((BPy_StrokeAttribute *)obj1)->sa), *(((BPy_StrokeAttribute *)obj2)->sa), t); } @@ -111,7 +113,8 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj &blue, &alpha, &thickness_right, - &thickness_left)) { + &thickness_left)) + { self->sa = new StrokeAttribute(red, green, blue, alpha, thickness_right, thickness_left); } else { diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp index 388f5d52ff0..8d6bd2e7d7d 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp @@ -102,7 +102,8 @@ static PyObject *UnaryPredicate0D___call__(BPy_UnaryPredicate0D *self, PyObject *py_if0D_it; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp index 9240b4ed3ea..27708692533 100644 --- a/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp +++ b/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp @@ -159,8 +159,8 @@ static PyObject *UnaryPredicate1D___call__(BPy_UnaryPredicate1D *self, static const char *kwlist[] = {"inter", nullptr}; PyObject *py_if1D; - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index 58c60e9b9fd..f5c2e547a44 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -73,7 +73,8 @@ static int ViewShape_init(BPy_ViewShape *self, PyObject *args, PyObject *kwds) } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &SShape_Type, &obj)) { + PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &SShape_Type, &obj)) + { BPy_SShape *py_ss = (BPy_SShape *)obj; self->vs = new ViewShape(py_ss->ss); self->py_ss = (!py_ss->borrowed) ? py_ss : nullptr; diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp index fd0d2dcfebd..31e556ac5f5 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp @@ -63,7 +63,8 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self, float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) { + args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp index 655f9cdce1e..9e8d52a19ca 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_CurvePoint.cpp @@ -80,7 +80,8 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds) &obj1, &SVertex_Type, &obj2, - &t2d)) { + &t2d)) + { self->cp = new CurvePoint(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv, t2d); } else if ((void)PyErr_Clear(), @@ -92,7 +93,8 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds) &obj1, &CurvePoint_Type, &obj2, - &t2d)) { + &t2d)) + { CurvePoint *cp1 = ((BPy_CurvePoint *)obj1)->cp; CurvePoint *cp2 = ((BPy_CurvePoint *)obj2)->cp; if (!cp1 || cp1->A() == nullptr || cp1->B() == nullptr) { diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 9d3089e2bc2..df48754d9a7 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -59,7 +59,8 @@ static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds) } else if ((void)PyErr_Clear(), PyArg_ParseTupleAndKeywords( - args, kwds, "O&O!", (char **)kwlist_2, convert_v3, v, &Id_Type, &obj)) { + args, kwds, "O&O!", (char **)kwlist_2, convert_v3, v, &Id_Type, &obj)) + { Vec3r point_3d(v[0], v[1], v[2]); self->sv = new SVertex(point_3d, *(((BPy_Id *)obj)->id)); } diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp index f6edde778d4..83be08179fa 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp @@ -65,8 +65,8 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k PyObject *obj1 = nullptr, *obj2 = nullptr; float t3d; - if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &StrokeVertex_Type, &obj1)) { + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &StrokeVertex_Type, &obj1)) + { if (!obj1) { self->sv = new StrokeVertex(); } @@ -87,7 +87,8 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k &obj1, &StrokeVertex_Type, &obj2, - &t3d)) { + &t3d)) + { StrokeVertex *sv1 = ((BPy_StrokeVertex *)obj1)->sv; StrokeVertex *sv2 = ((BPy_StrokeVertex *)obj2)->sv; if (!sv1 || (sv1->A() == nullptr && sv1->B() == nullptr)) { @@ -102,7 +103,8 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k } else if ((void)PyErr_Clear(), PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_3, &CurvePoint_Type, &obj1)) { + args, kwds, "O!", (char **)kwlist_3, &CurvePoint_Type, &obj1)) + { CurvePoint *cp = ((BPy_CurvePoint *)obj1)->cp; if (!cp || cp->A() == nullptr || cp->B() == nullptr) { PyErr_SetString(PyExc_TypeError, "argument 1 is an invalid CurvePoint object"); @@ -119,7 +121,8 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k &SVertex_Type, &obj1, &StrokeAttribute_Type, - &obj2)) { + &obj2)) + { if (!obj2) { self->sv = new StrokeVertex(((BPy_SVertex *)obj1)->sv); } diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp index 9684f96d586..8cb4b181abc 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp @@ -63,14 +63,9 @@ static int FEdge_init(BPy_FEdge *self, PyObject *args, PyObject *kwds) } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist_2, - &SVertex_Type, - &obj1, - &SVertex_Type, - &obj2)) { + PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist_2, &SVertex_Type, &obj1, &SVertex_Type, &obj2)) + { self->fe = new FEdge(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); } else { diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp index cc6e6cb7d53..84d74e20cb6 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp @@ -55,7 +55,8 @@ static int FrsCurve_init(BPy_FrsCurve *self, PyObject *args, PyObject *kwds) } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) { + PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) + { self->c = new Curve(*(((BPy_Id *)obj)->id)); } else { diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp index 8acbfefa995..fd2be86fc05 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -180,7 +180,8 @@ static PyObject *Stroke_insert_vertex(BPy_Stroke *self, PyObject *args, PyObject &StrokeVertex_Type, &py_sv, &StrokeVertexIterator_Type, - &py_sv_it)) { + &py_sv_it)) + { return nullptr; } @@ -207,8 +208,8 @@ static PyObject *Stroke_remove_vertex(BPy_Stroke *self, PyObject *args, PyObject static const char *kwlist[] = {"vertex", nullptr}; PyObject *py_sv = nullptr; - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &StrokeVertex_Type, &py_sv)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &StrokeVertex_Type, &py_sv)) + { return nullptr; } if (((BPy_StrokeVertex *)py_sv)->sv) { diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp index e69572687ca..969f0f0597a 100644 --- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp @@ -54,7 +54,8 @@ static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds) } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) { + PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) + { self->c = new Chain(*(((BPy_Id *)obj)->id)); } else { @@ -84,7 +85,8 @@ static PyObject *Chain_push_viewedge_back(BPy_Chain *self, PyObject *args, PyObj PyObject *obj1 = nullptr, *obj2 = nullptr; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) { + args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) + { return nullptr; } ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve; @@ -110,7 +112,8 @@ static PyObject *Chain_push_viewedge_front(BPy_Chain *self, PyObject *args, PyOb PyObject *obj1 = nullptr, *obj2 = nullptr; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) { + args, kwds, "O!O!", (char **)kwlist, &ViewEdge_Type, &obj1, &PyBool_Type, &obj2)) + { return nullptr; } ViewEdge *ve = ((BPy_ViewEdge *)obj1)->ve; diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp index bb8c8f42042..2535c67277a 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp @@ -60,14 +60,9 @@ static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds) } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist_2, - &SVertex_Type, - &obj1, - &SVertex_Type, - &obj2)) { + PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist_2, &SVertex_Type, &obj1, &SVertex_Type, &obj2)) + { self->fes = new FEdgeSharp(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); } else { diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp index 47f0aff8374..2051c85a99b 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp @@ -48,8 +48,8 @@ static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwd static const char *kwlist_2[] = {"first_vertex", "second_vertex", nullptr}; PyObject *obj1 = nullptr, *obj2 = nullptr; - if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) { + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) + { if (!obj1) { self->fes = new FEdgeSmooth(); } @@ -58,14 +58,9 @@ static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwd } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, - kwds, - "O!O!", - (char **)kwlist_2, - &SVertex_Type, - &obj1, - &SVertex_Type, - &obj2)) { + PyArg_ParseTupleAndKeywords( + args, kwds, "O!O!", (char **)kwlist_2, &SVertex_Type, &obj1, &SVertex_Type, &obj2)) + { self->fes = new FEdgeSmooth(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv); } else { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp index ba17a92ca0d..5953b6a6718 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp @@ -54,7 +54,8 @@ static int AdjacencyIterator_init(BPy_AdjacencyIterator *self, PyObject *args, P PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &AdjacencyIterator_Type, &obj1)) { + args, kwds, "|O!", (char **)kwlist_1, &AdjacencyIterator_Type, &obj1)) + { if (!obj1) { self->a_it = new AdjacencyIterator(); self->at_start = true; @@ -75,7 +76,8 @@ static int AdjacencyIterator_init(BPy_AdjacencyIterator *self, PyObject *args, P &PyBool_Type, &obj2, &PyBool_Type, - &obj3)) { + &obj3)) + { bool restrictToSelection = (!obj2) ? true : bool_from_PyBool(obj2); bool restrictToUnvisited = (!obj3) ? true : bool_from_PyBool(obj3); self->a_it = new AdjacencyIterator( diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp index 4d35cdabee9..e08d3d1177c 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp @@ -93,7 +93,8 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self, *obj6 = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_1, &ChainPredicateIterator_Type, &obj1)) { + args, kwds, "O!", (char **)kwlist_1, &ChainPredicateIterator_Type, &obj1)) + { self->cp_it = new ChainPredicateIterator(*(((BPy_ChainPredicateIterator *)obj1)->cp_it)); self->upred = ((BPy_ChainPredicateIterator *)obj1)->upred; self->bpred = ((BPy_ChainPredicateIterator *)obj1)->bpred; @@ -117,7 +118,8 @@ static int ChainPredicateIterator_init(BPy_ChainPredicateIterator *self, check_begin, &obj5, &PyBool_Type, - &obj6)) { + &obj6)) + { UnaryPredicate1D *up1D = ((BPy_UnaryPredicate1D *)obj1)->up1D; BinaryPredicate1D *bp1D = ((BPy_BinaryPredicate1D *)obj2)->bp1D; bool restrict_to_selection = (!obj3) ? true : bool_from_PyBool(obj3); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp index ea4ab4b5a7b..6cf6027ed7b 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp @@ -72,7 +72,8 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self, PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) { + args, kwds, "O!", (char **)kwlist_1, &ChainSilhouetteIterator_Type, &obj1)) + { self->cs_it = new ChainSilhouetteIterator(*(((BPy_ChainSilhouetteIterator *)obj1)->cs_it)); } else if ((void)PyErr_Clear(), @@ -86,7 +87,8 @@ static int ChainSilhouetteIterator_init(BPy_ChainSilhouetteIterator *self, check_begin, &obj2, &PyBool_Type, - &obj3)) { + &obj3)) + { bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1); ViewEdge *begin = (!obj2 || obj2 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj2)->ve; bool orientation = (!obj3) ? true : bool_from_PyBool(obj3); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index 3fde8abe1f9..a3f10d5f730 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -72,7 +72,8 @@ static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args, PyObject *obj1 = nullptr, *obj2 = nullptr, *obj3 = nullptr, *obj4 = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_1, &ChainingIterator_Type, &obj1)) { + args, kwds, "O!", (char **)kwlist_1, &ChainingIterator_Type, &obj1)) + { self->c_it = new ChainingIterator(*(((BPy_ChainingIterator *)obj1)->c_it)); } else if ((void)PyErr_Clear(), @@ -88,7 +89,8 @@ static int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args, check_begin, &obj3, &PyBool_Type, - &obj4)) { + &obj4)) + { bool restrict_to_selection = (!obj1) ? true : bool_from_PyBool(obj1); bool restrict_to_unvisited = (!obj2) ? true : bool_from_PyBool(obj2); ViewEdge *begin = (!obj3 || obj3 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj3)->ve; @@ -151,7 +153,8 @@ static PyObject *ChainingIterator_traverse(BPy_ChainingIterator *self, return nullptr; } if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &AdjacencyIterator_Type, &py_a_it)) { + args, kwds, "O!", (char **)kwlist, &AdjacencyIterator_Type, &py_a_it)) + { return nullptr; } if (((BPy_AdjacencyIterator *)py_a_it)->a_it) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp index 180a3e00a9b..63dcca1a834 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -48,7 +48,8 @@ static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, float step; if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &CurvePointIterator_Type, &brother)) { + args, kwds, "|O!", (char **)kwlist_1, &CurvePointIterator_Type, &brother)) + { if (!brother) { self->cp_it = new CurveInternal::CurvePointIterator(); } @@ -58,7 +59,8 @@ static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args, } } else if ((void)PyErr_Clear(), - PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step)) { + PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step)) + { self->cp_it = new CurveInternal::CurvePointIterator(step); } else { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 9d12de9efb7..b1da748f9c8 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -60,21 +60,24 @@ static int Interface0DIterator_init(BPy_Interface0DIterator *self, PyObject *arg PyObject *brother, *inter; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O&", (char **)kwlist_1, convert_nested_it, &nested_it)) { + args, kwds, "O&", (char **)kwlist_1, convert_nested_it, &nested_it)) + { self->if0D_it = new Interface0DIterator(nested_it->copy()); self->at_start = true; self->reversed = false; } else if ((void)PyErr_Clear(), PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_2, &Interface1D_Type, &inter)) { + args, kwds, "O!", (char **)kwlist_2, &Interface1D_Type, &inter)) + { self->if0D_it = new Interface0DIterator(((BPy_Interface1D *)inter)->if1D->verticesBegin()); self->at_start = true; self->reversed = false; } else if ((void)PyErr_Clear(), PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_3, &Interface0DIterator_Type, &brother)) { + args, kwds, "O!", (char **)kwlist_3, &Interface0DIterator_Type, &brother)) + { self->if0D_it = new Interface0DIterator(*(((BPy_Interface0DIterator *)brother)->if0D_it)); self->at_start = ((BPy_Interface0DIterator *)brother)->at_start; self->reversed = ((BPy_Interface0DIterator *)brother)->reversed; diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp index 78b8cd07fb4..046fd280ef6 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp @@ -56,7 +56,8 @@ static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObj float t; if (PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1)) { + args, kwds, "|O!", (char **)kwlist_1, &SVertexIterator_Type, &obj1)) + { if (!obj1) { self->sv_it = new ViewEdgeInternal::SVertexIterator(); } @@ -77,7 +78,8 @@ static int SVertexIterator_init(BPy_SVertexIterator *self, PyObject *args, PyObj &obj3, &FEdge_Type, &obj4, - &t)) { + &t)) + { self->sv_it = new ViewEdgeInternal::SVertexIterator(((BPy_SVertex *)obj1)->sv, ((BPy_SVertex *)obj2)->sv, ((BPy_FEdge *)obj3)->fe, diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index abbaae19b9e..ab24350caa4 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -53,7 +53,8 @@ static int StrokeVertexIterator_init(BPy_StrokeVertexIterator *self, PyObject *brother = nullptr, *stroke = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_1, &StrokeVertexIterator_Type, &brother)) { + args, kwds, "O!", (char **)kwlist_1, &StrokeVertexIterator_Type, &brother)) + { self->sv_it = new StrokeInternal::StrokeVertexIterator( *(((BPy_StrokeVertexIterator *)brother)->sv_it)); self->reversed = ((BPy_StrokeVertexIterator *)brother)->reversed; @@ -62,7 +63,8 @@ static int StrokeVertexIterator_init(BPy_StrokeVertexIterator *self, else if ((void)PyErr_Clear(), PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist_2, &Stroke_Type, &stroke)) { + args, kwds, "|O!", (char **)kwlist_2, &Stroke_Type, &stroke)) + { if (!stroke) { self->sv_it = new StrokeInternal::StrokeVertexIterator(); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp index 7d1691d577f..0360072f76d 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -59,13 +59,15 @@ static int ViewEdgeIterator_init(BPy_ViewEdgeIterator *self, PyObject *args, PyO PyObject *obj1 = nullptr, *obj2 = nullptr; if (PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist_1, &ViewEdgeIterator_Type, &obj1)) { + args, kwds, "O!", (char **)kwlist_1, &ViewEdgeIterator_Type, &obj1)) + { self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(*(((BPy_ViewEdgeIterator *)obj1)->ve_it)); } else if ((void)PyErr_Clear(), (void)(obj1 = obj2 = nullptr), PyArg_ParseTupleAndKeywords( - args, kwds, "|O&O!", (char **)kwlist_2, check_begin, &obj1, &PyBool_Type, &obj2)) { + args, kwds, "|O&O!", (char **)kwlist_2, check_begin, &obj1, &PyBool_Type, &obj2)) + { ViewEdge *begin = (!obj1 || obj1 == Py_None) ? nullptr : ((BPy_ViewEdge *)obj1)->ve; bool orientation = (!obj2) ? true : bool_from_PyBool(obj2); self->ve_it = new ViewEdgeInternal::ViewEdgeIterator(begin, orientation); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp index 7dad62818f4..09e2f7d50b0 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp @@ -43,7 +43,8 @@ static int orientedViewEdgeIterator_init(BPy_orientedViewEdgeIterator *self, PyObject *brother = nullptr; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother)) { + args, kwds, "|O!", (char **)kwlist, &orientedViewEdgeIterator_Type, &brother)) + { return -1; } if (!brother) { diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp index 99e344ee24b..ac805000e85 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp @@ -62,7 +62,8 @@ static int CalligraphicShader___init__(BPy_CalligraphicShader *self, PyObject *obj4 = nullptr; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "ddO&O!", (char **)kwlist, &d1, &d2, convert_v2, f3, &PyBool_Type, &obj4)) { + args, kwds, "ddO&O!", (char **)kwlist, &d1, &d2, convert_v2, f3, &PyBool_Type, &obj4)) + { return -1; } Vec2f v(f3[0], f3[1]); diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp index d8f8ae84543..200ee6eadaa 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp @@ -72,7 +72,8 @@ static int IncreasingColorShader___init__(BPy_IncreasingColorShader *self, float f1, f2, f3, f4, f5, f6, f7, f8; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "ffffffff", (char **)kwlist, &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8)) { + args, kwds, "ffffffff", (char **)kwlist, &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8)) + { return -1; } self->py_ss.ss = new StrokeShaders::IncreasingColorShader(f1, f2, f3, f4, f5, f6, f7, f8); diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp index b07a1f26a3e..a672e203a0a 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp @@ -74,7 +74,8 @@ static int SmoothingShader___init__(BPy_SmoothingShader *self, PyObject *args, P double d2 = 0.1, d3 = 0.0, d4 = 0.2, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 1.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "|iddddddd", (char **)kwlist, &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8)) { + args, kwds, "|iddddddd", (char **)kwlist, &i1, &d2, &d3, &d4, &d5, &d6, &d7, &d8)) + { return -1; } self->py_ss.ss = new SmoothingShader(i1, d2, d3, d4, d5, d6, d7, d8); diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp index 04ea15d7b47..93606624b63 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp @@ -67,7 +67,8 @@ static int SpatialNoiseShader___init__(BPy_SpatialNoiseShader *self, &PyBool_Type, &obj4, &PyBool_Type, - &obj5)) { + &obj5)) + { return -1; } self->py_ss.ss = new SpatialNoiseShader( diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp index a8be9722cff..e3b5621320a 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DDouble.cpp @@ -150,7 +150,8 @@ static PyObject *UnaryFunction0DDouble___call__(BPy_UnaryFunction0DDouble *self, PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp index b1a1cf816d4..9cfcb0e8cc3 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DEdgeNature.cpp @@ -89,7 +89,8 @@ static PyObject *UnaryFunction0DEdgeNature___call__(BPy_UnaryFunction0DEdgeNatur PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp index 588959667c5..64da3ae5dde 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DFloat.cpp @@ -126,7 +126,8 @@ static PyObject *UnaryFunction0DFloat___call__(BPy_UnaryFunction0DFloat *self, PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp index f0a62995c6d..7c5df84f238 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DId.cpp @@ -85,7 +85,8 @@ static PyObject *UnaryFunction0DId___call__(BPy_UnaryFunction0DId *self, PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp index 0c8294ff8dc..bdecfac48f2 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DMaterial.cpp @@ -88,7 +88,8 @@ static PyObject *UnaryFunction0DMaterial___call__(BPy_UnaryFunction0DMaterial *s PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp index c6e7fed4424..6536148b156 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DUnsigned.cpp @@ -91,7 +91,8 @@ static PyObject *UnaryFunction0DUnsigned___call__(BPy_UnaryFunction0DUnsigned *s PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp index fda4536b252..4b9ff5627cd 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.cpp @@ -94,7 +94,8 @@ static PyObject *UnaryFunction0DVec2f___call__(BPy_UnaryFunction0DVec2f *self, PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp index 5409bd94789..ba012461c97 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec3f.cpp @@ -87,7 +87,8 @@ static PyObject *UnaryFunction0DVec3f___call__(BPy_UnaryFunction0DVec3f *self, PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp index 73049f8e0c2..5f5b51c9758 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp @@ -92,7 +92,8 @@ static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVect PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp index 319087b5092..dd960c30a16 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DViewShape.cpp @@ -96,7 +96,8 @@ static PyObject *UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape PyObject *obj; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) { + args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) + { return nullptr; } diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp index 34c222cae28..14702c17d10 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp @@ -61,7 +61,8 @@ static int DensityF1D___init__(BPy_DensityF1D *self, PyObject *args, PyObject *k float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "|dO!f", (char **)kwlist, &d, &IntegrationType_Type, &obj, &f)) { + args, kwds, "|dO!f", (char **)kwlist, &d, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp index 42ab6926557..0283ffbeec2 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp @@ -65,7 +65,8 @@ static int GetCompleteViewMapDensityF1D___init__(BPy_GetCompleteViewMapDensityF1 float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) { + args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp index dcd5d2189bf..3c93598b1aa 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp @@ -73,7 +73,8 @@ static int GetDirectionalViewMapDensityF1D___init__(BPy_GetDirectionalViewMapDen float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "II|O!f", (char **)kwlist, &u1, &u2, &IntegrationType_Type, &obj, &f)) { + args, kwds, "II|O!f", (char **)kwlist, &u1, &u2, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp index ad1a65f9f81..d2f8c89d367 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp @@ -62,7 +62,8 @@ static int GetSteerableViewMapDensityF1D___init__(BPy_GetSteerableViewMapDensity float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) { + args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp index 90912e32747..8c3f558d590 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp @@ -62,7 +62,8 @@ static int GetViewMapGradientNormF1D___init__(BPy_GetViewMapGradientNormF1D *sel float f = 2.0; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) { + args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp index df77dd26b38..ea90c8967c6 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp @@ -57,7 +57,8 @@ static int LocalAverageDepthF1D___init__(BPy_LocalAverageDepthF1D *self, double d; if (!PyArg_ParseTupleAndKeywords( - args, kwds, "d|O!", (char **)kwlist, &d, &IntegrationType_Type, &obj)) { + args, kwds, "d|O!", (char **)kwlist, &d, &IntegrationType_Type, &obj)) + { return -1; } IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN; diff --git a/source/blender/freestyle/intern/scene_graph/LineRep.h b/source/blender/freestyle/intern/scene_graph/LineRep.h index f11c23e89b3..5775d3507ae 100644 --- a/source/blender/freestyle/intern/scene_graph/LineRep.h +++ b/source/blender/freestyle/intern/scene_graph/LineRep.h @@ -102,8 +102,8 @@ class LineRep : public Rep { if (0 != _vertices.size()) { _vertices.clear(); } - for (vector::const_iterator v = iVertices.begin(), end = iVertices.end(); v != end; - ++v) { + for (vector::const_iterator v = iVertices.begin(), end = iVertices.end(); v != end; ++v) + { _vertices.push_back(*v); } } diff --git a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp index 37f5fb5cfbb..33282e0658a 100644 --- a/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp +++ b/source/blender/freestyle/intern/stroke/AdvancedFunctions0D.cpp @@ -19,7 +19,8 @@ int DensityF0D::operator()(Interface0DIterator &iter) int bound = _filter.getBound(); if ((iter->getProjectedX() - bound < 0) || (iter->getProjectedX() + bound > canvas->width()) || - (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > canvas->height())) { + (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > canvas->height())) + { result = 0.0; return 0; } @@ -42,7 +43,8 @@ int LocalAverageDepthF0D::operator()(Interface0DIterator &iter) int bound = _filter.getBound(); if ((iter->getProjectedX() - bound < 0) || (iter->getProjectedX() + bound > iViewer->width()) || - (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > iViewer->height())) { + (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > iViewer->height())) + { result = 0.0; return 0; } diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index e77ba63f3d6..f14070abbe5 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -80,7 +80,8 @@ int IncreasingThicknessShader::shade(Stroke &stroke) const int n = stroke.strokeVerticesSize() - 1, i; StrokeInternal::StrokeVertexIterator v, vend; for (i = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; - ++v, ++i) { + ++v, ++i) + { float t; if (i < float(n) / 2.0f) { t = (1.0 - float(i) / float(n)) * _ThicknessMin + float(i) / float(n) * _ThicknessMax; @@ -100,7 +101,8 @@ int ConstrainedIncreasingThicknessShader::shade(Stroke &stroke) const int n = stroke.strokeVerticesSize() - 1, i; StrokeInternal::StrokeVertexIterator v, vend; for (i = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; - ++v, ++i) { + ++v, ++i) + { // XXX Why not using an if/else here? Else, if last condition is true, everything else is // computed for nothing! float t; @@ -213,7 +215,8 @@ int IncreasingColorShader::shade(Stroke &stroke) const int n = stroke.strokeVerticesSize() - 1, yo; float newcolor[4]; for (yo = 0, v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; - ++v, ++yo) { + ++v, ++yo) + { for (int i = 0; i < 4; ++i) { newcolor[i] = (1.0 - float(yo) / float(n)) * _colorMin[i] + float(yo) / float(n) * _colorMax[i]; @@ -375,7 +378,8 @@ int BezierCurveShader::shade(Stroke &stroke) const ++v; for (vend = stroke.strokeVerticesEnd(); v != vend; ++v) { if (!((fabs(v->x() - (previous)->x()) < M_EPSILON) && - (fabs(v->y() - (previous)->y()) < M_EPSILON))) { + (fabs(v->y() - (previous)->y()) < M_EPSILON))) + { data.emplace_back(v->x(), v->y()); } previous = v; @@ -432,7 +436,8 @@ int BezierCurveShader::shade(Stroke &stroke) const itend = stroke.strokeVerticesEnd(), pend = CurveVertices.end(); (it != itend) && (p != pend); - ++it, ++p, ++n) { + ++it, ++p, ++n) + { it->setX(p->x()); it->setY(p->y()); last = p; @@ -463,7 +468,8 @@ int BezierCurveShader::shade(Stroke &stroke) const for (vector::iterator vr = verticesToRemove.begin(), vrend = verticesToRemove.end(); vr != vrend; - ++vr) { + ++vr) + { stroke.RemoveVertex(*vr); } @@ -473,7 +479,8 @@ int BezierCurveShader::shade(Stroke &stroke) const int index2 = index1 + nExtraVertex; for (it = stroke.strokeVerticesBegin(), itend = stroke.strokeVerticesEnd(); (it != itend) && (a != aend); - ++it) { + ++it) + { (it)->setAttribute(*a); if ((index <= index1) || (index > index2)) { ++a; @@ -650,7 +657,8 @@ int TipRemoverShader::shade(Stroke &stroke) const vector oldAttributes; for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); v != vend; ++v) { if ((v->curvilinearAbscissa() < _tipLength) || - (v->strokeLength() - v->curvilinearAbscissa() < _tipLength)) { + (v->strokeLength() - v->curvilinearAbscissa() < _tipLength)) + { verticesToRemove.push_back(&(*v)); } oldAttributes.push_back(v->attribute()); @@ -676,7 +684,8 @@ int TipRemoverShader::shade(Stroke &stroke) const vector::iterator a = oldAttributes.begin(), aend = oldAttributes.end(); for (v = stroke.strokeVerticesBegin(), vend = stroke.strokeVerticesEnd(); (v != vend) && (a != aend); - ++v, ++a) { + ++v, ++a) + { v->setAttribute(*a); } // we're done! diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index 4df4dae7f3d..829de562333 100644 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -130,7 +130,8 @@ void Canvas::Clear() if (!_StyleModules.empty()) { for (deque::iterator s = _StyleModules.begin(), send = _StyleModules.end(); s != send; - ++s) { + ++s) + { if (*s) { delete (*s); } @@ -188,7 +189,8 @@ void Canvas::RemoveStyleModule(uint index) if (!_StyleModules.empty()) { for (deque::iterator s = _StyleModules.begin(), send = _StyleModules.end(); s != send; - ++s, ++i) { + ++s, ++i) + { if (i == index) { // remove shader if (*s) { @@ -203,7 +205,8 @@ void Canvas::RemoveStyleModule(uint index) if (!_Layers.empty()) { i = 0; for (deque::iterator sl = _Layers.begin(), slend = _Layers.end(); sl != slend; - ++sl, ++i) { + ++sl, ++i) + { if (i == index) { // remove layer if (*sl) { @@ -234,7 +237,8 @@ void Canvas::ReplaceStyleModule(uint index, StyleModule *iStyleModule) uint i = 0; for (deque::iterator s = _StyleModules.begin(), send = _StyleModules.end(); s != send; - ++s, ++i) { + ++s, ++i) + { if (i == index) { if (*s) { delete *s; @@ -418,11 +422,11 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, uint iNbLevels } } // soc qtmp.save(base + QString::number(i) + ".bmp", "BMP"); - stringstream filename; - filename << base; - filename << i << ".bmp"; + stringstream filepath; + filepath << base; + filepath << i << ".bmp"; qtmp->ftype = IMB_FTYPE_BMP; - IMB_saveiff(qtmp, const_cast(filename.str().c_str()), 0); + IMB_saveiff(qtmp, const_cast(filepath.str().c_str()), 0); } #if 0 diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp index ad6a72eaf80..0f1957ba7a1 100644 --- a/source/blender/freestyle/intern/stroke/Curve.cpp +++ b/source/blender/freestyle/intern/stroke/Curve.cpp @@ -57,7 +57,8 @@ CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3) float t1 = iA->t2d(); float t2 = iB->t2d(); if ((iA->A() == iB->A()) && (iA->B() == iB->B()) && (iA->A() != nullptr) && - (iA->B() != nullptr) && (iB->A() != nullptr) && (iB->B() != nullptr)) { + (iA->B() != nullptr) && (iB->A() != nullptr) && (iB->B() != nullptr)) + { __A = iA->A(); __B = iB->B(); _t2d = t1 + t2 * t3 - t1 * t3; @@ -120,15 +121,18 @@ CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3) } } else if (iA->A() != nullptr && iB->A() != nullptr && - (iA->A()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) { + (iA->A()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) + { goto iA_A_eq_iB_A; } else if (iA->B() != nullptr && iB->B() != nullptr && - (iA->B()->point3d() - iB->B()->point3d()).norm() < 1.0e-6) { + (iA->B()->point3d() - iB->B()->point3d()).norm() < 1.0e-6) + { goto iA_B_eq_iB_B; } else if (iA->B() != nullptr && iB->A() != nullptr && - (iA->B()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) { + (iA->B()->point3d() - iB->A()->point3d()).norm() < 1.0e-6) + { goto iA_B_eq_iB_A; } @@ -195,7 +199,8 @@ FEdge *CurvePoint::getFEdge(Interface0D &inter) return nullptr; } if (((__A == iVertexB->__A) && (__B == iVertexB->__B)) || - ((__A == iVertexB->__B) && (__B == iVertexB->__A))) { + ((__A == iVertexB->__B) && (__B == iVertexB->__A))) + { return __A->getFEdge(*__B); } if (__B == nullptr) { diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp index c55db18015b..a294527c24d 100644 --- a/source/blender/freestyle/intern/stroke/Operators.cpp +++ b/source/blender/freestyle/intern/stroke/Operators.cpp @@ -81,7 +81,8 @@ int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it, for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); - ++it_edge) { + ++it_edge) + { if (pred(**it_edge) < 0) { goto error; } @@ -147,7 +148,8 @@ int Operators::chain(ViewEdgeInternal::ViewEdgeIterator &it, UnaryPredicate1D &p for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); - ++it_edge) { + ++it_edge) + { if (pred(**it_edge) < 0) { goto error; } @@ -328,7 +330,8 @@ int Operators::bidirectionalChain(ChainingIterator &it, UnaryPredicate1D &pred) for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); - ++it_edge) { + ++it_edge) + { if (pred(**it_edge) < 0) { goto error; } @@ -431,7 +434,8 @@ int Operators::bidirectionalChain(ChainingIterator &it) for (I1DContainer::iterator it_edge = _current_view_edges_set.begin(); it_edge != _current_view_edges_set.end(); - ++it_edge) { + ++it_edge) + { if (pred_ts(**it_edge) < 0) { goto error; } @@ -745,7 +749,8 @@ static int __recursiveSplit(Chain *_curve, for (; (vit != vitend) && (vnext != vitend) && (vnext._CurvilinearLength < split._CurvilinearLength); - ++vit, ++vnext) { + ++vit, ++vnext) + { new_curve_a->push_vertex_back(&(*vit)); } if ((vit == vitend) || (vnext == vitend)) { @@ -928,7 +933,8 @@ static int __recursiveSplit(Chain *_curve, for (; (vit != vitend) && (vnext != vitend) && (vnext._CurvilinearLength < split._CurvilinearLength); - ++vit, ++vnext) { + ++vit, ++vnext) + { new_curve_a->push_vertex_back(&(*vit)); } if ((vit == vitend) || (vnext == vitend)) { @@ -1286,16 +1292,16 @@ int Operators::create(UnaryPredicate1D &pred, vector shaders) } } - for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end(); - ++it) { + for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end(); ++it) + { _current_strokes_set.push_back(*it); } new_strokes_set.clear(); return 0; error: - for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end(); - ++it) { + for (StrokesContainer::iterator it = new_strokes_set.begin(); it != new_strokes_set.end(); ++it) + { delete (*it); } new_strokes_set.clear(); @@ -1311,7 +1317,8 @@ void Operators::reset(bool removeStrokes) } _current_view_edges_set.clear(); for (I1DContainer::iterator it = _current_chains_set.begin(); it != _current_chains_set.end(); - ++it) { + ++it) + { delete *it; } _current_chains_set.clear(); diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 66a31d02a9b..af1f5b851c0 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -410,7 +410,8 @@ Stroke::Stroke(const Stroke &iBrother) : Interface1D(iBrother) for (vertex_container::const_iterator v = iBrother._Vertices.begin(), vend = iBrother._Vertices.end(); v != vend; - v++) { + v++) + { _Vertices.push_back(*v); } _Length = 0; @@ -436,8 +437,8 @@ Stroke::Stroke(const Stroke &iBrother) : Interface1D(iBrother) Stroke::~Stroke() { if (!_Vertices.empty()) { - for (vertex_container::iterator v = _Vertices.begin(), vend = _Vertices.end(); v != vend; - v++) { + for (vertex_container::iterator v = _Vertices.begin(), vend = _Vertices.end(); v != vend; v++) + { delete (*v); } _Vertices.clear(); @@ -459,7 +460,8 @@ Stroke &Stroke::operator=(const Stroke &iBrother) for (vertex_container::const_iterator v = iBrother._Vertices.begin(), vend = iBrother._Vertices.end(); v != vend; - v++) { + v++) + { _Vertices.push_back(*v); } _Length = iBrother._Length; @@ -560,7 +562,8 @@ int Stroke::Resample(int iNPoints) resampled = false; for (vector::iterator s = strokeSegments.begin(), send = strokeSegments.end(); s != send; - ++s) { + ++s) + { if (s->_sampling == 0.0f) { continue; } @@ -592,7 +595,8 @@ int Stroke::Resample(int iNPoints) // actually resample: for (vector::iterator s = strokeSegments.begin(), send = strokeSegments.end(); s != send; - ++s) { + ++s) + { newVertices.push_back(&*(s->_begin)); if (s->_sampling < _sampling) { _sampling = s->_sampling; diff --git a/source/blender/freestyle/intern/stroke/StrokeIO.cpp b/source/blender/freestyle/intern/stroke/StrokeIO.cpp index 578fcb31f73..8949ea4fa25 100644 --- a/source/blender/freestyle/intern/stroke/StrokeIO.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeIO.cpp @@ -44,7 +44,8 @@ ostream &operator<<(ostream &out, const Stroke &iStroke) out << " medium type : " << iStroke.getMediumType() << endl; for (Stroke::const_vertex_iterator v = iStroke.vertices_begin(), vend = iStroke.vertices_end(); v != vend; - ++v) { + ++v) + { out << *(*v) << endl; } return out; diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp index 96b0a089dff..b81fafa00c3 100644 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp @@ -20,7 +20,8 @@ void StrokeLayer::ScaleThickness(float iFactor) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; - ++s) { + ++s) + { (*s)->ScaleThickness(iFactor); } } @@ -29,7 +30,8 @@ void StrokeLayer::Render(const StrokeRenderer *iRenderer) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; - ++s) { + ++s) + { (*s)->Render(iRenderer); } } @@ -38,7 +40,8 @@ void StrokeLayer::RenderBasic(const StrokeRenderer *iRenderer) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; - ++s) { + ++s) + { (*s)->RenderBasic(iRenderer); } } diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index 89567d7e780..677864b9893 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -59,7 +59,8 @@ Strip::Strip(const Strip &iBrother) for (vertex_container::const_iterator v = iBrother._vertices.begin(), vend = iBrother._vertices.end(); v != vend; - ++v) { + ++v) + { _vertices.push_back(new StrokeVertexRep(**v)); } } @@ -69,8 +70,8 @@ Strip::Strip(const Strip &iBrother) Strip::~Strip() { if (!_vertices.empty()) { - for (vertex_container::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; - ++v) { + for (vertex_container::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; ++v) + { delete (*v); } _vertices.clear(); @@ -110,8 +111,8 @@ void Strip::createStrip(const vector &iStrokeVertices) } _vertices.reserve(2 * iStrokeVertices.size()); if (!_vertices.empty()) { - for (vertex_container::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; - ++v) { + for (vertex_container::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; ++v) + { delete (*v); } _vertices.clear(); @@ -275,14 +276,16 @@ void Strip::createStrip(const vector &iStrokeVertices) Vec2r vec_tmp(_vertices[i - 2]->point2d() - p); if ((vec_tmp.norm() > thickness[1] * MAX_RATIO_LENGTH_SINGU) || (dirNorm < ZERO) || (dirPrevNorm < ZERO) || notValid(_vertices[i - 2]->point2d()) || - (fabs(stripDir * dir) < EPS_SINGULARITY_RENDERER)) { + (fabs(stripDir * dir) < EPS_SINGULARITY_RENDERER)) + { _vertices[i - 2]->setPoint2d(p + thickness[1] * stripDir); } vec_tmp = _vertices[i - 1]->point2d() - p; if ((vec_tmp.norm() > thickness[0] * MAX_RATIO_LENGTH_SINGU) || (dirNorm < ZERO) || (dirPrevNorm < ZERO) || notValid(_vertices[i - 1]->point2d()) || - (fabs(stripDir * dir) < EPS_SINGULARITY_RENDERER)) { + (fabs(stripDir * dir) < EPS_SINGULARITY_RENDERER)) + { _vertices[i - 1]->setPoint2d(p - thickness[0] * stripDir); } } // end of for @@ -813,7 +816,8 @@ StrokeRep::StrokeRep(const StrokeRep &iBrother) } for (vector::const_iterator s = iBrother._strips.begin(), send = iBrother._strips.end(); s != send; - ++s) { + ++s) + { _strips.push_back(new Strip(**s)); } } diff --git a/source/blender/freestyle/intern/stroke/StyleModule.h b/source/blender/freestyle/intern/stroke/StyleModule.h index d1c36194ef9..72b0195bd82 100644 --- a/source/blender/freestyle/intern/stroke/StyleModule.h +++ b/source/blender/freestyle/intern/stroke/StyleModule.h @@ -68,7 +68,8 @@ class StyleModule { StrokeLayer *sl = new StrokeLayer; for (Operators::StrokesContainer::iterator it = strokes_set->begin(); it != strokes_set->end(); - ++it) { + ++it) + { sl->AddStroke(*it); } diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp index 7626beffd30..0e0450033bc 100644 --- a/source/blender/freestyle/intern/system/StringUtils.cpp +++ b/source/blender/freestyle/intern/system/StringUtils.cpp @@ -24,7 +24,8 @@ void getPathName(const string &path, const string &base, vector &pathnam pathnames.push_back(base); for (uint pos = 0, sep = path.find(Config::PATH_SEP, pos); pos < size; - pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) { + pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) + { if (sep == uint(string::npos)) { sep = size; } diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp index d2e760b6e6e..47e602d10e2 100644 --- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp +++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp @@ -125,8 +125,8 @@ void BoxGrid::assignCells(OccluderSource & /*source*/, // Identify cells that will be used, and set the dimensions for each ViewMap::fedges_container &fedges = viewMap->FEdges(); - for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; - ++f) { + for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; ++f) + { if ((*f)->isInImage()) { Vec3r point = transform((*f)->center3d()); uint i, j; diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h index f1b2ec218db..0b7c5852736 100644 --- a/source/blender/freestyle/intern/view_map/BoxGrid.h +++ b/source/blender/freestyle/intern/view_map/BoxGrid.h @@ -263,7 +263,8 @@ inline bool BoxGrid::Iterator::testOccluder(bool wantOccludee) Vec3r bbMin, bbMax; (*_current)->poly.getBBox(bbMin, bbMax); if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] || - _target[1] > bbMax[1]) { + _target[1] > bbMax[1]) + { #if BOX_GRID_LOGGING if (G.debug & G_DEBUG_FREESTYLE) { std::cout << "\t\tSkipping: bounding box violation" << std::endl; diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index b7e805f8767..28be72418c6 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -46,8 +46,8 @@ void FEdgeXDetector::processShapes(WingedEdge &we) #endif if (_changes) { vector &wfaces = wxs->GetFaceList(); - for (vector::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; - ++wf) { + for (vector::iterator wf = wfaces.begin(), wfend = wfaces.end(); wf != wfend; ++wf) + { WXFace *wxf = dynamic_cast(*wf); wxf->Clear(); } @@ -128,7 +128,8 @@ void FEdgeXDetector::preProcessShape(WXShape *iWShape) if (_computeRidgesAndValleys || _computeSuggestiveContours) { vector &wvertices = iWShape->getVertexList(); for (vector::iterator wv = wvertices.begin(), wvend = wvertices.end(); wv != wvend; - ++wv) { + ++wv) + { // Compute curvatures WXVertex *wxv = dynamic_cast(*wv); computeCurvatures(wxv); @@ -320,8 +321,8 @@ void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge) WXFace *fA = (WXFace *)iEdge->GetaOEdge()->GetaFace(); WXFace *fB = (WXFace *)iEdge->GetaOEdge()->GetbFace(); - if (fA->front() ^ - fB->front()) { // fA->visible XOR fB->visible (true if one is 0 and the other is 1) + /* fA->visible XOR fB->visible (true if one is 0 and the other is 1). */ + if (fA->front() ^ fB->front()) { // The only edges we want to set as silhouette edges in this way are the ones with 2 different // normals for 1 vertex for these two faces //-------------------- @@ -695,7 +696,8 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace) t = sc_edge->ta(); if (t * kr_derivatives[iFace->GetIndex(sc_oedge->GetaVertex())] + (1 - t) * kr_derivatives[iFace->GetIndex(sc_oedge->GetbVertex())] < - _kr_derivative_epsilon) { + _kr_derivative_epsilon) + { sc_layer->removeSmoothEdge(); return; } @@ -703,7 +705,8 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace) t = sc_edge->tb(); if (t * kr_derivatives[iFace->GetIndex(sc_oedge->GetaVertex())] + (1 - t) * kr_derivatives[iFace->GetIndex(sc_oedge->GetbVertex())] < - _kr_derivative_epsilon) { + _kr_derivative_epsilon) + { sc_layer->removeSmoothEdge(); } } @@ -765,7 +768,8 @@ void FEdgeXDetector::buildSmoothEdges(WXShape *iShape) vector &faceLayers = ((WXFace *)(*f))->getSmoothLayers(); for (vector::iterator wxfl = faceLayers.begin(), wxflend = faceLayers.end(); wxfl != wxflend; - ++wxfl) { + ++wxfl) + { if ((*wxfl)->BuildSmoothEdge()) { hasSmoothEdges = true; } @@ -775,7 +779,8 @@ void FEdgeXDetector::buildSmoothEdges(WXShape *iShape) if (hasSmoothEdges && !_computeRidgesAndValleys && !_computeSuggestiveContours) { vector &wvertices = iShape->getVertexList(); for (vector::iterator wv = wvertices.begin(), wvend = wvertices.end(); wv != wvend; - ++wv) { + ++wv) + { // Compute curvatures WXVertex *wxv = dynamic_cast(*wv); computeCurvatures(wxv); diff --git a/source/blender/freestyle/intern/view_map/Silhouette.cpp b/source/blender/freestyle/intern/view_map/Silhouette.cpp index 2398e82aca7..49bc5e2196d 100644 --- a/source/blender/freestyle/intern/view_map/Silhouette.cpp +++ b/source/blender/freestyle/intern/view_map/Silhouette.cpp @@ -159,7 +159,8 @@ FEdge *SVertex::getFEdge(Interface0D &inter) vector::const_iterator fe = _FEdges.begin(), feend = _FEdges.end(); for (; fe != feend; ++fe) { if ((((*fe)->vertexA() == this) && ((*fe)->vertexB() == iVertexB)) || - (((*fe)->vertexB() == this) && ((*fe)->vertexA() == iVertexB))) { + (((*fe)->vertexB() == this) && ((*fe)->vertexA() == iVertexB))) + { result = (*fe); } } @@ -175,7 +176,8 @@ FEdge *SVertex::getFEdge(Interface0D &inter) const vector &fedges = brother->fedges(); for (fe = fedges.begin(), feend = fedges.end(); fe != feend; ++fe) { if ((((*fe)->vertexA() == brother) && ((*fe)->vertexB() == iVertexB)) || - (((*fe)->vertexB() == brother) && ((*fe)->vertexA() == iVertexB))) { + (((*fe)->vertexB() == brother) && ((*fe)->vertexA() == iVertexB))) + { result = (*fe); } } @@ -192,7 +194,8 @@ FEdge *SVertex::getFEdge(Interface0D &inter) } for (fe = _FEdges.begin(), feend = _FEdges.end(); fe != feend; ++fe) { if ((((*fe)->vertexA() == this) && ((*fe)->vertexB() == brother)) || - (((*fe)->vertexB() == this) && ((*fe)->vertexA() == brother))) { + (((*fe)->vertexB() == this) && ((*fe)->vertexA() == brother))) + { result = (*fe); } } diff --git a/source/blender/freestyle/intern/view_map/Silhouette.h b/source/blender/freestyle/intern/view_map/Silhouette.h index 18fc262a35b..c678ff6c2e8 100644 --- a/source/blender/freestyle/intern/view_map/Silhouette.h +++ b/source/blender/freestyle/intern/view_map/Silhouette.h @@ -1474,7 +1474,8 @@ class SShape { vector newfedgelist; for (vector::const_iterator fed = fedgeList.begin(), fedend = fedgeList.end(); fed != fedend; - fed++) { + fed++) + { FEdge *current = *fed; newfedgelist.push_back((FEdge *)current->userdata); } @@ -1601,7 +1602,8 @@ class SShape { real t, T; for (vector::const_iterator p = iParameters.begin(), pend = iParameters.end(); p != pend; - p++) { + p++) + { T = (*p)[0]; t = (*p)[1]; @@ -1628,7 +1630,8 @@ class SShape { for (vector::iterator sv = intersections.begin(), svend = intersections.end(); sv != svend; - sv++) { + sv++) + { // SVertex *svA = fe->vertexA(); SVertex *svB = fe->vertexB(); @@ -1812,8 +1815,8 @@ class SShape { inline void RemoveEdgeFromChain(FEdge *iEdge) { - for (vector::iterator fe = _chains.begin(), feend = _chains.end(); fe != feend; - fe++) { + for (vector::iterator fe = _chains.begin(), feend = _chains.end(); fe != feend; fe++) + { if (iEdge == (*fe)) { _chains.erase(fe); break; @@ -1824,7 +1827,8 @@ class SShape { inline void RemoveEdge(FEdge *iEdge) { for (vector::iterator fe = _edgesList.begin(), feend = _edgesList.end(); fe != feend; - fe++) { + fe++) + { if (iEdge == (*fe)) { _edgesList.erase(fe); break; diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp index fb3b6bb546d..ba2708b84ff 100644 --- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp +++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp @@ -122,8 +122,8 @@ void SphericalGrid::assignCells(OccluderSource & /*source*/, // Identify cells that will be used, and set the dimensions for each ViewMap::fedges_container &fedges = viewMap->FEdges(); - for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; - ++f) { + for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; ++f) + { if ((*f)->isInImage()) { Vec3r point = SphericalGrid::Transform::sphericalProjection((*f)->center3d()); uint i, j; diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h index 9e2c2ae6ca9..fd43217ab7f 100644 --- a/source/blender/freestyle/intern/view_map/SphericalGrid.h +++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h @@ -264,7 +264,8 @@ inline bool SphericalGrid::Iterator::testOccluder(bool wantOccludee) Vec3r bbMin, bbMax; (*_current)->poly.getBBox(bbMin, bbMax); if (_target[0] < bbMin[0] || _target[0] > bbMax[0] || _target[1] < bbMin[1] || - _target[1] > bbMax[1]) { + _target[1] > bbMax[1]) + { #if SPHERICAL_GRID_LOGGING if (G.debug & G_DEBUG_FREESTYLE) { std::cout << "\t\tSkipping: bounding box violation" << std::endl; diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp index 20472599835..8e88b6c41f6 100644 --- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp @@ -79,8 +79,8 @@ void SteerableViewMap::Clear() _imagesPyramids = nullptr; } if (!_mapping.empty()) { - for (map::iterator m = _mapping.begin(), mend = _mapping.end(); m != mend; - ++m) { + for (map::iterator m = _mapping.begin(), mend = _mapping.end(); m != mend; ++m) + { delete[](*m).second; } _mapping.clear(); @@ -237,7 +237,7 @@ void SteerableViewMap::saveSteerableViewMap() const // soc QString base("SteerableViewMap"); string base("SteerableViewMap"); - stringstream filename; + stringstream filepath; for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { // soc float coeff = 1.0f; // 1 / 255.0f; // 100 * 255; // * pow(2, j); @@ -261,10 +261,10 @@ void SteerableViewMap::saveSteerableViewMap() const } // soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG"); - filename << base; - filename << i << "-" << j << ".png"; + filepath << base; + filepath << i << "-" << j << ".png"; ibuf->ftype = IMB_FTYPE_PNG; - IMB_saveiff(ibuf, const_cast(filename.str().c_str()), 0); + IMB_saveiff(ibuf, const_cast(filepath.str().c_str()), 0); } #if 0 QString base("SteerableViewMap"); diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index fcb157a4e60..94f7e8e8d24 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -66,7 +66,8 @@ void ViewEdgeXBuilder::BuildViewEdges(WXShape *iWShape, vector &smoothLayers = wxf->getSmoothLayers(); for (vector::iterator sl = smoothLayers.begin(), slend = smoothLayers.end(); sl != slend; - ++sl) { + ++sl) + { if (!(*sl)->hasSmoothEdge()) { continue; } @@ -168,7 +169,8 @@ ViewEdge *ViewEdgeXBuilder::BuildSmoothViewEdge(const OWXFaceLayer &iFaceLayer) FEdge *fefirst = nullptr; FEdge *fe = nullptr; for (list::iterator fl = facesChain.begin(), flend = facesChain.end(); fl != flend; - ++fl) { + ++fl) + { fe = BuildSmoothFEdge(feprevious, (*fl)); if (feprevious && fe == feprevious) { continue; @@ -475,8 +477,9 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer Vec3r normal; // Make the 2 Svertices - if (feprevious == - nullptr) { // that means that we don't have any vertex already built for that face + + /* That means that we don't have any vertex already built for that face. */ + if (feprevious == nullptr) { Vec3r A1(woea->GetaVertex()->GetVertex()); Vec3r A2(woea->GetbVertex()->GetVertex()); Vec3r A(A1 + ta * (A2 - A1)); diff --git a/source/blender/freestyle/intern/view_map/ViewMap.cpp b/source/blender/freestyle/intern/view_map/ViewMap.cpp index c7e57a81408..767ceff9638 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMap.cpp @@ -32,13 +32,15 @@ ViewMap::~ViewMap() // The view vertices must be deleted here as some of them are shared between two shapes: for (vector::iterator vv = _VVertices.begin(), vvend = _VVertices.end(); vv != vvend; - vv++) { + vv++) + { delete (*vv); } _VVertices.clear(); for (vector::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; - vs++) { + vs++) + { delete (*vs); } _VShapes.clear(); @@ -53,7 +55,8 @@ void ViewMap::Clean() vector tmpEdges; for (vector::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; - vs++) { + vs++) + { vector &edges = (*vs)->sshape()->getEdgeList(); for (vector::iterator it = edges.begin(), itend = edges.end(); it != itend; it++) { if ((*it)->isTemporary()) { @@ -63,10 +66,11 @@ void ViewMap::Clean() } } - for (vector::iterator it = tmpEdges.begin(), itend = tmpEdges.end(); it != itend; - it++) { + for (vector::iterator it = tmpEdges.begin(), itend = tmpEdges.end(); it != itend; it++) + { for (vector::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; - vs++) { + vs++) + { (*vs)->sshape()->RemoveEdge(*it); } (*it)->vertexA()->RemoveFEdge(*it); @@ -93,7 +97,8 @@ const FEdge *ViewMap::getClosestFEdge(real x, real y) const real minDist = DBL_MAX; FEdge *winner = nullptr; for (fedges_container::const_iterator fe = _FEdges.begin(), feend = _FEdges.end(); fe != feend; - fe++) { + fe++) + { Vec2d A((*fe)->vertexA()->point2D()[0], (*fe)->vertexA()->point2D()[1]); Vec2d B((*fe)->vertexB()->point2D()[0], (*fe)->vertexB()->point2D()[1]); real dist = GeomUtils::distPointSegment(Vec2r(x, y), A, B); @@ -112,7 +117,8 @@ const ViewEdge *ViewMap::getClosestViewEdge(real x, real y) const real minDist = DBL_MAX; FEdge *winner = nullptr; for (fedges_container::const_iterator fe = _FEdges.begin(), feend = _FEdges.end(); fe != feend; - fe++) { + fe++) + { Vec2d A((*fe)->vertexA()->point2D()[0], (*fe)->vertexA()->point2D()[1]); Vec2d B((*fe)->vertexB()->point2D()[0], (*fe)->vertexB()->point2D()[1]); real dist = GeomUtils::distPointSegment(Vec2r(x, y), A, B); @@ -451,7 +457,8 @@ ViewVertex::edge_iterator TVertex::edges_iterator(ViewEdge *iEdge) { for (edge_pointers_container::iterator it = _sortedEdges.begin(), itend = _sortedEdges.end(); it != itend; - it++) { + it++) + { if ((*it)->first == iEdge) { return edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), it); } @@ -481,7 +488,8 @@ ViewVertex::const_edge_iterator TVertex::edges_iterator(ViewEdge *iEdge) const for (edge_pointers_container::const_iterator it = _sortedEdges.begin(), itend = _sortedEdges.end(); it != itend; - it++) { + it++) + { if ((*it)->first == iEdge) { return const_edge_iterator(_sortedEdges.begin(), _sortedEdges.end(), it); } @@ -522,7 +530,8 @@ ViewVertexInternal::orientedViewEdgeIterator TVertex::edgesIterator(ViewEdge *iE { for (edge_pointers_container::iterator it = _sortedEdges.begin(), itend = _sortedEdges.end(); it != itend; - it++) { + it++) + { if ((*it)->first == iEdge) { return ViewVertexInternal::orientedViewEdgeIterator( _sortedEdges.begin(), _sortedEdges.end(), it); @@ -596,7 +605,8 @@ ViewVertex::const_edge_iterator NonTVertex::edges_end() const ViewVertex::edge_iterator NonTVertex::edges_iterator(ViewEdge *iEdge) { for (edges_container::iterator it = _ViewEdges.begin(), itend = _ViewEdges.end(); it != itend; - it++) { + it++) + { if ((it)->first == iEdge) { return edge_iterator(_ViewEdges.begin(), _ViewEdges.end(), it); } @@ -608,7 +618,8 @@ ViewVertex::const_edge_iterator NonTVertex::edges_iterator(ViewEdge *iEdge) cons { for (edges_container::const_iterator it = _ViewEdges.begin(), itend = _ViewEdges.end(); it != itend; - it++) { + it++) + { if ((it)->first == iEdge) { return const_edge_iterator(_ViewEdges.begin(), _ViewEdges.end(), it); } @@ -631,7 +642,8 @@ ViewVertexInternal::orientedViewEdgeIterator NonTVertex::edgesEnd() ViewVertexInternal::orientedViewEdgeIterator NonTVertex::edgesIterator(ViewEdge *iEdge) { for (edges_container::iterator it = _ViewEdges.begin(), itend = _ViewEdges.end(); it != itend; - it++) { + it++) + { if ((it)->first == iEdge) { return ViewVertexInternal::orientedViewEdgeIterator( _ViewEdges.begin(), _ViewEdges.end(), it); @@ -800,7 +812,8 @@ void ViewShape::RemoveEdge(ViewEdge *iViewEdge) void ViewShape::RemoveVertex(ViewVertex *iViewVertex) { for (vector::iterator vv = _Vertices.begin(), vvend = _Vertices.end(); vv != vvend; - vv++) { + vv++) + { if (iViewVertex == (*vv)) { _Vertices.erase(vv); break; diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index 401bdf51b50..317b8d6f0e8 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -1224,7 +1224,8 @@ class ViewEdge : public Interface1D { iMin, iMax, Vec2r(current->vertexA()->point2D()[0], current->vertexA()->point2D()[1]), - Vec2r(current->vertexB()->point2D()[0], current->vertexB()->point2D()[1]))) { + Vec2r(current->vertexB()->point2D()[0], current->vertexB()->point2D()[1]))) + { return true; } current = current->nextEdge(); @@ -1243,7 +1244,8 @@ class ViewEdge : public Interface1D { iMin, iMax, Vec2r(current->vertexA()->point2D()[0], current->vertexA()->point2D()[1]), - Vec2r(current->vertexB()->point2D()[0], current->vertexB()->point2D()[1]))) { + Vec2r(current->vertexB()->point2D()[0], current->vertexB()->point2D()[1]))) + { return false; } current = current->nextEdge(); @@ -1463,7 +1465,8 @@ class ViewShape { for (vector::iterator ve = vedges.begin(), veend = vedges.end(); ve != veend; - ve++) { + ve++) + { ViewEdge *current = (ViewEdge *)((ve)->first)->userdata; newEdges.push_back(ViewVertex::directedViewEdge(current, ve->second)); } diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index 183538ddd93..94339e7c619 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -91,7 +91,8 @@ static void findOccludee(FEdge *fe, for (vector::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; - ++fv) { + ++fv) + { if ((*fv)->isBoundary()) { continue; } @@ -121,7 +122,8 @@ static void findOccludee(FEdge *fe, //------------------------------------------------------------- // first let us compute the plane equation. if (GeomUtils::COINCIDENT == - GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) { + GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) + { #if LOGGING if (_global.debug & G_DEBUG_FREESTYLE) { cout << "\t\tRejecting occluder for target coincidence." << endl; @@ -275,7 +277,8 @@ static int computeVisibility(ViewMap *viewMap, for (vector::const_iterator woe = oface->getEdgeList().begin(), woend = oface->getEdgeList().end(); woe != woend; - woe++) { + woe++) + { points.push_back(Vec3r((*woe)->GetaVertex()->GetVertex())); } Polygon3r p1(points, oface->GetNormal()); @@ -310,7 +313,8 @@ static int computeVisibility(ViewMap *viewMap, for (vector::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; - ++fv) { + ++fv) + { if ((*fv)->isBoundary()) { continue; } @@ -348,7 +352,8 @@ static int computeVisibility(ViewMap *viewMap, //------------------------------------------------------------- // first let us compute the plane equation. if (GeomUtils::COINCIDENT == - GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) { + GeomUtils::intersectRayPlane(origin, edgeDir, p->getNormal(), d, t, epsilon)) + { #if LOGGING if (_global.debug & G_DEBUG_FREESTYLE) { cout << "\t\tRejecting occluder for target coincidence." << endl; @@ -596,7 +601,8 @@ static void computeCumulativeVisibility(ViewMap *ioViewMap, // its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>? for (set::iterator o = foundOccluders.begin(), oend = foundOccluders.end(); o != oend; - ++o) { + ++o) + { (*ve)->AddOccluder(*o); } #if LOGGING @@ -787,7 +793,8 @@ static void computeDetailedVisibility(ViewMap *ioViewMap, // out its contents. Is there a reason why ViewEdge::_Occluders cannot be converted to a set<>? for (set::iterator o = foundOccluders.begin(), oend = foundOccluders.end(); o != oend; - ++o) { + ++o) + { (*ve)->AddOccluder(*o); } #if LOGGING @@ -926,7 +933,8 @@ static void computeFastVisibility(ViewMap *ioViewMap, G &grid, real epsilon) // occluders -- for (set::iterator o = foundOccluders.begin(), oend = foundOccluders.end(); o != oend; - ++o) { + ++o) + { (*ve)->AddOccluder(*o); } @@ -1658,8 +1666,8 @@ void ViewMapBuilder::ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilo // qi -- (*ve)->setQI(maxIndex); // occluders -- - for (set::iterator o = occluders.begin(), oend = occluders.end(); o != oend; - ++o) { + for (set::iterator o = occluders.begin(), oend = occluders.end(); o != oend; ++o) + { (*ve)->AddOccluder(*o); } #if LOGGING @@ -1936,7 +1944,8 @@ void ViewMapBuilder::FindOccludee(FEdge *fe, for (vector::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; - ++fv) { + ++fv) + { if ((*fv)->isBoundary()) { continue; } @@ -2051,7 +2060,8 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, if ((center.x() < gridOrigin.x()) || (center.y() < gridOrigin.y()) || (center.z() < gridOrigin.z()) || (center.x() > gridExtremity.x()) || - (center.y() > gridExtremity.y()) || (center.z() > gridExtremity.z())) { + (center.y() > gridExtremity.y()) || (center.z() > gridExtremity.z())) + { cerr << "Warning: point is out of the grid for fedge " << fe->getId() << endl; // return 0; } @@ -2148,7 +2158,8 @@ int ViewMapBuilder::ComputeRayCastingVisibility(FEdge *fe, for (vector::iterator fv = faceVertices.begin(), fvend = faceVertices.end(); fv != fvend; - ++fv) { + ++fv) + { if ((*fv)->isBoundary()) { continue; } @@ -2316,7 +2327,8 @@ struct silhouette_binary_rule : public binary_rule { FEdge *f2 = s2.edge(); if (!(((f1)->getNature() & Nature::SILHOUETTE) || ((f1)->getNature() & Nature::BORDER)) && - !(((f2)->getNature() & Nature::SILHOUETTE) || ((f2)->getNature() & Nature::BORDER))) { + !(((f2)->getNature() & Nature::SILHOUETTE) || ((f2)->getNature() & Nature::BORDER))) + { return false; } @@ -2372,7 +2384,8 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi vector vsegments; for (vector::iterator sv = svertices.begin(), svend = svertices.end(); sv != svend; - sv++) { + sv++) + { if (_pRenderMonitor && _pRenderMonitor->testBreak()) { break; } @@ -2381,7 +2394,8 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi for (vector::const_iterator sve = vedges.begin(), sveend = vedges.end(); sve != sveend; - sve++) { + sve++) + { vsegments.push_back((segment *)((*sve)->userdata)); } diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp index 36c06fde78e..be962dc7d6c 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp +++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp @@ -391,7 +391,8 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V /* check for solvability of the linear system */ if (((aterm_da * bterm_db - aterm_db * bterm_da) != 0.0) && - ((const_da != 0.0) || (const_db != 0.0))) { + ((const_da != 0.0) || (const_db != 0.0))) + { linsolve(aterm_da, bterm_da, -const_da, aterm_db, bterm_db, -const_db, &a, &b); c = normKh - a; diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.h b/source/blender/freestyle/intern/winged_edge/Curvature.h index 88eb74972ea..023e04dca43 100644 --- a/source/blender/freestyle/intern/winged_edge/Curvature.h +++ b/source/blender/freestyle/intern/winged_edge/Curvature.h @@ -86,7 +86,8 @@ class Face_Curvature_Info { for (vector::iterator ci = vec_curvature_info.begin(), ciend = vec_curvature_info.end(); ci != ciend; - ++ci) { + ++ci) + { delete (*ci); } vec_curvature_info.clear(); diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp index 677029feb4c..642507a81e7 100644 --- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp @@ -635,7 +635,8 @@ WFace *WShape::MakeFace(vector &iVertexList, if (3 == iVertexList.size()) { if ((iVertexList[0] == iVertexList[1]) || (iVertexList[0] == iVertexList[2]) || - (iVertexList[2] == iVertexList[1])) { + (iVertexList[2] == iVertexList[1])) + { cerr << "Warning: degenerated triangle detected, correcting" << endl; return nullptr; } @@ -713,7 +714,8 @@ real WShape::ComputeMeanEdgeSize() const real meanEdgeSize = 0.0; for (vector::const_iterator it = _EdgeList.begin(), itend = _EdgeList.end(); it != itend; - it++) { + it++) + { meanEdgeSize += (*it)->GetaOEdge()->GetVec().norm(); } return meanEdgeSize / (real)_EdgeList.size(); diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h index ed50142697f..dad2197accd 100644 --- a/source/blender/freestyle/intern/winged_edge/WEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WEdge.h @@ -762,7 +762,8 @@ class WFace { int index = 0; for (vector::iterator woe = _OEdgeList.begin(), woend = _OEdgeList.end(); woe != woend; - woe++) { + woe++) + { if ((*woe)->GetaVertex() == iVertex) { return index; } @@ -775,7 +776,8 @@ class WFace { { for (vector::iterator woe = _OEdgeList.begin(), woend = _OEdgeList.end(); woe != woend; - woe++) { + woe++) + { oVertices.push_back((*woe)->GetaVertex()); } } @@ -784,7 +786,8 @@ class WFace { { for (vector::iterator woe = _OEdgeList.begin(), woend = _OEdgeList.end(); woe != woend; - woe++) { + woe++) + { WFace *af; if ((af = (*woe)->GetaFace())) { oWFaces.push_back(af); @@ -836,7 +839,8 @@ class WFace { int index = 0; for (vector::const_iterator woe = _OEdgeList.begin(), woend = _OEdgeList.end(); woe != woend; - woe++) { + woe++) + { if ((*woe)->GetaVertex() == iVertex) { index = i; break; @@ -887,7 +891,8 @@ class WFace { { for (vector::const_iterator woe = _OEdgeList.begin(), woeend = _OEdgeList.end(); woe != woeend; - ++woe) { + ++woe) + { if ((*woe)->GetOwner()->GetbOEdge() == 0) { return true; } diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp index 6838060b44e..0cb578e9940 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp @@ -243,7 +243,8 @@ void WXFace::ComputeCenter() Vec3f center; for (vector::iterator wv = iVertexList.begin(), wvend = iVertexList.end(); wv != wvend; - ++wv) { + ++wv) + { center += (*wv)->GetVertex(); } center /= float(iVertexList.size()); @@ -270,7 +271,8 @@ WFace *WXShape::MakeFace(vector &iVertexList, Vec3f center; for (vector::iterator wv = iVertexList.begin(), wvend = iVertexList.end(); wv != wvend; - ++wv) { + ++wv) + { center += (*wv)->GetVertex(); } center /= float(iVertexList.size()); diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h index 5cd27d96fca..f775eb82c5b 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.h +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h @@ -503,7 +503,8 @@ class WXFace : public WFace { for (vector::iterator wxf = iBrother._SmoothLayers.begin(), wxfend = iBrother._SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { _SmoothLayers.push_back(new WXFaceLayer(**wxf)); } } @@ -520,7 +521,8 @@ class WXFace : public WFace { for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { delete (*wxf); } _SmoothLayers.clear(); @@ -559,7 +561,8 @@ class WXFace : public WFace { for (vector::const_iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { if ((*wxf)->hasSmoothEdge()) { return true; } @@ -577,7 +580,8 @@ class WXFace : public WFace { { for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { if ((*wxf)->hasSmoothEdge() && ((*wxf)->_Nature & iNature)) { oSmoothEdges.push_back((*wxf)->_pSmoothEdge); } @@ -588,7 +592,8 @@ class WXFace : public WFace { { for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { if ((*wxf)->hasSmoothEdge() && ((*wxf)->_Nature & iNature)) { oSmoothEdgesLayers.push_back((*wxf)); } @@ -599,7 +604,8 @@ class WXFace : public WFace { { for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { if ((*wxf)->_Nature & iNature) { oSmoothLayers.push_back(*wxf); } @@ -645,7 +651,8 @@ class WXFace : public WFace { vector layersToKeep; for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { if ((*wxf)->isViewDependant()) { delete (*wxf); } @@ -661,7 +668,8 @@ class WXFace : public WFace { { for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { delete (*wxf); } _SmoothLayers.clear(); @@ -672,7 +680,8 @@ class WXFace : public WFace { WFace::ResetUserData(); for (vector::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end(); wxf != wxfend; - ++wxf) { + ++wxf) + { (*wxf)->userdata = NULL; } } diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp index ce6054830f3..20d02dc5330 100644 --- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp @@ -201,7 +201,8 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs) set normalsSet; vector &wvertices = shape.getVertexList(); for (vector::iterator wv = wvertices.begin(), wvend = wvertices.end(); wv != wvend; - ++wv) { + ++wv) + { if ((*wv)->isBoundary()) { continue; } diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index ec36dfd1282..5c112cc6cba 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -72,7 +72,8 @@ struct AllSpanOrSingle { } else if constexpr (ELEM(ParamTag::category, ParamCategory::SingleOutput, - ParamCategory::SingleMutable)) { + ParamCategory::SingleMutable)) + { T *ptr = std::get(loaded_params); return BasicDevirtualizer{ptr}; } @@ -106,7 +107,8 @@ template struct SomeSpanOrSingle { } else if constexpr (ELEM(ParamTag::category, ParamCategory::SingleOutput, - ParamCategory::SingleMutable)) { + ParamCategory::SingleMutable)) + { T *ptr = std::get(loaded_params); return BasicDevirtualizer{ptr}; } @@ -297,7 +299,8 @@ inline void execute_materialized(TypeSequence /* param_tags */, } else if constexpr (ELEM(ParamTag::category, ParamCategory::SingleOutput, - ParamCategory::SingleMutable)) { + ParamCategory::SingleMutable)) + { /* For outputs, just pass a pointer. This is important so that `__restrict` works. */ if (sliced_mask_is_range) { /* Can write into the caller-provided buffer directly. */ @@ -436,7 +439,8 @@ inline void execute_element_fn_as_multi_function(const ElementFn element_fn, } else if constexpr (ELEM(ParamTag::category, ParamCategory::SingleOutput, - ParamCategory::SingleMutable)) { + ParamCategory::SingleMutable)) + { T *ptr = std::get(loaded_params); return ptr; } diff --git a/source/blender/functions/intern/lazy_function_graph_executor.cc b/source/blender/functions/intern/lazy_function_graph_executor.cc index 6361c687693..7e677a5a6d0 100644 --- a/source/blender/functions/intern/lazy_function_graph_executor.cc +++ b/source/blender/functions/intern/lazy_function_graph_executor.cc @@ -1057,7 +1057,8 @@ class Executor { /* Forward the value to the outside of the graph. */ const int graph_output_index = self_.graph_outputs_.index_of_try(target_socket); if (graph_output_index != -1 && - params_->get_output_usage(graph_output_index) != ValueUsage::Unused) { + params_->get_output_usage(graph_output_index) != ValueUsage::Unused) + { void *dst_buffer = params_->get_output_data_ptr(graph_output_index); if (is_last_target) { type.move_construct(value_to_forward.get(), dst_buffer); @@ -1106,7 +1107,8 @@ class Executor { if (node_state.missing_required_inputs == 0 || (locked_node.node.is_function() && static_cast(locked_node.node) .function() - .allow_missing_requested_inputs())) { + .allow_missing_requested_inputs())) + { this->schedule_node(locked_node, current_task, false); } } diff --git a/source/blender/functions/intern/multi_function.cc b/source/blender/functions/intern/multi_function.cc index 7cf79cc4b81..712a7a3922f 100644 --- a/source/blender/functions/intern/multi_function.cc +++ b/source/blender/functions/intern/multi_function.cc @@ -25,7 +25,8 @@ static bool supports_threading_by_slicing_params(const MultiFunction &fn) const ParamType param_type = fn.param_type(i); if (ELEM(param_type.interface_type(), ParamType::InterfaceType::Mutable, - ParamType::InterfaceType::Output)) { + ParamType::InterfaceType::Output)) + { if (param_type.data_type().is_vector()) { return false; } diff --git a/source/blender/functions/intern/multi_function_procedure.cc b/source/blender/functions/intern/multi_function_procedure.cc index a785f69718d..d555cd2d13e 100644 --- a/source/blender/functions/intern/multi_function_procedure.cc +++ b/source/blender/functions/intern/multi_function_procedure.cc @@ -681,7 +681,8 @@ class ProcedureDotExport { } if (ELEM(instruction.prev()[0].type(), InstructionCursor::Type::Branch, - InstructionCursor::Type::Entry)) { + InstructionCursor::Type::Entry)) + { return true; } return false; @@ -739,7 +740,8 @@ class ProcedureDotExport { Vector instructions; const Instruction &begin = this->get_first_instruction_in_block(representative); for (const Instruction *current = &begin; current != nullptr; - current = this->get_next_instruction_in_block(*current, begin)) { + current = this->get_next_instruction_in_block(*current, begin)) + { instructions.append(current); } return instructions; diff --git a/source/blender/geometry/intern/add_curves_on_mesh.cc b/source/blender/geometry/intern/add_curves_on_mesh.cc index 8421c28d1d6..0910bf1ca89 100644 --- a/source/blender/geometry/intern/add_curves_on_mesh.cc +++ b/source/blender/geometry/intern/add_curves_on_mesh.cc @@ -339,14 +339,12 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves, /* Find surface normal at root points. */ Array new_normals_su(added_curves_num); - bke::mesh_surface_sample::sample_corner_attribute( - inputs.surface_looptris, - looptri_indices, - bary_coords, - VArray::ForSpan(inputs.corner_normals_su), - IndexMask(added_curves_num), - new_normals_su.as_mutable_span()); - /* TODO: Normalization. */ + bke::mesh_surface_sample::sample_corner_normals(inputs.surface_looptris, + looptri_indices, + bary_coords, + inputs.corner_normals_su, + IndexMask(added_curves_num), + new_normals_su); /* Initialize position attribute. */ if (inputs.interpolate_shape) { diff --git a/source/blender/geometry/intern/fillet_curves.cc b/source/blender/geometry/intern/fillet_curves.cc index e43960db1e7..820e8ab2945 100644 --- a/source/blender/geometry/intern/fillet_curves.cc +++ b/source/blender/geometry/intern/fillet_curves.cc @@ -524,7 +524,8 @@ static bke::CurvesGeometry fillet_curves( dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info, - {"position", "handle_type_left", "handle_type_right", "handle_right", "handle_left"})) { + {"position", "handle_type_left", "handle_type_right", "handle_right", "handle_left"})) + { duplicate_fillet_point_data(src_points_by_curve, dst_points_by_curve, curve_selection, @@ -536,7 +537,8 @@ static bke::CurvesGeometry fillet_curves( if (!unselected_ranges.is_empty()) { for (auto &attribute : bke::retrieve_attributes_for_transfer( - src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) { + src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) + { bke::curves::copy_point_data(src_points_by_curve, dst_points_by_curve, unselected_ranges, diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc index ba869b10e9b..9d9b6c352de 100644 --- a/source/blender/geometry/intern/mesh_merge_by_distance.cc +++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc @@ -180,7 +180,8 @@ static void weld_assert_poly_and_loop_kill_len(WeldMesh *weld_mesh, corner_verts, corner_edges, weld_mesh->loop_map, - nullptr)) { + nullptr)) + { poly_kills++; continue; } @@ -1186,7 +1187,8 @@ static int poly_find_doubles(const OffsetIndices poly_corners_offsets, for (int corner_index = poly_corners_offsets[poly_index].last(); corner_index >= poly_corners_offsets[poly_index].first(); - corner_index--) { + corner_index--) + { const int elem_index = corners[corner_index]; linked_polys_buffer[--linked_polys_offset[elem_index]] = poly_index; } @@ -1660,7 +1662,8 @@ static Mesh *create_merged_mesh(const Mesh &mesh, src_corner_verts, src_corner_edges, weld_mesh.loop_map, - group_buffer.data())) { + group_buffer.data())) + { continue; } @@ -1692,7 +1695,8 @@ static Mesh *create_merged_mesh(const Mesh &mesh, src_corner_verts, src_corner_edges, weld_mesh.loop_map, - group_buffer.data())) { + group_buffer.data())) + { continue; } @@ -1737,7 +1741,7 @@ std::optional mesh_merge_by_distance_all(const Mesh &mesh, BLI_kdtree_3d_balance(tree); const int vert_kill_len = BLI_kdtree_3d_calc_duplicates_fast( - tree, merge_distance, false, vert_dest_map.data()); + tree, merge_distance, true, vert_dest_map.data()); BLI_kdtree_3d_free(tree); if (vert_kill_len == 0) { diff --git a/source/blender/geometry/intern/mesh_split_edges.cc b/source/blender/geometry/intern/mesh_split_edges.cc index 47dcabc9b59..af5c7af130a 100644 --- a/source/blender/geometry/intern/mesh_split_edges.cc +++ b/source/blender/geometry/intern/mesh_split_edges.cc @@ -54,11 +54,13 @@ static void add_new_vertices(Mesh &mesh, const Span new_to_old_verts_map) attribute.finish(); } if (float3 *orco = static_cast( - CustomData_get_layer_for_write(&mesh.vdata, CD_ORCO, mesh.totvert))) { + CustomData_get_layer_for_write(&mesh.vdata, CD_ORCO, mesh.totvert))) + { copy_to_new_verts({orco, mesh.totvert}, new_to_old_verts_map); } if (int *orig_indices = static_cast( - CustomData_get_layer_for_write(&mesh.vdata, CD_ORIGINDEX, mesh.totvert))) { + CustomData_get_layer_for_write(&mesh.vdata, CD_ORIGINDEX, mesh.totvert))) + { copy_to_new_verts({orig_indices, mesh.totvert}, new_to_old_verts_map); } } @@ -131,7 +133,8 @@ static void add_new_edges(Mesh &mesh, int *new_orig_indices = nullptr; if (const int *orig_indices = static_cast( - CustomData_get_layer(&mesh.edata, CD_ORIGINDEX))) { + CustomData_get_layer(&mesh.edata, CD_ORIGINDEX))) + { new_orig_indices = static_cast( MEM_malloc_arrayN(new_edges.size(), sizeof(int), __func__)); array_utils::gather(Span(orig_indices, mesh.totedge), diff --git a/source/blender/geometry/intern/resample_curves.cc b/source/blender/geometry/intern/resample_curves.cc index 1ea955be68b..5590f5f1ccf 100644 --- a/source/blender/geometry/intern/resample_curves.cc +++ b/source/blender/geometry/intern/resample_curves.cc @@ -57,7 +57,8 @@ static bool interpolate_attribute_to_curves(const bke::AttributeIDRef &attribute "handle_type_left", "handle_type_right", "handle_left", - "handle_right")) { + "handle_right")) + { return type_counts[CURVE_TYPE_BEZIER] != 0; } if (ELEM(attribute_id.name(), "nurbs_weight")) { diff --git a/source/blender/geometry/intern/subdivide_curves.cc b/source/blender/geometry/intern/subdivide_curves.cc index f2286d8f28c..9b4aa260ce1 100644 --- a/source/blender/geometry/intern/subdivide_curves.cc +++ b/source/blender/geometry/intern/subdivide_curves.cc @@ -342,7 +342,8 @@ bke::CurvesGeometry subdivide_curves( auto subdivide_catmull_rom = [&](IndexMask selection) { for (auto &attribute : bke::retrieve_attributes_for_transfer( - src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) { + src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) + { subdivide_attribute_catmull_rom(src_points_by_curve, dst_points_by_curve, selection, @@ -356,7 +357,8 @@ bke::CurvesGeometry subdivide_curves( auto subdivide_poly = [&](IndexMask selection) { for (auto &attribute : bke::retrieve_attributes_for_transfer( - src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) { + src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) + { subdivide_attribute_linear(src_points_by_curve, dst_points_by_curve, selection, @@ -402,15 +404,13 @@ bke::CurvesGeometry subdivide_curves( } }); - for (auto &attribute : bke::retrieve_attributes_for_transfer(src_attributes, - dst_attributes, - ATTR_DOMAIN_MASK_POINT, - propagation_info, - {"position", - "handle_type_left", - "handle_type_right", - "handle_right", - "handle_left"})) { + for (auto &attribute : bke::retrieve_attributes_for_transfer( + src_attributes, + dst_attributes, + ATTR_DOMAIN_MASK_POINT, + propagation_info, + {"position", "handle_type_left", "handle_type_right", "handle_right", "handle_left"})) + { subdivide_attribute_linear(src_points_by_curve, dst_points_by_curve, selection, @@ -435,7 +435,8 @@ bke::CurvesGeometry subdivide_curves( if (!unselected_ranges.is_empty()) { for (auto &attribute : bke::retrieve_attributes_for_transfer( - src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) { + src_attributes, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info)) + { bke::curves::copy_point_data(src_points_by_curve, dst_points_by_curve, unselected_ranges, diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 1f4ea939fa0..b022289b960 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -129,7 +129,8 @@ static bke::curves::CurvePoint lookup_point_bezier( const int num_curve_points) { if (bke::curves::bezier::has_vector_handles( - num_curve_points, evaluated_points_by_curve[curve_index].size(), cyclic, resolution)) { + num_curve_points, evaluated_points_by_curve[curve_index].size(), cyclic, resolution)) + { const Span bezier_offsets = src_curves.bezier_evaluated_offsets_for_curve(curve_index); return lookup_point_bezier( bezier_offsets, accumulated_lengths, sample_length, cyclic, num_curve_points); @@ -553,7 +554,8 @@ static void sample_interval_bezier(const Span src_positions, src_positions, src_handles_l, src_handles_r, end_point); if ((start_point.parameter >= end_point.parameter && end_point.index == start_point.index) || - (start_point.parameter == 0.0f && end_point.next_index == start_point.index)) { + (start_point.parameter == 0.0f && end_point.next_index == start_point.index)) + { /* Start point is next controlpoint. */ dst_handles_l[dst_range.first()] = end_point_insert.handle_next; /* No need to change handle type (remains the same). */ @@ -1071,7 +1073,8 @@ bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, Set copy_point_skip; if (!dst_curves.has_curve_with_type(CURVE_TYPE_NURBS) && - src_curves.has_curve_with_type(CURVE_TYPE_NURBS)) { + src_curves.has_curve_with_type(CURVE_TYPE_NURBS)) + { copy_point_skip.add("nurbs_weight"); } @@ -1080,7 +1083,8 @@ bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, dst_attributes, ATTR_DOMAIN_MASK_POINT, propagation_info, - copy_point_skip)) { + copy_point_skip)) + { bke::curves::copy_point_data(src_points_by_curve, dst_points_by_curve, unselected_ranges, diff --git a/source/blender/geometry/intern/uv_pack.cc b/source/blender/geometry/intern/uv_pack.cc index 43377652e21..469c80d79f2 100644 --- a/source/blender/geometry/intern/uv_pack.cc +++ b/source/blender/geometry/intern/uv_pack.cc @@ -747,8 +747,8 @@ float2 PackIsland::get_diagonal_support(const float scale, return half_diagonal_ * scale + margin; } - if (rotation == DEG2RADF(-90.0f) || rotation == DEG2RADF(90.0f) || - rotation == DEG2RADF(270.0f)) { + if (rotation == DEG2RADF(-90.0f) || rotation == DEG2RADF(90.0f) || rotation == DEG2RADF(270.0f)) + { return float2(half_diagonal_.y / aspect_y, half_diagonal_.x * aspect_y) * scale + margin; } @@ -761,7 +761,7 @@ float2 PackIsland::get_diagonal_support(const float scale, float sx = fabsf(diagonal_rotated[0]); float sy = fabsf(diagonal_rotated[1]); - return float2(sx + sy * 0.5f + margin, sx * 0.5f + sy + margin); /* Upper bound. */ + return float2(sx + sy * 0.7071f + margin, sx * 0.7071f + sy + margin); /* Upper bound. */ } float Occupancy::trace_island(const PackIsland *island, @@ -954,13 +954,18 @@ static bool rotate_inside_square(const Span island_indices, float *r_max_u, float *r_max_v) { + if (island_indices.size() == 0) { + return false; /* Nothing to do. */ + } if (!params.rotate) { return false; /* Unable to rotate. */ } if (params.shape_method == ED_UVPACK_SHAPE_AABB) { - return false; /* AABB margin calculations are not preserved under rotations. */ + /* AABB margin calculations are not preserved under rotations. */ + if (island_indices.size() > 1) { /* Unless there's only one island...*/ + return false; + } } - BLI_assert(islands.size() > 0); UVMinimumEnclosingSquareFinder square_finder(scale, margin, ¶ms); square_finder.best_quad = std::max(*r_max_u / params.target_aspect_y, *r_max_v); @@ -991,7 +996,7 @@ static bool rotate_inside_square(const Span island_indices, square_finder.indices.resize(square_finder.points.size()); int convex_size = BLI_convexhull_2d( - source, static_cast(square_finder.points.size()), square_finder.indices.data()); + source, int(square_finder.points.size()), square_finder.indices.data()); square_finder.indices.resize(convex_size); const float quad_180 = square_finder.update(DEG2RADF(-180.0f)); @@ -1100,7 +1105,8 @@ static void pack_island_xatlas(const Span island_indices, scan_line += 2; } if (scan_line < occupancy.bitmap_radix * - sqrtf(std::min(params.target_aspect_y, 1.0f / params.target_aspect_y))) { + sqrtf(std::min(params.target_aspect_y, 1.0f / params.target_aspect_y))) + { continue; /* Try again on next scan_line. */ } @@ -1123,7 +1129,8 @@ static void pack_island_xatlas(const Span island_indices, margin, r_phis, &max_u, - &max_v)) { + &max_v)) + { scan_line = 0; traced_islands = 0; occupancy.clear(); @@ -1262,6 +1269,15 @@ static float pack_islands_scale_margin(const Span islands, /* At this stage, `max_u` and `max_v` contain the box_pack/xatlas UVs. */ + rotate_inside_square(aabbs.as_span().take_front(max_box_pack), + islands, + params, + scale, + margin, + r_phis, + &max_u, + &max_v); + /* Call Alpaca. */ if (params.rotate) { pack_islands_alpaca_rotate( @@ -1271,8 +1287,6 @@ static float pack_islands_scale_margin(const Span islands, pack_islands_alpaca_turbo(max_box_pack, aabbs, params.target_aspect_y, r_phis, &max_u, &max_v); } - rotate_inside_square(aabbs, islands, params, scale, margin, r_phis, &max_u, &max_v); - return std::max(max_u / params.target_aspect_y, max_v); } @@ -1443,7 +1457,8 @@ class OverlapMerger { a->triangle_vertices_[i + 2], b->triangle_vertices_[j + 0], b->triangle_vertices_[j + 1], - b->triangle_vertices_[j + 2])) { + b->triangle_vertices_[j + 2])) + { return true; /* Two triangles overlap => islands overlap. */ } } @@ -1554,7 +1569,8 @@ float pack_islands(const Span &islands, const UVPackIsland_Params finalize_geometry(islands, params); if (params.margin_method == ED_UVPACK_MARGIN_FRACTION && params.margin > 0.0f && - params.scale_to_fit) { + params.scale_to_fit) + { /* Uses a line search on scale. ~10x slower than other method. */ return pack_islands_margin_fraction(islands, params.margin, params); } diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 278a6209e17..a01c4c2a305 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -2834,8 +2834,8 @@ static bool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PVe nextbe = p_boundary_edge_next(be); - if ((be->vert->flag & PVERT_SPLIT) || - (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) { + if ((be->vert->flag & PVERT_SPLIT) || (lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) + { if (!cure) { if (be == outer) { firste1 = be; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c index 19ca882ef40..4d243a8c43d 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.c @@ -143,7 +143,8 @@ static bool gpencil_data_selected_minmax(ArrayGpencilModifierData *mmd, mmd->flag & GP_ARRAY_INVERT_LAYER, mmd->flag & GP_ARRAY_INVERT_PASS, mmd->flag & GP_ARRAY_INVERT_LAYERPASS, - mmd->flag & GP_ARRAY_INVERT_MATERIAL)) { + mmd->flag & GP_ARRAY_INVERT_MATERIAL)) + { changed |= BKE_gpencil_stroke_minmax(gps, false, r_min, r_max); } } @@ -198,7 +199,8 @@ static void generate_geometry(GpencilModifierData *md, mmd->flag & GP_ARRAY_INVERT_LAYER, mmd->flag & GP_ARRAY_INVERT_PASS, mmd->flag & GP_ARRAY_INVERT_LAYERPASS, - mmd->flag & GP_ARRAY_INVERT_MATERIAL)) { + mmd->flag & GP_ARRAY_INVERT_MATERIAL)) + { tmpStrokes *tmp = MEM_callocN(sizeof(tmpStrokes), __func__); tmp->gpf = gpf; tmp->gps = gps; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c index 57d743809ee..b4b4f8d41b7 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.c @@ -418,8 +418,8 @@ static void build_sequential(Object *ob, float gp_build_speedfactor = mmd->speed_fac; /* If current frame can't be built before next frame, adjust gp_build_speedfactor. */ - if (gpf->next && - (gpf->framenum + sumtime * fps / gp_build_speedfactor) > gpf->next->framenum) { + if (gpf->next && (gpf->framenum + sumtime * fps / gp_build_speedfactor) > gpf->next->framenum) + { gp_build_speedfactor = sumtime * fps / (gpf->next->framenum - gpf->framenum); } /* Apply gp_build_speedfactor to all points & to sumtime. */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c index 2ccd6518265..a6d4cade6ad 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.c @@ -91,7 +91,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_COLOR_INVERT_LAYER, mmd->flag & GP_COLOR_INVERT_PASS, mmd->flag & GP_COLOR_INVERT_LAYERPASS, - mmd->flag & GP_COLOR_INVERT_MATERIAL)) { + mmd->flag & GP_COLOR_INVERT_MATERIAL)) + { return; } @@ -102,8 +103,8 @@ static void deformStroke(GpencilModifierData *md, /* Fill */ if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) { /* If not using Vertex Color, use the material color. */ - if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) && - (gp_style->fill_rgba[3] > 0.0f)) { + if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) && (gp_style->fill_rgba[3] > 0.0f)) + { copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba); gps->vert_color_fill[3] = 1.0f; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c index cf8380d30e6..11099aa9aa1 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c @@ -211,7 +211,8 @@ static void apply_dash_for_frame( dmd->flag & GP_LENGTH_INVERT_LAYER, dmd->flag & GP_LENGTH_INVERT_PASS, dmd->flag & GP_LENGTH_INVERT_LAYERPASS, - dmd->flag & GP_LENGTH_INVERT_MATERIAL)) { + dmd->flag & GP_LENGTH_INVERT_MATERIAL)) + { if (stroke_dash(gps, dmd, &result)) { BLI_remlink(&gpf->strokes, gps); BKE_gpencil_free_stroke(gps); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c index 3ce6ed33648..76d30ef2bfe 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.c @@ -319,7 +319,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_ENVELOPE_INVERT_LAYER, mmd->flag & GP_ENVELOPE_INVERT_PASS, mmd->flag & GP_ENVELOPE_INVERT_LAYERPASS, - mmd->flag & GP_ENVELOPE_INVERT_MATERIAL)) { + mmd->flag & GP_ENVELOPE_INVERT_MATERIAL)) + { return; } @@ -481,7 +482,8 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp mmd->flag & GP_ENVELOPE_INVERT_LAYER, mmd->flag & GP_ENVELOPE_INVERT_PASS, mmd->flag & GP_ENVELOPE_INVERT_LAYERPASS, - mmd->flag & GP_ENVELOPE_INVERT_MATERIAL)) { + mmd->flag & GP_ENVELOPE_INVERT_MATERIAL)) + { continue; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c index 7aa836c6740..f78754fe358 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.c @@ -208,7 +208,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_HOOK_INVERT_LAYER, mmd->flag & GP_HOOK_INVERT_PASS, mmd->flag & GP_HOOK_INVERT_LAYERPASS, - mmd->flag & GP_HOOK_INVERT_MATERIAL)) { + mmd->flag & GP_HOOK_INVERT_MATERIAL)) + { return; } bGPdata *gpd = ob->data; @@ -329,7 +330,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); if (!RNA_pointer_is_null(&hook_object_ptr) && - RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) { + RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) + { PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data"); uiItemPointerR( col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c index ccd3ab59e92..b532a60dac4 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.c @@ -81,7 +81,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_LATTICE_INVERT_LAYER, mmd->flag & GP_LATTICE_INVERT_PASS, mmd->flag & GP_LATTICE_INVERT_LAYERPASS, - mmd->flag & GP_LATTICE_INVERT_MATERIAL)) { + mmd->flag & GP_LATTICE_INVERT_MATERIAL)) + { return; } @@ -215,7 +216,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); if (!RNA_pointer_is_null(&hook_object_ptr) && - RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) { + RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) + { PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data"); uiItemPointerR( col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c index 0dca04f568b..3c9f68db787 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.c @@ -225,7 +225,8 @@ static void deformStroke(GpencilModifierData *md, lmd->flag & GP_LENGTH_INVERT_LAYER, lmd->flag & GP_LENGTH_INVERT_PASS, lmd->flag & GP_LENGTH_INVERT_LAYERPASS, - lmd->flag & GP_LENGTH_INVERT_MATERIAL)) { + lmd->flag & GP_LENGTH_INVERT_MATERIAL)) + { return; } if ((gps->flag & GP_STROKE_CYCLIC) != 0) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c index 9d5074238c9..5d88e499574 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.c @@ -225,7 +225,8 @@ static void add_this_collection(Collection *c, FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (c, ob, mode) { if (ELEM(ob->type, OB_MESH, OB_MBALL, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { if ((ob->lineart.usage == OBJECT_LRT_INHERIT && default_add) || - ob->lineart.usage != OBJECT_LRT_EXCLUDE) { + ob->lineart.usage != OBJECT_LRT_EXCLUDE) + { DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_GEOMETRY, "Line Art Modifier"); DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_TRANSFORM, "Line Art Modifier"); } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c index 6e3461d6833..3d9ccda92d1 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.c @@ -129,7 +129,8 @@ static void generate_geometry( mmd->flag & GP_MIRROR_INVERT_LAYER, mmd->flag & GP_MIRROR_INVERT_PASS, mmd->flag & GP_MIRROR_INVERT_LAYERPASS, - mmd->flag & GP_MIRROR_INVERT_MATERIAL)) { + mmd->flag & GP_MIRROR_INVERT_MATERIAL)) + { gps_new = BKE_gpencil_stroke_duplicate(gps, true, true); update_position(ob, mmd, gps_new, xi); if (update) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c index bce0f02d6d7..fcf96745384 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.c @@ -195,7 +195,8 @@ static void generate_geometry(GpencilModifierData *md, Object *ob, bGPDlayer *gp mmd->flag & GP_MIRROR_INVERT_LAYER, mmd->flag & GP_MIRROR_INVERT_PASS, mmd->flag & GP_MIRROR_INVERT_LAYERPASS, - mmd->flag & GP_MIRROR_INVERT_MATERIAL)) { + mmd->flag & GP_MIRROR_INVERT_MATERIAL)) + { continue; } if (mmd->duplications > 0) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c index 3be6aff0979..9ddf4739680 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.c @@ -135,7 +135,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_NOISE_INVERT_LAYER, mmd->flag & GP_NOISE_INVERT_PASS, mmd->flag & GP_NOISE_INVERT_LAYERPASS, - mmd->flag & GP_NOISE_INVERT_MATERIAL)) { + mmd->flag & GP_NOISE_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c index 5337ca62dd5..f27ae283a01 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.c @@ -86,7 +86,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_OFFSET_INVERT_LAYER, mmd->flag & GP_OFFSET_INVERT_PASS, mmd->flag & GP_OFFSET_INVERT_LAYERPASS, - mmd->flag & GP_OFFSET_INVERT_MATERIAL)) { + mmd->flag & GP_OFFSET_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c index 9901b4412c8..1eb087637f7 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.c @@ -92,7 +92,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_OPACITY_INVERT_LAYER, mmd->flag & GP_OPACITY_INVERT_PASS, mmd->flag & GP_OPACITY_INVERT_LAYERPASS, - mmd->flag & GP_OPACITY_INVERT_MATERIAL)) { + mmd->flag & GP_OPACITY_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c index 7332d2e0891..efbaa7b6b33 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.c @@ -99,7 +99,8 @@ static void convert_stroke(GpencilModifierData *md, mmd->flag & GP_OUTLINE_INVERT_LAYER, mmd->flag & GP_OUTLINE_INVERT_PASS, mmd->flag & GP_OUTLINE_INVERT_LAYERPASS, - mmd->flag & GP_OUTLINE_INVERT_MATERIAL)) { + mmd->flag & GP_OUTLINE_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c index 2900f51a29e..b7157d92ced 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.c @@ -84,7 +84,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_SHRINKWRAP_INVERT_LAYER, mmd->flag & GP_SHRINKWRAP_INVERT_PASS, mmd->flag & GP_SHRINKWRAP_INVERT_LAYERPASS, - mmd->flag & GP_SHRINKWRAP_INVERT_MATERIAL)) { + mmd->flag & GP_SHRINKWRAP_INVERT_MATERIAL)) + { return; } @@ -253,7 +254,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) if (ELEM(wrap_method, MOD_SHRINKWRAP_PROJECT, MOD_SHRINKWRAP_NEAREST_SURFACE, - MOD_SHRINKWRAP_TARGET_PROJECT)) { + MOD_SHRINKWRAP_TARGET_PROJECT)) + { uiItemR(layout, ptr, "wrap_mode", 0, NULL, ICON_NONE); } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c index 713c4531043..16a26b69017 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.c @@ -71,7 +71,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_SIMPLIFY_INVERT_LAYER, mmd->flag & GP_SIMPLIFY_INVERT_PASS, mmd->flag & GP_SIMPLIFY_INVERT_LAYERPASS, - mmd->flag & GP_SIMPLIFY_INVERT_MATERIAL)) { + mmd->flag & GP_SIMPLIFY_INVERT_MATERIAL)) + { return; } bGPdata *gpd = ob->data; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c index 497622ab141..ab7170a3efd 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.c @@ -94,7 +94,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_SMOOTH_INVERT_LAYER, mmd->flag & GP_SMOOTH_INVERT_PASS, mmd->flag & GP_SMOOTH_INVERT_LAYERPASS, - mmd->flag & GP_SMOOTH_INVERT_MATERIAL)) { + mmd->flag & GP_SMOOTH_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c index bc5ea5a4cf4..7ce4c294cdc 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.c @@ -71,7 +71,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_SUBDIV_INVERT_LAYER, mmd->flag & GP_SUBDIV_INVERT_PASS, mmd->flag & GP_SUBDIV_INVERT_LAYERPASS, - mmd->flag & GP_SUBDIV_INVERT_MATERIAL)) { + mmd->flag & GP_SUBDIV_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c index b19f4f739cc..c6d8f3d3f74 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.c @@ -76,7 +76,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_TEX_INVERT_LAYER, mmd->flag & GP_TEX_INVERT_PASS, mmd->flag & GP_TEX_INVERT_LAYERPASS, - mmd->flag & GP_TEX_INVERT_MATERIAL)) { + mmd->flag & GP_TEX_INVERT_MATERIAL)) + { return; } if (ELEM(mmd->mode, FILL, STROKE_AND_FILL)) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c index 1ebca18bcde..b6341a562cb 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.c @@ -97,7 +97,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_THICK_INVERT_LAYER, mmd->flag & GP_THICK_INVERT_PASS, mmd->flag & GP_THICK_INVERT_LAYERPASS, - mmd->flag & GP_THICK_INVERT_MATERIAL)) { + mmd->flag & GP_THICK_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c index 499d490d135..a30f11b77f5 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.c @@ -126,7 +126,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_TINT_INVERT_LAYER, mmd->flag & GP_TINT_INVERT_PASS, mmd->flag & GP_TINT_INVERT_LAYERPASS, - mmd->flag & GP_TINT_INVERT_MATERIAL)) { + mmd->flag & GP_TINT_INVERT_MATERIAL)) + { return; } MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c index 916298e2f17..0814339989e 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.c @@ -76,7 +76,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_WEIGHT_INVERT_LAYER, mmd->flag & GP_WEIGHT_INVERT_PASS, mmd->flag & GP_WEIGHT_INVERT_LAYERPASS, - mmd->flag & GP_WEIGHT_INVERT_MATERIAL)) { + mmd->flag & GP_WEIGHT_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c index d1bfb65e6b7..93f7b3acbc5 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.c @@ -102,7 +102,8 @@ static void deformStroke(GpencilModifierData *md, mmd->flag & GP_WEIGHT_INVERT_LAYER, mmd->flag & GP_WEIGHT_INVERT_PASS, mmd->flag & GP_WEIGHT_INVERT_LAYERPASS, - mmd->flag & GP_WEIGHT_INVERT_MATERIAL)) { + mmd->flag & GP_WEIGHT_INVERT_MATERIAL)) + { return; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h index 562cac2c7bb..86ed62512ec 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h @@ -681,12 +681,14 @@ BLI_INLINE int lineart_intersect_seg_seg(const double a1[2], if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff2, 0)) { /* This means two segments are both vertical. */ if ((LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b1[1])) || - (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) { + (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) + { *r_aligned = true; *r_ratio = 1; } else if ((LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b1[1])) || - (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) { + (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) + { *r_aligned = true; *r_ratio = 0; } @@ -712,14 +714,15 @@ BLI_INLINE int lineart_intersect_seg_seg(const double a1[2], /* This means two segments are parallel. This also handles k==0 (both completely * horizontal) cases. */ if ((LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b1[1])) || - (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) { + (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) + { *r_aligned = true; *r_ratio = 1; } else if ((LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b1[1])) || - (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) && - LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) { + (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) + { *r_aligned = true; *r_ratio = 0; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c index e3e37b222e9..371cdf826c9 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.c @@ -85,7 +85,8 @@ static bool lineart_point_overlapping(LineartEdgeChainItem *eci, return false; } if (((eci->pos[0] + threshold) >= x) && ((eci->pos[0] - threshold) <= x) && - ((eci->pos[1] + threshold) >= y) && ((eci->pos[1] - threshold) <= y)) { + ((eci->pos[1] + threshold) >= y) && ((eci->pos[1] - threshold) <= y)) + { return true; } return false; @@ -234,7 +235,8 @@ void MOD_lineart_chain_feature_lines(LineartData *ld) es->shadow_mask_bits, e->v1->index); while (ba && (new_e = lineart_line_get_connected( - ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) { + ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) + { new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; if (new_e->t1 || new_e->t2) { @@ -378,7 +380,8 @@ void MOD_lineart_chain_feature_lines(LineartData *ld) ba = MOD_lineart_get_bounding_area(ld, e->v2->fbcoord[0], e->v2->fbcoord[1]); new_vt = e->v2; while (ba && (new_e = lineart_line_get_connected( - ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) { + ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) + { new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; if (new_e->t1 || new_e->t2) { @@ -613,7 +616,8 @@ static bool lineart_chain_fix_ambiguous_segments(LineartEdgeChain *ec, break; } if (eci->material_mask_bits == fixed_mask && eci->occlusion == fixed_occ && - eci->shadow_mask_bits == fixed_shadow) { + eci->shadow_mask_bits == fixed_shadow) + { can_skip_to = eci; } } @@ -624,7 +628,8 @@ static bool lineart_chain_fix_ambiguous_segments(LineartEdgeChain *ec, for (LineartEdgeChainItem *eci = last_matching_eci->next; eci != can_skip_to; eci = next_eci) { next_eci = eci->next; if (eci->material_mask_bits == fixed_mask && eci->occlusion == fixed_occ && - eci->shadow_mask_bits == fixed_shadow) { + eci->shadow_mask_bits == fixed_shadow) + { continue; } if (preserve_details) { @@ -671,7 +676,8 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartData *ld) for (eci = first_eci->next; eci; eci = next_eci) { next_eci = eci->next; if (eci->occlusion != fixed_occ || eci->material_mask_bits != fixed_mask || - eci->shadow_mask_bits != fixed_shadow) { + eci->shadow_mask_bits != fixed_shadow) + { if (next_eci) { if (lineart_point_overlapping(next_eci, eci->pos[0], eci->pos[1], 1e-5)) { continue; @@ -680,7 +686,8 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartData *ld) eci->prev, ld->conf.chaining_image_threshold, ld->conf.chain_preserve_details, - &next_eci)) { + &next_eci)) + { continue; } } @@ -824,7 +831,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartData *ld, } if (cre->ec == ec || (!cre->ec->chain.first) || (cre->ec->level != occlusion) || (cre->ec->material_mask_bits != material_mask_bits) || - (cre->ec->intersection_mask != isec_mask) || (cre->ec->shadow_mask_bits != shadow_mask)) { + (cre->ec->intersection_mask != isec_mask) || (cre->ec->shadow_mask_bits != shadow_mask)) + { continue; } if (!ld->conf.fuzzy_everything) { @@ -847,7 +855,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartData *ld, * distance is small enough. This way we can better chain smaller loops and smooth them out * later. */ if (((cre->ec->loop_id == loop_id) && (new_len < dist)) || - ((cre->ec->loop_id != loop_id) && (new_len < dist / 10))) { + ((cre->ec->loop_id != loop_id) && (new_len < dist / 10))) + { closest_cre = cre; dist = new_len; if (result_new_len) { @@ -936,7 +945,8 @@ void MOD_lineart_chain_connect(LineartData *ld) eci_l = ec->chain.first; eci_r = ec->chain.last; while ((ba_l = lineart_bounding_area_get_end_point(ld, eci_l)) && - (ba_r = lineart_bounding_area_get_end_point(ld, eci_r))) { + (ba_r = lineart_bounding_area_get_end_point(ld, eci_r))) + { closest_cre_l = lineart_chain_get_closest_cre(ld, ba_l, ec, @@ -1067,7 +1077,8 @@ void MOD_lineart_finalize_chains(LineartData *ld) if (ELEM(ec->type, LRT_EDGE_FLAG_INTERSECTION, LRT_EDGE_FLAG_PROJECTED_SHADOW, - LRT_EDGE_FLAG_LIGHT_CONTOUR)) { + LRT_EDGE_FLAG_LIGHT_CONTOUR)) + { continue; } LineartElementLinkNode *eln = lineart_find_matching_eln_obj(&ld->geom.vertex_buffer_pointers, @@ -1088,8 +1099,8 @@ void MOD_lineart_smooth_chains(LineartData *ld, float tolerance) LISTBASE_FOREACH (LineartEdgeChain *, ec, &ld->chains) { /* Go through the chain two times, once from each direction. */ for (int times = 0; times < 2; times++) { - for (LineartEdgeChainItem *eci = ec->chain.first, *next_eci = eci->next; eci; - eci = next_eci) { + for (LineartEdgeChainItem *eci = ec->chain.first, *next_eci = eci->next; eci; eci = next_eci) + { LineartEdgeChainItem *eci2, *eci3, *eci4; if (!(eci2 = eci->next) || !(eci3 = eci2->next)) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index b2276d85f68..a31008d39f0 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -324,7 +324,8 @@ void lineart_edge_cut(LineartData *ld, if (prev_seg && prev_seg->occlusion == seg->occlusion && prev_seg->material_mask_bits == seg->material_mask_bits && - prev_seg->shadow_mask_bits == seg->shadow_mask_bits) { + prev_seg->shadow_mask_bits == seg->shadow_mask_bits) + { BLI_remlink(&e->segments, seg); /* This puts the node back to the render buffer, if more cut happens, these unused nodes get * picked first. */ @@ -389,7 +390,8 @@ static void lineart_occlusion_single_line(LineartData *ld, LineartEdge *e, int t lineart_occlusion_is_adjacent_intersection(e, (LineartTriangle *)tri) || /* Or if this triangle isn't effectively occluding anything nor it's providing a * material flag. */ - ((!tri->base.mat_occlusion) && (!tri->base.material_mask_bits))) { + ((!tri->base.mat_occlusion) && (!tri->base.material_mask_bits))) + { continue; } tri->testing_e[thread_id] = e; @@ -403,7 +405,8 @@ static void lineart_occlusion_single_line(LineartData *ld, LineartEdge *e, int t ld->conf.shift_x, ld->conf.shift_y, &l, - &r)) { + &r)) + { lineart_edge_cut(ld, e, l, r, tri->base.material_mask_bits, tri->base.mat_occlusion, 0); if (e->min_occ > ld->conf.max_occlusion_level) { /* No need to calculate any longer on this line because no level more than set value is @@ -573,7 +576,8 @@ static LineartPointTri lineart_point_triangle_relation(double v[2], double cl, c; double r; if (lineart_point_on_line_segment(v, v0, v1) || lineart_point_on_line_segment(v, v1, v2) || - lineart_point_on_line_segment(v, v2, v0)) { + lineart_point_on_line_segment(v, v2, v0)) + { return LRT_ON_TRIANGLE; } @@ -1335,7 +1339,8 @@ void lineart_main_free_adjacent_data(LineartData *ld) { LinkData *link; while ((link = static_cast(BLI_pophead(&ld->geom.triangle_adjacent_pointers))) != - nullptr) { + nullptr) + { MEM_freeN(link->data); } LISTBASE_FOREACH (LineartElementLinkNode *, eln, &ld->geom.triangle_buffer_pointers) { @@ -1527,7 +1532,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, ff2 = ff1; } if (e_feat_data->ld->conf.filter_face_mark_boundaries ^ - e_feat_data->ld->conf.filter_face_mark_invert) { + e_feat_data->ld->conf.filter_face_mark_invert) + { if ((ff1->flag & FREESTYLE_FACE_MARK) || (ff2->flag & FREESTYLE_FACE_MARK)) { face_mark_filtered = true; } @@ -1632,7 +1638,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, bool do_crease = true; if (!ld->conf.force_crease && !e_feat_data->use_auto_smooth && (!e_feat_data->sharp_faces[looptris[f1].poly]) && - (!e_feat_data->sharp_faces[looptris[f2].poly])) { + (!e_feat_data->sharp_faces[looptris[f2].poly])) + { do_crease = false; } if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) { @@ -1648,7 +1655,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, Material *m2 = BKE_object_material_get_eval(ob_eval, mat2 + 1); if (m1 && m2 && ((m1->lineart.mat_occlusion == 0 && m2->lineart.mat_occlusion != 0) || - (m2->lineart.mat_occlusion == 0 && m1->lineart.mat_occlusion != 0))) { + (m2->lineart.mat_occlusion == 0 && m1->lineart.mat_occlusion != 0))) + { if (ld->conf.use_contour) { edge_flag_result |= LRT_EDGE_FLAG_CONTOUR; } @@ -2216,7 +2224,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, OBJECT_LRT_INHERIT, OBJECT_LRT_INCLUDE, OBJECT_LRT_NO_INTERSECTION, - OBJECT_LRT_FORCE_INTERSECTION)) { + OBJECT_LRT_FORCE_INTERSECTION)) + { lineart_add_edge_to_array_thread(ob_info, la_edge); } @@ -2249,7 +2258,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, OBJECT_LRT_INHERIT, OBJECT_LRT_INCLUDE, OBJECT_LRT_NO_INTERSECTION, - OBJECT_LRT_FORCE_INTERSECTION)) { + OBJECT_LRT_FORCE_INTERSECTION)) + { lineart_add_edge_to_array_thread(ob_info, la_edge); if (shadow_eln) { LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, la_edge->edge_identifier); @@ -2337,7 +2347,8 @@ static int lineart_usage_check(Collection *c, Object *ob, bool is_render) if (c->gobject.first) { if (BKE_collection_has_object(c, (Object *)(ob->id.orig_id))) { if ((is_render && (c->flag & COLLECTION_HIDE_RENDER)) || - ((!is_render) && (c->flag & COLLECTION_HIDE_VIEWPORT))) { + ((!is_render) && (c->flag & COLLECTION_HIDE_VIEWPORT))) + { return OBJECT_LRT_EXCLUDE; } if (ob->lineart.usage == OBJECT_LRT_INHERIT) { @@ -2482,7 +2493,8 @@ static void lineart_object_load_single_instance(LineartData *ld, } if (!lineart_geometry_check_visible( - obi->model_view_proj, ld->conf.shift_x, ld->conf.shift_y, use_mesh)) { + obi->model_view_proj, ld->conf.shift_x, ld->conf.shift_y, use_mesh)) + { return; } @@ -2697,14 +2709,16 @@ bool lineart_edge_from_triangle(const LineartTriangle *tri, const LineartEdge *use_e = e; if (e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { if (((e->target_reference & LRT_LIGHT_CONTOUR_TARGET) == tri->target_reference) || - (((e->target_reference >> 32) & LRT_LIGHT_CONTOUR_TARGET) == tri->target_reference)) { + (((e->target_reference >> 32) & LRT_LIGHT_CONTOUR_TARGET) == tri->target_reference)) + { return true; } } else { /* Normally we just determine from identifiers of adjacent triangles. */ if ((use_e->t1 && use_e->t1->target_reference == tri->target_reference) || - (use_e->t2 && use_e->t2->target_reference == tri->target_reference)) { + (use_e->t2 && use_e->t2->target_reference == tri->target_reference)) + { return true; } } @@ -2722,7 +2736,8 @@ bool lineart_edge_from_triangle(const LineartTriangle *tri, if ((LRT_TRI_SAME_POINT(tri, 0, e->v1) || LRT_TRI_SAME_POINT(tri, 1, e->v1) || LRT_TRI_SAME_POINT(tri, 2, e->v1)) && (LRT_TRI_SAME_POINT(tri, 0, e->v2) || LRT_TRI_SAME_POINT(tri, 1, e->v2) || - LRT_TRI_SAME_POINT(tri, 2, e->v2))) { + LRT_TRI_SAME_POINT(tri, 2, e->v2))) + { return true; } #undef LRT_TRI_SAME_POINT @@ -2820,7 +2835,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t (MIN3(FBC0[0], FBC1[0], FBC2[0]) > MAX2(LFBC[0], RFBC[0])) || (MAX3(FBC0[1], FBC1[1], FBC2[1]) < MIN2(LFBC[1], RFBC[1])) || (MIN3(FBC0[1], FBC1[1], FBC2[1]) > MAX2(LFBC[1], RFBC[1])) || - (MIN3(FBC0[3], FBC1[3], FBC2[3]) > MAX2(LFBC[3], RFBC[3]))) { + (MIN3(FBC0[3], FBC1[3], FBC2[3]) > MAX2(LFBC[3], RFBC[3]))) + { return false; } @@ -2853,7 +2869,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t if ((e->flags & LRT_EDGE_FLAG_PROJECTED_SHADOW) && (e->target_reference == tri->target_reference)) { if (((dot_f > 0) && (e->flags & LRT_EDGE_FLAG_SHADOW_FACING_LIGHT)) || - ((dot_f < 0) && !(e->flags & LRT_EDGE_FLAG_SHADOW_FACING_LIGHT))) { + ((dot_f < 0) && !(e->flags & LRT_EDGE_FLAG_SHADOW_FACING_LIGHT))) + { *from = 0.0f; *to = 1.0f; return true; @@ -2914,8 +2931,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t trans[0] -= cam_shift_x * 2; trans[1] -= cam_shift_y * 2; /* To accommodate `k=0` and `k=inf` (vertical) lines. here the cut is in image space. */ - if (fabs(e->v1->fbcoord[0] - e->v2->fbcoord[0]) > - fabs(e->v1->fbcoord[1] - e->v2->fbcoord[1])) { + if (fabs(e->v1->fbcoord[0] - e->v2->fbcoord[0]) > fabs(e->v1->fbcoord[1] - e->v2->fbcoord[1])) + { cut = ratiod(e->v1->fbcoord[0], e->v2->fbcoord[0], trans[0]); } else { @@ -2979,7 +2996,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t /* We could have the edge being completely parallel to the triangle where there isn't a * viable occlusion result. */ if ((LRT_PARALLEL(cross_v1) && !LRT_ISEC(cross_v1)) || - (LRT_PARALLEL(cross_v2) && !LRT_ISEC(cross_v2))) { + (LRT_PARALLEL(cross_v2) && !LRT_ISEC(cross_v2))) + { return false; } } @@ -3007,7 +3025,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t LRT_GUARD_NOT_FOUND /* The same logic applies as above case. */ if ((LRT_PARALLEL(cross_v1) && !LRT_ISEC(cross_v1)) || - (LRT_PARALLEL(cross_v2) && !LRT_ISEC(cross_v2))) { + (LRT_PARALLEL(cross_v2) && !LRT_ISEC(cross_v2))) + { return false; } } @@ -3077,37 +3096,43 @@ static bool lineart_triangle_share_edge(const LineartTriangle *l, const LineartT { if (l->v[0]->index == r->v[0]->index) { if (l->v[1]->index == r->v[1]->index || l->v[1]->index == r->v[2]->index || - l->v[2]->index == r->v[2]->index || l->v[2]->index == r->v[1]->index) { + l->v[2]->index == r->v[2]->index || l->v[2]->index == r->v[1]->index) + { return true; } } if (l->v[0]->index == r->v[1]->index) { if (l->v[1]->index == r->v[0]->index || l->v[1]->index == r->v[2]->index || - l->v[2]->index == r->v[2]->index || l->v[2]->index == r->v[0]->index) { + l->v[2]->index == r->v[2]->index || l->v[2]->index == r->v[0]->index) + { return true; } } if (l->v[0]->index == r->v[2]->index) { if (l->v[1]->index == r->v[1]->index || l->v[1]->index == r->v[0]->index || - l->v[2]->index == r->v[0]->index || l->v[2]->index == r->v[1]->index) { + l->v[2]->index == r->v[0]->index || l->v[2]->index == r->v[1]->index) + { return true; } } if (l->v[1]->index == r->v[0]->index) { if (l->v[2]->index == r->v[1]->index || l->v[2]->index == r->v[2]->index || - l->v[0]->index == r->v[2]->index || l->v[0]->index == r->v[1]->index) { + l->v[0]->index == r->v[2]->index || l->v[0]->index == r->v[1]->index) + { return true; } } if (l->v[1]->index == r->v[1]->index) { if (l->v[2]->index == r->v[0]->index || l->v[2]->index == r->v[2]->index || - l->v[0]->index == r->v[2]->index || l->v[0]->index == r->v[0]->index) { + l->v[0]->index == r->v[2]->index || l->v[0]->index == r->v[0]->index) + { return true; } } if (l->v[1]->index == r->v[2]->index) { if (l->v[2]->index == r->v[1]->index || l->v[2]->index == r->v[0]->index || - l->v[0]->index == r->v[0]->index || l->v[0]->index == r->v[1]->index) { + l->v[0]->index == r->v[0]->index || l->v[0]->index == r->v[1]->index) + { return true; } } @@ -3175,7 +3200,8 @@ static bool lineart_triangle_2v_intersection_math( /* Due to precision issue, we might end up with the same point as the one we already detected. */ if (last && LRT_DOUBLE_CLOSE_ENOUGH(last[0], gloc[0]) && - LRT_DOUBLE_CLOSE_ENOUGH(last[1], gloc[1]) && LRT_DOUBLE_CLOSE_ENOUGH(last[2], gloc[2])) { + LRT_DOUBLE_CLOSE_ENOUGH(last[1], gloc[1]) && LRT_DOUBLE_CLOSE_ENOUGH(last[2], gloc[2])) + { return false; } @@ -3392,7 +3418,8 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, if (!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)) { if (((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_NO_INTERSECTION) || - (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) { + (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) + { continue; } } @@ -3407,7 +3434,8 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, (MAX3(G0[0], G1[0], G2[0]) < MIN3(RG0[0], RG1[0], RG2[0])) || (MIN3(G0[1], G1[1], G2[1]) > MAX3(RG0[1], RG1[1], RG2[1])) || (MAX3(G0[1], G1[1], G2[1]) < MIN3(RG0[1], RG1[1], RG2[1])) || - lineart_triangle_share_edge(tri, testing_triangle)) { + lineart_triangle_share_edge(tri, testing_triangle)) + { continue; } @@ -3819,7 +3847,8 @@ static void lineart_bounding_areas_connect_new(LineartData *ld, LineartBoundingA * their original adjacent areas. */ LISTBASE_FOREACH (LinkData *, lip, &root->lp) { for (lip2 = static_cast(((LineartBoundingArea *)lip->data)->rp.first); lip2; - lip2 = next_lip) { + lip2 = next_lip) + { next_lip = lip2->next; tba = static_cast(lip2->data); if (tba == root) { @@ -3835,7 +3864,8 @@ static void lineart_bounding_areas_connect_new(LineartData *ld, LineartBoundingA } LISTBASE_FOREACH (LinkData *, lip, &root->rp) { for (lip2 = static_cast(((LineartBoundingArea *)lip->data)->lp.first); lip2; - lip2 = next_lip) { + lip2 = next_lip) + { next_lip = lip2->next; tba = static_cast(lip2->data); if (tba == root) { @@ -3851,7 +3881,8 @@ static void lineart_bounding_areas_connect_new(LineartData *ld, LineartBoundingA } LISTBASE_FOREACH (LinkData *, lip, &root->up) { for (lip2 = static_cast(((LineartBoundingArea *)lip->data)->bp.first); lip2; - lip2 = next_lip) { + lip2 = next_lip) + { next_lip = lip2->next; tba = static_cast(lip2->data); if (tba == root) { @@ -3867,7 +3898,8 @@ static void lineart_bounding_areas_connect_new(LineartData *ld, LineartBoundingA } LISTBASE_FOREACH (LinkData *, lip, &root->bp) { for (lip2 = static_cast(((LineartBoundingArea *)lip->data)->up.first); lip2; - lip2 = next_lip) { + lip2 = next_lip) + { next_lip = lip2->next; tba = static_cast(lip2->data); if (tba == root) { @@ -4024,7 +4056,8 @@ static bool lineart_bounding_area_edge_intersect(LineartData * /*fb*/, double c1, c; if (((converted[0] = ba->l) > MAX2(l[0], r[0])) || ((converted[1] = ba->r) < MIN2(l[0], r[0])) || - ((converted[2] = ba->b) > MAX2(l[1], r[1])) || ((converted[3] = ba->u) < MIN2(l[1], r[1]))) { + ((converted[2] = ba->b) > MAX2(l[1], r[1])) || ((converted[3] = ba->u) < MIN2(l[1], r[1]))) + { return false; } @@ -4070,7 +4103,8 @@ static bool lineart_bounding_area_triangle_intersect(LineartData *fb, if ((FBC1[0] >= p1[0] && FBC1[0] <= p2[0] && FBC1[1] >= p1[1] && FBC1[1] <= p3[1]) || (FBC2[0] >= p1[0] && FBC2[0] <= p2[0] && FBC2[1] >= p1[1] && FBC2[1] <= p3[1]) || - (FBC3[0] >= p1[0] && FBC3[0] <= p2[0] && FBC3[1] >= p1[1] && FBC3[1] <= p3[1])) { + (FBC3[0] >= p1[0] && FBC3[0] <= p2[0] && FBC3[1] >= p1[1] && FBC3[1] <= p3[1])) + { *r_triangle_vert_inside = true; return true; } @@ -4080,13 +4114,15 @@ static bool lineart_bounding_area_triangle_intersect(LineartData *fb, if (lineart_point_inside_triangle(p1, FBC1, FBC2, FBC3) || lineart_point_inside_triangle(p2, FBC1, FBC2, FBC3) || lineart_point_inside_triangle(p3, FBC1, FBC2, FBC3) || - lineart_point_inside_triangle(p4, FBC1, FBC2, FBC3)) { + lineart_point_inside_triangle(p4, FBC1, FBC2, FBC3)) + { return true; } if (lineart_bounding_area_edge_intersect(fb, FBC1, FBC2, ba) || lineart_bounding_area_edge_intersect(fb, FBC2, FBC3, ba) || - lineart_bounding_area_edge_intersect(fb, FBC3, FBC1, ba)) { + lineart_bounding_area_edge_intersect(fb, FBC3, FBC1, ba)) + { return true; } @@ -4171,7 +4207,8 @@ static void lineart_bounding_area_link_triangle(LineartData *ld, else { /* We need to wait for either splitting or array extension to be done. */ if (recursive_level < ld->qtree.recursive_level && - old_ba->insider_triangle_count >= LRT_TILE_SPLITTING_TRIANGLE_LIMIT) { + old_ba->insider_triangle_count >= LRT_TILE_SPLITTING_TRIANGLE_LIMIT) + { if (!old_ba->child) { /* old_ba->child==nullptr, means we are the thread that's doing the splitting. */ lineart_bounding_area_split(ld, old_ba, recursive_level); @@ -4954,8 +4991,8 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, if (lmd->calculation_flags & LRT_USE_CUSTOM_CAMERA) { if (!lmd->source_camera || - (use_camera = DEG_get_evaluated_object(depsgraph, lmd->source_camera))->type != - OB_CAMERA) { + (use_camera = DEG_get_evaluated_object(depsgraph, lmd->source_camera))->type != OB_CAMERA) + { return false; } } @@ -5228,17 +5265,20 @@ static void lineart_gpencil_generate(LineartCache *cache, if (ec->shadow_mask_bits != LRT_SHADOW_MASK_UNDEFINED) { /* TODO(@Yiming): Give a behavior option for how to display undefined shadow info. */ if (shaodow_selection == LRT_SHADOW_FILTER_ILLUMINATED && - !(ec->shadow_mask_bits & LRT_SHADOW_MASK_ILLUMINATED)) { + !(ec->shadow_mask_bits & LRT_SHADOW_MASK_ILLUMINATED)) + { continue; } if (shaodow_selection == LRT_SHADOW_FILTER_SHADED && - !(ec->shadow_mask_bits & LRT_SHADOW_MASK_SHADED)) { + !(ec->shadow_mask_bits & LRT_SHADOW_MASK_SHADED)) + { continue; } if (shaodow_selection == LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES) { uint32_t test_bits = ec->shadow_mask_bits & LRT_SHADOW_TEST_SHAPE_BITS; if ((test_bits != LRT_SHADOW_MASK_ILLUMINATED) && - (test_bits != (LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_ILLUMINATED_SHAPE))) { + (test_bits != (LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_ILLUMINATED_SHAPE))) + { continue; } } @@ -5250,8 +5290,8 @@ static void lineart_gpencil_generate(LineartCache *cache, if (!ec->silhouette_backdrop) { is_silhouette = true; } - else if (!BKE_collection_has_object_recursive_instanced(orig_col, - ec->silhouette_backdrop)) { + else if (!BKE_collection_has_object_recursive_instanced(orig_col, ec->silhouette_backdrop)) + { is_silhouette = true; } } @@ -5262,7 +5302,8 @@ static void lineart_gpencil_generate(LineartCache *cache, } if ((silhouette_mode == LRT_SILHOUETTE_FILTER_INDIVIDUAL || orig_ob) && - ec->silhouette_backdrop != ec->object_ref) { + ec->silhouette_backdrop != ec->object_ref) + { is_silhouette = true; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c index 54e5658f637..8e369f60d2b 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.c @@ -90,7 +90,8 @@ static bool lineart_contour_viewed_from_dark_side(LineartData *ld, LineartEdge * side_1_facing_camera = (dot_view_1 > 0); if ((side_1_facing_camera && (!side_1_facing_light) && side_2_facing_light) || - ((!side_1_facing_camera) && side_1_facing_light && (!side_2_facing_light))) { + ((!side_1_facing_camera) && side_1_facing_light && (!side_2_facing_light))) + { return true; } return false; @@ -109,8 +110,8 @@ void lineart_register_shadow_cuts(LineartData *ld, LineartEdge *e, LineartEdge * uchar shadow_bits = (es->occlusion != 0) ? LRT_SHADOW_MASK_SHADED : LRT_SHADOW_MASK_ILLUMINATED; - if (lineart_contour_viewed_from_dark_side(ld, e) && - shadow_bits == LRT_SHADOW_MASK_ILLUMINATED) { + if (lineart_contour_viewed_from_dark_side(ld, e) && shadow_bits == LRT_SHADOW_MASK_ILLUMINATED) + { shadow_bits = LRT_SHADOW_MASK_SHADED; } @@ -297,8 +298,8 @@ static void lineart_shadow_create_shadow_edge_array(LineartData *ld, /* If the segment is short enough, we ignore them because it's not prominently visible anyway. */ #define DISCARD_NONSENSE_SEGMENTS \ if (es->occlusion != 0 || \ - (es->next && \ - LRT_DOUBLE_CLOSE_ENOUGH(es->ratio, ((LineartEdgeSegment *)es->next)->ratio))) { \ + (es->next && LRT_DOUBLE_CLOSE_ENOUGH(es->ratio, ((LineartEdgeSegment *)es->next)->ratio))) \ + { \ LRT_ITER_ALL_LINES_NEXT; \ continue; \ } @@ -674,7 +675,8 @@ static void lineart_shadow_edge_cut(LineartData *ld, r_new_in_the_middle_global, &r_new_at, &is_side_2r, - &use_new_ref))) { + &use_new_ref))) + { LineartShadowSegment *ss_middle = lineart_give_shadow_segment(ld); ss_middle->ratio = interpf(seg_2->ratio, seg_1->ratio, r_new_at); ss_middle->flag = LRT_SHADOW_CASTED | @@ -729,7 +731,8 @@ static bool lineart_shadow_cast_onto_triangle(LineartData *ld, if ((MAX3(FBC0[0], FBC1[0], FBC2[0]) < MIN2(LFBC[0], RFBC[0])) || (MIN3(FBC0[0], FBC1[0], FBC2[0]) > MAX2(LFBC[0], RFBC[0])) || (MAX3(FBC0[1], FBC1[1], FBC2[1]) < MIN2(LFBC[1], RFBC[1])) || - (MIN3(FBC0[1], FBC1[1], FBC2[1]) > MAX2(LFBC[1], RFBC[1]))) { + (MIN3(FBC0[1], FBC1[1], FBC2[1]) > MAX2(LFBC[1], RFBC[1]))) + { return false; } @@ -760,7 +763,8 @@ static bool lineart_shadow_cast_onto_triangle(LineartData *ld, if ((trie[0] == 0 && LRT_DOUBLE_CLOSE_ENOUGH(ratio[0], 0.0f) && LRT_DOUBLE_CLOSE_ENOUGH(ratio[1], 1.0f)) || (trie[0] == 1 && LRT_DOUBLE_CLOSE_ENOUGH(ratio[0], 1.0f) && - LRT_DOUBLE_CLOSE_ENOUGH(ratio[1], 0.0f))) { + LRT_DOUBLE_CLOSE_ENOUGH(ratio[1], 0.0f))) + { return false; } trie[pi] = 2; @@ -895,7 +899,8 @@ static void lineart_shadow_cast(LineartData *ld, bool transform_edge_cuts, bool tri = (LineartTriangleThread *)nba->linked_triangles[i]; if (tri->testing_e[0] == (LineartEdge *)sedge || tri->base.mat_occlusion == 0 || lineart_edge_from_triangle( - (LineartTriangle *)tri, sedge->e_ref, ld->conf.allow_overlapping_edges)) { + (LineartTriangle *)tri, sedge->e_ref, ld->conf.allow_overlapping_edges)) + { continue; } tri->testing_e[0] = (LineartEdge *)sedge; @@ -909,7 +914,8 @@ static void lineart_shadow_cast(LineartData *ld, bool transform_edge_cuts, bool fb_co_2, global_1, global_2, - &facing_light)) { + &facing_light)) + { lineart_shadow_edge_cut(ld, sedge, at_1, @@ -1130,7 +1136,8 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph, { if ((!original_ld->conf.use_shadow && !original_ld->conf.use_light_contour && !original_ld->conf.shadow_selection) || - (!lmd->light_contour_object)) { + (!lmd->light_contour_object)) + { return false; } diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index d7a826b9a03..b695ed9b1ed 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -703,7 +703,7 @@ void GPU_texture_free(GPUTexture *texture); * TODO(fclem): Target conversion (ex: Texture 2D as Texture 2D Array) is not implemented yet. */ GPUTexture *GPU_texture_create_view(const char *name, - const GPUTexture *source_texture, + GPUTexture *source_texture, eGPUTextureFormat view_format, int mip_start, int mip_len, diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 21c97405c66..77d06bb69d7 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -157,7 +157,8 @@ static GPUPass *gpu_pass_cache_resolve_collision(GPUPass *pass, BLI_spin_lock(&pass_cache_spin); for (; pass && (pass->hash == hash); pass = pass->next) { if (*reinterpret_cast(info) == - *reinterpret_cast(pass->create_info)) { + *reinterpret_cast(pass->create_info)) + { BLI_spin_unlock(&pass_cache_spin); return pass; } @@ -842,7 +843,8 @@ static bool gpu_pass_shader_validate(GPUPass *pass, GPUShader *shader) /* Validate against opengl limit. */ if ((active_samplers_len > GPU_max_textures_frag()) || - (active_samplers_len > GPU_max_textures_vert())) { + (active_samplers_len > GPU_max_textures_vert())) + { return false; } diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index d7d0d84c5d1..ff2c2cbf5a1 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -97,7 +97,8 @@ void FrameBuffer::attachment_set(GPUAttachmentType type, const GPUAttachment &ne GPUAttachment &attachment = attachments_[type]; if (attachment.tex == new_attachment.tex && attachment.layer == new_attachment.layer && - attachment.mip == new_attachment.mip) { + attachment.mip == new_attachment.mip) + { return; /* Exact same texture already bound here. */ } /* Unbind previous and bind new. */ diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc index 9698a676c36..141d602d8d4 100644 --- a/source/blender/gpu/intern/gpu_immediate.cc +++ b/source/blender/gpu/intern/gpu_immediate.cc @@ -169,7 +169,8 @@ static void wide_line_workaround_start(GPUPrimType prim_type) if (ELEM(polyline_sh, GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR, - GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR)) { + GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR)) + { immUniformColor4fv(imm->uniform_color); } } diff --git a/source/blender/gpu/intern/gpu_node_graph.cc b/source/blender/gpu/intern/gpu_node_graph.cc index ffa9a006925..09acd03fd9a 100644 --- a/source/blender/gpu/intern/gpu_node_graph.cc +++ b/source/blender/gpu/intern/gpu_node_graph.cc @@ -231,7 +231,8 @@ static void gpu_node_input_socket( gpu_node_input_link(node, sock->link, sock->type); } else if ((material != nullptr) && - (gpu_uniformbuffer_link(material, bnode, sock, index, SOCK_IN) != nullptr)) { + (gpu_uniformbuffer_link(material, bnode, sock, index, SOCK_IN) != nullptr)) + { gpu_node_input_link(node, sock->link, sock->type); } else { @@ -484,7 +485,8 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph, GPUMaterialTexture *tex = static_cast(graph->textures.first); for (; tex; tex = tex->next) { if (tex->ima == ima && tex->colorband == colorband && tex->sky == sky && - tex->sampler_state == sampler_state) { + tex->sampler_state == sampler_state) + { break; } num_textures++; @@ -936,7 +938,8 @@ void gpu_node_graph_prune_unused(GPUNodeGraph *graph) } for (GPUNode *node = static_cast(graph->nodes.first), *next = nullptr; node; - node = next) { + node = next) + { next = node->next; if (node->tag == GPU_NODE_TAG_NONE) { @@ -948,7 +951,8 @@ void gpu_node_graph_prune_unused(GPUNodeGraph *graph) for (GPUMaterialAttribute *attr = static_cast(graph->attributes.first), *next = nullptr; attr; - attr = next) { + attr = next) + { next = attr->next; if (attr->users == 0) { BLI_freelinkN(&graph->attributes, attr); @@ -958,7 +962,8 @@ void gpu_node_graph_prune_unused(GPUNodeGraph *graph) for (GPUMaterialTexture *tex = static_cast(graph->textures.first), *next = nullptr; tex; - tex = next) { + tex = next) + { next = tex->next; if (tex->users == 0) { BLI_freelinkN(&graph->textures, tex); diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 7e29eef8fa6..a22a735491b 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -745,8 +745,8 @@ void gpu_select_pick_cache_load_id(void) } } else { - if (depth_buf_subrect_depth_any_filled( - rect_depth, rect_depth->next, &ps->cache.sub_rect)) { + if (depth_buf_subrect_depth_any_filled(rect_depth, rect_depth->next, &ps->cache.sub_rect)) + { gpu_select_load_id_pass_nearest(rect_depth, rect_depth->next); } } diff --git a/source/blender/gpu/intern/gpu_shader_builtin.cc b/source/blender/gpu/intern/gpu_shader_builtin.cc index 91163a20f40..0ba5a3b8b80 100644 --- a/source/blender/gpu/intern/gpu_shader_builtin.cc +++ b/source/blender/gpu/intern/gpu_shader_builtin.cc @@ -128,7 +128,8 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR, GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, GPU_SHADER_3D_POLYLINE_FLAT_COLOR, - GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR)) { + GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR)) + { /* Set a default value for `lineSmooth`. * Ideally this value should be set by the caller. */ GPU_shader_bind(*sh_p); diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index a305fbe68d0..6cde2d71a40 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -310,7 +310,8 @@ void gpu_shader_create_info_init() GPU_DRIVER_ANY, GPU_BACKEND_OPENGL) || GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL) || - GPU_crappy_amd_driver()) { + GPU_crappy_amd_driver()) + { draw_modelmat = draw_modelmat_legacy; } @@ -433,7 +434,8 @@ bool gpu_shader_create_info_compile_all() (GPU_compute_shader_support() == false && info->compute_source_ != nullptr) || (GPU_geometry_shader_support() == false && info->geometry_source_ != nullptr) || (GPU_shader_image_load_store_support() == false && info->has_resource_image()) || - (GPU_shader_storage_buffer_objects_support() == false && info->has_resource_storage())) { + (GPU_shader_storage_buffer_objects_support() == false && info->has_resource_storage())) + { skipped++; continue; } diff --git a/source/blender/gpu/intern/gpu_shader_dependency.cc b/source/blender/gpu/intern/gpu_shader_dependency.cc index 0faa556bf1b..4e663fc81d1 100644 --- a/source/blender/gpu/intern/gpu_shader_dependency.cc +++ b/source/blender/gpu/intern/gpu_shader_dependency.cc @@ -112,7 +112,8 @@ struct GPUSource { } if ((source.find("drw_debug_") != StringRef::not_found) && /* Avoid these two files where it makes no sense to add the dependency. */ - !ELEM(filename, "common_debug_draw_lib.glsl", "draw_debug_draw_display_vert.glsl")) { + !ELEM(filename, "common_debug_draw_lib.glsl", "draw_debug_draw_display_vert.glsl")) + { builtins |= shader::BuiltinBits::USE_DEBUG_DRAW; } check_no_quotes(); diff --git a/source/blender/gpu/intern/gpu_shader_log.cc b/source/blender/gpu/intern/gpu_shader_log.cc index 28db1166c95..b2b4f582a17 100644 --- a/source/blender/gpu/intern/gpu_shader_log.cc +++ b/source/blender/gpu/intern/gpu_shader_log.cc @@ -95,7 +95,8 @@ void Shader::print_log(Span sources, /* Silence not useful lines. */ StringRef logref = StringRefNull(log_line).substr(0, size_t(line_end) - size_t(log_line)); if (logref.endswith(" shader failed to compile with the following errors:") || - logref.endswith(" No code generated")) { + logref.endswith(" No code generated")) + { log_line += size_t(line_end) - size_t(log_line); continue; } @@ -123,7 +124,8 @@ void Shader::print_log(Span sources, /* Separate from previous block. */ if (previous_location.source != log_item.cursor.source || - previous_location.row != log_item.cursor.row) { + previous_location.row != log_item.cursor.row) + { BLI_dynstr_appendf(dynstr, "%s%s%s\n", info_col, line_prefix, reset_col); } else if (log_item.cursor.column != previous_location.column) { @@ -131,7 +133,8 @@ void Shader::print_log(Span sources, } /* Print line from the source file that is producing the error. */ if ((log_item.cursor.row != -1) && (log_item.cursor.row != previous_location.row || - log_item.cursor.column != previous_location.column)) { + log_item.cursor.column != previous_location.column)) + { const char *src_line_end; found_line_id = false; /* error_line is 1 based in this case. */ diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 8cdb7ea754b..9d50ad2d681 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -132,7 +132,7 @@ bool Texture::init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format) return this->init_internal(vbo); } -bool Texture::init_view(const GPUTexture *src_, +bool Texture::init_view(GPUTexture *src_, eGPUTextureFormat format, eGPUTextureType type, int mip_start, @@ -448,7 +448,7 @@ GPUTexture *GPU_texture_create_error(int dimension, bool is_array) } GPUTexture *GPU_texture_create_view(const char *name, - const GPUTexture *src, + GPUTexture *src, eGPUTextureFormat format, int mip_start, int mip_len, diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh index dbcc9ed7f43..1ea1d600e62 100644 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@ -132,7 +132,7 @@ class Texture { bool init_3D(int w, int h, int d, int mip_len, eGPUTextureFormat format); bool init_cubemap(int w, int layers, int mip_len, eGPUTextureFormat format); bool init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format); - bool init_view(const GPUTexture *src, + bool init_view(GPUTexture *src, eGPUTextureFormat format, eGPUTextureType type, int mip_start, @@ -313,7 +313,7 @@ class Texture { protected: virtual bool init_internal() = 0; virtual bool init_internal(GPUVertBuf *vbo) = 0; - virtual bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset) = 0; + virtual bool init_internal(GPUTexture *src, int mip_offset, int layer_offset) = 0; }; /* Syntactic sugar. */ @@ -751,7 +751,8 @@ inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_form * Standard component len calculation does not apply, as the texture formats contain multiple * channels, but associated data format contains several compacted components. */ if ((tex_format == GPU_R11F_G11F_B10F && data_format == GPU_DATA_10_11_11_REV) || - (tex_format == GPU_RGB10_A2 && data_format == GPU_DATA_2_10_10_10_REV)) { + (tex_format == GPU_RGB10_A2 && data_format == GPU_DATA_2_10_10_10_REV)) + { return 4; } diff --git a/source/blender/gpu/intern/gpu_uniform_buffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc index 3d147bf9f18..b79abea3001 100644 --- a/source/blender/gpu/intern/gpu_uniform_buffer.cc +++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc @@ -63,7 +63,8 @@ static eGPUType get_padded_gpu_type(LinkData *link) } /* Unless the vec3 is followed by a float we need to treat it as a vec4. */ if (gputype == GPU_VEC3 && (link->next != nullptr) && - (((GPUInput *)link->next->data)->type != GPU_FLOAT)) { + (((GPUInput *)link->next->data)->type != GPU_FLOAT)) + { gputype = GPU_VEC4; } return gputype; diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index c1e6bc29e3c..25c678a0b29 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -244,7 +244,8 @@ void GPU_viewport_colorspace_set(GPUViewport *viewport, if (view_settings->curve_mapping) { if (viewport->view_settings.curve_mapping) { if (view_settings->curve_mapping->changed_timestamp != - viewport->view_settings.curve_mapping->changed_timestamp) { + viewport->view_settings.curve_mapping->changed_timestamp) + { BKE_color_managed_view_settings_free(&viewport->view_settings); } } diff --git a/source/blender/gpu/metal/mtl_batch.mm b/source/blender/gpu/metal/mtl_batch.mm index 21e6e39e2a3..d93ced7b650 100644 --- a/source/blender/gpu/metal/mtl_batch.mm +++ b/source/blender/gpu/metal/mtl_batch.mm @@ -923,7 +923,8 @@ id MTLBatch::get_emulated_toplogy_buffer(GPUPrimType &in_out_prim_typ /* Check if topology buffer exists and is valid. */ if (this->emulated_topology_buffer_ != nullptr && - (emulated_topology_type_ != input_prim_type || topology_buffer_input_v_count_ != v_count)) { + (emulated_topology_type_ != input_prim_type || topology_buffer_input_v_count_ != v_count)) + { /* Release existing topology buffer. */ emulated_topology_buffer_->free(); diff --git a/source/blender/gpu/metal/mtl_command_buffer.mm b/source/blender/gpu/metal/mtl_command_buffer.mm index a10e46cdf77..794885f1bf7 100644 --- a/source/blender/gpu/metal/mtl_command_buffer.mm +++ b/source/blender/gpu/metal/mtl_command_buffer.mm @@ -153,7 +153,8 @@ bool MTLCommandBufferManager::submit(bool wait) /* If we have too many active command buffers in flight, wait until completed to avoid running * out. We can increase */ if (MTLCommandBufferManager::num_active_cmd_bufs >= - (GHOST_ContextCGL::max_command_buffer_count - 1)) { + (GHOST_ContextCGL::max_command_buffer_count - 1)) + { wait = true; MTL_LOG_WARNING( "Maximum number of command buffers in flight. Host will wait until GPU work has " @@ -325,7 +326,8 @@ id MTLCommandBufferManager::ensure_begin_render_command /* Begin new command encoder if the currently active one is * incompatible or requires updating. */ if (active_command_encoder_type_ != MTL_RENDER_COMMAND_ENCODER || - active_frame_buffer_ != ctx_framebuffer || force_begin) { + active_frame_buffer_ != ctx_framebuffer || force_begin) + { this->end_active_command_encoder(); /* Determine if this is a re-bind of the same frame-buffer. */ @@ -465,7 +467,8 @@ bool MTLCommandBufferManager::do_break_submission() /* Use optimized heuristic to split heavy command buffer submissions to better saturate the * hardware and also reduce stalling from individual large submissions. */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY) || - GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) { + GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) + { return ((current_draw_call_count_ > 30000) || (vertex_submitted_count_ > 100000000) || (encoder_count_ > 25)); } @@ -511,21 +514,23 @@ bool MTLCommandBufferManager::insert_memory_barrier(eGPUBarrier barrier_bits, * NOTE(Metal): MTLFence/MTLEvent may be required to synchronize work if * untracked resources are ever used. */ if ([context_.device hasUnifiedMemory] && - (active_command_encoder_type_ != MTL_COMPUTE_COMMAND_ENCODER)) { + (active_command_encoder_type_ != MTL_COMPUTE_COMMAND_ENCODER)) + { return false; } /* Resolve scope. */ MTLBarrierScope scope = 0; - if (barrier_bits & GPU_BARRIER_SHADER_IMAGE_ACCESS || - barrier_bits & GPU_BARRIER_TEXTURE_FETCH) { + if (barrier_bits & GPU_BARRIER_SHADER_IMAGE_ACCESS || barrier_bits & GPU_BARRIER_TEXTURE_FETCH) + { bool is_compute = (active_command_encoder_type_ != MTL_RENDER_COMMAND_ENCODER); scope |= (is_compute ? 0 : MTLBarrierScopeRenderTargets) | MTLBarrierScopeTextures; } if (barrier_bits & GPU_BARRIER_SHADER_STORAGE || barrier_bits & GPU_BARRIER_VERTEX_ATTRIB_ARRAY || barrier_bits & GPU_BARRIER_ELEMENT_ARRAY || barrier_bits & GPU_BARRIER_UNIFORM || - barrier_bits & GPU_BARRIER_BUFFER_UPDATE) { + barrier_bits & GPU_BARRIER_BUFFER_UPDATE) + { scope = scope | MTLBarrierScopeBuffers; } @@ -715,7 +720,8 @@ void MTLRenderPassState::bind_vertex_sampler(MTLSamplerBinding &sampler_binding, /* If sampler state has not changed for the given slot, we do not need to fetch. */ if (this->cached_vertex_sampler_state_bindings[slot].sampler_state == nil || !(this->cached_vertex_sampler_state_bindings[slot].binding_state == sampler_binding.state) || - use_argument_buffer_for_samplers) { + use_argument_buffer_for_samplers) + { id sampler_state = (sampler_binding.state == DEFAULT_SAMPLER_STATE) ? ctx.get_default_sampler_state() : @@ -755,7 +761,8 @@ void MTLRenderPassState::bind_fragment_sampler(MTLSamplerBinding &sampler_bindin if (this->cached_fragment_sampler_state_bindings[slot].sampler_state == nil || !(this->cached_fragment_sampler_state_bindings[slot].binding_state == sampler_binding.state) || - use_argument_buffer_for_samplers) { + use_argument_buffer_for_samplers) + { id sampler_state = (sampler_binding.state == DEFAULT_SAMPLER_STATE) ? ctx.get_default_sampler_state() : @@ -795,7 +802,8 @@ void MTLComputeState::bind_compute_sampler(MTLSamplerBinding &sampler_binding, if (this->cached_compute_sampler_state_bindings[slot].sampler_state == nil || !(this->cached_compute_sampler_state_bindings[slot].binding_state == sampler_binding.state) || - use_argument_buffer_for_samplers) { + use_argument_buffer_for_samplers) + { id sampler_state = (sampler_binding.state == DEFAULT_SAMPLER_STATE) ? ctx.get_default_sampler_state() : @@ -828,7 +836,8 @@ void MTLRenderPassState::bind_vertex_buffer(id buffer, uint buffer_of BufferBindingCached ¤t_vert_ubo_binding = this->cached_vertex_buffer_bindings[index]; if (current_vert_ubo_binding.offset != buffer_offset || - current_vert_ubo_binding.metal_buffer != buffer || current_vert_ubo_binding.is_bytes) { + current_vert_ubo_binding.metal_buffer != buffer || current_vert_ubo_binding.is_bytes) + { id rec = this->cmd.get_active_render_command_encoder(); BLI_assert(rec != nil); @@ -857,7 +866,8 @@ void MTLRenderPassState::bind_fragment_buffer(id buffer, uint buffer_ BufferBindingCached ¤t_frag_ubo_binding = this->cached_fragment_buffer_bindings[index]; if (current_frag_ubo_binding.offset != buffer_offset || - current_frag_ubo_binding.metal_buffer != buffer || current_frag_ubo_binding.is_bytes) { + current_frag_ubo_binding.metal_buffer != buffer || current_frag_ubo_binding.is_bytes) + { id rec = this->cmd.get_active_render_command_encoder(); BLI_assert(rec != nil); @@ -889,7 +899,8 @@ void MTLComputeState::bind_compute_buffer(id buffer, BufferBindingCached ¤t_comp_ubo_binding = this->cached_compute_buffer_bindings[index]; if (current_comp_ubo_binding.offset != buffer_offset || - current_comp_ubo_binding.metal_buffer != buffer || current_comp_ubo_binding.is_bytes) { + current_comp_ubo_binding.metal_buffer != buffer || current_comp_ubo_binding.is_bytes) + { id rec = this->cmd.get_active_compute_command_encoder(); BLI_assert(rec != nil); diff --git a/source/blender/gpu/metal/mtl_context.mm b/source/blender/gpu/metal/mtl_context.mm index 26e8aaff900..37e948766db 100644 --- a/source/blender/gpu/metal/mtl_context.mm +++ b/source/blender/gpu/metal/mtl_context.mm @@ -271,7 +271,8 @@ MTLContext::~MTLContext() /* Unbind UBOs */ for (int i = 0; i < MTL_MAX_UNIFORM_BUFFER_BINDINGS; i++) { if (this->pipeline_state.ubo_bindings[i].bound && - this->pipeline_state.ubo_bindings[i].ubo != nullptr) { + this->pipeline_state.ubo_bindings[i].ubo != nullptr) + { GPUUniformBuf *ubo = wrap( static_cast(this->pipeline_state.ubo_bindings[i].ubo)); GPU_uniformbuf_unbind(ubo); @@ -372,7 +373,8 @@ void MTLContext::activate() /* Reset UBO bind state. */ for (int i = 0; i < MTL_MAX_UNIFORM_BUFFER_BINDINGS; i++) { if (this->pipeline_state.ubo_bindings[i].bound && - this->pipeline_state.ubo_bindings[i].ubo != nullptr) { + this->pipeline_state.ubo_bindings[i].ubo != nullptr) + { this->pipeline_state.ubo_bindings[i].bound = false; this->pipeline_state.ubo_bindings[i].ubo = nullptr; } @@ -440,7 +442,8 @@ id MTLContext::ensure_begin_render_pass() /* Ensure command buffer workload submissions are optimal -- * Though do not split a batch mid-IMM recording. */ if (this->main_command_buffer.do_break_submission() && - !((MTLImmediate *)(this->imm))->imm_is_recording()) { + !((MTLImmediate *)(this->imm))->imm_is_recording()) + { this->flush(); } @@ -449,7 +452,8 @@ id MTLContext::ensure_begin_render_pass() if (!this->main_command_buffer.is_inside_render_pass() || this->active_fb != this->main_command_buffer.get_active_framebuffer() || this->main_command_buffer.get_active_framebuffer()->get_dirty() || - this->is_visibility_dirty()) { + this->is_visibility_dirty()) + { /* Validate bound framebuffer before beginning render pass. */ if (!static_cast(this->active_fb)->validate_render_pass()) { @@ -1062,7 +1066,8 @@ bool MTLContext::ensure_uniform_buffer_bindings( * the current RenderCommandEncoder. */ if (this->pipeline_state.active_shader->get_push_constant_is_dirty() || active_shader_changed || !rps.cached_vertex_buffer_bindings[buffer_index].is_bytes || - !rps.cached_fragment_buffer_bindings[buffer_index].is_bytes || true) { + !rps.cached_fragment_buffer_bindings[buffer_index].is_bytes || true) + { /* Bind push constant data. */ BLI_assert(this->pipeline_state.active_shader->get_push_constant_data() != nullptr); @@ -1981,7 +1986,8 @@ void MTLContext::texture_bind(gpu::MTLTexture *mtl_texture, uint texture_unit) BLI_assert(mtl_texture); if (texture_unit < 0 || texture_unit >= GPU_max_textures() || - texture_unit >= MTL_MAX_TEXTURE_SLOTS) { + texture_unit >= MTL_MAX_TEXTURE_SLOTS) + { MTL_LOG_WARNING("Attempting to bind texture '%s' to invalid texture unit %d\n", mtl_texture->get_name(), texture_unit); @@ -1999,7 +2005,8 @@ void MTLContext::sampler_bind(MTLSamplerState sampler_state, uint sampler_unit) { BLI_assert(this); if (sampler_unit < 0 || sampler_unit >= GPU_max_textures() || - sampler_unit >= MTL_MAX_SAMPLER_SLOTS) { + sampler_unit >= MTL_MAX_SAMPLER_SLOTS) + { MTL_LOG_WARNING("Attempting to bind sampler to invalid sampler unit %d\n", sampler_unit); BLI_assert(false); return; @@ -2030,7 +2037,8 @@ void MTLContext::texture_unbind_all() /* Iterate through context's bound textures. */ for (int t = 0; t < min_uu(GPU_max_textures(), MTL_MAX_TEXTURE_SLOTS); t++) { if (this->pipeline_state.texture_bindings[t].used && - this->pipeline_state.texture_bindings[t].texture_resource) { + this->pipeline_state.texture_bindings[t].texture_resource) + { this->pipeline_state.texture_bindings[t].used = false; this->pipeline_state.texture_bindings[t].texture_resource = nullptr; diff --git a/source/blender/gpu/metal/mtl_framebuffer.mm b/source/blender/gpu/metal/mtl_framebuffer.mm index 2b70285d32a..bed1854c291 100644 --- a/source/blender/gpu/metal/mtl_framebuffer.mm +++ b/source/blender/gpu/metal/mtl_framebuffer.mm @@ -266,8 +266,8 @@ bool MTLFrameBuffer::check(char err_out[256]) } } else { - if (dim_x != stencil_att.texture->width_get() || - dim_y != stencil_att.texture->height_get()) { + if (dim_x != stencil_att.texture->width_get() || dim_y != stencil_att.texture->height_get()) + { const char *format = "Framebuffer %s: Stencil attachment dimensions do not match that of previous " "attachment"; @@ -1235,7 +1235,8 @@ void MTLFrameBuffer::ensure_render_target_size() { /* If we have no attachments, reset width and height to zero. */ if (colour_attachment_count_ == 0 && !this->has_depth_attachment() && - !this->has_stencil_attachment()) { + !this->has_stencil_attachment()) + { /* Reset default size for empty framebuffer. */ this->default_size_set(0, 0); @@ -1291,7 +1292,8 @@ bool MTLFrameBuffer::set_depth_attachment_clear_value(float depth_clear) BLI_assert(this); if (mtl_depth_attachment_.clear_value.depth != depth_clear || - mtl_depth_attachment_.load_action != GPU_LOADACTION_CLEAR) { + mtl_depth_attachment_.load_action != GPU_LOADACTION_CLEAR) + { mtl_depth_attachment_.clear_value.depth = depth_clear; mtl_depth_attachment_.load_action = GPU_LOADACTION_CLEAR; this->mark_loadstore_dirty(); @@ -1304,7 +1306,8 @@ bool MTLFrameBuffer::set_stencil_attachment_clear_value(uint stencil_clear) BLI_assert(this); if (mtl_stencil_attachment_.clear_value.stencil != stencil_clear || - mtl_stencil_attachment_.load_action != GPU_LOADACTION_CLEAR) { + mtl_stencil_attachment_.load_action != GPU_LOADACTION_CLEAR) + { mtl_stencil_attachment_.clear_value.stencil = stencil_clear; mtl_stencil_attachment_.load_action = GPU_LOADACTION_CLEAR; this->mark_loadstore_dirty(); @@ -1397,7 +1400,8 @@ bool MTLFrameBuffer::has_color_attachment_with_texture(gpu::MTLTexture *texture) for (int attachment = 0; attachment < this->get_attachment_limit(); attachment++) { if (mtl_color_attachments_[attachment].used && - mtl_color_attachments_[attachment].texture == texture) { + mtl_color_attachments_[attachment].texture == texture) + { return true; } } @@ -1423,7 +1427,8 @@ int MTLFrameBuffer::get_color_attachment_slot_from_texture(gpu::MTLTexture *text for (int attachment = 0; attachment < this->get_attachment_limit(); attachment++) { if (mtl_color_attachments_[attachment].used && - (mtl_color_attachments_[attachment].texture == texture)) { + (mtl_color_attachments_[attachment].texture == texture)) + { return attachment; } } @@ -1564,8 +1569,8 @@ MTLRenderPassDescriptor *MTLFrameBuffer::bake_render_pass_descriptor(bool load_c int len = 0; bool valid = true; - for (int attachment_ind = 0; attachment_ind < GPU_FB_MAX_COLOR_ATTACHMENT; - attachment_ind++) { + for (int attachment_ind = 0; attachment_ind < GPU_FB_MAX_COLOR_ATTACHMENT; attachment_ind++) + { if (mtl_color_attachments_[attachment_ind].used) { if (len == 0) { len = mtl_color_attachments_[attachment_ind].render_target_array_length; @@ -1624,7 +1629,8 @@ MTLRenderPassDescriptor *MTLFrameBuffer::bake_render_pass_descriptor(bool load_c id source_color_texture = texture; if (this->get_is_srgb() && mtl_color_attachments_[attachment_ind].texture->is_format_srgb() && - !this->get_srgb_enabled()) { + !this->get_srgb_enabled()) + { source_color_texture = mtl_color_attachments_[attachment_ind].texture->get_non_srgb_handle(); BLI_assert(source_color_texture != nil); @@ -1637,8 +1643,8 @@ MTLRenderPassDescriptor *MTLFrameBuffer::bake_render_pass_descriptor(bool load_c /* MTL_FB_CONFIG_LOAD must always load. */ load_action = GPU_LOADACTION_LOAD; } - else if (descriptor_config == MTL_FB_CONFIG_CUSTOM && - load_action == GPU_LOADACTION_CLEAR) { + else if (descriptor_config == MTL_FB_CONFIG_CUSTOM && load_action == GPU_LOADACTION_CLEAR) + { /* Custom config should be LOAD or DONT_CARE only. */ load_action = GPU_LOADACTION_LOAD; } @@ -1781,7 +1787,8 @@ void MTLFrameBuffer::blit(uint read_slot, /* If the color format is not the same, we cannot use the BlitCommandEncoder, and instead use * a Graphics-based blit. */ if (do_color && (this->get_color_attachment(read_slot).texture->format_get() != - metal_fb_write->get_color_attachment(read_slot).texture->format_get())) { + metal_fb_write->get_color_attachment(read_slot).texture->format_get())) + { MTLAttachment src_attachment = this->get_color_attachment(read_slot); MTLAttachment dst_attachment = metal_fb_write->get_color_attachment(write_slot); diff --git a/source/blender/gpu/metal/mtl_immediate.mm b/source/blender/gpu/metal/mtl_immediate.mm index 2918a9c5edb..d68eab0294c 100644 --- a/source/blender/gpu/metal/mtl_immediate.mm +++ b/source/blender/gpu/metal/mtl_immediate.mm @@ -66,7 +66,8 @@ void MTLImmediate::end() /* Skip draw if Metal shader is not valid. */ if (active_mtl_shader == nullptr || !active_mtl_shader->is_valid() || - active_mtl_shader->get_interface() == nullptr) { + active_mtl_shader->get_interface() == nullptr) + { const char *ptr = (active_mtl_shader) ? active_mtl_shader->name_get() : nullptr; MTL_LOG_WARNING( diff --git a/source/blender/gpu/metal/mtl_memory.mm b/source/blender/gpu/metal/mtl_memory.mm index e51d7b8c3a0..75a863da807 100644 --- a/source/blender/gpu/metal/mtl_memory.mm +++ b/source/blender/gpu/metal/mtl_memory.mm @@ -53,7 +53,8 @@ void MTLBufferPool::free() allocations_.clear(); for (std::multiset *buffer_pool : - buffer_pools_.values()) { + buffer_pools_.values()) + { delete buffer_pool; } buffer_pools_.clear(); @@ -117,7 +118,8 @@ gpu::MTLBuffer *MTLBufferPool::allocate_aligned(uint64_t size, uint64_t found_size = found_buffer->get_size(); if (found_size >= aligned_alloc_size && - found_size <= (aligned_alloc_size * mtl_buffer_size_threshold_factor_)) { + found_size <= (aligned_alloc_size * mtl_buffer_size_threshold_factor_)) + { MTL_LOG_INFO( "[MemoryAllocator] Suitable Buffer of size %lld found, for requested size: %lld\n", found_size, @@ -231,7 +233,8 @@ void MTLBufferPool::update_memory_pools() /* Always free oldest MTLSafeFreeList first. */ for (int safe_pool_free_index = 0; safe_pool_free_index < completed_safelist_queue_.size(); - safe_pool_free_index++) { + safe_pool_free_index++) + { MTLSafeFreeList *current_pool = completed_safelist_queue_[safe_pool_free_index]; /* Iterate through all MTLSafeFreeList linked-chunks. */ diff --git a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh index a3d2ded72a2..6f57783e7f6 100644 --- a/source/blender/gpu/metal/mtl_pso_descriptor_state.hh +++ b/source/blender/gpu/metal/mtl_pso_descriptor_state.hh @@ -125,7 +125,8 @@ struct MTLVertexDescriptor { { if ((this->max_attribute_value != other.max_attribute_value) || (this->total_attributes != other.total_attributes) || - (this->num_vert_buffers != other.num_vert_buffers)) { + (this->num_vert_buffers != other.num_vert_buffers)) + { return false; } if (this->prim_topology_class != other.prim_topology_class) { @@ -227,7 +228,8 @@ struct MTLRenderPipelineStateDescriptor { (src_alpha_blend_factor != other.src_alpha_blend_factor) || (src_rgb_blend_factor != other.src_rgb_blend_factor) || (vertex_descriptor.prim_topology_class != other.vertex_descriptor.prim_topology_class) || - (point_size != other.point_size)) { + (point_size != other.point_size)) + { return false; } diff --git a/source/blender/gpu/metal/mtl_shader.hh b/source/blender/gpu/metal/mtl_shader.hh index 941f93675c8..5903d562ac7 100644 --- a/source/blender/gpu/metal/mtl_shader.hh +++ b/source/blender/gpu/metal/mtl_shader.hh @@ -672,7 +672,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatChar || shader_attrib_format == MTLVertexFormatChar2 || shader_attrib_format == MTLVertexFormatChar3 || - shader_attrib_format == MTLVertexFormatChar4) { + shader_attrib_format == MTLVertexFormatChar4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( @@ -752,7 +753,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatUChar || shader_attrib_format == MTLVertexFormatUChar2 || shader_attrib_format == MTLVertexFormatUChar3 || - shader_attrib_format == MTLVertexFormatUChar4) { + shader_attrib_format == MTLVertexFormatUChar4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( @@ -837,7 +839,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatShort || shader_attrib_format == MTLVertexFormatShort2 || shader_attrib_format == MTLVertexFormatShort3 || - shader_attrib_format == MTLVertexFormatShort4) { + shader_attrib_format == MTLVertexFormatShort4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( shader_attrib_format, component_length, &out_vert_format); @@ -892,7 +895,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatUShort || shader_attrib_format == MTLVertexFormatUShort2 || shader_attrib_format == MTLVertexFormatUShort3 || - shader_attrib_format == MTLVertexFormatUShort4) { + shader_attrib_format == MTLVertexFormatUShort4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( shader_attrib_format, component_length, &out_vert_format); @@ -947,7 +951,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatInt || shader_attrib_format == MTLVertexFormatInt2 || shader_attrib_format == MTLVertexFormatInt3 || - shader_attrib_format == MTLVertexFormatInt4) { + shader_attrib_format == MTLVertexFormatInt4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( shader_attrib_format, component_length, &out_vert_format); @@ -978,7 +983,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatUInt || shader_attrib_format == MTLVertexFormatUInt2 || shader_attrib_format == MTLVertexFormatUInt3 || - shader_attrib_format == MTLVertexFormatUInt4) { + shader_attrib_format == MTLVertexFormatUInt4) + { /* No conversion Needed (as type matches) - Just a vector resize if needed. */ bool can_convert = mtl_vertex_format_resize( shader_attrib_format, component_length, &out_vert_format); @@ -1014,7 +1020,8 @@ inline bool mtl_convert_vertex_format(MTLVertexFormat shader_attrib_format, if (shader_attrib_format == MTLVertexFormatFloat || shader_attrib_format == MTLVertexFormatFloat2 || shader_attrib_format == MTLVertexFormatFloat3 || - shader_attrib_format == MTLVertexFormatFloat4) { + shader_attrib_format == MTLVertexFormatFloat4) + { /* No conversion Needed (as type matches) - Just a vector resize, if needed. */ bool can_convert = mtl_vertex_format_resize( shader_attrib_format, component_length, &out_vert_format); diff --git a/source/blender/gpu/metal/mtl_shader.mm b/source/blender/gpu/metal/mtl_shader.mm index 283d0adedd8..5b5af064b25 100644 --- a/source/blender/gpu/metal/mtl_shader.mm +++ b/source/blender/gpu/metal/mtl_shader.mm @@ -291,8 +291,8 @@ bool MTLShader::finalize(const shader::ShaderCreateInfo *info) shd_builder_->msl_source_frag_); /* Transform feedback, skip compilation. */ - if (src_stage == ShaderStage::FRAGMENT && - (transform_feedback_type_ != GPU_SHADER_TFB_NONE)) { + if (src_stage == ShaderStage::FRAGMENT && (transform_feedback_type_ != GPU_SHADER_TFB_NONE)) + { shader_library_frag_ = nil; break; } @@ -576,7 +576,8 @@ void MTLShader::uniform_int(int location, int comp_len, int array_size, const in * Metal, as we cannot point a texture binding at a different slot. */ MTLShaderInterface *mtl_interface = this->get_interface(); if (location >= mtl_interface->get_total_uniforms() && - location < (mtl_interface->get_total_uniforms() + mtl_interface->get_total_textures())) { + location < (mtl_interface->get_total_uniforms() + mtl_interface->get_total_textures())) + { MTL_LOG_WARNING( "Texture uniform location re-mapping unsupported in Metal. (Possibly also bad uniform " "location %d)\n", @@ -893,7 +894,8 @@ MTLRenderPipelineStateInstance *MTLShader::bake_pipeline_state( type:MTLDataTypeInt withName:[NSString stringWithFormat:@"MTL_AttributeConvert%d", i]]; if (MTL_attribute_conversion_mode == GPU_FETCH_INT_TO_FLOAT_UNIT || - MTL_attribute_conversion_mode == GPU_FETCH_INT_TO_FLOAT) { + MTL_attribute_conversion_mode == GPU_FETCH_INT_TO_FLOAT) + { shader_debug_printf( "TODO(Metal): Shader %s needs to support internal format conversion\n", mtl_interface->name); @@ -926,7 +928,8 @@ MTLRenderPipelineStateInstance *MTLShader::bake_pipeline_state( /* Mark empty attribute conversion. */ for (int i = pipeline_descriptor.vertex_descriptor.max_attribute_value + 1; i < GPU_VERT_ATTR_MAX_LEN; - i++) { + i++) + { int MTL_attribute_conversion_mode = 0; [values setConstantValue:&MTL_attribute_conversion_mode type:MTLDataTypeInt diff --git a/source/blender/gpu/metal/mtl_shader_generator.hh b/source/blender/gpu/metal/mtl_shader_generator.hh index 333c70a6fcb..8b5e438bd44 100644 --- a/source/blender/gpu/metal/mtl_shader_generator.hh +++ b/source/blender/gpu/metal/mtl_shader_generator.hh @@ -787,7 +787,8 @@ inline char *next_word_in_range(char *begin, char *end) for (char *a = begin; a < end; a++) { char chr = *a; if ((chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') || - (chr == '_')) { + (chr == '_')) + { return a; } } diff --git a/source/blender/gpu/metal/mtl_shader_generator.mm b/source/blender/gpu/metal/mtl_shader_generator.mm index 8a2cb59ee05..8e85d12a98e 100644 --- a/source/blender/gpu/metal/mtl_shader_generator.mm +++ b/source/blender/gpu/metal/mtl_shader_generator.mm @@ -165,7 +165,8 @@ static bool is_program_word(const char *chr, int *len) char ch = *c; /* Note: Hash (`#`) is not valid in var names, but is used by Closure macro patterns. */ if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || - (numchars > 0 && ch >= '0' && ch <= '9') || ch == '_' || ch == '#') { + (numchars > 0 && ch >= '0' && ch <= '9') || ch == '_' || ch == '#') + { numchars++; } else { @@ -185,7 +186,8 @@ static int backwards_program_word_scan(const char *array_loc, const char *min) for (start = array_loc - 1; (start >= min) && (*start != '\0'); start--) { char ch = *start; if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || - ch == '_' || ch == '#') { + ch == '_' || ch == '#') + { numchars++; last_char = ch; } @@ -466,7 +468,8 @@ static void extract_global_scope_constants(std::string &str, std::stringstream & /* Check For global const declarations */ if (nested_bracket_depth == 0 && strncmp(c, "const ", 6) == 0 && - strncmp(c, "const constant ", 15) != 0) { + strncmp(c, "const constant ", 15) != 0) + { char *c_expr_end = strchr(c, ';'); if (c_expr_end != nullptr && balanced_braces(c, c_expr_end)) { MTL_LOG_INFO( @@ -1736,7 +1739,8 @@ void MSLGeneratorInterface::prepare_from_createinfo(const shader::ShaderCreateIn /* TextureBuffers must have read/write/read-write access pattern. */ if (res.sampler.type == ImageType::FLOAT_BUFFER || res.sampler.type == ImageType::INT_BUFFER || - res.sampler.type == ImageType::UINT_BUFFER) { + res.sampler.type == ImageType::UINT_BUFFER) + { access = MSLTextureSamplerAccess::TEXTURE_ACCESS_READ; } @@ -2757,7 +2761,8 @@ std::string MSLGeneratorInterface::generate_msl_vertex_attribute_input_populatio << this->vertex_input_attributes[attribute].name << 0; for (int elem = 1; elem < get_matrix_location_count(this->vertex_input_attributes[attribute].type); - elem++) { + elem++) + { out << ",\n" << "v_in.__internal_" << this->vertex_input_attributes[attribute].name << elem; } @@ -2963,10 +2968,11 @@ std::string MSLGeneratorInterface::generate_msl_fragment_input_population() * vertex shader, a warning will be provided. */ for (int f_input = (this->uses_gl_Position) ? 0 : 1; f_input < this->fragment_input_varyings.size(); - f_input++) { + f_input++) + { bool exists_in_vertex_output = false; - for (int v_o = 0; v_o < this->vertex_output_varyings.size() && !exists_in_vertex_output; - v_o++) { + for (int v_o = 0; v_o < this->vertex_output_varyings.size() && !exists_in_vertex_output; v_o++) + { if (this->fragment_input_varyings[f_input].name == this->vertex_output_varyings[v_o].name) { exists_in_vertex_output = true; } @@ -3215,7 +3221,8 @@ MTLShaderInterface *MSLGeneratorInterface::bake_shader_interface(const char *nam int size = mtl_get_data_type_size(mtl_type); for (int elem = 0; elem < get_matrix_location_count(this->vertex_input_attributes[attribute].type); - elem++) { + elem++) + { /* First attribute matches the core name -- subsequent attributes tagged with * `__internal_`. */ std::string _internal_name = (elem == 0) ? diff --git a/source/blender/gpu/metal/mtl_state.mm b/source/blender/gpu/metal/mtl_state.mm index 5f570625ff1..a77d7069b5a 100644 --- a/source/blender/gpu/metal/mtl_state.mm +++ b/source/blender/gpu/metal/mtl_state.mm @@ -147,7 +147,8 @@ void MTLStateManager::set_mutable_state(const GPUStateMutable &state) } if (changed.stencil_compare_mask != 0 || changed.stencil_reference != 0 || - changed.stencil_write_mask != 0) { + changed.stencil_write_mask != 0) + { set_stencil_mask((eGPUStencilTest)current_.stencil_test, state); } diff --git a/source/blender/gpu/metal/mtl_texture.hh b/source/blender/gpu/metal/mtl_texture.hh index 7df91d461ae..d7191cd647c 100644 --- a/source/blender/gpu/metal/mtl_texture.hh +++ b/source/blender/gpu/metal/mtl_texture.hh @@ -181,7 +181,6 @@ class MTLTexture : public Texture { bool is_baked_ = false; MTLTextureDescriptor *texture_descriptor_ = nullptr; id texture_ = nil; - MTLTextureUsage usage_; /* Texture Storage. */ id texture_buffer_ = nil; @@ -284,7 +283,7 @@ class MTLTexture : public Texture { protected: bool init_internal() override; bool init_internal(GPUVertBuf *vbo) override; - bool init_internal(const GPUTexture *src, + bool init_internal(GPUTexture *src, int mip_offset, int layer_offset) override; /* Texture View */ diff --git a/source/blender/gpu/metal/mtl_texture.mm b/source/blender/gpu/metal/mtl_texture.mm index 8eb8d4ab597..9c67e901034 100644 --- a/source/blender/gpu/metal/mtl_texture.mm +++ b/source/blender/gpu/metal/mtl_texture.mm @@ -120,7 +120,8 @@ void gpu::MTLTexture::bake_mip_swizzle_view() * Only apply this if mipmap is the only change, and we have not previously generated * a texture view. For textures which are created as views, this should also be skipped. */ if (resource_mode_ != MTL_TEXTURE_MODE_TEXTURE_VIEW && - texture_view_dirty_flags_ == TEXTURE_VIEW_MIP_DIRTY && mip_swizzle_view_ == nil) { + texture_view_dirty_flags_ == TEXTURE_VIEW_MIP_DIRTY && mip_swizzle_view_ == nil) + { if (mip_texture_base_level_ == 0 && mip_texture_max_level_ == mtl_max_mips_) { texture_view_dirty_flags_ = TEXTURE_VIEW_NOT_DIRTY; @@ -159,7 +160,7 @@ void gpu::MTLTexture::bake_mip_swizzle_view() } int range_len = min_ii((mip_texture_max_level_ - mip_texture_base_level_) + 1, - texture_.mipmapLevelCount); + texture_.mipmapLevelCount - mip_texture_base_level_); BLI_assert(range_len > 0); BLI_assert(mip_texture_base_level_ < texture_.mipmapLevelCount); BLI_assert(mip_texture_base_layer_ < num_slices); @@ -534,7 +535,8 @@ void gpu::MTLTexture::update_sub( /* Determine whether we can do direct BLIT or not. */ bool can_use_direct_blit = true; if (expected_dst_bytes_per_pixel != input_bytes_per_pixel || - num_channels != destination_num_channels) { + num_channels != destination_num_channels) + { can_use_direct_blit = false; } @@ -628,7 +630,8 @@ void gpu::MTLTexture::update_sub( * format is unwritable, if our texture has not been initialized with * texture view support, use a staging texture. */ if ((compatible_write_format != destination_format) && - !(gpu_image_usage_flags_ & GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW)) { + !(gpu_image_usage_flags_ & GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW)) + { use_staging_texture = true; } } @@ -1152,7 +1155,7 @@ void gpu::MTLTexture::ensure_mipmaps(int miplvl) void gpu::MTLTexture::generate_mipmap() { /* Fetch Active Context. */ - MTLContext *ctx = reinterpret_cast(GPU_context_active_get()); + MTLContext *ctx = static_cast(unwrap(GPU_context_active_get())); BLI_assert(ctx); if (!ctx->device) { @@ -1176,7 +1179,8 @@ void gpu::MTLTexture::generate_mipmap() /* Verify if we can perform mipmap generation. */ if (format_ == GPU_DEPTH_COMPONENT32F || format_ == GPU_DEPTH_COMPONENT24 || format_ == GPU_DEPTH_COMPONENT16 || format_ == GPU_DEPTH32F_STENCIL8 || - format_ == GPU_DEPTH24_STENCIL8) { + format_ == GPU_DEPTH24_STENCIL8) + { MTL_LOG_WARNING("Cannot generate mipmaps for textures using DEPTH formats\n"); return; } @@ -1265,7 +1269,7 @@ void gpu::MTLTexture::clear(eGPUDataFormat data_format, const void *data) /* Create clear framebuffer. */ GPUFrameBuffer *prev_fb = GPU_framebuffer_active_get(); - FrameBuffer *fb = reinterpret_cast(this->get_blit_framebuffer(0, 0)); + FrameBuffer *fb = unwrap(this->get_blit_framebuffer(0, 0)); fb->bind(true); fb->clear_attachment(this->attachment_type(0), data_format, data); GPU_framebuffer_bind(prev_fb); @@ -1330,7 +1334,8 @@ void gpu::MTLTexture::mip_range_set(int min, int max) mip_max_ = max; if ((type_ == GPU_TEXTURE_1D || type_ == GPU_TEXTURE_1D_ARRAY || type_ == GPU_TEXTURE_BUFFER) && - max > 1) { + max > 1) + { MTL_LOG_ERROR( " MTLTexture of type TEXTURE_1D_ARRAY or TEXTURE_BUFFER cannot have a mipcount " @@ -1805,7 +1810,7 @@ bool gpu::MTLTexture::init_internal(GPUVertBuf *vbo) return true; } -bool gpu::MTLTexture::init_internal(const GPUTexture *src, int mip_offset, int layer_offset) +bool gpu::MTLTexture::init_internal(GPUTexture *src, int mip_offset, int layer_offset) { BLI_assert(src); @@ -1817,12 +1822,17 @@ bool gpu::MTLTexture::init_internal(const GPUTexture *src, int mip_offset, int l source_texture_ = src; mip_texture_base_level_ = mip_offset; mip_texture_base_layer_ = layer_offset; + texture_view_dirty_flags_ |= TEXTURE_VIEW_MIP_DIRTY; /* Assign usage. */ gpu_image_usage_flags_ = GPU_texture_usage(src); + BLI_assert_msg( + gpu_image_usage_flags_ & GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, + "Source texture of TextureView must have GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW usage flag."); /* Assign texture as view. */ - const gpu::MTLTexture *mtltex = static_cast(unwrap(src)); + gpu::MTLTexture *mtltex = static_cast(unwrap(src)); + mtltex->ensure_baked(); texture_ = mtltex->texture_; BLI_assert(texture_); [texture_ retain]; diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc index 738961047c9..d336985d0a7 100644 --- a/source/blender/gpu/opengl/gl_backend.cc +++ b/source/blender/gpu/opengl/gl_backend.cc @@ -66,14 +66,16 @@ void GLBackend::platform_init() } else if (strstr(vendor, "Intel") || /* src/mesa/drivers/dri/intel/intel_context.c */ - strstr(renderer, "Mesa DRI Intel") || strstr(renderer, "Mesa DRI Mobile Intel")) { + strstr(renderer, "Mesa DRI Intel") || strstr(renderer, "Mesa DRI Mobile Intel")) + { device = GPU_DEVICE_INTEL; driver = GPU_DRIVER_OFFICIAL; if (strstr(renderer, "UHD Graphics") || /* Not UHD but affected by the same bugs. */ strstr(renderer, "HD Graphics 530") || strstr(renderer, "Kaby Lake GT2") || - strstr(renderer, "Whiskey Lake")) { + strstr(renderer, "Whiskey Lake")) + { device |= GPU_DEVICE_INTEL_UHD; } } @@ -81,7 +83,8 @@ void GLBackend::platform_init() (strstr(renderer, "Radeon") && strstr(vendor, "X.Org")) || (strstr(renderer, "AMD") && strstr(vendor, "X.Org")) || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI ")) || - (strstr(renderer, "Gallium ") && strstr(renderer, " on AMD "))) { + (strstr(renderer, "Gallium ") && strstr(renderer, " on AMD "))) + { device = GPU_DEVICE_ATI; driver = GPU_DRIVER_OPENSOURCE; } @@ -130,7 +133,8 @@ void GLBackend::platform_init() strstr(version, "Build 8.15") || strstr(version, "Build 9.17") || strstr(version, "Build 9.18") || strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") || strstr(version, "Build 10.18.10.5") || - strstr(version, "Build 10.18.14.4")) { + strstr(version, "Build 10.18.14.4")) + { support_level = GPU_SUPPORT_LEVEL_LIMITED; } } @@ -267,7 +271,8 @@ static void detect_workarounds() } if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) && (strstr(version, "4.5.13399") || strstr(version, "4.5.13417") || - strstr(version, "4.5.13422") || strstr(version, "4.5.13467"))) { + strstr(version, "4.5.13422") || strstr(version, "4.5.13467"))) + { /* The renderers include: * Radeon HD 5000; * Radeon HD 7500M; @@ -283,13 +288,15 @@ static void detect_workarounds() } /* Compute shaders have some issues with those versions (see #94936). */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) && - (strstr(version, "4.5.14831") || strstr(version, "4.5.14760"))) { + (strstr(version, "4.5.14831") || strstr(version, "4.5.14760"))) + { GCaps.compute_shader_support = false; } /* We have issues with this specific renderer. (see #74024) */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) && (strstr(renderer, "AMD VERDE") || strstr(renderer, "AMD KAVERI") || - strstr(renderer, "AMD TAHITI"))) { + strstr(renderer, "AMD TAHITI"))) + { GLContext::unused_fb_slot_workaround = true; GCaps.shader_image_load_store_support = false; GCaps.shader_draw_parameters_support = false; @@ -297,7 +304,8 @@ static void detect_workarounds() } /* Fix slowdown on this particular driver. (see #77641) */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) && - strstr(version, "Mesa 19.3.4")) { + strstr(version, "Mesa 19.3.4")) + { GCaps.shader_image_load_store_support = false; GCaps.shader_draw_parameters_support = false; GCaps.broken_amd_driver = true; @@ -321,7 +329,8 @@ static void detect_workarounds() * still be broken. */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) { if (strstr(renderer, "AMD Radeon Pro") || strstr(renderer, "AMD Radeon R9") || - strstr(renderer, "AMD Radeon RX")) { + strstr(renderer, "AMD Radeon RX")) + { GCaps.depth_blitting_workaround = true; } } @@ -329,19 +338,22 @@ static void detect_workarounds() * covered since they only support GL 4.4 on windows. * This fixes some issues with workbench anti-aliasing on Win + Intel GPU. (see #76273) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) && - !(epoxy_gl_version() >= 45)) { + !(epoxy_gl_version() >= 45)) + { GLContext::copy_image_support = false; } /* Special fix for these specific GPUs. * Without this workaround, blender crashes on startup. (see #72098) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) && - (strstr(renderer, "HD Graphics 620") || strstr(renderer, "HD Graphics 630"))) { + (strstr(renderer, "HD Graphics 620") || strstr(renderer, "HD Graphics 630"))) + { GCaps.mip_render_workaround = true; } /* Intel Ivy Bridge GPU's seems to have buggy cube-map array support. (see #75943) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) && (strstr(renderer, "HD Graphics 4000") || strstr(renderer, "HD Graphics 4400") || - strstr(renderer, "HD Graphics 2500"))) { + strstr(renderer, "HD Graphics 2500"))) + { GLContext::texture_cube_map_array_support = false; } /* Maybe not all of these drivers have problems with `GL_ARB_base_instance`. @@ -351,20 +363,23 @@ static void detect_workarounds() if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY) && (strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") || strstr(version, "Build 10.18.10.5") || strstr(version, "Build 10.18.14.4") || - strstr(version, "Build 10.18.14.5"))) { + strstr(version, "Build 10.18.14.5"))) + { GLContext::base_instance_support = false; GCaps.use_main_context_workaround = true; } /* Somehow fixes armature display issues (see #69743). */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY) && - strstr(version, "Build 20.19.15.4285")) { + strstr(version, "Build 20.19.15.4285")) + { GCaps.use_main_context_workaround = true; } /* See #70187: merging vertices fail. This has been tested from `18.2.2` till `19.3.0~dev` * of the Mesa driver */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) && (strstr(version, "Mesa 18.") || strstr(version, "Mesa 19.0") || - strstr(version, "Mesa 19.1") || strstr(version, "Mesa 19.2"))) { + strstr(version, "Mesa 19.1") || strstr(version, "Mesa 19.2"))) + { GLContext::unused_fb_slot_workaround = true; } /* There is a bug on older Nvidia GPU where GL_ARB_texture_gather @@ -375,8 +390,8 @@ static void detect_workarounds() } /* dFdx/dFdy calculation factors, those are dependent on driver. */ - if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY) && - strstr(version, "3.3.10750")) { + if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY) && strstr(version, "3.3.10750")) + { GLContext::derivative_signs[0] = 1.0; GLContext::derivative_signs[1] = -1.0; } @@ -386,7 +401,8 @@ static void detect_workarounds() strstr(version, "4.0.0 - Build 9.18.10.3165") || strstr(version, "3.1.0 - Build 9.17.10.3347") || strstr(version, "3.1.0 - Build 9.17.10.4101") || - strstr(version, "3.3.0 - Build 8.15.10.2618")) { + strstr(version, "3.3.0 - Build 8.15.10.2618")) + { GLContext::derivative_signs[0] = -1.0; GLContext::derivative_signs[1] = 1.0; } @@ -415,20 +431,23 @@ static void detect_workarounds() /* Broken glGenerateMipmap on macOS 10.15.7 security update. */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY) && - strstr(renderer, "HD Graphics 4000")) { + strstr(renderer, "HD Graphics 4000")) + { GLContext::generate_mipmap_workaround = true; } /* Buggy interface query functions cause crashes when handling SSBOs (#93680) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY) && - (strstr(renderer, "HD Graphics 4400") || strstr(renderer, "HD Graphics 4600"))) { + (strstr(renderer, "HD Graphics 4400") || strstr(renderer, "HD Graphics 4600"))) + { GCaps.shader_storage_buffer_objects_support = false; } /* Certain Intel/AMD based platforms don't clear the viewport textures. Always clearing leads to * noticeable performance regressions on other platforms as well. */ if (GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY) || - GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) { + GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) + { GCaps.clear_viewport_workaround = true; } diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc index 799c62c30c3..d6dc32265c4 100644 --- a/source/blender/gpu/opengl/gl_debug.cc +++ b/source/blender/gpu/opengl/gl_debug.cc @@ -68,7 +68,8 @@ static void APIENTRY debug_callback(GLenum /*source*/, * In this case invoking `GPU_type_matches` would fail and * therefore the message is checked before the platform matching. */ if (TRIM_NVIDIA_BUFFER_INFO && STRPREFIX(message, "Buffer detailed info") && - GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) { + GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) + { /** Suppress buffer infos flooding the output. */ return; } @@ -327,7 +328,8 @@ static const char *to_str_suffix(GLenum type) void object_label(GLenum type, GLuint object, const char *name) { if ((G.debug & G_DEBUG_GPU) && - (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) { + (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) + { char label[64]; SNPRINTF(label, "%s%s%s", to_str_prefix(type), name, to_str_suffix(type)); /* Small convenience for caller. */ @@ -366,7 +368,8 @@ namespace blender::gpu { void GLContext::debug_group_begin(const char *name, int index) { if ((G.debug & G_DEBUG_GPU) && - (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) { + (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) + { /* Add 10 to avoid collision with other indices from other possible callback layers. */ index += 10; glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, index, -1, name); @@ -376,7 +379,8 @@ void GLContext::debug_group_begin(const char *name, int index) void GLContext::debug_group_end() { if ((G.debug & G_DEBUG_GPU) && - (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) { + (epoxy_gl_version() >= 43 || epoxy_has_gl_extension("GL_KHR_debug"))) + { glPopDebugGroup(); } } diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index cfbc5197a1b..4a1005f47fa 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -162,8 +162,8 @@ void GLFrameBuffer::update_attachments() continue; } GLuint gl_tex = static_cast(unwrap(attach.tex))->tex_id_; - if (attach.layer > -1 && GPU_texture_is_cube(attach.tex) && - !GPU_texture_is_array(attach.tex)) { + if (attach.layer > -1 && GPU_texture_is_cube(attach.tex) && !GPU_texture_is_array(attach.tex)) + { /* Could be avoided if ARB_direct_state_access is required. In this case * #glFramebufferTextureLayer would bind the correct face. */ GLenum gl_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach.layer; diff --git a/source/blender/gpu/opengl/gl_immediate.cc b/source/blender/gpu/opengl/gl_immediate.cc index b0840e0bc22..6571df6d951 100644 --- a/source/blender/gpu/opengl/gl_immediate.cc +++ b/source/blender/gpu/opengl/gl_immediate.cc @@ -79,7 +79,8 @@ uchar *GLImmediate::begin() recreate_buffer = true; } else if (bytes_needed < DEFAULT_INTERNAL_BUFFER_SIZE && - buffer_size() > DEFAULT_INTERNAL_BUFFER_SIZE) { + buffer_size() > DEFAULT_INTERNAL_BUFFER_SIZE) + { /* shrink the internal buffer */ buffer_size() = DEFAULT_INTERNAL_BUFFER_SIZE; recreate_buffer = true; diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 471399ec30a..51ec9667d57 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -531,14 +531,16 @@ std::string GLShader::vertex_interface_declare(const ShaderCreateInfo &info) con for (const ShaderCreateInfo::VertIn &attr : info.vertex_inputs_) { if (GLContext::explicit_location_support && /* Fix issue with AMDGPU-PRO + workbench_prepass_mesh_vert.glsl being quantized. */ - GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) == false) { + GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) == false) + { ss << "layout(location = " << attr.index << ") "; } ss << "in " << to_string(attr.type) << " " << attr.name << ";\n"; } /* NOTE(D4490): Fix a bug where shader without any vertex attributes do not behave correctly. */ if (GPU_type_matches_ex(GPU_DEVICE_APPLE, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL) && - info.vertex_inputs_.is_empty()) { + info.vertex_inputs_.is_empty()) + { ss << "in float gpu_dummy_workaround;\n"; } ss << "\n/* Interfaces. */\n"; diff --git a/source/blender/gpu/opengl/gl_shader_log.cc b/source/blender/gpu/opengl/gl_shader_log.cc index 8c7cbbfdcd8..2588beafef4 100644 --- a/source/blender/gpu/opengl/gl_shader_log.cc +++ b/source/blender/gpu/opengl/gl_shader_log.cc @@ -40,14 +40,16 @@ char *GLLogParser::parse_line(char *log_line, GPULogItem &log_item) if ((log_item.cursor.row != -1) && (log_item.cursor.column != -1)) { if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_OFFICIAL) || GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL) || - GPU_type_matches(GPU_DEVICE_APPLE, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) { + GPU_type_matches(GPU_DEVICE_APPLE, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) + { /* 0:line */ log_item.cursor.row = log_item.cursor.column; log_item.cursor.column = -1; } else if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL) && /* WORKAROUND(@fclem): Both Mesa and AMDGPU-PRO are reported as official. */ - StringRefNull(GPU_platform_version()).find(" Mesa ") == -1) { + StringRefNull(GPU_platform_version()).find(" Mesa ") == -1) + { /* source:row */ log_item.cursor.source = log_item.cursor.row; log_item.cursor.row = log_item.cursor.column; diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index 22431b922db..3cd77ca5f98 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -160,7 +160,8 @@ void GLStateManager::set_mutable_state(const GPUStateMutable &state) } if (changed.stencil_compare_mask != 0 || changed.stencil_reference != 0 || - changed.stencil_write_mask != 0) { + changed.stencil_write_mask != 0) + { set_stencil_mask((eGPUStencilTest)current_.stencil_test, state); } @@ -453,7 +454,8 @@ void GLStateManager::texture_bind(Texture *tex_, GPUSamplerState sampler_state, } /* Eliminate redundant binds. */ if ((textures_[unit] == tex->tex_id_) && - (samplers_[unit] == GLTexture::get_sampler(sampler_state))) { + (samplers_[unit] == GLTexture::get_sampler(sampler_state))) + { return; } targets_[unit] = tex->target_; diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc index dc561208c16..fd7d60d92d4 100644 --- a/source/blender/gpu/opengl/gl_texture.cc +++ b/source/blender/gpu/opengl/gl_texture.cc @@ -178,7 +178,7 @@ bool GLTexture::init_internal(GPUVertBuf *vbo) return true; } -bool GLTexture::init_internal(const GPUTexture *src, int mip_offset, int layer_offset) +bool GLTexture::init_internal(GPUTexture *src, int mip_offset, int layer_offset) { BLI_assert(GLContext::texture_storage_support); @@ -729,7 +729,8 @@ bool GLTexture::proxy_check(int mip) if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_ANY) || GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_OFFICIAL) || - GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL)) { + GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL)) + { /* Some AMD drivers have a faulty `GL_PROXY_TEXTURE_..` check. * (see #55888, #56185, #59351). * Checking with `GL_PROXY_TEXTURE_..` doesn't prevent `Out Of Memory` issue, @@ -740,7 +741,8 @@ bool GLTexture::proxy_check(int mip) } if ((type_ == GPU_TEXTURE_CUBE_ARRAY) && - GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY)) { + GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY)) + { /* Special fix for #79703. */ return true; } diff --git a/source/blender/gpu/opengl/gl_texture.hh b/source/blender/gpu/opengl/gl_texture.hh index 46d73fed4da..f8f1b7e6306 100644 --- a/source/blender/gpu/opengl/gl_texture.hh +++ b/source/blender/gpu/opengl/gl_texture.hh @@ -117,7 +117,7 @@ class GLTexture : public Texture { /** Return true on success. */ bool init_internal(GPUVertBuf *vbo) override; /** Return true on success. */ - bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset) override; + bool init_internal(GPUTexture *src, int mip_offset, int layer_offset) override; private: bool proxy_check(int mip); diff --git a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl index 0faade796d6..03788cfc91f 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl @@ -1127,7 +1127,8 @@ float SMAASearchXLeft(SMAATexture2D(edgesTex), */ float2 e = float2(0.0, 1.0); while (texcoord.x > end && e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e.r == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1157,7 +1158,8 @@ float SMAASearchXRight(SMAATexture2D(edgesTex), { float2 e = float2(0.0, 1.0); while (texcoord.x < end && e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e.r == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1170,7 +1172,8 @@ float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 te { float2 e = float2(1.0, 0.0); while (texcoord.y > end && e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e.g == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(-float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); } @@ -1186,7 +1189,8 @@ float SMAASearchYDown(SMAATexture2D(edgesTex), { float2 e = float2(1.0, 0.0); while (texcoord.y < end && e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e.g == 0.0) // Or is there a crossing edge that breaks the line? + { e = SMAASampleLevelZero(edgesTex, texcoord).rg; texcoord = mad(float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); } diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl index 75caf81f9fe..8e1c7c358dc 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl @@ -111,7 +111,8 @@ void main(void) /* If the link is not muted or is not a reroute arrow the points are squashed to the center of * the line. Magic numbers are defined in drawnode.c */ if ((expand.x == 1.0 && !doMuted) || - (expand.y != 1.0 && (pos.x < 0.70 || pos.x > 0.71) && !doArrow)) { + (expand.y != 1.0 && (pos.x < 0.70 || pos.x > 0.71) && !doArrow)) + { gl_Position.xy *= 0.0; } } diff --git a/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl index 522f6de169d..de180d4d60e 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl @@ -27,8 +27,8 @@ void main() { ivec2 texel = ivec2(gl_FragCoord.xy); - if (stereo_display_mode == S3D_DISPLAY_INTERLACE && - (interlace(texel) == stereo_interlace_swap)) { + if (stereo_display_mode == S3D_DISPLAY_INTERLACE && (interlace(texel) == stereo_interlace_swap)) + { discard; } diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl index 22599ca9fe5..5de0c12b6a5 100644 --- a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl @@ -32,7 +32,8 @@ void main() finalFlags = flags; if (!test(GPU_KEYFRAME_SHAPE_DIAMOND | GPU_KEYFRAME_SHAPE_CIRCLE | - GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL | GPU_KEYFRAME_SHAPE_CLIPPED_HORIZONTAL)) { + GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL | GPU_KEYFRAME_SHAPE_CLIPPED_HORIZONTAL)) + { finalFlags |= GPU_KEYFRAME_SHAPE_DIAMOND; } diff --git a/source/blender/gpu/tests/index_buffer_test.cc b/source/blender/gpu/tests/index_buffer_test.cc index bf1643d84a0..7a44dd6bc8a 100644 --- a/source/blender/gpu/tests/index_buffer_test.cc +++ b/source/blender/gpu/tests/index_buffer_test.cc @@ -27,7 +27,8 @@ static void test_index_buffer_subbuilders() for (int subbuilder_index = 0; subbuilder_index < num_subbuilders; subbuilder_index++) { GPUIndexBufBuilder &subbuilder = subbuilders[subbuilder_index]; for (int subbuilder_vert_index = 0; subbuilder_vert_index < verts_per_subbuilders; - subbuilder_vert_index++) { + subbuilder_vert_index++) + { int vert_index_to_update = subbuilder_index * verts_per_subbuilders + subbuilder_vert_index; GPU_indexbuf_set_point_vert(&subbuilder, vert_index_to_update, vert_index_to_update); } diff --git a/source/blender/gpu/tests/texture_test.cc b/source/blender/gpu/tests/texture_test.cc index 6a5028b16ec..785f37fbcac 100644 --- a/source/blender/gpu/tests/texture_test.cc +++ b/source/blender/gpu/tests/texture_test.cc @@ -262,13 +262,11 @@ static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_R11F_G11F_B10F() GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_R11F_G11F_B10F); #endif -#if RUN_SRGB_UNIMPLEMENTED static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_SRGB8_A8() { - texture_create_upload_read_with_bias(0.0f); + texture_create_upload_read_with_bias(0.003f); } GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_SRGB8_A8); -#endif static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_RGBA8_SNORM() { @@ -405,13 +403,13 @@ static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH_COMPONENT32F() GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH_COMPONENT32F); #endif -#if RUN_COMPONENT_UNIMPLEMENTED static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH_COMPONENT24() { - texture_create_upload_read_with_bias(0.0f); + texture_create_upload_read_with_bias(0.0000001f); } GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH_COMPONENT24); +#if RUN_COMPONENT_UNIMPLEMENTED static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_DEPTH_COMPONENT16() { texture_create_upload_read_with_bias(0.0f); diff --git a/source/blender/gpu/vulkan/vk_command_buffer.cc b/source/blender/gpu/vulkan/vk_command_buffer.cc index 20508e24f48..003478edc94 100644 --- a/source/blender/gpu/vulkan/vk_command_buffer.cc +++ b/source/blender/gpu/vulkan/vk_command_buffer.cc @@ -120,7 +120,7 @@ void VKCommandBuffer::begin_render_pass(const VKFrameBuffer &framebuffer) void VKCommandBuffer::end_render_pass(const VKFrameBuffer &framebuffer) { - UNUSED_VARS_NDEBUG(framebuffer) + UNUSED_VARS_NDEBUG(framebuffer); validate_framebuffer_exists(); BLI_assert(state.framebuffer_ == &framebuffer); ensure_no_active_framebuffer(); diff --git a/source/blender/gpu/vulkan/vk_command_buffer.hh b/source/blender/gpu/vulkan/vk_command_buffer.hh index ecc5165488c..f921ce39aa3 100644 --- a/source/blender/gpu/vulkan/vk_command_buffer.hh +++ b/source/blender/gpu/vulkan/vk_command_buffer.hh @@ -118,6 +118,7 @@ class VKCommandBuffer : NonCopyable, NonMovable { void stage_transfer(Stage stage_from, Stage stage_to) { BLI_assert(is_in_stage(stage_from)); + UNUSED_VARS_NDEBUG(stage_from); #if 0 printf(" *** Transfer stage from %s to %s\n", to_string(stage_from).c_str(), diff --git a/source/blender/gpu/vulkan/vk_common.cc b/source/blender/gpu/vulkan/vk_common.cc index fb20a44d5d7..ede3abf35da 100644 --- a/source/blender/gpu/vulkan/vk_common.cc +++ b/source/blender/gpu/vulkan/vk_common.cc @@ -50,15 +50,13 @@ VkImageAspectFlagBits to_vk_image_aspect_flag_bits(const eGPUTextureFormat forma case GPU_R11F_G11F_B10F: case GPU_SRGB8_A8: return VK_IMAGE_ASPECT_COLOR_BIT; - case GPU_DEPTH32F_STENCIL8: - case GPU_DEPTH24_STENCIL8: - return static_cast(VK_IMAGE_ASPECT_DEPTH_BIT | - VK_IMAGE_ASPECT_STENCIL_BIT); /* Depth Formats. */ case GPU_DEPTH_COMPONENT32F: case GPU_DEPTH_COMPONENT24: case GPU_DEPTH_COMPONENT16: + case GPU_DEPTH32F_STENCIL8: + case GPU_DEPTH24_STENCIL8: return VK_IMAGE_ASPECT_DEPTH_BIT; /* Texture only formats. */ diff --git a/source/blender/gpu/vulkan/vk_data_conversion.cc b/source/blender/gpu/vulkan/vk_data_conversion.cc index c44e6b6f2d2..5851189c5d3 100644 --- a/source/blender/gpu/vulkan/vk_data_conversion.cc +++ b/source/blender/gpu/vulkan/vk_data_conversion.cc @@ -7,6 +7,8 @@ #include "vk_data_conversion.hh" +#include "BLI_color.hh" + #include "Imath/half.h" namespace blender::gpu { @@ -47,6 +49,12 @@ enum class ConversionType { HALF_TO_FLOAT, FLOAT_TO_HALF, + FLOAT_TO_SRGBA8, + SRGBA8_TO_FLOAT, + + FLOAT_TO_DEPTH_COMPONENT24, + DEPTH_COMPONENT24_TO_FLOAT, + /** * The requested conversion isn't supported. */ @@ -90,6 +98,12 @@ static ConversionType type_of_conversion_float(eGPUTextureFormat device_format) case GPU_R16_SNORM: return ConversionType::FLOAT_TO_SNORM16; + case GPU_SRGB8_A8: + return ConversionType::FLOAT_TO_SRGBA8; + + case GPU_DEPTH_COMPONENT24: + return ConversionType::FLOAT_TO_DEPTH_COMPONENT24; + case GPU_RGB32F: /* GPU_RGB32F Not supported by vendors. */ case GPU_RGBA8UI: case GPU_RGBA8I: @@ -114,7 +128,6 @@ static ConversionType type_of_conversion_float(eGPUTextureFormat device_format) case GPU_R11F_G11F_B10F: case GPU_DEPTH32F_STENCIL8: case GPU_DEPTH24_STENCIL8: - case GPU_SRGB8_A8: case GPU_RGB8UI: case GPU_RGB8I: case GPU_RGB8: @@ -131,7 +144,6 @@ static ConversionType type_of_conversion_float(eGPUTextureFormat device_format) case GPU_RGBA8_DXT5: case GPU_SRGB8: case GPU_RGB9_E5: - case GPU_DEPTH_COMPONENT24: case GPU_DEPTH_COMPONENT16: return ConversionType::UNSUPPORTED; } @@ -512,6 +524,8 @@ static ConversionType reversed(ConversionType type) CASE_PAIR(UI32, UI8) CASE_PAIR(I32, I8) CASE_PAIR(FLOAT, HALF) + CASE_PAIR(FLOAT, SRGBA8) + CASE_PAIR(FLOAT, DEPTH_COMPONENT24) case ConversionType::UNSUPPORTED: return ConversionType::UNSUPPORTED; @@ -529,6 +543,44 @@ static ConversionType reversed(ConversionType type) /** \name Data Conversion * \{ */ +template struct ComponentValue { + InnerType value; +}; +template struct PixelValue { + InnerType value; +}; + +using UI8 = ComponentValue; +using UI16 = ComponentValue; +using UI32 = ComponentValue; +using I8 = ComponentValue; +using I16 = ComponentValue; +using I32 = ComponentValue; +using F32 = ComponentValue; +using F16 = ComponentValue; +using SRGBA8 = PixelValue>; +using FLOAT4 = PixelValue>; + +class DepthComponent24 : public ComponentValue { + public: + operator uint32_t() const + { + return value; + } + + DepthComponent24 &operator=(uint32_t new_value) + { + value = new_value; + return *this; + } + + /* Depth component24 are 4 bytes, but 1 isn't used. */ + static constexpr size_t used_byte_size() + { + return 3; + } +}; + template struct SignedNormalized { static_assert(std::is_same() || std::is_same()); InnerType value; @@ -550,35 +602,33 @@ template struct SignedNormalized { }; template struct UnsignedNormalized { - static_assert(std::is_same() || std::is_same()); + static_assert(std::is_same() || std::is_same() || + std::is_same()); InnerType value; + static constexpr size_t used_byte_size() + { + if constexpr (std::is_same()) { + return InnerType::used_byte_size(); + } + else { + return sizeof(InnerType); + } + } + static constexpr int32_t scalar() { - return (1 << (sizeof(InnerType) * 8)) - 1; + + return (1 << (used_byte_size() * 8)) - 1; } static constexpr int32_t max() { - return ((1 << (sizeof(InnerType) * 8)) - 1); + return ((1 << (used_byte_size() * 8)) - 1); } }; -template struct ComponentValue { - InnerType value; -}; - -using UI8 = ComponentValue; -using UI16 = ComponentValue; -using UI32 = ComponentValue; -using I8 = ComponentValue; -using I16 = ComponentValue; -using I32 = ComponentValue; -using F32 = ComponentValue; -using F16 = ComponentValue; - -template -void convert_component(SignedNormalized &dst, const F32 &src) +template void convert(SignedNormalized &dst, const F32 &src) { static constexpr int32_t scalar = SignedNormalized::scalar(); static constexpr int32_t delta = SignedNormalized::delta(); @@ -586,32 +636,29 @@ void convert_component(SignedNormalized &dst, const F32 &src) dst.value = (clamp_i((src.value * scalar + delta), 0, max)); } -template -void convert_component(F32 &dst, const SignedNormalized &src) +template void convert(F32 &dst, const SignedNormalized &src) { static constexpr int32_t scalar = SignedNormalized::scalar(); static constexpr int32_t delta = SignedNormalized::delta(); dst.value = float(int32_t(src.value) - delta) / scalar; } -template -void convert_component(UnsignedNormalized &dst, const F32 &src) +template void convert(UnsignedNormalized &dst, const F32 &src) { static constexpr int32_t scalar = UnsignedNormalized::scalar(); static constexpr int32_t max = scalar; dst.value = (clamp_i((src.value * scalar), 0, max)); } -template -void convert_component(F32 &dst, const UnsignedNormalized &src) +template void convert(F32 &dst, const UnsignedNormalized &src) { static constexpr int32_t scalar = UnsignedNormalized::scalar(); - dst.value = float(src.value) / scalar; + dst.value = float(int32_t(src.value)) / scalar; } /* Copy the contents of src to dst with out performing any actual conversion. */ template -void convert_component(DestinationType &dst, const SourceType &src) +void convert(DestinationType &dst, const SourceType &src) { static_assert(std::is_same() || std::is_same() || std::is_same() || std::is_same() || @@ -623,24 +670,34 @@ void convert_component(DestinationType &dst, const SourceType &src) dst.value = src.value; } -static void convert_component(F16 &dst, const F32 &src) +static void convert(F16 &dst, const F32 &src) { dst.value = imath_float_to_half(src.value); } -static void convert_component(F32 &dst, const F16 &src) +static void convert(F32 &dst, const F16 &src) { dst.value = imath_half_to_float(src.value); } +static void convert(SRGBA8 &dst, const FLOAT4 &src) +{ + dst.value = src.value.encode(); +} + +static void convert(FLOAT4 &dst, const SRGBA8 &src) +{ + dst.value = src.value.decode(); +} + /* \} */ template -void convert_per_component(MutableSpan dst, Span src) +void convert(MutableSpan dst, Span src) { BLI_assert(src.size() == dst.size()); for (int64_t index : IndexRange(src.size())) { - convert_component(dst[index], src[index]); + convert(dst[index], src[index]); } } @@ -655,7 +712,17 @@ void convert_per_component(void *dst_memory, total_components); MutableSpan dst = MutableSpan( static_cast(dst_memory), total_components); - convert_per_component(dst, src); + convert(dst, src); +} + +template +void convert_per_pixel(void *dst_memory, const void *src_memory, size_t buffer_size) +{ + Span src = Span(static_cast(src_memory), + buffer_size); + MutableSpan dst = MutableSpan( + static_cast(dst_memory), buffer_size); + convert(dst, src); } static void convert_buffer(void *dst_memory, @@ -746,6 +813,22 @@ static void convert_buffer(void *dst_memory, case ConversionType::HALF_TO_FLOAT: convert_per_component(dst_memory, src_memory, buffer_size, device_format); break; + + case ConversionType::FLOAT_TO_SRGBA8: + convert_per_pixel(dst_memory, src_memory, buffer_size); + break; + case ConversionType::SRGBA8_TO_FLOAT: + convert_per_pixel(dst_memory, src_memory, buffer_size); + break; + + case ConversionType::FLOAT_TO_DEPTH_COMPONENT24: + convert_per_component, F32>( + dst_memory, src_memory, buffer_size, device_format); + break; + case ConversionType::DEPTH_COMPONENT24_TO_FLOAT: + convert_per_component>( + dst_memory, src_memory, buffer_size, device_format); + break; } } diff --git a/source/blender/gpu/vulkan/vk_framebuffer.cc b/source/blender/gpu/vulkan/vk_framebuffer.cc index 5fe258b67ac..1fdb85a3a39 100644 --- a/source/blender/gpu/vulkan/vk_framebuffer.cc +++ b/source/blender/gpu/vulkan/vk_framebuffer.cc @@ -269,7 +269,8 @@ void VKFrameBuffer::render_pass_create() /* Keep the first attachment to the first color attachment, or to the depth buffer when there * is no color attachment. */ if (attachment.tex != nullptr && - (first_attachment == GPU_FB_MAX_ATTACHMENT || type >= GPU_FB_COLOR_ATTACHMENT0)) { + (first_attachment == GPU_FB_MAX_ATTACHMENT || type >= GPU_FB_COLOR_ATTACHMENT0)) + { first_attachment = static_cast(type); } diff --git a/source/blender/gpu/vulkan/vk_pipeline.cc b/source/blender/gpu/vulkan/vk_pipeline.cc index 1b17c4ed804..bc0d471f5ac 100644 --- a/source/blender/gpu/vulkan/vk_pipeline.cc +++ b/source/blender/gpu/vulkan/vk_pipeline.cc @@ -52,7 +52,8 @@ VKPipeline VKPipeline::create_compute_pipeline( VkPipeline vk_pipeline; if (vkCreateComputePipelines( vk_device, nullptr, 1, &pipeline_info, vk_allocation_callbacks, &vk_pipeline) != - VK_SUCCESS) { + VK_SUCCESS) + { return VKPipeline(); } diff --git a/source/blender/gpu/vulkan/vk_push_constants.hh b/source/blender/gpu/vulkan/vk_push_constants.hh index 843aaa4ede2..b13fce6cb1c 100644 --- a/source/blender/gpu/vulkan/vk_push_constants.hh +++ b/source/blender/gpu/vulkan/vk_push_constants.hh @@ -214,7 +214,8 @@ class VKPushConstants : VKResourceTracker { T *dst = static_cast(static_cast(&bytes[push_constant_layout->offset])); const bool is_tightly_std140_packed = (comp_len % 4) == 0; if (layout_->storage_type_get() == StorageType::PUSH_CONSTANTS || array_size == 0 || - push_constant_layout->array_size == 0 || is_tightly_std140_packed) { + push_constant_layout->array_size == 0 || is_tightly_std140_packed) + { const size_t copy_size_in_bytes = comp_len * max_ii(array_size, 1) * sizeof(T); BLI_assert_msg(push_constant_layout->offset + copy_size_in_bytes <= layout_->size_in_bytes(), "Tried to write outside the push constant allocated memory."); diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index 034d08b7b1f..7118a56947f 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -748,7 +748,8 @@ bool VKShader::finalize_pipeline_layout(VkDevice vk_device, } if (vkCreatePipelineLayout( - vk_device, &pipeline_info, vk_allocation_callbacks, &pipeline_layout_) != VK_SUCCESS) { + vk_device, &pipeline_info, vk_allocation_callbacks, &pipeline_layout_) != VK_SUCCESS) + { return false; }; @@ -942,7 +943,8 @@ bool VKShader::finalize_descriptor_set_layouts(VkDevice vk_device, VkDescriptorSetLayoutCreateInfo layout_info = create_descriptor_set_layout( shader_interface, all_resources, bindings); if (vkCreateDescriptorSetLayout(vk_device, &layout_info, vk_allocation_callbacks, &layout_) != - VK_SUCCESS) { + VK_SUCCESS) + { return false; }; diff --git a/source/blender/gpu/vulkan/vk_texture.cc b/source/blender/gpu/vulkan/vk_texture.cc index 35cf9847b46..26366655da8 100644 --- a/source/blender/gpu/vulkan/vk_texture.cc +++ b/source/blender/gpu/vulkan/vk_texture.cc @@ -174,7 +174,7 @@ bool VKTexture::init_internal(GPUVertBuf * /*vbo*/) return false; } -bool VKTexture::init_internal(const GPUTexture * /*src*/, int /*mip_offset*/, int /*layer_offset*/) +bool VKTexture::init_internal(GPUTexture * /*src*/, int /*mip_offset*/, int /*layer_offset*/) { return false; } diff --git a/source/blender/gpu/vulkan/vk_texture.hh b/source/blender/gpu/vulkan/vk_texture.hh index dbd4741713f..6e026e0a4e6 100644 --- a/source/blender/gpu/vulkan/vk_texture.hh +++ b/source/blender/gpu/vulkan/vk_texture.hh @@ -61,7 +61,7 @@ class VKTexture : public Texture { protected: bool init_internal() override; bool init_internal(GPUVertBuf *vbo) override; - bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset) override; + bool init_internal(GPUTexture *src, int mip_offset, int layer_offset) override; private: /** Is this texture already allocated on device. */ diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 2878bbb6da7..2b708d2af0b 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -260,7 +260,8 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co /* now that we know how many segment we have, set the flag */ for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; - segcount++, curchan = curchan->parent) { + segcount++, curchan = curchan->parent) + { chanlist[segcount] = curchan; curchan->flag |= POSE_CHAIN; } @@ -949,17 +950,20 @@ static int convert_channels(struct Depsgraph *depsgraph, flag = 0; if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP) && (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0] < 0.0f || - pchan->limitmax[0] > 0.0f)) { + pchan->limitmax[0] > 0.0f)) + { flag |= IK_XDOF; } if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP) && (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1] < 0.0f || - pchan->limitmax[1] > 0.0f)) { + pchan->limitmax[1] > 0.0f)) + { flag |= IK_YDOF; } if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP) && (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2] < 0.0f || - pchan->limitmax[2] > 0.0f)) { + pchan->limitmax[2] > 0.0f)) + { flag |= IK_ZDOF; } @@ -1069,7 +1073,8 @@ static void convert_pose(IK_Scene *ikscene) rot = ikscene->jointArray(0); for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; - a++, ikchan++) { + a++, ikchan++) + { pchan = ikchan->pchan; bone = pchan->bone; @@ -1112,7 +1117,8 @@ static void BKE_pose_rest(IK_Scene *ikscene) rot = ikscene->jointArray(0); for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; - a++, ikchan++) { + a++, ikchan++) + { pchan = ikchan->pchan; bone = pchan->bone; @@ -1389,7 +1395,8 @@ static IK_Scene *convert_tree( } } if ((ikchan->jointType & IK_SWING) && - (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) { + (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) + { joint = bone->name; joint += ":SW"; if (pchan->ikflag & BONE_IK_XLIMIT) { @@ -1426,7 +1433,8 @@ static IK_Scene *convert_tree( /* for each target, we need to add an end effector in the armature */ for (numtarget = 0, polarcon = nullptr, ret = true, target = (PoseTarget *)tree->targets.first; target; - target = (PoseTarget *)target->next) { + target = (PoseTarget *)target->next) + { condata = (bKinematicConstraint *)target->con->data; pchan = tree->pchan[target->tip]; @@ -1519,7 +1527,8 @@ static IK_Scene *convert_tree( /* add the end effector * estimate the average bone length, used to clamp feedback error */ for (bone_count = 0, bone_length = 0.0f, a = iktarget->channel; a >= 0; - a = tree->parent[a], bone_count++) { + a = tree->parent[a], bone_count++) + { bone_length += ikscene->blScale * tree->pchan[a]->bone->length; } bone_length /= bone_count; @@ -1619,7 +1628,8 @@ static IK_Scene *convert_tree( } } if (!ret || !scene->addCache(ikscene->cache) || !scene->addSolver(ikscene->solver) || - !scene->initialize()) { + !scene->initialize()) + { delete ikscene; ikscene = nullptr; } @@ -1769,7 +1779,8 @@ static void execute_scene(struct Depsgraph *depsgraph, /* how many times do we reiterate? */ for (i = 0; i < ikparam->numiter; i++) { if (ikscene->armature->getMaxJointChange() < ikparam->precision || - ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) { + ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) + { break; } ikscene->scene->update(timestamp, timestep, numstep, true, false, simulation); diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 81d0722044b..9ca56b6d0d2 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -21,13 +21,13 @@ set(INC_SYS ) set(SRC - intern/allocimbuf.c - intern/anim_movie.c - intern/colormanagement.c - intern/colormanagement_inline.c - intern/divers.c - intern/filetype.c - intern/filter.c + intern/allocimbuf.cc + intern/anim_movie.cc + intern/colormanagement.cc + intern/colormanagement_inline.h + intern/divers.cc + intern/filetype.cc + intern/filter.cc intern/format_bmp.cc intern/format_dds.cc intern/format_hdr.cc @@ -35,25 +35,25 @@ set(SRC intern/format_psd.cc intern/format_targa.cc intern/format_tiff.cc - intern/imageprocess.c - intern/indexer.c - intern/iris.c - intern/jpeg.c - intern/metadata.c - intern/module.c + intern/imageprocess.cc + intern/indexer.cc + intern/iris.cc + intern/jpeg.cc + intern/metadata.cc + intern/module.cc intern/moviecache.cc - intern/readimage.c - intern/rectop.c - intern/rotate.c - intern/scaling.c - intern/stereoimbuf.c - intern/thumbs.c - intern/thumbs_blend.c - intern/thumbs_font.c + intern/readimage.cc + intern/rectop.cc + intern/rotate.cc + intern/scaling.cc + intern/stereoimbuf.cc + intern/thumbs.cc + intern/thumbs_blend.cc + intern/thumbs_font.cc intern/transform.cc - intern/util.c - intern/util_gpu.c - intern/writeimage.c + intern/util.cc + intern/util_gpu.cc + intern/writeimage.cc IMB_colormanagement.h IMB_imbuf.h @@ -102,7 +102,7 @@ if(WITH_IMAGE_OPENJPEG) ${OPENJPEG_INCLUDE_DIRS} ) list(APPEND SRC - intern/jp2.c + intern/jp2.cc ) list(APPEND LIB ${OPENJPEG_LIBRARIES} @@ -147,7 +147,7 @@ endif() if(WITH_IMAGE_WEBP) list(APPEND SRC - intern/webp.c + intern/webp.cc ) list(APPEND INC_SYS ${WEBP_INCLUDE_DIRS} @@ -182,7 +182,7 @@ endif() # no need to compile object files for inline headers. set_source_files_properties( - intern/colormanagement_inline.c + intern/colormanagement_inline.cc PROPERTIES HEADER_FILE_ONLY TRUE ) diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index a9ecafe7d3b..cd90c0e082d 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -531,4 +531,4 @@ void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width); } #endif -#include "intern/colormanagement_inline.c" +#include "intern/colormanagement_inline.h" diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 40c7c113129..256bd93669d 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -335,11 +335,11 @@ typedef enum eIMBInterpolationFilterMode { * Defaults to BL_proxy within the directory of the animation. */ void IMB_anim_set_index_dir(struct anim *anim, const char *dir); -void IMB_anim_get_fname(struct anim *anim, char *file, int size); +void IMB_anim_get_filename(struct anim *anim, char *filename, int filename_maxncpy); int IMB_anim_index_get_frame_index(struct anim *anim, IMB_Timecode_Type tc, int position); -IMB_Proxy_Size IMB_anim_proxy_get_existing(struct anim *anim); +int IMB_anim_proxy_get_existing(struct anim *anim); struct IndexBuildContext; @@ -348,7 +348,7 @@ struct IndexBuildContext; */ struct IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecode_Type tcs_in_use, - IMB_Proxy_Size proxy_sizes_in_use, + int proxy_sizes_in_use, int quality, const bool overwrite, struct GSet *file_list, @@ -386,7 +386,7 @@ bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bo /** * \attention Defined in anim_movie.c */ -struct anim *IMB_open_anim(const char *name, +struct anim *IMB_open_anim(const char *filepath, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]); @@ -791,8 +791,11 @@ void buf_rectfill_area(unsigned char *rect, /** * Exported for image tools in blender, to quickly allocate 32 bits rect. */ -void *imb_alloc_pixels( - unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name); +void *imb_alloc_pixels(unsigned int x, + unsigned int y, + unsigned int channels, + size_t typesize, + const char *alloc_name); bool imb_addrectImBuf(struct ImBuf *ibuf); /** diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 874e038230d..f18116a3301 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -26,7 +26,7 @@ extern "C" { */ #define IMB_MIPMAP_LEVELS 20 -#define IMB_FILENAME_SIZE 1024 +#define IMB_FILEPATH_SIZE 1024 typedef struct DDSData { /** DDS fourcc info */ @@ -221,8 +221,8 @@ typedef struct ImBuf { enum eImbFileType ftype; /** file format specific flags */ ImbFormatOptions foptions; - /** filename associated with this image */ - char name[IMB_FILENAME_SIZE]; + /** The absolute file path associated with this image. */ + char filepath[IMB_FILEPATH_SIZE]; /* memory cache limiter */ /** reference counter for multiple users */ diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 0ac1d7bfb74..904f54f6d9e 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -43,9 +43,11 @@ #include "IMB_allocimbuf.h" #ifdef WITH_FFMPEG +extern "C" { # include # include # include +} #endif /* more endianness... should move to a separate file... */ @@ -79,9 +81,9 @@ struct anim { int x, y; /* for number */ - char name[1024]; + char filepath[1024]; /* for sequence */ - char first[1024]; + char filepath_first[1024]; /* movie */ void *movie; diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h index 378e0c9ffac..a7ba5b29026 100644 --- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h +++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h @@ -15,7 +15,8 @@ extern "C" { #endif struct ImBuf; -struct OCIO_ConstCPUProcessorRcPtr; +struct OCIO_ConstCPUProcessorRc; +typedef struct OCIO_ConstCPUProcessorRc *OCIO_ConstCPUProcessorRcPtr; extern float imbuf_luma_coefficients[3]; extern float imbuf_scene_linear_to_xyz[3][3]; @@ -34,8 +35,8 @@ typedef struct ColorSpace { char name[MAX_COLORSPACE_NAME]; char description[MAX_COLORSPACE_DESCRIPTION]; - struct OCIO_ConstCPUProcessorRcPtr *to_scene_linear; - struct OCIO_ConstCPUProcessorRcPtr *from_scene_linear; + OCIO_ConstCPUProcessorRcPtr *to_scene_linear; + OCIO_ConstCPUProcessorRcPtr *from_scene_linear; char (*aliases)[MAX_COLORSPACE_NAME]; int num_aliases; @@ -57,8 +58,8 @@ typedef struct ColorManagedDisplay { char name[MAX_COLORSPACE_NAME]; ListBase views; /* LinkData.data -> ColorManagedView */ - struct OCIO_ConstCPUProcessorRcPtr *to_scene_linear; - struct OCIO_ConstCPUProcessorRcPtr *from_scene_linear; + OCIO_ConstCPUProcessorRcPtr *to_scene_linear; + OCIO_ConstCPUProcessorRcPtr *from_scene_linear; } ColorManagedDisplay; typedef struct ColorManagedView { diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 76106fce53a..f60201af0b3 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -41,7 +41,7 @@ typedef struct anim_index_entry { } anim_index_entry; struct anim_index { - char name[1024]; + char filepath[1024]; int num_entries; struct anim_index_entry *entries; @@ -51,8 +51,8 @@ struct anim_index_builder; typedef struct anim_index_builder { FILE *fp; - char name[FILE_MAX]; - char temp_name[FILE_MAX]; + char filepath[FILE_MAX]; + char filepath_temp[FILE_MAX]; void *private_data; @@ -63,7 +63,7 @@ typedef struct anim_index_builder { struct anim_index_entry *entry); } anim_index_builder; -anim_index_builder *IMB_index_builder_create(const char *name); +anim_index_builder *IMB_index_builder_create(const char *filepath); void IMB_index_builder_add_entry(anim_index_builder *fp, int frameno, uint64_t seek_pos, diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.cc similarity index 80% rename from source/blender/imbuf/intern/allocimbuf.c rename to source/blender/imbuf/intern/allocimbuf.cc index 3f9388ee1ad..af7acbb0873 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.cc @@ -68,9 +68,9 @@ void imb_freemipmapImBuf(ImBuf *ibuf) /* Do not trust ibuf->miptot, in some cases IMB_remakemipmap can leave unfreed unused levels, * leading to memory leaks... */ for (a = 0; a < IMB_MIPMAP_LEVELS; a++) { - if (ibuf->mipmap[a] != NULL) { + if (ibuf->mipmap[a] != nullptr) { IMB_freeImBuf(ibuf->mipmap[a]); - ibuf->mipmap[a] = NULL; + ibuf->mipmap[a] = nullptr; } } @@ -79,31 +79,31 @@ void imb_freemipmapImBuf(ImBuf *ibuf) void imb_freerectfloatImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) { MEM_freeN(ibuf->rect_float); - ibuf->rect_float = NULL; + ibuf->rect_float = nullptr; } imb_freemipmapImBuf(ibuf); - ibuf->rect_float = NULL; + ibuf->rect_float = nullptr; ibuf->mall &= ~IB_rectfloat; } void imb_freerectImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } if (ibuf->rect && (ibuf->mall & IB_rect)) { MEM_freeN(ibuf->rect); } - ibuf->rect = NULL; + ibuf->rect = nullptr; imb_freemipmapImBuf(ibuf); @@ -112,7 +112,7 @@ void imb_freerectImBuf(ImBuf *ibuf) static void freeencodedbufferImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -120,7 +120,7 @@ static void freeencodedbufferImBuf(ImBuf *ibuf) MEM_freeN(ibuf->encodedbuffer); } - ibuf->encodedbuffer = NULL; + ibuf->encodedbuffer = nullptr; ibuf->encodedbuffersize = 0; ibuf->encodedsize = 0; ibuf->mall &= ~IB_mem; @@ -128,7 +128,7 @@ static void freeencodedbufferImBuf(ImBuf *ibuf) void IMB_freezbufImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -136,13 +136,13 @@ void IMB_freezbufImBuf(ImBuf *ibuf) MEM_freeN(ibuf->zbuf); } - ibuf->zbuf = NULL; + ibuf->zbuf = nullptr; ibuf->mall &= ~IB_zbuf; } void IMB_freezbuffloatImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -150,7 +150,7 @@ void IMB_freezbuffloatImBuf(ImBuf *ibuf) MEM_freeN(ibuf->zbuf_float); } - ibuf->zbuf_float = NULL; + ibuf->zbuf_float = nullptr; ibuf->mall &= ~IB_zbuffloat; } @@ -182,7 +182,7 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_metadata_free(ibuf->metadata); colormanage_cache_free(ibuf); - if (ibuf->dds_data.data != NULL) { + if (ibuf->dds_data.data != nullptr) { /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */ free(ibuf->dds_data.data); } @@ -212,7 +212,7 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf) } } else { - return NULL; + return nullptr; } rval = IMB_dupImBuf(ibuf); @@ -226,13 +226,15 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf) bool addzbufImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } IMB_freezbufImBuf(ibuf); - if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(uint), __func__))) { + if ((ibuf->zbuf = static_cast( + imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(uint), __func__)))) + { ibuf->mall |= IB_zbuf; ibuf->flags |= IB_zbuf; return true; @@ -243,13 +245,15 @@ bool addzbufImBuf(ImBuf *ibuf) bool addzbuffloatImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } IMB_freezbuffloatImBuf(ibuf); - if ((ibuf->zbuf_float = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(float), __func__))) { + if ((ibuf->zbuf_float = static_cast( + imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(float), __func__)))) + { ibuf->mall |= IB_zbuffloat; ibuf->flags |= IB_zbuffloat; return true; @@ -260,7 +264,7 @@ bool addzbuffloatImBuf(ImBuf *ibuf) bool imb_addencodedbufferImBuf(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } @@ -272,7 +276,8 @@ bool imb_addencodedbufferImBuf(ImBuf *ibuf) ibuf->encodedsize = 0; - if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, __func__))) { + if ((ibuf->encodedbuffer = static_cast(MEM_mallocN(ibuf->encodedbuffersize, __func__)))) + { ibuf->mall |= IB_mem; ibuf->flags |= IB_mem; return true; @@ -286,7 +291,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) uint newsize, encodedsize; void *newbuffer; - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } @@ -301,7 +306,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) } newbuffer = MEM_mallocN(newsize, __func__); - if (newbuffer == NULL) { + if (newbuffer == nullptr) { return false; } @@ -318,28 +323,28 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) ibuf->encodedbuffersize = newsize; ibuf->encodedsize = encodedsize; - ibuf->encodedbuffer = newbuffer; + ibuf->encodedbuffer = static_cast(newbuffer); ibuf->mall |= IB_mem; ibuf->flags |= IB_mem; return true; } -void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *name) +void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *alloc_name) { /* Protect against buffer overflow vulnerabilities from files specifying * a width and height that overflow and alloc too little memory. */ - if (!((uint64_t)x * (uint64_t)y < (SIZE_MAX / (channels * typesize)))) { - return NULL; + if (!(uint64_t(x) * uint64_t(y) < (SIZE_MAX / (channels * typesize)))) { + return nullptr; } - size_t size = (size_t)x * (size_t)y * (size_t)channels * typesize; - return MEM_callocN(size, name); + size_t size = size_t(x) * size_t(y) * size_t(channels) * typesize; + return MEM_callocN(size, alloc_name); } bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } @@ -348,7 +353,9 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels) } ibuf->channels = channels; - if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(float), __func__))) { + if ((ibuf->rect_float = static_cast( + imb_alloc_pixels(ibuf->x, ibuf->y, channels, sizeof(float), __func__)))) + { ibuf->mall |= IB_rectfloat; ibuf->flags |= IB_rectfloat; return true; @@ -361,7 +368,7 @@ bool imb_addrectImBuf(ImBuf *ibuf) { /* Question; why also add ZBUF (when `planes > 32`)? */ - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } @@ -370,9 +377,11 @@ bool imb_addrectImBuf(ImBuf *ibuf) if (ibuf->rect && (ibuf->mall & IB_rect)) { MEM_freeN(ibuf->rect); } - ibuf->rect = NULL; + ibuf->rect = nullptr; - if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(uchar), __func__))) { + if ((ibuf->rect = static_cast( + imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(uchar), __func__)))) + { ibuf->mall |= IB_rect; ibuf->flags |= IB_rect; if (ibuf->planes > 32) { @@ -387,10 +396,10 @@ bool imb_addrectImBuf(ImBuf *ibuf) struct ImBuf *IMB_allocFromBufferOwn(uint *rect, float *rectf, uint w, uint h, uint channels) { - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; if (!(rect || rectf)) { - return NULL; + return nullptr; } ibuf = IMB_allocImBuf(w, h, 32, 0); @@ -419,10 +428,10 @@ struct ImBuf *IMB_allocFromBufferOwn(uint *rect, float *rectf, uint w, uint h, u struct ImBuf *IMB_allocFromBuffer( const uint *rect, const float *rectf, uint w, uint h, uint channels) { - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; if (!(rect || rectf)) { - return NULL; + return nullptr; } ibuf = IMB_allocImBuf(w, h, 32, 0); @@ -432,7 +441,7 @@ struct ImBuf *IMB_allocFromBuffer( /* Avoid #MEM_dupallocN since the buffers might not be allocated using guarded-allocation. */ if (rectf) { const size_t size = sizeof(float[4]) * w * h; - ibuf->rect_float = MEM_mallocN(size, __func__); + ibuf->rect_float = static_cast(MEM_mallocN(size, __func__)); memcpy(ibuf->rect_float, rectf, size); ibuf->flags |= IB_rectfloat; @@ -440,7 +449,7 @@ struct ImBuf *IMB_allocFromBuffer( } if (rect) { const size_t size = sizeof(uchar[4]) * w * h; - ibuf->rect = MEM_mallocN(size, __func__); + ibuf->rect = static_cast(MEM_mallocN(size, __func__)); memcpy(ibuf->rect, rect, size); ibuf->flags |= IB_rect; @@ -452,14 +461,12 @@ struct ImBuf *IMB_allocFromBuffer( ImBuf *IMB_allocImBuf(uint x, uint y, uchar planes, uint flags) { - ImBuf *ibuf; - - ibuf = MEM_mallocN(sizeof(ImBuf), "ImBuf_struct"); + ImBuf *ibuf = MEM_cnew("ImBuf_struct"); if (ibuf) { if (!IMB_initImBuf(ibuf, x, y, planes, flags)) { IMB_freeImBuf(ibuf); - return NULL; + return nullptr; } } @@ -517,8 +524,8 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) int flags = 0; int a, x, y; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } if (ibuf1->rect) { @@ -538,32 +545,31 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) y = ibuf1->y; ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } if (flags & IB_rect) { - memcpy(ibuf2->rect, ibuf1->rect, ((size_t)x) * y * sizeof(int)); + memcpy(ibuf2->rect, ibuf1->rect, size_t(x) * y * sizeof(int)); } if (flags & IB_rectfloat) { - memcpy( - ibuf2->rect_float, ibuf1->rect_float, ((size_t)ibuf1->channels) * x * y * sizeof(float)); + memcpy(ibuf2->rect_float, ibuf1->rect_float, size_t(ibuf1->channels) * x * y * sizeof(float)); } if (flags & IB_zbuf) { - memcpy(ibuf2->zbuf, ibuf1->zbuf, ((size_t)x) * y * sizeof(int)); + memcpy(ibuf2->zbuf, ibuf1->zbuf, size_t(x) * y * sizeof(int)); } if (flags & IB_zbuffloat) { - memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, ((size_t)x) * y * sizeof(float)); + memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, size_t(x) * y * sizeof(float)); } if (ibuf1->encodedbuffer) { ibuf2->encodedbuffersize = ibuf1->encodedbuffersize; if (imb_addencodedbufferImBuf(ibuf2) == false) { IMB_freeImBuf(ibuf2); - return NULL; + return nullptr; } memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize); @@ -579,19 +585,19 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) tbuf.zbuf = ibuf2->zbuf; tbuf.zbuf_float = ibuf2->zbuf_float; for (a = 0; a < IMB_MIPMAP_LEVELS; a++) { - tbuf.mipmap[a] = NULL; + tbuf.mipmap[a] = nullptr; } - tbuf.dds_data.data = NULL; + tbuf.dds_data.data = nullptr; /* set malloc flag */ tbuf.mall = ibuf2->mall; tbuf.refcounter = 0; /* for now don't duplicate metadata */ - tbuf.metadata = NULL; + tbuf.metadata = nullptr; - tbuf.display_buffer_flags = NULL; - tbuf.colormanage_cache = NULL; + tbuf.display_buffer_flags = nullptr; + tbuf.colormanage_cache = nullptr; *ibuf2 = tbuf; @@ -600,7 +606,7 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) size_t IMB_get_rect_len(const ImBuf *ibuf) { - return (size_t)ibuf->x * (size_t)ibuf->y; + return size_t(ibuf->x) * size_t(ibuf->y); } size_t IMB_get_size_in_memory(ImBuf *ibuf) diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.cc similarity index 88% rename from source/blender/imbuf/intern/anim_movie.c rename to source/blender/imbuf/intern/anim_movie.cc index b37191c335c..0fc3426c8c2 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -63,6 +63,7 @@ #ifdef WITH_FFMPEG # include "BKE_global.h" /* ENDIAN_ORDER */ +extern "C" { # include # include # include @@ -70,23 +71,25 @@ # include # include "ffmpeg_compat.h" +} + #endif /* WITH_FFMPEG */ -int ismovie(const char *UNUSED(filepath)) +int ismovie(const char * /*filepath*/) { return 0; } /* never called, just keep the linker happy */ -static int startmovie(struct anim *UNUSED(anim)) +static int startmovie(struct anim * /*anim*/) { return 1; } -static ImBuf *movie_fetchibuf(struct anim *UNUSED(anim), int UNUSED(position)) +static ImBuf *movie_fetchibuf(struct anim * /*anim*/, int /*position*/) { - return NULL; + return nullptr; } -static void free_anim_movie(struct anim *UNUSED(anim)) +static void free_anim_movie(struct anim * /*anim*/) { /* pass */ } @@ -131,7 +134,7 @@ static int an_stringdec(const char *string, char *head, char *tail, ushort *numl strcpy(head, string); head[nums] = '\0'; *numlen = nume - nums + 1; - return (int)atoi(&(string[nums])); + return int(atoi(&(string)[nums])); } tail[0] = '\0'; strcpy(head, string); @@ -156,22 +159,22 @@ static void free_anim_avi(struct anim *anim) int i; # endif - if (anim == NULL) { + if (anim == nullptr) { return; } - if (anim->avi == NULL) { + if (anim->avi == nullptr) { return; } AVI_close(anim->avi); MEM_freeN(anim->avi); - anim->avi = NULL; + anim->avi = nullptr; # if defined(_WIN32) if (anim->pgf) { AVIStreamGetFrameClose(anim->pgf); - anim->pgf = NULL; + anim->pgf = nullptr; } for (i = 0; i < anim->avistreams; i++) { @@ -196,8 +199,8 @@ static void free_anim_ffmpeg(struct anim *anim); void IMB_free_anim(struct anim *anim) { - if (anim == NULL) { - printf("free anim, anim == NULL\n"); + if (anim == nullptr) { + printf("free anim, anim == nullptr\n"); return; } @@ -218,7 +221,7 @@ void IMB_free_anim(struct anim *anim) void IMB_close_anim(struct anim *anim) { - if (anim == NULL) { + if (anim == nullptr) { return; } @@ -227,7 +230,7 @@ void IMB_close_anim(struct anim *anim) void IMB_close_anim_proxies(struct anim *anim) { - if (anim == NULL) { + if (anim == nullptr) { return; } @@ -239,14 +242,14 @@ struct IDProperty *IMB_anim_load_metadata(struct anim *anim) switch (anim->curtype) { case ANIM_FFMPEG: { #ifdef WITH_FFMPEG - AVDictionaryEntry *entry = NULL; + AVDictionaryEntry *entry = nullptr; - BLI_assert(anim->pFormatCtx != NULL); + BLI_assert(anim->pFormatCtx != nullptr); av_log(anim->pFormatCtx, AV_LOG_DEBUG, "METADATA FETCH\n"); while (true) { entry = av_dict_get(anim->pFormatCtx->metadata, "", entry, AV_DICT_IGNORE_SUFFIX); - if (entry == NULL) { + if (entry == nullptr) { break; } @@ -269,17 +272,17 @@ struct IDProperty *IMB_anim_load_metadata(struct anim *anim) return anim->metadata; } -struct anim *IMB_open_anim(const char *name, +struct anim *IMB_open_anim(const char *filepath, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE]) { struct anim *anim; - BLI_assert(!BLI_path_is_rel(name)); + BLI_assert(!BLI_path_is_rel(filepath)); anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct"); - if (anim != NULL) { + if (anim != nullptr) { if (colorspace) { colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); BLI_strncpy(anim->colorspace, colorspace, sizeof(anim->colorspace)); @@ -289,7 +292,7 @@ struct anim *IMB_open_anim(const char *name, anim->colorspace, sizeof(anim->colorspace), COLOR_ROLE_DEFAULT_BYTE); } - BLI_strncpy(anim->name, name, sizeof(anim->name)); + BLI_strncpy(anim->filepath, filepath, sizeof(anim->filepath)); anim->ib_flags = ib_flags; anim->streamindex = streamindex; } @@ -303,12 +306,12 @@ bool IMB_anim_can_produce_frames(const struct anim *anim) #endif #ifdef WITH_AVI - if (anim->avi != NULL) { + if (anim->avi != nullptr) { return true; } #endif #ifdef WITH_FFMPEG - if (anim->pCodecCtx != NULL) { + if (anim->pCodecCtx != nullptr) { return true; } #endif @@ -337,19 +340,19 @@ static int startavi(struct anim *anim) streamcount = anim->streamindex; # endif - anim->avi = MEM_callocN(sizeof(AviMovie), "animavi"); + anim->avi = MEM_cnew("animavi"); - if (anim->avi == NULL) { - printf("Can't open avi: %s\n", anim->name); + if (anim->avi == nullptr) { + printf("Can't open avi: %s\n", anim->filepath); return -1; } - avierror = AVI_open_movie(anim->name, anim->avi); + avierror = AVI_open_movie(anim->filepath, anim->avi); # if defined(_WIN32) if (avierror == AVI_ERROR_COMPRESSION) { AVIFileInit(); - hr = AVIFileOpen(&anim->pfile, anim->name, OF_READ, 0L); + hr = AVIFileOpen(&anim->pfile, anim->filepath, OF_READ, 0L); if (hr == 0) { anim->pfileopen = 1; for (i = 0; i < MAXNUMSTREAMS; i++) { @@ -363,7 +366,7 @@ static int startavi(struct anim *anim) streamcount--; continue; } - anim->pgf = AVIStreamGetFrameOpen(anim->pavi[i], NULL); + anim->pgf = AVIStreamGetFrameOpen(anim->pavi[i], nullptr); if (anim->pgf) { firstvideo = i; @@ -409,14 +412,14 @@ static int startavi(struct anim *anim) if (avierror != AVI_ERROR_NONE) { AVI_print_error(avierror); - printf("Error loading avi: %s\n", anim->name); + printf("Error loading avi: %s\n", anim->filepath); free_anim_avi(anim); return -1; } anim->duration_in_frames = anim->avi->header->TotalFrames; anim->start_offset = 0.0f; - anim->params = NULL; + anim->params = nullptr; anim->x = anim->avi->header->Width; anim->y = anim->avi->header->Height; @@ -442,12 +445,12 @@ static int startavi(struct anim *anim) #ifdef WITH_AVI static ImBuf *avi_fetchibuf(struct anim *anim, int position) { - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; int *tmp; int y; - if (anim == NULL) { - return NULL; + if (anim == nullptr) { + return nullptr; } # if defined(_WIN32) @@ -455,7 +458,8 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) LPBITMAPINFOHEADER lpbi; if (anim->pgf) { - lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo])); + lpbi = static_cast( + AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]))); if (lpbi) { ibuf = IMB_ibImageFromMemory( (const uchar *)lpbi, 100, IB_rect, anim->colorspace, ""); @@ -468,13 +472,13 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) { ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect); - tmp = AVI_read_frame( - anim->avi, AVI_FORMAT_RGB32, position, AVI_get_stream(anim->avi, AVIST_VIDEO, 0)); + tmp = static_cast(AVI_read_frame( + anim->avi, AVI_FORMAT_RGB32, position, AVI_get_stream(anim->avi, AVIST_VIDEO, 0))); - if (tmp == NULL) { - printf("Error reading frame from AVI: '%s'\n", anim->name); + if (tmp == nullptr) { + printf("Error reading frame from AVI: '%s'\n", anim->filepath); IMB_freeImBuf(ibuf); - return NULL; + return nullptr; } for (y = 0; y < anim->y; y++) { @@ -497,7 +501,7 @@ static int startffmpeg(struct anim *anim) int i, video_stream_index; const AVCodec *pCodec; - AVFormatContext *pFormatCtx = NULL; + AVFormatContext *pFormatCtx = nullptr; AVCodecContext *pCodecCtx; AVRational frame_rate; AVStream *video_stream; @@ -510,22 +514,22 @@ static int startffmpeg(struct anim *anim) int *table; const int *inv_table; - if (anim == NULL) { + if (anim == nullptr) { return (-1); } streamcount = anim->streamindex; - if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, anim->filepath, nullptr, nullptr) != 0) { return -1; } - if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) { avformat_close_input(&pFormatCtx); return -1; } - av_dump_format(pFormatCtx, 0, anim->name, 0); + av_dump_format(pFormatCtx, 0, anim->filepath, 0); /* Find the video stream */ video_stream_index = -1; @@ -550,12 +554,12 @@ static int startffmpeg(struct anim *anim) /* Find the decoder for the video stream */ pCodec = avcodec_find_decoder(video_stream->codecpar->codec_id); - if (pCodec == NULL) { + if (pCodec == nullptr) { avformat_close_input(&pFormatCtx); return -1; } - pCodecCtx = avcodec_alloc_context3(NULL); + pCodecCtx = avcodec_alloc_context3(nullptr); avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar); pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT; @@ -573,7 +577,7 @@ static int startffmpeg(struct anim *anim) pCodecCtx->thread_type = FF_THREAD_SLICE; } - if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { + if (avcodec_open2(pCodecCtx, pCodec, nullptr) < 0) { avformat_close_input(&pFormatCtx); return -1; } @@ -590,7 +594,7 @@ static int startffmpeg(struct anim *anim) video_start = video_stream->start_time * pts_time_base; } - frame_rate = av_guess_frame_rate(pFormatCtx, video_stream, NULL); + frame_rate = av_guess_frame_rate(pFormatCtx, video_stream, nullptr); anim->duration_in_frames = 0; /* Take from the stream if we can. */ @@ -601,7 +605,7 @@ static int startffmpeg(struct anim *anim) * #68091. */ if (frame_rate.den != 0 && pFormatCtx->duration > 0) { double stream_sec = anim->duration_in_frames * av_q2d(frame_rate); - double container_sec = pFormatCtx->duration / (double)AV_TIME_BASE; + double container_sec = pFormatCtx->duration / double(AV_TIME_BASE); if (stream_sec > 4.0 * container_sec) { /* The stream is significantly longer than the container duration, which is * suspicious. */ @@ -637,16 +641,16 @@ static int startffmpeg(struct anim *anim) } if (video_start > audio_start) { - stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - (video_start - audio_start); + stream_dur = double(pFormatCtx->duration) / AV_TIME_BASE - (video_start - audio_start); } else { /* The video stream starts before or at the same time as the audio stream! * We have to assume that the video stream is as long as the full pFormatCtx->duration. */ - stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE; + stream_dur = double(pFormatCtx->duration) / AV_TIME_BASE; } } - anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f); + anim->duration_in_frames = int(stream_dur * av_q2d(frame_rate) + 0.5f); } frs_num = frame_rate.num; @@ -705,7 +709,7 @@ static int startffmpeg(struct anim *anim) av_frame_free(&anim->pFrameDeinterlaced); av_frame_free(&anim->pFrame); av_frame_free(&anim->pFrame_backup); - anim->pCodecCtx = NULL; + anim->pCodecCtx = nullptr; return -1; } @@ -718,22 +722,22 @@ static int startffmpeg(struct anim *anim) av_frame_free(&anim->pFrameDeinterlaced); av_frame_free(&anim->pFrame); av_frame_free(&anim->pFrame_backup); - anim->pCodecCtx = NULL; + anim->pCodecCtx = nullptr; return -1; } if (anim->ib_flags & IB_animdeinterlace) { - av_image_fill_arrays(anim->pFrameDeinterlaced->data, - anim->pFrameDeinterlaced->linesize, - MEM_callocN(av_image_get_buffer_size(anim->pCodecCtx->pix_fmt, - anim->pCodecCtx->width, - anim->pCodecCtx->height, - 1), - "ffmpeg deinterlace"), - anim->pCodecCtx->pix_fmt, - anim->pCodecCtx->width, - anim->pCodecCtx->height, - 1); + av_image_fill_arrays( + anim->pFrameDeinterlaced->data, + anim->pFrameDeinterlaced->linesize, + static_cast(MEM_callocN( + av_image_get_buffer_size( + anim->pCodecCtx->pix_fmt, anim->pCodecCtx->width, anim->pCodecCtx->height, 1), + "ffmpeg deinterlace")), + anim->pCodecCtx->pix_fmt, + anim->pCodecCtx->width, + anim->pCodecCtx->height, + 1); } anim->img_convert_ctx = sws_getContext(anim->x, @@ -743,9 +747,9 @@ static int startffmpeg(struct anim *anim) anim->y, AV_PIX_FMT_RGBA, SWS_BILINEAR | SWS_PRINT_INFO | SWS_FULL_CHR_H_INT, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); if (!anim->img_convert_ctx) { fprintf(stderr, "Can't transform color space??? Bailing out...\n"); @@ -756,7 +760,7 @@ static int startffmpeg(struct anim *anim) av_frame_free(&anim->pFrameDeinterlaced); av_frame_free(&anim->pFrame); av_frame_free(&anim->pFrame_backup); - anim->pCodecCtx = NULL; + anim->pCodecCtx = nullptr; return -1; } @@ -768,7 +772,8 @@ static int startffmpeg(struct anim *anim) &dstRange, &brightness, &contrast, - &saturation)) { + &saturation)) + { srcRange = srcRange || anim->pCodecCtx->color_range == AVCOL_RANGE_JPEG; inv_table = sws_getCoefficients(anim->pCodecCtx->colorspace); @@ -779,7 +784,8 @@ static int startffmpeg(struct anim *anim) dstRange, brightness, contrast, - saturation)) { + saturation)) + { fprintf(stderr, "Warning: Could not set libswscale colorspace details.\n"); } } @@ -794,7 +800,7 @@ static double ffmpeg_steps_per_frame_get(struct anim *anim) { AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream]; AVRational time_base = v_st->time_base; - AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL); + AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, nullptr); return av_q2d(av_inv_q(av_mul_q(frame_rate, time_base))); } @@ -841,7 +847,7 @@ static AVFrame *ffmpeg_double_buffer_frame_fallback_get(struct anim *anim) if (anim->pFrame_backup_complete) { return anim->pFrame_backup; } - return NULL; + return nullptr; } /* postprocess the image in anim->pFrame and do color conversion @@ -877,7 +883,8 @@ static void ffmpeg_postprocess(struct anim *anim, AVFrame *input) anim->pFrame, anim->pCodecCtx->pix_fmt, anim->pCodecCtx->width, - anim->pCodecCtx->height) < 0) { + anim->pCodecCtx->height) < 0) + { filter_y = true; } else { @@ -902,7 +909,7 @@ static void ffmpeg_postprocess(struct anim *anim, AVFrame *input) * explicitly. */ const int src_linesize[4] = {-anim->pFrameRGB->linesize[0], 0, 0, 0}; int dst_size = av_image_get_buffer_size( - anim->pFrameRGB->format, anim->pFrameRGB->width, anim->pFrameRGB->height, 1); + AVPixelFormat(anim->pFrameRGB->format), anim->pFrameRGB->width, anim->pFrameRGB->height, 1); av_image_copy_to_buffer( (uint8_t *)ibuf->rect, dst_size, src, src_linesize, AV_PIX_FMT_RGBA, anim->x, anim->y, 1); if (filter_y) { @@ -928,15 +935,15 @@ static bool ffmpeg_pts_isect(int64_t pts_start, int64_t pts_end, int64_t pts_to_ return pts_start <= pts_to_search && pts_to_search < pts_end; } -/* Return frame that matches `pts_to_search`, NULL if matching frame does not exist. */ +/* Return frame that matches `pts_to_search`, nullptr if matching frame does not exist. */ static AVFrame *ffmpeg_frame_by_pts_get(struct anim *anim, int64_t pts_to_search) { /* NOTE: `frame->pts + frame->pkt_duration` does not always match pts of next frame. * See footage from #86361. Here it is OK to use, because PTS must match current or backup frame. - * If there is no current frame, return NULL. + * If there is no current frame, return nullptr. */ if (!anim->pFrame_complete) { - return NULL; + return nullptr; } const bool backup_frame_ready = anim->pFrame_backup_complete; @@ -944,7 +951,7 @@ static AVFrame *ffmpeg_frame_by_pts_get(struct anim *anim, int64_t pts_to_search const int64_t recent_end = recent_start + anim->pFrame->pkt_duration; const int64_t backup_start = backup_frame_ready ? av_get_pts_from_frame(anim->pFrame_backup) : 0; - AVFrame *best_frame = NULL; + AVFrame *best_frame = nullptr; if (ffmpeg_pts_isect(recent_start, recent_end, pts_to_search)) { final_frame_log(anim, recent_start, recent_end, "Recent"); best_frame = anim->pFrame; @@ -968,7 +975,7 @@ static void ffmpeg_decode_store_frame_pts(struct anim *anim) AV_LOG_DEBUG, " FRAME DONE: cur_pts=%" PRId64 ", guessed_pts=%" PRId64 "\n", av_get_pts_from_frame(anim->pFrame), - (int64_t)anim->cur_pts); + int64_t(anim->cur_pts)); } static int ffmpeg_read_video_frame(struct anim *anim, AVPacket *packet) @@ -1014,8 +1021,8 @@ static int ffmpeg_decode_video_frame(struct anim *anim) AV_LOG_DEBUG, "READ: strID=%d dts=%" PRId64 " pts=%" PRId64 " %s\n", anim->cur_packet->stream_index, - (anim->cur_packet->dts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->dts, - (anim->cur_packet->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->pts, + (anim->cur_packet->dts == AV_NOPTS_VALUE) ? -1 : int64_t(anim->cur_packet->dts), + (anim->cur_packet->pts == AV_NOPTS_VALUE) ? -1 : int64_t(anim->cur_packet->pts), (anim->cur_packet->flags & AV_PKT_FLAG_KEY) ? " KEY" : ""); avcodec_send_packet(anim->pCodecCtx, anim->cur_packet); @@ -1031,7 +1038,7 @@ static int ffmpeg_decode_video_frame(struct anim *anim) if (rval == AVERROR_EOF) { /* Flush any remaining frames out of the decoder. */ - avcodec_send_packet(anim->pCodecCtx, NULL); + avcodec_send_packet(anim->pCodecCtx, nullptr); anim->pFrame_complete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; if (anim->pFrame_complete) { @@ -1044,11 +1051,14 @@ static int ffmpeg_decode_video_frame(struct anim *anim) av_packet_unref(anim->cur_packet); anim->cur_packet->stream_index = -1; + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, rval); + av_log(anim->pFormatCtx, AV_LOG_ERROR, " DECODE READ FAILED: av_read_frame() " "returned error: %s\n", - av_err2str(rval)); + error_str); } return (rval >= 0); @@ -1192,12 +1202,12 @@ static int ffmpeg_generic_seek_workaround(struct anim *anim, /* Step backward frame by frame until we find the key frame we are looking for. */ while (current_pts != 0) { - current_pts = *requested_pts - (int64_t)round(offset * ffmpeg_steps_per_frame_get(anim)); + current_pts = *requested_pts - int64_t(round(offset * ffmpeg_steps_per_frame_get(anim))); current_pts = MAX2(current_pts, 0); /* Seek to timestamp. */ - if (av_seek_frame(anim->pFormatCtx, anim->videoStream, current_pts, AVSEEK_FLAG_BACKWARD) < - 0) { + if (av_seek_frame(anim->pFormatCtx, anim->videoStream, current_pts, AVSEEK_FLAG_BACKWARD) < 0) + { break; } @@ -1389,8 +1399,8 @@ static bool ffmpeg_must_seek(struct anim *anim, int position) static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Type tc) { - if (anim == NULL) { - return NULL; + if (anim == nullptr) { + return nullptr; } av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: seek_pos=%d\n", position); @@ -1406,7 +1416,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ AV_LOG_DEBUG, "FETCH: looking for PTS=%" PRId64 " (pts_timebase=%g, frame_rate=%g, start_pts=%" PRId64 ")\n", - (int64_t)pts_to_search, + int64_t(pts_to_search), pts_time_base, frame_rate, start_pts); @@ -1450,22 +1460,22 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ } anim->cur_frame_final = IMB_allocImBuf(anim->x, anim->y, planes, 0); - anim->cur_frame_final->rect = MEM_mallocN_aligned( - (size_t)4 * anim->x * anim->y, 32, "ffmpeg ibuf"); + anim->cur_frame_final->rect = static_cast( + MEM_mallocN_aligned(size_t(4) * anim->x * anim->y, 32, "ffmpeg ibuf")); anim->cur_frame_final->mall |= IB_rect; anim->cur_frame_final->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace); AVFrame *final_frame = ffmpeg_frame_by_pts_get(anim, pts_to_search); - if (final_frame == NULL) { + if (final_frame == nullptr) { /* No valid frame was decoded for requested PTS, fall back on most recent decoded frame, even * if it is incorrect. */ final_frame = ffmpeg_double_buffer_frame_fallback_get(anim); } - /* Even with the fallback from above it is possible that the current decode frame is NULL. In + /* Even with the fallback from above it is possible that the current decode frame is nullptr. In * this case skip post-processing and return current image buffer. */ - if (final_frame != NULL) { + if (final_frame != nullptr) { ffmpeg_postprocess(anim, final_frame); } @@ -1478,7 +1488,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ static void free_anim_ffmpeg(struct anim *anim) { - if (anim == NULL) { + if (anim == nullptr) { return; } @@ -1507,7 +1517,7 @@ static void free_anim_ffmpeg(struct anim *anim) static bool anim_getnew(struct anim *anim) { BLI_assert(anim->curtype == ANIM_NONE); - if (anim == NULL) { + if (anim == nullptr) { /* Nothing to initialize. */ return false; } @@ -1522,13 +1532,13 @@ static bool anim_getnew(struct anim *anim) free_anim_ffmpeg(anim); #endif - anim->curtype = imb_get_anim_type(anim->name); + anim->curtype = imb_get_anim_type(anim->filepath); switch (anim->curtype) { case ANIM_SEQUENCE: { - ImBuf *ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace); + ImBuf *ibuf = IMB_loadiffname(anim->filepath, anim->ib_flags, anim->colorspace); if (ibuf) { - BLI_strncpy(anim->first, anim->name, sizeof(anim->first)); + BLI_strncpy(anim->filepath_first, anim->filepath, sizeof(anim->filepath_first)); anim->duration_in_frames = 1; IMB_freeImBuf(ibuf); } @@ -1563,7 +1573,7 @@ static bool anim_getnew(struct anim *anim) struct ImBuf *IMB_anim_previewframe(struct anim *anim) { - struct ImBuf *ibuf = NULL; + struct ImBuf *ibuf = nullptr; int position = 0; ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -1580,13 +1590,13 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size) { - struct ImBuf *ibuf = NULL; + struct ImBuf *ibuf = nullptr; char head[256], tail[256]; ushort digits; int pic; int filter_y; - if (anim == NULL) { - return NULL; + if (anim == nullptr) { + return nullptr; } filter_y = (anim->ib_flags & IB_animdeinterlace); @@ -1594,15 +1604,15 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, if (preview_size == IMB_PROXY_NONE) { if (anim->curtype == ANIM_NONE) { if (!anim_getnew(anim)) { - return NULL; + return nullptr; } } if (position < 0) { - return NULL; + return nullptr; } if (position >= anim->duration_in_frames) { - return NULL; + return nullptr; } } else { @@ -1617,10 +1627,10 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, switch (anim->curtype) { case ANIM_SEQUENCE: - pic = an_stringdec(anim->first, head, tail, &digits); + pic = an_stringdec(anim->filepath_first, head, tail, &digits); pic += position; - an_stringenc(anim->name, sizeof(anim->name), head, tail, digits, pic); - ibuf = IMB_loadiffname(anim->name, IB_rect, anim->colorspace); + an_stringenc(anim->filepath, sizeof(anim->filepath), head, tail, digits, pic); + ibuf = IMB_loadiffname(anim->filepath, IB_rect, anim->colorspace); if (ibuf) { anim->cur_position = position; } @@ -1655,7 +1665,8 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, if (filter_y) { IMB_filtery(ibuf); } - BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->cur_position + 1); + BLI_snprintf( + ibuf->filepath, sizeof(ibuf->filepath), "%s.%04d", anim->filepath, anim->cur_position + 1); } return ibuf; } @@ -1690,7 +1701,7 @@ bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bo /* We cannot store original rational in our short/float format, * we need to approximate it as best as we can... */ *frs_sec = SHRT_MAX; - frs_sec_base_double = anim->frs_sec_base * (double)SHRT_MAX / (double)anim->frs_sec; + frs_sec_base_double = anim->frs_sec_base * double(SHRT_MAX) / double(anim->frs_sec); } else { *frs_sec = anim->frs_sec; @@ -1698,14 +1709,14 @@ bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bo } #ifdef WITH_FFMPEG if (no_av_base) { - *frs_sec_base = (float)(frs_sec_base_double / AV_TIME_BASE); + *frs_sec_base = float(frs_sec_base_double / AV_TIME_BASE); } else { - *frs_sec_base = (float)frs_sec_base_double; + *frs_sec_base = float(frs_sec_base_double); } #else UNUSED_VARS(no_av_base); - *frs_sec_base = (float)frs_sec_base_double; + *frs_sec_base = float(frs_sec_base_double); #endif BLI_assert(*frs_sec > 0); BLI_assert(*frs_sec_base > 0.0f); diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt index d54a88bc6ea..23fb630f676 100644 --- a/source/blender/imbuf/intern/cineon/CMakeLists.txt +++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt @@ -21,11 +21,11 @@ set(SRC logImageCore.h logmemfile.h - cineon_dpx.c - cineonlib.c - dpxlib.c - logImageCore.c - logmemfile.c + cineon_dpx.cc + cineonlib.cc + dpxlib.cc + logImageCore.cc + logmemfile.cc ) set(LIB diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.cc similarity index 89% rename from source/blender/imbuf/intern/cineon/cineon_dpx.c rename to source/blender/imbuf/intern/cineon/cineon_dpx.cc index e6ee1144ff7..7043a033ed4 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.cc @@ -34,24 +34,24 @@ static struct ImBuf *imb_load_dpx_cineon( image = logImageOpenFromMemory(mem, size); - if (image == NULL) { + if (image == nullptr) { printf("DPX/Cineon: error opening image.\n"); - return NULL; + return nullptr; } logImageGetSize(image, &width, &height, &depth); ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags); - if (ibuf == NULL) { + if (ibuf == nullptr) { logImageClose(image); - return NULL; + return nullptr; } if (!(flags & IB_test)) { if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) { logImageClose(image); IMB_freeImBuf(ibuf); - return NULL; + return nullptr; } IMB_flipy(ibuf); } @@ -112,12 +112,12 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon -1, "Blender"); - if (logImage == NULL) { + if (logImage == nullptr) { printf("DPX/Cineon: error creating file.\n"); return 0; } - if (ibuf->rect_float != NULL && bitspersample != 8) { + if (ibuf->rect_float != nullptr && bitspersample != 8) { /* Don't use the float buffer to save 8 BPP picture to prevent color banding * (there's no dithering algorithm behind the #logImageSetDataRGBA function). */ @@ -136,13 +136,13 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon MEM_freeN(fbuf); } else { - if (ibuf->rect == NULL) { + if (ibuf->rect == nullptr) { IMB_rect_from_float(ibuf); } fbuf = (float *)MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, "fbuf in imb_save_dpx_cineon"); - if (fbuf == NULL) { + if (fbuf == nullptr) { printf("DPX/Cineon: error allocating memory.\n"); logImageClose(logImage); return 0; @@ -151,10 +151,10 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon for (x = 0; x < ibuf->x; x++) { fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x); rect_ptr = (uchar *)ibuf->rect + 4 * (y * ibuf->x + x); - fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f; - fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f; - fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f; - fbuf_ptr[3] = (depth == 4) ? ((float)rect_ptr[3] / 255.0f) : 1.0f; + fbuf_ptr[0] = float(rect_ptr[0]) / 255.0f; + fbuf_ptr[1] = float(rect_ptr[1]) / 255.0f; + fbuf_ptr[2] = float(rect_ptr[2]) / 255.0f; + fbuf_ptr[3] = (depth == 4) ? (float(rect_ptr[3]) / 255.0f) : 1.0f; } } rvalue = (logImageSetDataRGBA(logImage, fbuf, 0) == 0); @@ -178,7 +178,7 @@ bool imb_is_a_cineon(const uchar *buf, size_t size) ImBuf *imb_load_cineon(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { if (!imb_is_a_cineon(mem, size)) { - return NULL; + return nullptr; } return imb_load_dpx_cineon(mem, size, 1, flags, colorspace); } diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.cc similarity index 94% rename from source/blender/imbuf/intern/cineon/cineonlib.c rename to source/blender/imbuf/intern/cineon/cineonlib.cc index 6417d92644f..d090dadf729 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.cc @@ -59,7 +59,7 @@ static void fillCineonMainHeader(LogImageFile *cineon, cineon->isMSB); STRNCPY(header->fileHeader.version, "v4.5"); STRNCPY(header->fileHeader.file_name, filepath); - fileClock = time(NULL); + fileClock = time(nullptr); fileTime = localtime(&fileClock); strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime); strftime(header->fileHeader.creation_time, 12, "%H:%M:%S%Z", fileTime); @@ -129,32 +129,32 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi int i; uint dataOffset; - if (cineon == NULL) { + if (cineon == nullptr) { if (verbose) { printf("Cineon: Failed to malloc cineon file structure.\n"); } - return NULL; + return nullptr; } /* zero the header */ memset(&header, 0, sizeof(CineonMainHeader)); /* for close routine */ - cineon->file = NULL; + cineon->file = nullptr; if (fromMemory == 0) { /* byteStuff is then the filepath */ cineon->file = BLI_fopen(filepath, "rb"); - if (cineon->file == NULL) { + if (cineon->file == nullptr) { if (verbose) { printf("Cineon: Failed to open file \"%s\".\n", filepath); } logImageClose(cineon); - return NULL; + return nullptr; } /* not used in this case */ - cineon->memBuffer = NULL; - cineon->memCursor = NULL; + cineon->memBuffer = nullptr; + cineon->memCursor = nullptr; cineon->memBufferSize = 0; } else { @@ -168,7 +168,7 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff); } logImageClose(cineon); - return NULL; + return nullptr; } /* endianness determination */ @@ -187,11 +187,11 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi else { if (verbose) { printf("Cineon: Bad magic number %lu in \"%s\".\n", - (ulong)header.fileHeader.magic_num, + ulong(header.fileHeader.magic_num), byteStuff); } logImageClose(cineon); - return NULL; + return nullptr; } cineon->width = swap_uint(header.imageHeader.element[0].pixels_per_line, cineon->isMSB); @@ -202,7 +202,7 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi printf("Cineon: Wrong image dimension: %dx%d\n", cineon->width, cineon->height); } logImageClose(cineon); - return NULL; + return nullptr; } cineon->depth = header.imageHeader.elements_per_image; @@ -219,7 +219,7 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave); } logImageClose(cineon); - return NULL; + return nullptr; } if (cineon->depth == 1) { @@ -252,7 +252,7 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth); } logImageClose(cineon); - return NULL; + return nullptr; } dataOffset = swap_uint(header.fileHeader.offset, cineon->isMSB); @@ -288,7 +288,7 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing); } logImageClose(cineon); - return NULL; + return nullptr; } if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32) { @@ -296,16 +296,18 @@ LogImageFile *cineonOpen(const uchar *byteStuff, int fromMemory, size_t bufferSi } if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32) { - cineon->element[i].refHighData = (uint)cineon->element[i].maxValue; + cineon->element[i].refHighData = uint(cineon->element[i].maxValue); } if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || - isnan(cineon->element[i].refLowQuantity)) { + isnan(cineon->element[i].refLowQuantity)) + { cineon->element[i].refLowQuantity = 0.0f; } if (cineon->element[i].refHighQuantity == CINEON_UNDEFINED_R32 || - isnan(cineon->element[i].refHighQuantity)) { + isnan(cineon->element[i].refHighQuantity)) + { if (cineon->element[i].transfer == transfer_PrintingDensity) { cineon->element[i].refHighQuantity = 2.048f; } @@ -352,15 +354,15 @@ LogImageFile *cineonCreate( const char *filepath, int width, int height, int bitsPerSample, const char *creator) { CineonMainHeader header; - const char *shortFilename = NULL; + const char *shortFilename = nullptr; /* uchar pad[6044]; */ LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); - if (cineon == NULL) { + if (cineon == nullptr) { if (verbose) { printf("cineon: Failed to malloc cineon file structure.\n"); } - return NULL; + return nullptr; } /* Only 10 bits Cineon are supported */ @@ -369,7 +371,7 @@ LogImageFile *cineonCreate( printf("cineon: Only 10 bits Cineon are supported.\n"); } logImageClose(cineon); - return NULL; + return nullptr; } cineon->width = width; @@ -393,7 +395,7 @@ LogImageFile *cineonCreate( cineon->gamma = 1.7f; shortFilename = strrchr(filepath, PATHSEP_CHAR); - if (shortFilename == NULL) { + if (shortFilename == nullptr) { shortFilename = filepath; } else { @@ -401,12 +403,12 @@ LogImageFile *cineonCreate( } cineon->file = BLI_fopen(filepath, "wb"); - if (cineon->file == NULL) { + if (cineon->file == nullptr) { if (verbose) { printf("cineon: Couldn't open file %s\n", filepath); } logImageClose(cineon); - return NULL; + return nullptr; } fillCineonMainHeader(cineon, &header, shortFilename, creator); @@ -416,7 +418,7 @@ LogImageFile *cineonCreate( printf("cineon: Couldn't write image header\n"); } logImageClose(cineon); - return NULL; + return nullptr; } return cineon; diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.cc similarity index 95% rename from source/blender/imbuf/intern/cineon/dpxlib.c rename to source/blender/imbuf/intern/cineon/dpxlib.cc index be8fab26301..02ea2730785 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.cc @@ -62,7 +62,7 @@ static void fillDpxMainHeader(LogImageFile *dpx, dpx->isMSB); header->fileHeader.user_data_size = DPX_UNDEFINED_U32; STRNCPY(header->fileHeader.file_name, filename); - fileClock = time(NULL); + fileClock = time(nullptr); fileTime = localtime(&fileClock); strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime); header->fileHeader.creation_date[23] = 0; @@ -126,32 +126,32 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) const char *filepath = (const char *)byteStuff; int i; - if (dpx == NULL) { + if (dpx == nullptr) { if (verbose) { printf("DPX: Failed to malloc dpx file structure.\n"); } - return NULL; + return nullptr; } /* zero the header */ memset(&header, 0, sizeof(DpxMainHeader)); /* for close routine */ - dpx->file = NULL; + dpx->file = nullptr; if (fromMemory == 0) { /* byteStuff is then the filepath */ dpx->file = BLI_fopen(filepath, "rb"); - if (dpx->file == NULL) { + if (dpx->file == nullptr) { if (verbose) { printf("DPX: Failed to open file \"%s\".\n", filepath); } logImageClose(dpx); - return NULL; + return nullptr; } /* not used in this case */ - dpx->memBuffer = NULL; - dpx->memCursor = NULL; + dpx->memBuffer = nullptr; + dpx->memCursor = nullptr; dpx->memBufferSize = 0; } else { @@ -165,7 +165,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Not enough data for header in \"%s\".\n", byteStuff); } logImageClose(dpx); - return NULL; + return nullptr; } /* endianness determination */ @@ -186,7 +186,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Bad magic number %u in \"%s\".\n", header.fileHeader.magic_num, byteStuff); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->srcFormat = format_DPX; @@ -197,7 +197,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Wrong number of elements: %d\n", dpx->numElements); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB); @@ -208,7 +208,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Wrong image dimension: %dx%d\n", dpx->width, dpx->height); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->depth = 0; @@ -257,7 +257,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Unsupported image depth: %d\n", dpx->depth); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample; @@ -268,7 +268,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) dpx->element[i].bitsPerSample); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f; @@ -279,7 +279,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Unsupported packing for element %d: %d\n", i, dpx->element[i].packing); } logImageClose(dpx); - return NULL; + return nullptr; } /* Sometimes, the offset is not set correctly in the header */ @@ -293,7 +293,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) printf("DPX: Image header is corrupted.\n"); } logImageClose(dpx); - return NULL; + return nullptr; } dpx->element[i].transfer = header.imageHeader.element[i].transfer; @@ -320,7 +320,7 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) } if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) { - dpx->element[i].refHighData = (uint)dpx->element[i].maxValue; + dpx->element[i].refHighData = uint(dpx->element[i].maxValue); } if (IS_DPX_UNDEFINED_R32(dpx->element[i].refLowQuantity)) { @@ -373,7 +373,8 @@ LogImageFile *dpxOpen(const uchar *byteStuff, int fromMemory, size_t bufferSize) if (IS_DPX_UNDEFINED_R32(dpx->referenceBlack) || (dpx->referenceWhite <= dpx->referenceBlack || IS_DPX_UNDEFINED_R32(dpx->referenceWhite)) || - (dpx->gamma <= 0 || IS_DPX_UNDEFINED_R32(dpx->gamma))) { + (dpx->gamma <= 0 || IS_DPX_UNDEFINED_R32(dpx->gamma))) + { dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue; dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue; dpx->gamma = 1.7f; @@ -417,15 +418,15 @@ LogImageFile *dpxCreate(const char *filepath, const char *creator) { DpxMainHeader header; - const char *shortFilename = NULL; + const char *shortFilename = nullptr; uchar pad[6044]; LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); - if (dpx == NULL) { + if (dpx == nullptr) { if (verbose) { printf("DPX: Failed to malloc dpx file structure.\n"); } - return NULL; + return nullptr; } dpx->width = width; @@ -453,7 +454,7 @@ LogImageFile *dpxCreate(const char *filepath, printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample); } logImageClose(dpx); - return NULL; + return nullptr; } if (hasAlpha == 0) { @@ -502,7 +503,7 @@ LogImageFile *dpxCreate(const char *filepath, } shortFilename = strrchr(filepath, PATHSEP_CHAR); - if (shortFilename == NULL) { + if (shortFilename == nullptr) { shortFilename = filepath; } else { @@ -511,12 +512,12 @@ LogImageFile *dpxCreate(const char *filepath, dpx->file = BLI_fopen(filepath, "wb"); - if (dpx->file == NULL) { + if (dpx->file == nullptr) { if (verbose) { printf("DPX: Couldn't open file %s\n", filepath); } logImageClose(dpx); - return NULL; + return nullptr; } fillDpxMainHeader(dpx, &header, shortFilename, creator); @@ -526,7 +527,7 @@ LogImageFile *dpxCreate(const char *filepath, printf("DPX: Couldn't write image header\n"); } logImageClose(dpx); - return NULL; + return nullptr; } /* Header should be rounded to next 8k block @@ -537,7 +538,7 @@ LogImageFile *dpxCreate(const char *filepath, printf("DPX: Couldn't write image header\n"); } logImageClose(dpx); - return NULL; + return nullptr; } return dpx; diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.cc similarity index 93% rename from source/blender/imbuf/intern/cineon/logImageCore.c rename to source/blender/imbuf/intern/cineon/logImageCore.cc index 9ec48447884..5018028e1a2 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.cc @@ -108,13 +108,13 @@ LogImageFile *logImageOpenFromFile(const char *filepath, int cineon) (void)cineon; - if (f == NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } if (fread(&magicNum, sizeof(magicNum), 1, f) != 1) { fclose(f); - return NULL; + return nullptr; } fclose(f); @@ -126,7 +126,7 @@ LogImageFile *logImageOpenFromFile(const char *filepath, int cineon) return cineonOpen((const uchar *)filepath, 0, 0); } - return NULL; + return nullptr; } LogImageFile *logImageOpenFromMemory(const uchar *buffer, uint size) @@ -138,7 +138,7 @@ LogImageFile *logImageOpenFromMemory(const uchar *buffer, uint size) return cineonOpen(buffer, 1, size); } - return NULL; + return nullptr; } LogImageFile *logImageCreate(const char *filepath, @@ -169,15 +169,15 @@ LogImageFile *logImageCreate(const char *filepath, gamma, creator); - return NULL; + return nullptr; } void logImageClose(LogImageFile *logImage) { - if (logImage != NULL) { + if (logImage != nullptr) { if (logImage->file) { fclose(logImage->file); - logImage->file = NULL; + logImage->file = nullptr; } MEM_freeN(logImage); } @@ -237,12 +237,13 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB elementData = (float *)imb_alloc_pixels( logImage->width, logImage->height, logImage->depth, sizeof(float), __func__); - if (elementData == NULL) { + if (elementData == nullptr) { return 1; } if (convertRGBAToLogElement( - data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) { + data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) + { MEM_freeN(elementData); return 1; } @@ -279,7 +280,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, uchar *row; row = (uchar *)MEM_mallocN(rowLength, __func__); - if (row == NULL) { + if (row == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate row.\n"); } @@ -289,7 +290,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, for (size_t y = 0; y < logImage->height; y++) { for (size_t x = 0; x < logImage->width * logImage->depth; x++) { - row[x] = (uchar)float_uint(data[y * logImage->width * logImage->depth + x], 255); + row[x] = uchar(float_uint(data[y * logImage->width * logImage->depth + x], 255)); } if (logimage_fwrite(row, rowLength, 1, logImage) == 0) { @@ -311,7 +312,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, uint *row; row = (uint *)MEM_mallocN(rowLength, __func__); - if (row == NULL) { + if (row == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate row.\n"); } @@ -324,7 +325,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, pixel = 0; for (size_t x = 0; x < logImage->width * logImage->depth; x++) { - pixel |= (uint)float_uint(data[y * logImage->width * logImage->depth + x], 1023) << offset; + pixel |= uint(float_uint(data[y * logImage->width * logImage->depth + x], 1023)) << offset; offset -= 10; if (offset < 0) { row[index] = swap_uint(pixel, logImage->isMSB); @@ -355,7 +356,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, ushort *row; row = (ushort *)MEM_mallocN(rowLength, __func__); - if (row == NULL) { + if (row == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate row.\n"); } @@ -365,7 +366,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, for (size_t y = 0; y < logImage->height; y++) { for (size_t x = 0; x < logImage->width * logImage->depth; x++) { row[x] = swap_ushort( - (ushort)float_uint(data[y * logImage->width * logImage->depth + x], 4095) << 4, + ushort(float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4, logImage->isMSB); } @@ -387,7 +388,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, ushort *row; row = (ushort *)MEM_mallocN(rowLength, __func__); - if (row == NULL) { + if (row == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate row.\n"); } @@ -397,7 +398,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, for (size_t y = 0; y < logImage->height; y++) { for (size_t x = 0; x < logImage->width * logImage->depth; x++) { row[x] = swap_ushort( - (ushort)float_uint(data[y * logImage->width * logImage->depth + x], 65535), + ushort(float_uint(data[y * logImage->width * logImage->depth + x], 65535)), logImage->isMSB); } @@ -436,14 +437,14 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB /* descriptor_Depth and descriptor_Composite are not supported */ if (!ELEM(logImage->element[i].descriptor, descriptor_Depth, descriptor_Composite)) { /* Allocate memory */ - elementData[i] = imb_alloc_pixels( - logImage->width, logImage->height, logImage->element[i].depth, sizeof(float), __func__); - if (elementData[i] == NULL) { + elementData[i] = static_cast(imb_alloc_pixels( + logImage->width, logImage->height, logImage->element[i].depth, sizeof(float), __func__)); + if (elementData[i] == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i); } for (j = 0; j < i; j++) { - if (elementData[j] != NULL) { + if (elementData[j] != nullptr) { MEM_freeN(elementData[j]); } } @@ -457,7 +458,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB printf("DPX/Cineon: Cannot read elementData[%d]\n.", i); } for (j = 0; j < i; j++) { - if (elementData[j] != NULL) { + if (elementData[j] != nullptr) { MEM_freeN(elementData[j]); } } @@ -623,12 +624,12 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB mergedData = (float *)imb_alloc_pixels( logImage->width, logImage->height, mergedElement.depth, sizeof(float), __func__); - if (mergedData == NULL) { + if (mergedData == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate mergedData.\n"); } for (i = 0; i < logImage->numElements; i++) { - if (elementData[i] != NULL) { + if (elementData[i] != nullptr) { MEM_freeN(elementData[i]); } } @@ -646,7 +647,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB /* Done with elements data, clean-up */ for (i = 0; i < logImage->numElements; i++) { - if (elementData[i] != NULL) { + if (elementData[i] != nullptr) { MEM_freeN(elementData[i]); } } @@ -715,8 +716,8 @@ static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logEl } pixel = swap_uint(pixel, logImage->isMSB); for (int offset = 0; offset < 32 && x + offset < logImage->width; offset++) { - data[y * logImage->width * logElement.depth + x + offset] = (float)((pixel >> offset) & - 0x01); + data[y * logImage->width * logElement.depth + x + offset] = float((pixel >> offset) & + 0x01); } } } @@ -733,7 +734,7 @@ static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logEl /* 8 bits are 32-bits padded so we need to seek at each row */ if (logimage_fseek(logImage, logElement.dataOffset + y * rowLength, SEEK_SET) != 0) { if (verbose) { - printf("DPX/Cineon: Couldn't seek at %d\n", (int)(logElement.dataOffset + y * rowLength)); + printf("DPX/Cineon: Couldn't seek at %d\n", int(logElement.dataOffset + y * rowLength)); } return 1; } @@ -745,7 +746,7 @@ static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logEl } return 1; } - data[y * logImage->width * logElement.depth + x] = (float)pixel / 255.0f; + data[y * logImage->width * logElement.depth + x] = float(pixel) / 255.0f; } } return 0; @@ -786,7 +787,7 @@ static int logImageElementGetData10(LogImageFile *logImage, } pixel = swap_uint(pixel, logImage->isMSB); } - data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / + data[y * logImage->width * logElement.depth + x] = float((pixel >> offset) & 0x3ff) / 1023.0f; offset += 10; } @@ -813,7 +814,7 @@ static int logImageElementGetData10(LogImageFile *logImage, } pixel = swap_uint(pixel, logImage->isMSB); } - data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / + data[y * logImage->width * logElement.depth + x] = float((pixel >> offset) & 0x3ff) / 1023.0f; offset -= 10; } @@ -835,7 +836,7 @@ static int logImageElementGetData10Packed(LogImageFile *logImage, /* seek to data */ if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) { if (verbose) { - printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset)); + printf("DPX/Cineon: Couldn't seek at %u\n", uint(y * rowLength + logElement.dataOffset)); } return 1; } @@ -871,7 +872,7 @@ static int logImageElementGetData10Packed(LogImageFile *logImage, pixel = swap_uint(pixel, logImage->isMSB); } data[y * logImage->width * logElement.depth + x] = - (float)((((pixel << offset2) >> offset) & 0x3ff) | oldPixel) / 1023.0f; + float((((pixel << offset2) >> offset) & 0x3ff) | oldPixel) / 1023.0f; offset += 10; } } @@ -907,10 +908,10 @@ static int logImageElementGetData12(LogImageFile *logImage, pixel = swap_ushort(pixel, logImage->isMSB); if (logElement.packing == 1) { /* padded to the right */ - data[sampleIndex] = (float)(pixel >> 4) / 4095.0f; + data[sampleIndex] = float(pixel >> 4) / 4095.0f; } else if (logElement.packing == 2) { /* padded to the left */ - data[sampleIndex] = (float)pixel / 4095.0f; + data[sampleIndex] = float(pixel) / 4095.0f; } } return 0; @@ -928,7 +929,7 @@ static int logImageElementGetData12Packed(LogImageFile *logImage, /* seek to data */ if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) { if (verbose) { - printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset)); + printf("DPX/Cineon: Couldn't seek at %u\n", uint(y * rowLength + logElement.dataOffset)); } return 1; } @@ -964,7 +965,7 @@ static int logImageElementGetData12Packed(LogImageFile *logImage, pixel = swap_uint(pixel, logImage->isMSB); } data[y * logImage->width * logElement.depth + x] = - (float)((((pixel << offset2) >> offset) & 0xfff) | oldPixel) / 4095.0f; + float((((pixel << offset2) >> offset) & 0xfff) | oldPixel) / 4095.0f; offset += 12; } } @@ -995,7 +996,7 @@ static int logImageElementGetData16(LogImageFile *logImage, return 1; } pixel = swap_ushort(pixel, logImage->isMSB); - data[sampleIndex] = (float)pixel / 65535.0f; + data[sampleIndex] = float(pixel) / 65535.0f; } return 0; @@ -1008,8 +1009,8 @@ static int logImageElementGetData16(LogImageFile *logImage, static int getYUVtoRGBMatrix(float *matrix, LogImageElement logElement) { float scaleY, scaleCbCr; - float refHighData = (float)logElement.refHighData / logElement.maxValue; - float refLowData = (float)logElement.refLowData / logElement.maxValue; + float refHighData = float(logElement.refHighData) / logElement.maxValue; + float refLowData = float(logElement.refLowData) / logElement.maxValue; scaleY = 1.0f / (refHighData - refLowData); scaleCbCr = scaleY * ((940.0f - 64.0f) / (960.0f - 64.0f)); @@ -1073,10 +1074,10 @@ static float *getLinToLogLut(LogImageFile *logImage, LogImageElement logElement) { float *lut; float gain, negativeFilmGamma, offset, step; - uint lutsize = (uint)(logElement.maxValue + 1); + uint lutsize = uint(logElement.maxValue + 1); uint i; - lut = MEM_mallocN(sizeof(float) * lutsize, "getLinToLogLut"); + lut = static_cast(MEM_mallocN(sizeof(float) * lutsize, "getLinToLogLut")); negativeFilmGamma = 0.6; step = logElement.refHighQuantity / logElement.maxValue; @@ -1101,10 +1102,10 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement) float *lut; float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip; /* float filmGamma; unused */ - uint lutsize = (uint)(logElement.maxValue + 1); + uint lutsize = uint(logElement.maxValue + 1); uint i; - lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut"); + lut = static_cast(MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut")); /* Building the Log -> Lin LUT */ step = logElement.refHighQuantity / logElement.maxValue; @@ -1137,7 +1138,7 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement) } else { lut[i] = (powf(10, - ((float)i - logImage->referenceWhite) * step / negativeFilmGamma * + (float(i) - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset) / @@ -1151,13 +1152,13 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement) static float *getLinToSrgbLut(LogImageElement logElement) { float col, *lut; - uint lutsize = (uint)(logElement.maxValue + 1); + uint lutsize = uint(logElement.maxValue + 1); uint i; - lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut"); + lut = static_cast(MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut")); for (i = 0; i < lutsize; i++) { - col = (float)i / logElement.maxValue; + col = float(i) / logElement.maxValue; if (col < 0.0031308f) { lut[i] = (col < 0.0f) ? 0.0f : col * 12.92f; } @@ -1172,13 +1173,13 @@ static float *getLinToSrgbLut(LogImageElement logElement) static float *getSrgbToLinLut(LogImageElement logElement) { float col, *lut; - uint lutsize = (uint)(logElement.maxValue + 1); + uint lutsize = uint(logElement.maxValue + 1); uint i; - lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut"); + lut = static_cast(MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut")); for (i = 0; i < lutsize; i++) { - col = (float)i / logElement.maxValue; + col = float(i) / logElement.maxValue; if (col < 0.04045f) { lut[i] = (col < 0.0f) ? 0.0f : col * (1.0f / 12.92f); } @@ -1314,7 +1315,7 @@ static int convertRGBA_RGBA(float *src, case transfer_UserDefined: case transfer_Linear: case transfer_Logarithmic: { - memcpy(dst, src, 4 * (size_t)logImage->width * (size_t)logImage->height * sizeof(float)); + memcpy(dst, src, 4 * size_t(logImage->width) * size_t(logImage->height) * sizeof(float)); return 0; } @@ -1413,7 +1414,7 @@ static int convertCbYCr_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height; i++) { cb = *(src_ptr++) - 0.5f; @@ -1445,7 +1446,7 @@ static int convertCbYCrA_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height; i++) { cb = *(src_ptr++) - 0.5f; @@ -1478,7 +1479,7 @@ static int convertCbYCrY_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height / 2; i++) { cb = *(src_ptr++) - 0.5f; @@ -1530,7 +1531,7 @@ static int convertCbYACrYA_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height / 2; i++) { cb = *(src_ptr++) - 0.5f; @@ -1584,7 +1585,7 @@ static int convertLuminance_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height; i++) { value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f); @@ -1610,7 +1611,7 @@ static int convertYA_RGBA(float *src, return 1; } - refLowData = (float)logElement.refLowData / logElement.maxValue; + refLowData = float(logElement.refLowData) / logElement.maxValue; for (i = 0; i < logImage->width * logImage->height; i++) { value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f); @@ -1706,11 +1707,11 @@ static int convertRGBAToLogElement( /* we need to convert src to sRGB */ srgbSrc = (float *)imb_alloc_pixels( logImage->width, logImage->height, 4, sizeof(float), __func__); - if (srgbSrc == NULL) { + if (srgbSrc == nullptr) { return 1; } - memcpy(srgbSrc, src, 4 * (size_t)logImage->width * (size_t)logImage->height * sizeof(float)); + memcpy(srgbSrc, src, 4 * size_t(logImage->width) * size_t(logImage->height) * sizeof(float)); srgbSrc_ptr = srgbSrc; /* convert data from Linear RGB to sRGB via lut */ diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.cc similarity index 86% rename from source/blender/imbuf/intern/cineon/logmemfile.c rename to source/blender/imbuf/intern/cineon/logmemfile.cc index 6c24d67b33f..8ef559e0d7d 100644 --- a/source/blender/imbuf/intern/cineon/logmemfile.c +++ b/source/blender/imbuf/intern/cineon/logmemfile.cc @@ -33,7 +33,7 @@ int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin) logFile->memCursor = (logFile->memBuffer + logFile->memBufferSize) - offset; } else if (origin == SEEK_CUR) { - uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + uintptr_t pos = uintptr_t(logFile->memCursor) - uintptr_t(logFile->memBuffer); if (pos + offset > logFile->memBufferSize) { return 1; } @@ -61,7 +61,7 @@ int logimage_fread(void *buffer, size_t size, uint count, LogImageFile *logFile) } /* we're reading from memory */ uchar *buf = (uchar *)buffer; - uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + uintptr_t pos = uintptr_t(logFile->memCursor) - uintptr_t(logFile->memBuffer); size_t total_size = size * count; if (pos + total_size > logFile->memBufferSize) { /* how many elements can we read without overflow ? */ @@ -79,7 +79,7 @@ int logimage_fread(void *buffer, size_t size, uint count, LogImageFile *logFile) int logimage_read_uchar(uchar *x, LogImageFile *logFile) { - uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + uintptr_t pos = uintptr_t(logFile->memCursor) - uintptr_t(logFile->memBuffer); if (pos + sizeof(uchar) > logFile->memBufferSize) { return 1; } @@ -91,7 +91,7 @@ int logimage_read_uchar(uchar *x, LogImageFile *logFile) int logimage_read_ushort(ushort *x, LogImageFile *logFile) { - uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + uintptr_t pos = uintptr_t(logFile->memCursor) - uintptr_t(logFile->memBuffer); if (pos + sizeof(ushort) > logFile->memBufferSize) { return 1; } @@ -103,7 +103,7 @@ int logimage_read_ushort(ushort *x, LogImageFile *logFile) int logimage_read_uint(uint *x, LogImageFile *logFile) { - uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + uintptr_t pos = uintptr_t(logFile->memCursor) - uintptr_t(logFile->memBuffer); if (pos + sizeof(uint) > logFile->memBufferSize) { return 1; } diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.cc similarity index 91% rename from source/blender/imbuf/intern/colormanagement.c rename to source/blender/imbuf/intern/colormanagement.cc index 9407739e890..04bc3c3866b 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -62,10 +62,10 @@ static char global_role_default_byte[MAX_COLORSPACE_NAME]; static char global_role_default_float[MAX_COLORSPACE_NAME]; static char global_role_default_sequencer[MAX_COLORSPACE_NAME]; -static ListBase global_colorspaces = {NULL, NULL}; -static ListBase global_displays = {NULL, NULL}; -static ListBase global_views = {NULL, NULL}; -static ListBase global_looks = {NULL, NULL}; +static ListBase global_colorspaces = {nullptr, nullptr}; +static ListBase global_displays = {nullptr, nullptr}; +static ListBase global_views = {nullptr, nullptr}; +static ListBase global_looks = {nullptr, nullptr}; static int global_tot_colorspace = 0; static int global_tot_display = 0; @@ -111,7 +111,7 @@ static struct global_color_picking_state { OCIO_ConstCPUProcessorRcPtr *cpu_processor_to; OCIO_ConstCPUProcessorRcPtr *cpu_processor_from; bool failed; -} global_color_picking_state = {NULL}; +} global_color_picking_state = {nullptr}; /** \} */ @@ -222,7 +222,7 @@ typedef struct ColormanageCache { static struct MovieCache *colormanage_moviecache_get(const ImBuf *ibuf) { if (!ibuf->colormanage_cache) { - return NULL; + return nullptr; } return ibuf->colormanage_cache->moviecache; @@ -231,7 +231,7 @@ static struct MovieCache *colormanage_moviecache_get(const ImBuf *ibuf) static ColormanageCacheData *colormanage_cachedata_get(const ImBuf *ibuf) { if (!ibuf->colormanage_cache) { - return NULL; + return nullptr; } return ibuf->colormanage_cache->data; @@ -239,7 +239,7 @@ static ColormanageCacheData *colormanage_cachedata_get(const ImBuf *ibuf) static uint colormanage_hashhash(const void *key_v) { - const ColormanageCacheKey *key = key_v; + const ColormanageCacheKey *key = static_cast(key_v); uint rval = (key->display << 16) | (key->view % 0xffff); @@ -248,8 +248,8 @@ static uint colormanage_hashhash(const void *key_v) static bool colormanage_hashcmp(const void *av, const void *bv) { - const ColormanageCacheKey *a = av; - const ColormanageCacheKey *b = bv; + const ColormanageCacheKey *a = static_cast(av); + const ColormanageCacheKey *b = static_cast(bv); return ((a->view != b->view) || (a->display != b->display)); } @@ -257,7 +257,7 @@ static bool colormanage_hashcmp(const void *av, const void *bv) static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf) { if (!ibuf->colormanage_cache) { - ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache"); + ibuf->colormanage_cache = MEM_cnew("imbuf colormanage cache"); } if (!ibuf->colormanage_cache->moviecache) { @@ -277,7 +277,7 @@ static struct MovieCache *colormanage_moviecache_ensure(ImBuf *ibuf) static void colormanage_cachedata_set(ImBuf *ibuf, ColormanageCacheData *data) { if (!ibuf->colormanage_cache) { - ibuf->colormanage_cache = MEM_callocN(sizeof(ColormanageCache), "imbuf colormanage cache"); + ibuf->colormanage_cache = MEM_cnew("imbuf colormanage cache"); } ibuf->colormanage_cache->data = data; @@ -326,12 +326,12 @@ static ImBuf *colormanage_cache_get_ibuf(ImBuf *ibuf, if (!moviecache) { /* If there's no moviecache it means no color management was applied * on given image buffer before. */ - return NULL; + return nullptr; } - *cache_handle = NULL; + *cache_handle = nullptr; - cache_ibuf = IMB_moviecache_get(moviecache, key, NULL); + cache_ibuf = IMB_moviecache_get(moviecache, key, nullptr); *cache_handle = cache_ibuf; @@ -353,7 +353,7 @@ static uchar *colormanage_cache_get(ImBuf *ibuf, /* check whether image was marked as dirty for requested transform */ if ((ibuf->display_buffer_flags[display_settings->display - 1] & view_flag) == 0) { - return NULL; + return nullptr; } cache_ibuf = colormanage_cache_get_ibuf(ibuf, &key, cache_handle); @@ -376,18 +376,19 @@ static uchar *colormanage_cache_get(ImBuf *ibuf, cache_data->exposure != view_settings->exposure || cache_data->gamma != view_settings->gamma || cache_data->dither != view_settings->dither || cache_data->flag != view_settings->flag || cache_data->curve_mapping != curve_mapping || - cache_data->curve_mapping_timestamp != curve_mapping_timestamp) { - *cache_handle = NULL; + cache_data->curve_mapping_timestamp != curve_mapping_timestamp) + { + *cache_handle = nullptr; IMB_freeImBuf(cache_ibuf); - return NULL; + return nullptr; } return (uchar *)cache_ibuf->rect; } - return NULL; + return nullptr; } static void colormanage_cache_put(ImBuf *ibuf, @@ -418,7 +419,7 @@ static void colormanage_cache_put(ImBuf *ibuf, /* Store data which is needed to check whether cached buffer * could be used for color managed display settings. */ - cache_data = MEM_callocN(sizeof(ColormanageCacheData), "color manage cache imbuf data"); + cache_data = MEM_cnew("color manage cache imbuf data"); cache_data->look = view_settings->look; cache_data->exposure = view_settings->exposure; cache_data->gamma = view_settings->gamma; @@ -436,7 +437,7 @@ static void colormanage_cache_put(ImBuf *ibuf, static void colormanage_cache_handle_release(void *cache_handle) { - ImBuf *cache_ibuf = cache_handle; + ImBuf *cache_ibuf = static_cast(cache_handle); IMB_freeImBuf(cache_ibuf); } @@ -479,13 +480,13 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config) const char *name; /* get roles */ - colormanage_role_color_space_name_get(config, global_role_data, OCIO_ROLE_DATA, NULL); + colormanage_role_color_space_name_get(config, global_role_data, OCIO_ROLE_DATA, nullptr); colormanage_role_color_space_name_get( - config, global_role_scene_linear, OCIO_ROLE_SCENE_LINEAR, NULL); + config, global_role_scene_linear, OCIO_ROLE_SCENE_LINEAR, nullptr); colormanage_role_color_space_name_get( - config, global_role_color_picking, OCIO_ROLE_COLOR_PICKING, NULL); + config, global_role_color_picking, OCIO_ROLE_COLOR_PICKING, nullptr); colormanage_role_color_space_name_get( - config, global_role_texture_painting, OCIO_ROLE_TEXTURE_PAINT, NULL); + config, global_role_texture_painting, OCIO_ROLE_TEXTURE_PAINT, nullptr); colormanage_role_color_space_name_get( config, global_role_default_sequencer, OCIO_ROLE_DEFAULT_SEQUENCER, OCIO_ROLE_SCENE_LINEAR); colormanage_role_color_space_name_get( @@ -511,8 +512,8 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config) colorspace->num_aliases = OCIO_colorSpaceGetNumAliases(ocio_colorspace); if (colorspace->num_aliases > 0) { - colorspace->aliases = MEM_callocN(sizeof(*colorspace->aliases) * colorspace->num_aliases, - "ColorSpace aliases"); + colorspace->aliases = static_cast(MEM_callocN( + sizeof(*colorspace->aliases) * colorspace->num_aliases, "ColorSpace aliases")); for (int i = 0; i < colorspace->num_aliases; i++) { BLI_strncpy(colorspace->aliases[i], OCIO_colorSpaceGetAlias(ocio_colorspace, i), @@ -594,7 +595,7 @@ static void colormanage_free_config(void) ColorManagedDisplay *display; /* free color spaces */ - colorspace = global_colorspaces.first; + colorspace = static_cast(global_colorspaces.first); while (colorspace) { ColorSpace *colorspace_next = colorspace->next; @@ -616,7 +617,7 @@ static void colormanage_free_config(void) global_tot_colorspace = 0; /* free displays */ - display = global_displays.first; + display = static_cast(global_displays.first); while (display) { ColorManagedDisplay *display_next = display->next; @@ -653,7 +654,7 @@ void colormanagement_init(void) const char *ocio_env; const char *configdir; char configfile[FILE_MAX]; - OCIO_ConstConfigRcPtr *config = NULL; + OCIO_ConstConfigRcPtr *config = nullptr; OCIO_init(); @@ -661,12 +662,12 @@ void colormanagement_init(void) if (ocio_env && ocio_env[0] != '\0') { config = OCIO_configCreateFromEnv(); - if (config != NULL) { + if (config != nullptr) { printf("Color management: Using %s as a configuration file\n", ocio_env); } } - if (config == NULL) { + if (config == nullptr) { configdir = BKE_appdir_folder_id(BLENDER_DATAFILES, "colormanagement"); if (configdir) { @@ -676,7 +677,7 @@ void colormanagement_init(void) } } - if (config == NULL) { + if (config == nullptr) { printf("Color management: using fallback mode for management\n"); config = OCIO_configCreateFallback(); @@ -771,7 +772,7 @@ void colormanage_cache_free(ImBuf *ibuf) MEM_freeN(ibuf->colormanage_cache); - ibuf->colormanage_cache = NULL; + ibuf->colormanage_cache = nullptr; } } @@ -788,7 +789,7 @@ void IMB_colormanagement_display_settings_from_ctx( if (sima && sima->image) { if ((sima->image->flag & IMA_VIEW_AS_RENDER) == 0) { - *r_view_settings = NULL; + *r_view_settings = nullptr; } } } @@ -819,7 +820,7 @@ static ColorSpace *display_transform_get_colorspace( return colormanage_colorspace_get_named(colorspace_name); } - return NULL; + return nullptr; } static OCIO_ConstCPUProcessorRcPtr *create_display_buffer_processor(const char *look, @@ -845,8 +846,8 @@ static OCIO_ConstCPUProcessorRcPtr *create_display_buffer_processor(const char * OCIO_configRelease(config); - if (processor == NULL) { - return NULL; + if (processor == nullptr) { + return nullptr; } OCIO_ConstCPUProcessorRcPtr *cpu_processor = OCIO_processorGetCPUProcessor(processor); @@ -871,16 +872,16 @@ static OCIO_ConstProcessorRcPtr *create_colorspace_transform_processor(const cha static OCIO_ConstCPUProcessorRcPtr *colorspace_to_scene_linear_cpu_processor( ColorSpace *colorspace) { - if (colorspace->to_scene_linear == NULL) { + if (colorspace->to_scene_linear == nullptr) { BLI_mutex_lock(&processor_lock); - if (colorspace->to_scene_linear == NULL) { + if (colorspace->to_scene_linear == nullptr) { OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor( colorspace->name, global_role_scene_linear); - if (processor != NULL) { - colorspace->to_scene_linear = (struct OCIO_ConstCPUProcessorRcPtr *) - OCIO_processorGetCPUProcessor(processor); + if (processor != nullptr) { + colorspace->to_scene_linear = (OCIO_ConstCPUProcessorRcPtr *)OCIO_processorGetCPUProcessor( + processor); OCIO_processorRelease(processor); } } @@ -894,15 +895,15 @@ static OCIO_ConstCPUProcessorRcPtr *colorspace_to_scene_linear_cpu_processor( static OCIO_ConstCPUProcessorRcPtr *colorspace_from_scene_linear_cpu_processor( ColorSpace *colorspace) { - if (colorspace->from_scene_linear == NULL) { + if (colorspace->from_scene_linear == nullptr) { BLI_mutex_lock(&processor_lock); - if (colorspace->from_scene_linear == NULL) { + if (colorspace->from_scene_linear == nullptr) { OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor( global_role_scene_linear, colorspace->name); - if (processor != NULL) { - colorspace->from_scene_linear = (struct OCIO_ConstCPUProcessorRcPtr *) + if (processor != nullptr) { + colorspace->from_scene_linear = (OCIO_ConstCPUProcessorRcPtr *) OCIO_processorGetCPUProcessor(processor); OCIO_processorRelease(processor); } @@ -917,24 +918,30 @@ static OCIO_ConstCPUProcessorRcPtr *colorspace_from_scene_linear_cpu_processor( static OCIO_ConstCPUProcessorRcPtr *display_from_scene_linear_processor( ColorManagedDisplay *display) { - if (display->from_scene_linear == NULL) { + if (display->from_scene_linear == nullptr) { BLI_mutex_lock(&processor_lock); - if (display->from_scene_linear == NULL) { + if (display->from_scene_linear == nullptr) { const char *view_name = colormanage_view_get_default_name(display); OCIO_ConstConfigRcPtr *config = OCIO_getCurrentConfig(); - OCIO_ConstProcessorRcPtr *processor = NULL; + OCIO_ConstProcessorRcPtr *processor = nullptr; if (view_name && config) { - processor = OCIO_createDisplayProcessor( - config, global_role_scene_linear, view_name, display->name, NULL, 1.0f, 1.0f, false); + processor = OCIO_createDisplayProcessor(config, + global_role_scene_linear, + view_name, + display->name, + nullptr, + 1.0f, + 1.0f, + false); OCIO_configRelease(config); } - if (processor != NULL) { - display->from_scene_linear = (struct OCIO_ConstCPUProcessorRcPtr *) - OCIO_processorGetCPUProcessor(processor); + if (processor != nullptr) { + display->from_scene_linear = (OCIO_ConstCPUProcessorRcPtr *)OCIO_processorGetCPUProcessor( + processor); OCIO_processorRelease(processor); } } @@ -947,24 +954,24 @@ static OCIO_ConstCPUProcessorRcPtr *display_from_scene_linear_processor( static OCIO_ConstCPUProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDisplay *display) { - if (display->to_scene_linear == NULL) { + if (display->to_scene_linear == nullptr) { BLI_mutex_lock(&processor_lock); - if (display->to_scene_linear == NULL) { + if (display->to_scene_linear == nullptr) { const char *view_name = colormanage_view_get_default_name(display); OCIO_ConstConfigRcPtr *config = OCIO_getCurrentConfig(); - OCIO_ConstProcessorRcPtr *processor = NULL; + OCIO_ConstProcessorRcPtr *processor = nullptr; if (view_name && config) { processor = OCIO_createDisplayProcessor( - config, global_role_scene_linear, view_name, display->name, NULL, 1.0f, 1.0f, true); + config, global_role_scene_linear, view_name, display->name, nullptr, 1.0f, 1.0f, true); OCIO_configRelease(config); } - if (processor != NULL) { - display->to_scene_linear = (struct OCIO_ConstCPUProcessorRcPtr *) - OCIO_processorGetCPUProcessor(processor); + if (processor != nullptr) { + display->to_scene_linear = (OCIO_ConstCPUProcessorRcPtr *)OCIO_processorGetCPUProcessor( + processor); OCIO_processorRelease(processor); } } @@ -983,13 +990,13 @@ void IMB_colormanagement_init_default_view_settings( display_settings->display_device, "Standard"); /* If that fails, we fall back to the default view transform of the display * as per OCIO configuration. */ - if (default_view == NULL) { + if (default_view == nullptr) { ColorManagedDisplay *display = colormanage_display_get_named(display_settings->display_device); - if (display != NULL) { + if (display != nullptr) { default_view = colormanage_view_get_default(display); } } - if (default_view != NULL) { + if (default_view != nullptr) { BLI_strncpy( view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); } @@ -1002,7 +1009,7 @@ void IMB_colormanagement_init_default_view_settings( view_settings->flag = 0; view_settings->gamma = 1.0f; view_settings->exposure = 0.0f; - view_settings->curve_mapping = NULL; + view_settings->curve_mapping = nullptr; } static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels) @@ -1099,7 +1106,7 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display const char *what) { ColorManagedDisplay *display; - ColorManagedView *default_view = NULL; + ColorManagedView *default_view = nullptr; ColorManagedLook *default_look = (ColorManagedLook *)global_looks.first; if (view_settings->view_transform[0] == '\0') { @@ -1143,7 +1150,7 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display } else { ColorManagedLook *look = colormanage_look_get_named(view_settings->look); - if (look == NULL) { + if (look == nullptr) { printf("Color management: %s look \"%s\" not found, setting default \"%s\".\n", what, view_settings->look, @@ -1181,7 +1188,7 @@ static void colormanage_check_colorspace_settings( (void)what; } -static bool seq_callback(Sequence *seq, void *UNUSED(user_data)) +static bool seq_callback(Sequence *seq, void * /*user_data*/) { if (seq->strip) { colormanage_check_colorspace_settings(&seq->strip->colorspace_settings, "sequencer strip"); @@ -1191,20 +1198,13 @@ static bool seq_callback(Sequence *seq, void *UNUSED(user_data)) void IMB_colormanagement_check_file_config(Main *bmain) { - Scene *scene; - Image *image; - MovieClip *clip; - - ColorManagedDisplay *default_display; - - default_display = colormanage_display_get_default(); - + ColorManagedDisplay *default_display = colormanage_display_get_default(); if (!default_display) { /* happens when OCIO configuration is incorrect */ return; } - for (scene = bmain->scenes.first; scene; scene = scene->id.next) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { ColorManagedColorspaceSettings *sequencer_colorspace_settings; /* check scene color management settings */ @@ -1221,18 +1221,18 @@ void IMB_colormanagement_check_file_config(Main *bmain) } /* check sequencer strip input color space settings */ - if (scene->ed != NULL) { - SEQ_for_each_callback(&scene->ed->seqbase, seq_callback, NULL); + if (scene->ed != nullptr) { + SEQ_for_each_callback(&scene->ed->seqbase, seq_callback, nullptr); } } /* ** check input color space settings ** */ - for (image = bmain->images.first; image; image = image->id.next) { + LISTBASE_FOREACH (Image *, image, &bmain->images) { colormanage_check_colorspace_settings(&image->colorspace_settings, "image"); } - for (clip = bmain->movieclips.first; clip; clip = clip->id.next) { + LISTBASE_FOREACH (MovieClip *, clip, &bmain->movieclips) { colormanage_check_colorspace_settings(&clip->colorspace_settings, "clip"); } } @@ -1240,23 +1240,20 @@ void IMB_colormanagement_check_file_config(Main *bmain) void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings) { - ColorManagedDisplay *display; - ColorManagedView *default_view = NULL; - LinkData *view_link; + ColorManagedDisplay *display = colormanage_display_get_named(display_settings->display_device); + ColorManagedView *default_view = colormanage_view_get_default(display); - display = colormanage_display_get_named(display_settings->display_device); - - default_view = colormanage_view_get_default(display); - - for (view_link = display->views.first; view_link; view_link = view_link->next) { - ColorManagedView *view = view_link->data; + bool found = false; + LISTBASE_FOREACH (LinkData *, view_link, &display->views) { + ColorManagedView *view = static_cast(view_link->data); if (STREQ(view->name, view_settings->view_transform)) { + found = true; break; } } - if (view_link == NULL && default_view) { + if (!found && default_view) { BLI_strncpy( view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); } @@ -1285,7 +1282,7 @@ const char *IMB_colormanagement_role_colorspace_name_get(int role) break; } - return NULL; + return nullptr; } void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name) @@ -1478,8 +1475,8 @@ static void display_buffer_init_handle(void *handle_v, float dither = ibuf->dither; bool is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0; - size_t offset = ((size_t)channels) * start_line * ibuf->x; - size_t display_buffer_byte_offset = ((size_t)DISPLAY_BUFFER_CHANNELS) * start_line * ibuf->x; + size_t offset = size_t(channels) * start_line * ibuf->x; + size_t display_buffer_byte_offset = size_t(DISPLAY_BUFFER_CHANNELS) * start_line * ibuf->x; memset(handle, 0, sizeof(DisplayBufferThread)); @@ -1523,7 +1520,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, int channels = handle->channels; int width = handle->width; - size_t buffer_size = ((size_t)channels) * width * height; + size_t buffer_size = size_t(channels) * width * height; bool is_data = handle->is_data; bool is_data_display = handle->cm_processor->is_data_result; @@ -1537,7 +1534,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, float *fp; uchar *cp; - const size_t i_last = ((size_t)width) * height; + const size_t i_last = size_t(width) * height; size_t i; /* first convert byte buffer to float, keep in image space */ @@ -1606,7 +1603,7 @@ static void *do_display_buffer_apply_thread(void *handle_v) float dither = handle->dither; bool is_data = handle->is_data; - if (cm_processor == NULL) { + if (cm_processor == nullptr) { if (display_buffer_byte && display_buffer_byte != handle->byte_buffer) { IMB_buffer_byte_from_byte(display_buffer_byte, handle->byte_buffer, @@ -1633,8 +1630,8 @@ static void *do_display_buffer_apply_thread(void *handle_v) } else { bool is_straight_alpha; - float *linear_buffer = MEM_mallocN(((size_t)channels) * width * height * sizeof(float), - "color conversion linear buffer"); + float *linear_buffer = static_cast(MEM_mallocN( + size_t(channels) * width * height * sizeof(float), "color conversion linear buffer")); display_buffer_apply_get_linear_buffer(handle, height, linear_buffer, &is_straight_alpha); @@ -1668,10 +1665,10 @@ static void *do_display_buffer_apply_thread(void *handle_v) } if (display_buffer) { - memcpy(display_buffer, linear_buffer, ((size_t)width) * height * channels * sizeof(float)); + memcpy(display_buffer, linear_buffer, size_t(width) * height * channels * sizeof(float)); if (is_straight_alpha && channels == 4) { - const size_t i_last = ((size_t)width) * height; + const size_t i_last = size_t(width) * height; size_t i; float *fp; @@ -1684,7 +1681,7 @@ static void *do_display_buffer_apply_thread(void *handle_v) MEM_freeN(linear_buffer); } - return NULL; + return nullptr; } static void display_buffer_apply_threaded(ImBuf *ibuf, @@ -1703,7 +1700,7 @@ static void display_buffer_apply_threaded(ImBuf *ibuf, init_data.display_buffer = display_buffer; init_data.display_buffer_byte = display_buffer_byte; - if (ibuf->rect_colorspace != NULL) { + if (ibuf->rect_colorspace != nullptr) { init_data.byte_colorspace = ibuf->rect_colorspace->name; } else { @@ -1713,12 +1710,12 @@ static void display_buffer_apply_threaded(ImBuf *ibuf, init_data.byte_colorspace = global_role_default_byte; } - if (ibuf->float_colorspace != NULL) { + if (ibuf->float_colorspace != nullptr) { /* sequencer stores float buffers in non-linear space */ init_data.float_colorspace = ibuf->float_colorspace->name; } else { - init_data.float_colorspace = NULL; + init_data.float_colorspace = nullptr; } IMB_processor_apply_threaded(ibuf->y, @@ -1733,11 +1730,12 @@ static bool is_ibuf_rect_in_display_space(ImBuf *ibuf, const ColorManagedDisplaySettings *display_settings) { if ((view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) == 0 && - view_settings->exposure == 0.0f && view_settings->gamma == 1.0f) { + view_settings->exposure == 0.0f && view_settings->gamma == 1.0f) + { const char *from_colorspace = ibuf->rect_colorspace->name; const char *to_colorspace = get_display_colorspace_name(view_settings, display_settings); ColorManagedLook *look_descr = colormanage_look_get_named(view_settings->look); - if (look_descr != NULL && !STREQ(look_descr->process_space, "")) { + if (look_descr != nullptr && !STREQ(look_descr->process_space, "")) { return false; } @@ -1756,7 +1754,7 @@ static void colormanage_display_buffer_process_ex( const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings) { - ColormanageProcessor *cm_processor = NULL; + ColormanageProcessor *cm_processor = nullptr; bool skip_transform = false; /* if we're going to transform byte buffer, check whether transformation would @@ -1764,7 +1762,7 @@ static void colormanage_display_buffer_process_ex( * this would save byte -> float -> byte conversions making display buffer * computation noticeable faster */ - if (ibuf->rect_float == NULL && ibuf->rect_colorspace) { + if (ibuf->rect_float == nullptr && ibuf->rect_colorspace) { skip_transform = is_ibuf_rect_in_display_space(ibuf, view_settings, display_settings); } @@ -1790,7 +1788,7 @@ static void colormanage_display_buffer_process(ImBuf *ibuf, const ColorManagedDisplaySettings *display_settings) { colormanage_display_buffer_process_ex( - ibuf, NULL, display_buffer, view_settings, display_settings); + ibuf, nullptr, display_buffer, view_settings, display_settings); } /** \} */ @@ -1835,17 +1833,17 @@ static void processor_transform_init_handle(void *handle_v, const bool predivide = init_data->predivide; const bool float_from_byte = init_data->float_from_byte; - const size_t offset = ((size_t)channels) * start_line * width; + const size_t offset = size_t(channels) * start_line * width; memset(handle, 0, sizeof(ProcessorTransformThread)); handle->cm_processor = init_data->cm_processor; - if (init_data->byte_buffer != NULL) { + if (init_data->byte_buffer != nullptr) { /* TODO(serge): Offset might be different for byte and float buffers. */ handle->byte_buffer = init_data->byte_buffer + offset; } - if (init_data->float_buffer != NULL) { + if (init_data->float_buffer != nullptr) { handle->float_buffer = init_data->float_buffer + offset; } @@ -1885,17 +1883,17 @@ static void *do_processor_transform_thread(void *handle_v) IMB_premultiply_rect_float(float_buffer, 4, width, height); } else { - if (byte_buffer != NULL) { + if (byte_buffer != nullptr) { IMB_colormanagement_processor_apply_byte( handle->cm_processor, byte_buffer, width, height, channels); } - if (float_buffer != NULL) { + if (float_buffer != nullptr) { IMB_colormanagement_processor_apply( handle->cm_processor, float_buffer, width, height, channels, predivide); } } - return NULL; + return nullptr; } static void processor_transform_apply_threaded(uchar *byte_buffer, @@ -1963,10 +1961,10 @@ static void colormanagement_transform_ex(uchar *byte_buffer, byte_buffer, float_buffer, width, height, channels, cm_processor, predivide, false); } else { - if (byte_buffer != NULL) { + if (byte_buffer != nullptr) { IMB_colormanagement_processor_apply_byte(cm_processor, byte_buffer, width, height, channels); } - if (float_buffer != NULL) { + if (float_buffer != nullptr) { IMB_colormanagement_processor_apply( cm_processor, float_buffer, width, height, channels, predivide); } @@ -1984,7 +1982,7 @@ void IMB_colormanagement_transform(float *buffer, bool predivide) { colormanagement_transform_ex( - NULL, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, false); + nullptr, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, false); } void IMB_colormanagement_transform_threaded(float *buffer, @@ -1996,7 +1994,7 @@ void IMB_colormanagement_transform_threaded(float *buffer, bool predivide) { colormanagement_transform_ex( - NULL, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, true); + nullptr, buffer, width, height, channels, from_colorspace, to_colorspace, predivide, true); } void IMB_colormanagement_transform_byte(uchar *buffer, @@ -2007,7 +2005,7 @@ void IMB_colormanagement_transform_byte(uchar *buffer, const char *to_colorspace) { colormanagement_transform_ex( - buffer, NULL, width, height, channels, from_colorspace, to_colorspace, false, false); + buffer, nullptr, width, height, channels, from_colorspace, to_colorspace, false, false); } void IMB_colormanagement_transform_byte_threaded(uchar *buffer, int width, @@ -2017,7 +2015,7 @@ void IMB_colormanagement_transform_byte_threaded(uchar *buffer, const char *to_colorspace) { colormanagement_transform_ex( - buffer, NULL, width, height, channels, from_colorspace, to_colorspace, false, true); + buffer, nullptr, width, height, channels, from_colorspace, to_colorspace, false, true); } void IMB_colormanagement_transform_from_byte(float *float_buffer, @@ -2049,7 +2047,7 @@ void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer, const char *to_colorspace) { ColormanageProcessor *cm_processor; - if (from_colorspace == NULL || from_colorspace[0] == '\0') { + if (from_colorspace == nullptr || from_colorspace[0] == '\0') { return; } if (STREQ(from_colorspace, to_colorspace)) { @@ -2111,7 +2109,7 @@ void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpac processor = colorspace_to_scene_linear_cpu_processor(colorspace); - if (processor != NULL) { + if (processor != nullptr) { OCIO_cpuProcessorApplyRGB(processor, pixel); } } @@ -2128,7 +2126,7 @@ void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpac processor = colorspace_from_scene_linear_cpu_processor(colorspace); - if (processor != NULL) { + if (processor != nullptr) { OCIO_cpuProcessorApplyRGB(processor, pixel); } } @@ -2147,7 +2145,7 @@ void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], processor = colorspace_to_scene_linear_cpu_processor(colorspace); - if (processor != NULL) { + if (processor != nullptr) { if (predivide) { OCIO_cpuProcessorApplyRGBA_predivide(processor, pixel); } @@ -2174,7 +2172,7 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, processor = colorspace_to_scene_linear_cpu_processor(colorspace); - if (processor != NULL) { + if (processor != nullptr) { OCIO_PackedImageDesc *img; img = OCIO_createOCIO_PackedImageDesc(buffer, @@ -2182,8 +2180,8 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, height, channels, sizeof(float), - (size_t)channels * sizeof(float), - (size_t)channels * sizeof(float) * width); + size_t(channels) * sizeof(float), + size_t(channels) * sizeof(float) * width); if (predivide) { OCIO_cpuProcessorApply_predivide(processor, img); @@ -2206,7 +2204,7 @@ void IMB_colormanagement_imbuf_to_byte_texture(uchar *out_buffer, { /* Byte buffer storage, only for sRGB, scene linear and data texture since other * color space conversions can't be done on the GPU. */ - BLI_assert(ibuf->rect && ibuf->rect_float == NULL); + BLI_assert(ibuf->rect && ibuf->rect_float == nullptr); BLI_assert(IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) || IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace) || IMB_colormanagement_space_is_data(ibuf->rect_colorspace)); @@ -2252,9 +2250,9 @@ typedef struct ImbufByteToFloatData { static void imbuf_byte_to_float_cb(void *__restrict userdata, const int y, - const TaskParallelTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict /*tls*/) { - ImbufByteToFloatData *data = userdata; + ImbufByteToFloatData *data = static_cast(userdata); const size_t in_offset = data->offset + y * data->stride; const size_t out_offset = y * data->width; @@ -2339,17 +2337,16 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, OCIO_ConstCPUProcessorRcPtr *processor = (ibuf->rect_colorspace) ? colorspace_to_scene_linear_cpu_processor( ibuf->rect_colorspace) : - NULL; + nullptr; - ImbufByteToFloatData data = { - .processor = processor, - .width = width, - .offset = offset_y * ibuf->x + offset_x, - .stride = ibuf->x, - .in_buffer = in_buffer, - .out_buffer = out_buffer, - .use_premultiply = use_premultiply, - }; + ImbufByteToFloatData data = {}; + data.processor = processor; + data.width = width; + data.offset = offset_y * ibuf->x + offset_x; + data.stride = ibuf->x; + data.in_buffer = in_buffer; + data.out_buffer = out_buffer; + data.use_premultiply = use_premultiply; TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); @@ -2369,7 +2366,7 @@ void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3] OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor( global_role_scene_linear, global_role_color_picking); - if (processor != NULL) { + if (processor != nullptr) { global_color_picking_state.cpu_processor_to = OCIO_processorGetCPUProcessor(processor); OCIO_processorRelease(processor); } @@ -2399,7 +2396,7 @@ void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3], OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor( global_role_color_picking, global_role_scene_linear); - if (processor != NULL) { + if (processor != nullptr) { global_color_picking_state.cpu_processor_from = OCIO_processorGetCPUProcessor(processor); OCIO_processorRelease(processor); } @@ -2422,7 +2419,7 @@ void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManaged { OCIO_ConstCPUProcessorRcPtr *processor = display_from_scene_linear_processor(display); - if (processor != NULL) { + if (processor != nullptr) { OCIO_cpuProcessorApplyRGB(processor, pixel); } } @@ -2431,7 +2428,7 @@ void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManaged { OCIO_ConstCPUProcessorRcPtr *processor = display_to_scene_linear_processor(display); - if (processor != NULL) { + if (processor != nullptr) { OCIO_cpuProcessorApplyRGB(processor, pixel); } } @@ -2506,12 +2503,12 @@ static ImBuf *imbuf_ensure_editable(ImBuf *ibuf, ImBuf *colormanaged_ibuf, bool * but it's re-using byte and float buffers from render result make copy of this buffers * here sine this buffers would be transformed to other color space here. */ if (ibuf->rect && (ibuf->mall & IB_rect) == 0) { - ibuf->rect = MEM_dupallocN(ibuf->rect); + ibuf->rect = static_cast(MEM_dupallocN(ibuf->rect)); ibuf->mall |= IB_rect; } if (ibuf->rect_float && (ibuf->mall & IB_rectfloat) == 0) { - ibuf->rect_float = MEM_dupallocN(ibuf->rect_float); + ibuf->rect_float = static_cast(MEM_dupallocN(ibuf->rect_float)); ibuf->mall |= IB_rectfloat; } @@ -2527,7 +2524,8 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, /* Update byte buffer if exists but invalid. */ if (ibuf->rect_float && ibuf->rect && - (ibuf->userflags & (IB_DISPLAY_BUFFER_INVALID | IB_RECT_INVALID)) != 0) { + (ibuf->userflags & (IB_DISPLAY_BUFFER_INVALID | IB_RECT_INVALID)) != 0) + { IMB_rect_from_float(ibuf); ibuf->userflags &= ~(IB_RECT_INVALID | IB_DISPLAY_BUFFER_INVALID); } @@ -2581,7 +2579,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, if (colormanaged_ibuf->rect_float) { /* Float buffer isn't linear anymore, * image format write callback should check for this flag and assume - * no space conversion should happen if ibuf->float_colorspace != NULL. */ + * no space conversion should happen if ibuf->float_colorspace != nullptr. */ colormanaged_ibuf->float_colorspace = display_transform_get_colorspace( &image_format->view_settings, &image_format->display_settings); if (byte_output) { @@ -2679,10 +2677,10 @@ uchar *IMB_display_buffer_acquire(ImBuf *ibuf, ColorManagedViewSettings default_view_settings; const ColorManagedViewSettings *applied_view_settings; - *cache_handle = NULL; + *cache_handle = nullptr; if (!ibuf->x || !ibuf->y) { - return NULL; + return nullptr; } if (view_settings) { @@ -2698,7 +2696,7 @@ uchar *IMB_display_buffer_acquire(ImBuf *ibuf, /* early out: no float buffer and byte buffer is already in display space, * let's just use if */ - if (ibuf->rect_float == NULL && ibuf->rect_colorspace && ibuf->channels == 4) { + if (ibuf->rect_float == nullptr && ibuf->rect_colorspace && ibuf->channels == 4) { if (is_ibuf_rect_in_display_space(ibuf, applied_view_settings, display_settings)) { return (uchar *)ibuf->rect; } @@ -2730,8 +2728,8 @@ uchar *IMB_display_buffer_acquire(ImBuf *ibuf, /* ensure color management bit fields exists */ if (!ibuf->display_buffer_flags) { - ibuf->display_buffer_flags = MEM_callocN(sizeof(uint) * global_tot_display, - "imbuf display_buffer_flags"); + ibuf->display_buffer_flags = static_cast( + MEM_callocN(sizeof(uint) * global_tot_display, "imbuf display_buffer_flags")); } else if (ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) { /* all display buffers were marked as invalid from other areas, @@ -2750,8 +2748,8 @@ uchar *IMB_display_buffer_acquire(ImBuf *ibuf, return display_buffer; } - buffer_size = DISPLAY_BUFFER_CHANNELS * ((size_t)ibuf->x) * ibuf->y * sizeof(char); - display_buffer = MEM_callocN(buffer_size, "imbuf display buffer"); + buffer_size = DISPLAY_BUFFER_CHANNELS * size_t(ibuf->x) * ibuf->y * sizeof(char); + display_buffer = static_cast(MEM_callocN(buffer_size, "imbuf display buffer")); colormanage_display_buffer_process( ibuf, display_buffer, applied_view_settings, display_settings); @@ -2787,9 +2785,9 @@ void IMB_display_buffer_transform_apply(uchar *display_buffer, ColormanageProcessor *cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); - buffer = MEM_mallocN((size_t)channels * width * height * sizeof(float), - "display transform temp buffer"); - memcpy(buffer, linear_buffer, (size_t)channels * width * height * sizeof(float)); + buffer = static_cast(MEM_mallocN(size_t(channels) * width * height * sizeof(float), + "display transform temp buffer")); + memcpy(buffer, linear_buffer, size_t(channels) * width * height * sizeof(float)); IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide); @@ -2844,7 +2842,7 @@ ColorManagedDisplay *colormanage_display_get_default(void) const char *display_name = colormanage_display_get_default_name(); if (display_name[0] == '\0') { - return NULL; + return nullptr; } return colormanage_display_get_named(display_name); @@ -2856,12 +2854,12 @@ ColorManagedDisplay *colormanage_display_add(const char *name) int index = 0; if (global_displays.last) { - ColorManagedDisplay *last_display = global_displays.last; + ColorManagedDisplay *last_display = static_cast(global_displays.last); index = last_display->index; } - display = MEM_callocN(sizeof(ColorManagedDisplay), "ColorManagedDisplay"); + display = MEM_cnew("ColorManagedDisplay"); display->index = index + 1; @@ -2874,21 +2872,19 @@ ColorManagedDisplay *colormanage_display_add(const char *name) ColorManagedDisplay *colormanage_display_get_named(const char *name) { - ColorManagedDisplay *display; - - for (display = global_displays.first; display; display = display->next) { + LISTBASE_FOREACH (ColorManagedDisplay *, display, &global_displays) { if (STREQ(display->name, name)) { return display; } } - return NULL; + return nullptr; } ColorManagedDisplay *colormanage_display_get_indexed(int index) { /* display indices are 1-based */ - return BLI_findlink(&global_displays, index - 1); + return static_cast(BLI_findlink(&global_displays, index - 1)); } int IMB_colormanagement_display_get_named_index(const char *name) @@ -2914,7 +2910,7 @@ const char *IMB_colormanagement_display_get_indexed_name(int index) return display->name; } - return NULL; + return nullptr; } const char *IMB_colormanagement_display_get_default_name(void) @@ -2931,7 +2927,7 @@ ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name) const char *IMB_colormanagement_display_get_none_name(void) { - if (colormanage_display_get_named("None") != NULL) { + if (colormanage_display_get_named("None") != nullptr) { return "None"; } @@ -2953,9 +2949,7 @@ const char *IMB_colormanagement_display_get_default_view_transform_name( const char *colormanage_view_get_default_name(const ColorManagedDisplay *display) { OCIO_ConstConfigRcPtr *config = OCIO_getCurrentConfig(); - const char *name; - - name = OCIO_configGetDefaultView(config, display->name); + const char *name = OCIO_configGetDefaultView(config, display->name); OCIO_configRelease(config); @@ -2967,7 +2961,7 @@ ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *displa const char *name = colormanage_view_get_default_name(display); if (!name || name[0] == '\0') { - return NULL; + return nullptr; } return colormanage_view_get_named(name); @@ -2978,7 +2972,7 @@ ColorManagedView *colormanage_view_add(const char *name) ColorManagedView *view; int index = global_tot_view; - view = MEM_callocN(sizeof(ColorManagedView), "ColorManagedView"); + view = MEM_cnew("ColorManagedView"); view->index = index + 1; BLI_strncpy(view->name, name, sizeof(view->name)); @@ -2991,37 +2985,35 @@ ColorManagedView *colormanage_view_add(const char *name) ColorManagedView *colormanage_view_get_named(const char *name) { - ColorManagedView *view; - - for (view = global_views.first; view; view = view->next) { + LISTBASE_FOREACH (ColorManagedView *, view, &global_views) { if (STREQ(view->name, name)) { return view; } } - return NULL; + return nullptr; } ColorManagedView *colormanage_view_get_indexed(int index) { /* view transform indices are 1-based */ - return BLI_findlink(&global_views, index - 1); + return static_cast(BLI_findlink(&global_views, index - 1)); } ColorManagedView *colormanage_view_get_named_for_display(const char *display_name, const char *name) { ColorManagedDisplay *display = colormanage_display_get_named(display_name); - if (display == NULL) { - return NULL; + if (display == nullptr) { + return nullptr; } LISTBASE_FOREACH (LinkData *, view_link, &display->views) { - ColorManagedView *view = view_link->data; + ColorManagedView *view = static_cast(view_link->data); if (STRCASEEQ(name, view->name)) { return view; } } - return NULL; + return nullptr; } int IMB_colormanagement_view_get_named_index(const char *name) @@ -3043,13 +3035,13 @@ const char *IMB_colormanagement_view_get_indexed_name(int index) return view->name; } - return NULL; + return nullptr; } const char *IMB_colormanagement_view_get_default_name(const char *display_name) { ColorManagedDisplay *display = colormanage_display_get_named(display_name); - ColorManagedView *view = NULL; + ColorManagedView *view = nullptr; if (display) { view = colormanage_view_get_default(display); @@ -3059,7 +3051,7 @@ const char *IMB_colormanagement_view_get_default_name(const char *display_name) return view->name; } - return NULL; + return nullptr; } /** \} */ @@ -3072,7 +3064,7 @@ static void colormanage_description_strip(char *description) { int i, n; - for (i = (int)strlen(description) - 1; i >= 0; i--) { + for (i = int(strlen(description)) - 1; i >= 0; i--) { if (ELEM(description[i], '\r', '\n')) { description[i] = '\0'; } @@ -3096,7 +3088,7 @@ ColorSpace *colormanage_colorspace_add(const char *name, ColorSpace *colorspace, *prev_space; int counter = 1; - colorspace = MEM_callocN(sizeof(ColorSpace), "ColorSpace"); + colorspace = MEM_cnew("ColorSpace"); BLI_strncpy(colorspace->name, name, sizeof(colorspace->name)); @@ -3109,7 +3101,9 @@ ColorSpace *colormanage_colorspace_add(const char *name, colorspace->is_invertible = is_invertible; colorspace->is_data = is_data; - for (prev_space = global_colorspaces.first; prev_space; prev_space = prev_space->next) { + for (prev_space = static_cast(global_colorspaces.first); prev_space; + prev_space = prev_space->next) + { if (BLI_strcasecmp(prev_space->name, colorspace->name) > 0) { break; } @@ -3136,9 +3130,7 @@ ColorSpace *colormanage_colorspace_add(const char *name, ColorSpace *colormanage_colorspace_get_named(const char *name) { - ColorSpace *colorspace; - - for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) { + LISTBASE_FOREACH (ColorSpace *, colorspace, &global_colorspaces) { if (STREQ(colorspace->name, name)) { return colorspace; } @@ -3150,7 +3142,7 @@ ColorSpace *colormanage_colorspace_get_named(const char *name) } } - return NULL; + return nullptr; } ColorSpace *colormanage_colorspace_get_roled(int role) @@ -3163,14 +3155,12 @@ ColorSpace *colormanage_colorspace_get_roled(int role) ColorSpace *colormanage_colorspace_get_indexed(int index) { /* color space indices are 1-based */ - return BLI_findlink(&global_colorspaces, index - 1); + return static_cast(BLI_findlink(&global_colorspaces, index - 1)); } int IMB_colormanagement_colorspace_get_named_index(const char *name) { - ColorSpace *colorspace; - - colorspace = colormanage_colorspace_get_named(name); + ColorSpace *colorspace = colormanage_colorspace_get_named(name); if (colorspace) { return colorspace->index; @@ -3181,9 +3171,7 @@ int IMB_colormanagement_colorspace_get_named_index(const char *name) const char *IMB_colormanagement_colorspace_get_indexed_name(int index) { - ColorSpace *colorspace; - - colorspace = colormanage_colorspace_get_indexed(index); + ColorSpace *colorspace = colormanage_colorspace_get_indexed(index); if (colorspace) { return colorspace->name; @@ -3209,8 +3197,8 @@ void IMB_colormanagement_colorspace_from_ibuf_ftype( /* Get color space from file type. */ const ImFileType *type = IMB_file_type_from_ibuf(ibuf); - if (type != NULL) { - if (type->save != NULL) { + if (type != nullptr) { + if (type->save != nullptr) { const char *role_colorspace = IMB_colormanagement_role_colorspace_name_get( type->default_save_role); BLI_strncpy(colorspace_settings->name, role_colorspace, sizeof(colorspace_settings->name)); @@ -3229,7 +3217,7 @@ ColorManagedLook *colormanage_look_add(const char *name, const char *process_spa ColorManagedLook *look; int index = global_tot_looks; - look = MEM_callocN(sizeof(ColorManagedLook), "ColorManagedLook"); + look = MEM_cnew("ColorManagedLook"); look->index = index + 1; BLI_strncpy(look->name, name, sizeof(look->name)); BLI_strncpy(look->ui_name, name, sizeof(look->ui_name)); @@ -3252,28 +3240,24 @@ ColorManagedLook *colormanage_look_add(const char *name, const char *process_spa ColorManagedLook *colormanage_look_get_named(const char *name) { - ColorManagedLook *look; - - for (look = global_looks.first; look; look = look->next) { + LISTBASE_FOREACH (ColorManagedLook *, look, &global_looks) { if (STREQ(look->name, name)) { return look; } } - return NULL; + return nullptr; } ColorManagedLook *colormanage_look_get_indexed(int index) { /* look indices are 1-based */ - return BLI_findlink(&global_looks, index - 1); + return static_cast(BLI_findlink(&global_looks, index - 1)); } int IMB_colormanagement_look_get_named_index(const char *name) { - ColorManagedLook *look; - - look = colormanage_look_get_named(name); + ColorManagedLook *look = colormanage_look_get_named(name); if (look) { return look->index; @@ -3292,7 +3276,7 @@ const char *IMB_colormanagement_look_get_indexed_name(int index) return look->name; } - return NULL; + return nullptr; } /** \} */ @@ -3303,9 +3287,7 @@ const char *IMB_colormanagement_look_get_indexed_name(int index) void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem) { - ColorManagedDisplay *display; - - for (display = global_displays.first; display; display = display->next) { + LISTBASE_FOREACH (ColorManagedDisplay *, display, &global_displays) { EnumPropertyItem item; item.value = display->index; @@ -3338,13 +3320,10 @@ void IMB_colormanagement_view_items_add(EnumPropertyItem **items, const char *display_name) { ColorManagedDisplay *display = colormanage_display_get_named(display_name); - ColorManagedView *view; if (display) { - LinkData *display_view; - - for (display_view = display->views.first; display_view; display_view = display_view->next) { - view = display_view->data; + LISTBASE_FOREACH (LinkData *, display_view, &display->views) { + ColorManagedView *view = static_cast(display_view->data); colormanagement_view_item_add(items, totitem, view); } @@ -3355,9 +3334,7 @@ void IMB_colormanagement_look_items_add(struct EnumPropertyItem **items, int *totitem, const char *view_name) { - ColorManagedLook *look; - - for (look = global_looks.first; look; look = look->next) { + LISTBASE_FOREACH (ColorManagedLook *, look, &global_looks) { if (!colormanage_compatible_look(look, view_name)) { continue; } @@ -3376,9 +3353,7 @@ void IMB_colormanagement_look_items_add(struct EnumPropertyItem **items, void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem) { - ColorSpace *colorspace; - - for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) { + LISTBASE_FOREACH (ColorSpace *, colorspace, &global_colorspaces) { EnumPropertyItem item; if (!colorspace->is_invertible) { @@ -3430,13 +3405,13 @@ static void partial_buffer_update_rect(ImBuf *ibuf, int channels = ibuf->channels; float dither = ibuf->dither; ColorSpace *rect_colorspace = ibuf->rect_colorspace; - float *display_buffer_float = NULL; + float *display_buffer_float = nullptr; const int width = xmax - xmin; const int height = ymax - ymin; bool is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0; if (dither != 0.0f) { - /* cm_processor is NULL in cases byte_buffer's space matches display + /* cm_processor is nullptr in cases byte_buffer's space matches display * buffer's space * in this case we could skip extra transform and only apply dither * use 4 channels for easier byte->float->byte conversion here so @@ -3447,15 +3422,15 @@ static void partial_buffer_update_rect(ImBuf *ibuf, channels = 4; } - display_buffer_float = MEM_callocN((size_t)channels * width * height * sizeof(float), - "display buffer for dither"); + display_buffer_float = static_cast(MEM_callocN( + size_t(channels) * width * height * sizeof(float), "display buffer for dither")); } if (cm_processor) { for (y = ymin; y < ymax; y++) { for (x = xmin; x < xmax; x++) { - size_t display_index = ((size_t)y * display_stride + x) * 4; - size_t linear_index = ((size_t)(y - linear_offset_y) * linear_stride + + size_t display_index = (size_t(y) * display_stride + x) * 4; + size_t linear_index = (size_t(y - linear_offset_y) * linear_stride + (x - linear_offset_x)) * channels; float pixel[4]; @@ -3486,7 +3461,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, } if (display_buffer_float) { - size_t index = ((size_t)(y - ymin) * width + (x - xmin)) * channels; + size_t index = (size_t(y - ymin) * width + (x - xmin)) * channels; if (channels == 4) { copy_v4_v4(display_buffer_float + index, pixel); @@ -3534,8 +3509,8 @@ static void partial_buffer_update_rect(ImBuf *ibuf, int i; for (i = ymin; i < ymax; i++) { - size_t byte_offset = ((size_t)linear_stride * i + xmin) * 4; - size_t display_offset = ((size_t)display_stride * i + xmin) * 4; + size_t byte_offset = (size_t(linear_stride) * i + xmin) * 4; + size_t display_offset = (size_t(display_stride) * i + xmin) * 4; memcpy( display_buffer + display_offset, byte_buffer + byte_offset, sizeof(char[4]) * width); @@ -3544,7 +3519,7 @@ static void partial_buffer_update_rect(ImBuf *ibuf, } if (display_buffer_float) { - size_t display_index = ((size_t)ymin * display_stride + xmin) * channels; + size_t display_index = (size_t(ymin) * display_stride + xmin) * channels; IMB_buffer_byte_from_float(display_buffer + display_index, display_buffer_float, @@ -3611,8 +3586,8 @@ static void imb_partial_display_buffer_update_ex( { ColormanageCacheViewSettings cache_view_settings; ColormanageCacheDisplaySettings cache_display_settings; - void *cache_handle = NULL; - uchar *display_buffer = NULL; + void *cache_handle = nullptr; + uchar *display_buffer = nullptr; int buffer_width = ibuf->x; if (ibuf->display_buffer_flags) { @@ -3645,7 +3620,7 @@ static void imb_partial_display_buffer_update_ex( } if (display_buffer) { - ColormanageProcessor *cm_processor = NULL; + ColormanageProcessor *cm_processor = nullptr; bool skip_transform = false; /* Byte buffer is assumed to be in imbuf's rect space, so if byte buffer @@ -3655,7 +3630,7 @@ static void imb_partial_display_buffer_update_ex( * But if there's a float buffer it's likely operation was performed on * it first and byte buffer is likely to be out of date here. */ - if (linear_buffer == NULL && byte_buffer != NULL) { + if (linear_buffer == nullptr && byte_buffer != nullptr) { skip_transform = is_ibuf_rect_in_display_space(ibuf, view_settings, display_settings); } @@ -3748,7 +3723,7 @@ void IMB_partial_display_buffer_update_threaded( { int width = xmax - xmin; int height = ymax - ymin; - bool do_threads = (((size_t)width) * height >= 64 * 64); + bool do_threads = (size_t(width) * height >= 64 * 64); imb_partial_display_buffer_update_ex(ibuf, linear_buffer, byte_buffer, @@ -3791,7 +3766,7 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new( const ColorManagedViewSettings *applied_view_settings; ColorSpace *display_space; - cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor"); + cm_processor = MEM_cnew("colormanagement processor"); if (view_settings) { applied_view_settings = view_settings; @@ -3828,14 +3803,14 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f ColormanageProcessor *cm_processor; ColorSpace *color_space; - cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor"); + cm_processor = MEM_cnew("colormanagement processor"); color_space = colormanage_colorspace_get_named(to_colorspace); cm_processor->is_data_result = color_space->is_data; OCIO_ConstProcessorRcPtr *processor = create_colorspace_transform_processor(from_colorspace, to_colorspace); - if (processor != NULL) { + if (processor != nullptr) { cm_processor->cpu_processor = OCIO_processorGetCPUProcessor(processor); } OCIO_processorRelease(processor); @@ -3911,7 +3886,7 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - float *pixel = buffer + channels * (((size_t)y) * width + x); + float *pixel = buffer + channels * (size_t(y) * width + x); curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, channels); } @@ -3927,8 +3902,8 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, height, channels, sizeof(float), - (size_t)channels * sizeof(float), - (size_t)channels * sizeof(float) * width); + size_t(channels) * sizeof(float), + size_t(channels) * sizeof(float) * width); if (predivide) { OCIO_cpuProcessorApply_predivide(cm_processor->cpu_processor, img); @@ -3951,7 +3926,7 @@ void IMB_colormanagement_processor_apply_byte( float pixel[4]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - size_t offset = channels * (((size_t)y) * width + x); + size_t offset = channels * (size_t(y) * width + x); rgba_uchar_to_float(pixel, buffer + offset); IMB_colormanagement_processor_apply_v4(cm_processor, pixel); rgba_float_to_uchar(buffer + offset, pixel); @@ -4003,7 +3978,7 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping, copy_v3_v3(curve_mapping_settings->black, curve_mapping->black); copy_v3_v3(curve_mapping_settings->bwmul, curve_mapping->bwmul); - curve_mapping_settings->cache_id = (size_t)curve_mapping + curve_mapping->changed_timestamp; + curve_mapping_settings->cache_id = size_t(curve_mapping) + curve_mapping->changed_timestamp; } static OCIO_CurveMappingSettings *update_glsl_curve_mapping( @@ -4012,19 +3987,20 @@ static OCIO_CurveMappingSettings *update_glsl_curve_mapping( /* Using curve mapping? */ const bool use_curve_mapping = (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) != 0; if (!use_curve_mapping) { - return NULL; + return nullptr; } /* Already up to date? */ OCIO_CurveMappingSettings *curve_mapping_settings = &global_gpu_state.curve_mapping_settings; if (view_settings->curve_mapping->changed_timestamp == global_gpu_state.curve_mapping_timestamp && - view_settings->curve_mapping == global_gpu_state.orig_curve_mapping) { + view_settings->curve_mapping == global_gpu_state.orig_curve_mapping) + { return curve_mapping_settings; } /* Need to update. */ - CurveMapping *new_curve_mapping = NULL; + CurveMapping *new_curve_mapping = nullptr; /* We're using curve mapping's address as a cache ID, * so we need to make sure re-allocation gives new address here. @@ -4036,8 +4012,8 @@ static OCIO_CurveMappingSettings *update_glsl_curve_mapping( if (global_gpu_state.curve_mapping) { BKE_curvemapping_free(global_gpu_state.curve_mapping); MEM_freeN(curve_mapping_settings->lut); - global_gpu_state.curve_mapping = NULL; - curve_mapping_settings->lut = NULL; + global_gpu_state.curve_mapping = nullptr; + curve_mapping_settings->lut = nullptr; } /* Fill in OCIO's curve mapping settings. */ @@ -4050,14 +4026,14 @@ static OCIO_CurveMappingSettings *update_glsl_curve_mapping( global_gpu_state.use_curve_mapping = true; } else { - global_gpu_state.orig_curve_mapping = NULL; + global_gpu_state.orig_curve_mapping = nullptr; global_gpu_state.use_curve_mapping = false; } return curve_mapping_settings; } -bool IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings *UNUSED(view_settings)) +bool IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings * /*view_settings*/) { return OCIO_supportGPUShader(); } @@ -4125,7 +4101,7 @@ bool IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_se bool predivide) { return IMB_colormanagement_setup_glsl_draw_from_space( - view_settings, display_settings, NULL, dither, predivide, false); + view_settings, display_settings, nullptr, dither, predivide, false); } bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C, @@ -4144,7 +4120,7 @@ bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C, bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide) { - return IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, NULL, dither, predivide); + return IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, nullptr, dither, predivide); } void IMB_colormanagement_finish_glsl_draw(void) @@ -4231,7 +4207,7 @@ void IMB_colormanagement_blackbody_temperature_to_rgb_table(float *r_table, const float max) { for (int i = 0; i < width; i++) { - float temperature = min + (max - min) / (float)width * (float)i; + float temperature = min + (max - min) / float(width) * float(i); float rec709[3]; blackbody_temperature_to_rec709(rec709, temperature); @@ -4289,7 +4265,7 @@ static float cie_colour_match[81][3] = { static void wavelength_to_xyz(float xyz[3], float lambda_nm) { float ii = (lambda_nm - 380.0f) * (1.0f / 5.0f); /* Scaled 0..80. */ - int i = (int)ii; + int i = int(ii); if (i < 0 || i >= 80) { xyz[0] = 0.0f; @@ -4297,7 +4273,7 @@ static void wavelength_to_xyz(float xyz[3], float lambda_nm) xyz[2] = 0.0f; } else { - ii -= (float)i; + ii -= float(i); const float *c = cie_colour_match[i]; xyz[0] = c[0] + ii * (c[3] - c[0]); xyz[1] = c[1] + ii * (c[4] - c[1]); @@ -4308,7 +4284,7 @@ static void wavelength_to_xyz(float xyz[3], float lambda_nm) void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, const int width) { for (int i = 0; i < width; i++) { - float temperature = 380 + 400 / (float)width * (float)i; + float temperature = 380 + 400 / float(width) * float(i); float xyz[3]; wavelength_to_xyz(xyz, temperature); diff --git a/source/blender/imbuf/intern/colormanagement_inline.c b/source/blender/imbuf/intern/colormanagement_inline.h similarity index 100% rename from source/blender/imbuf/intern/colormanagement_inline.c rename to source/blender/imbuf/intern/colormanagement_inline.h diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 7e147645c98..a97c169e4e2 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -532,7 +532,8 @@ static uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, ui for (int i = 0; i < s_d3dFormatCount; i++) { if (s_d3dFormats[i].bitcount == bitcount && s_d3dFormats[i].rmask == rmask && s_d3dFormats[i].gmask == gmask && s_d3dFormats[i].bmask == bmask && - s_d3dFormats[i].amask == amask) { + s_d3dFormats[i].amask == amask) + { return s_d3dFormats[i].format; } } @@ -690,7 +691,8 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask { /* Make sure the masks are correct. */ if ((rmask & gmask) || (rmask & bmask) || (rmask & amask) || (gmask & bmask) || - (gmask & amask) || (bmask & amask)) { + (gmask & amask) || (bmask & amask)) + { printf("DDS: bad RGBA masks, pixel format not set\n"); return; } @@ -912,7 +914,8 @@ bool DirectDrawSurface::isSupported() const DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC4_UNORM, - DXGI_FORMAT_BC5_UNORM)) { + DXGI_FORMAT_BC5_UNORM)) + { return true; } @@ -928,7 +931,8 @@ bool DirectDrawSurface::isSupported() const FOURCC_DXT5, FOURCC_RXGB, FOURCC_ATI1, - FOURCC_ATI2)) { + FOURCC_ATI2)) + { /* Unknown fourcc code. */ return false; } @@ -941,7 +945,8 @@ bool DirectDrawSurface::isSupported() const } if (isTextureCube() && - (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) { + (header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) + { /* Cube-maps must contain all faces. */ return false; } @@ -968,7 +973,8 @@ bool DirectDrawSurface::hasAlpha() const } if (header.pf.flags & DDPF_FOURCC) { if (header.pf.fourcc == FOURCC_RXGB || header.pf.fourcc == FOURCC_ATI1 || - header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) { + header.pf.fourcc == FOURCC_ATI2 || header.pf.flags & DDPF_NORMAL) + { return false; } @@ -1244,7 +1250,8 @@ void DirectDrawSurface::readBlock(ColorBlock *rgba) block.decodeBlock(rgba); } else if (fourcc == FOURCC_DXT4 || header.pf.fourcc == FOURCC_DXT5 || - header.pf.fourcc == FOURCC_RXGB) { + header.pf.fourcc == FOURCC_RXGB) + { BlockDXT5 block; mem_read(stream, block); block.decodeBlock(rgba); diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.cc similarity index 88% rename from source/blender/imbuf/intern/divers.c rename to source/blender/imbuf/intern/divers.cc index 61ef9c111d7..bdc7563e5ef 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.cc @@ -31,7 +31,7 @@ static DitherContext *create_dither_context(float dither) { DitherContext *di; - di = MEM_mallocN(sizeof(DitherContext), "dithering context"); + di = MEM_cnew("dithering context"); di->dither = dither; return di; @@ -64,7 +64,7 @@ MINLINE uchar ftochar(float value) MINLINE void ushort_to_byte_dither_v4( uchar b[4], const ushort us[4], DitherContext *di, float s, float t) { -#define USHORTTOFLOAT(val) ((float)val / 65535.0f) +#define USHORTTOFLOAT(val) (float(val) / 65535.0f) float dither_value = dither_random_value(s, t) * 0.0033f * di->dither; b[0] = ftochar(dither_value + USHORTTOFLOAT(us[0])); @@ -105,7 +105,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, { float tmp[4]; int x, y; - DitherContext *di = NULL; + DitherContext *di = nullptr; float inv_width = 1.0f / width; float inv_height = 1.0f / height; @@ -122,8 +122,8 @@ void IMB_buffer_byte_from_float(uchar *rect_to, if (channels_from == 1) { /* single channel input */ - const float *from = rect_from + ((size_t)stride_from) * y; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y; + uchar *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from++, to += 4) { to[0] = to[1] = to[2] = to[3] = unit_float_to_uchar_clamp(from[0]); @@ -131,8 +131,8 @@ void IMB_buffer_byte_from_float(uchar *rect_to, } else if (channels_from == 3) { /* RGB input */ - const float *from = rect_from + ((size_t)stride_from) * y * 3; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 3; + uchar *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { /* no color space conversion */ @@ -160,8 +160,8 @@ void IMB_buffer_byte_from_float(uchar *rect_to, } else if (channels_from == 4) { /* RGBA input */ - const float *from = rect_from + ((size_t)stride_from) * y * 4; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 4; + uchar *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { float straight[4]; @@ -170,12 +170,12 @@ void IMB_buffer_byte_from_float(uchar *rect_to, if (dither && predivide) { for (x = 0; x < width; x++, from += 4, to += 4) { premul_to_straight_v4_v4(straight, from); - float_to_byte_dither_v4(to, straight, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, straight, di, float(x) * inv_width, t); } } else if (dither) { for (x = 0; x < width; x++, from += 4, to += 4) { - float_to_byte_dither_v4(to, from, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, from, di, float(x) * inv_width, t); } } else if (predivide) { @@ -199,13 +199,13 @@ void IMB_buffer_byte_from_float(uchar *rect_to, for (x = 0; x < width; x++, from += 4, to += 4) { premul_to_straight_v4_v4(straight, from); linearrgb_to_srgb_ushort4(us, from); - ushort_to_byte_dither_v4(to, us, di, (float)x * inv_width, t); + ushort_to_byte_dither_v4(to, us, di, float(x) * inv_width, t); } } else if (dither) { for (x = 0; x < width; x++, from += 4, to += 4) { linearrgb_to_srgb_ushort4(us, from); - ushort_to_byte_dither_v4(to, us, di, (float)x * inv_width, t); + ushort_to_byte_dither_v4(to, us, di, float(x) * inv_width, t); } } else if (predivide) { @@ -227,13 +227,13 @@ void IMB_buffer_byte_from_float(uchar *rect_to, if (dither && predivide) { for (x = 0; x < width; x++, from += 4, to += 4) { srgb_to_linearrgb_predivide_v4(tmp, from); - float_to_byte_dither_v4(to, tmp, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, tmp, di, float(x) * inv_width, t); } } else if (dither) { for (x = 0; x < width; x++, from += 4, to += 4) { srgb_to_linearrgb_v4(tmp, from); - float_to_byte_dither_v4(to, tmp, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, tmp, di, float(x) * inv_width, t); } } else if (predivide) { @@ -269,7 +269,7 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, char *mask) { int x, y; - DitherContext *di = NULL; + DitherContext *di = nullptr; float inv_width = 1.0f / width, inv_height = 1.0f / height; if (dither) { @@ -281,8 +281,8 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, if (channels_from == 1) { /* single channel input */ - const float *from = rect_from + ((size_t)stride_from) * y; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y; + uchar *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from++, to += 4) { if (*mask++ == FILTER_MASK_USED) { @@ -292,8 +292,8 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, } else if (channels_from == 3) { /* RGB input */ - const float *from = rect_from + ((size_t)stride_from) * y * 3; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 3; + uchar *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from += 3, to += 4) { if (*mask++ == FILTER_MASK_USED) { @@ -304,8 +304,8 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, } else if (channels_from == 4) { /* RGBA input */ - const float *from = rect_from + ((size_t)stride_from) * y * 4; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 4; + uchar *to = rect_to + size_t(stride_to) * y * 4; float straight[4]; @@ -313,14 +313,14 @@ void IMB_buffer_byte_from_float_mask(uchar *rect_to, for (x = 0; x < width; x++, from += 4, to += 4) { if (*mask++ == FILTER_MASK_USED) { premul_to_straight_v4_v4(straight, from); - float_to_byte_dither_v4(to, straight, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, straight, di, float(x) * inv_width, t); } } } else if (dither) { for (x = 0; x < width; x++, from += 4, to += 4) { if (*mask++ == FILTER_MASK_USED) { - float_to_byte_dither_v4(to, from, di, (float)x * inv_width, t); + float_to_byte_dither_v4(to, from, di, float(x) * inv_width, t); } } } @@ -366,8 +366,8 @@ void IMB_buffer_float_from_byte(float *rect_to, /* RGBA input */ for (y = 0; y < height; y++) { - const uchar *from = rect_from + ((size_t)stride_from) * y * 4; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const uchar *from = rect_from + size_t(stride_from) * y * 4; + float *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { /* no color space conversion */ @@ -426,8 +426,8 @@ void IMB_buffer_float_from_float(float *rect_to, if (channels_from == 1) { /* single channel input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y; + float *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from++, to += 4) { to[0] = to[1] = to[2] = to[3] = from[0]; @@ -437,8 +437,8 @@ void IMB_buffer_float_from_float(float *rect_to, else if (channels_from == 3) { /* RGB input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y * 3; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 3; + float *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { /* no color space conversion */ @@ -466,12 +466,12 @@ void IMB_buffer_float_from_float(float *rect_to, else if (channels_from == 4) { /* RGBA input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y * 4; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 4; + float *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { /* same profile, copy */ - memcpy(to, from, sizeof(float) * ((size_t)4) * width); + memcpy(to, from, sizeof(float) * size_t(4) * width); } else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert to sRGB to linear */ @@ -519,8 +519,8 @@ static void imb_buffer_float_from_float_thread_do(void *data_v, int scanline) { const int num_scanlines = 1; FloatToFloatThreadData *data = (FloatToFloatThreadData *)data_v; - size_t offset_from = ((size_t)scanline) * data->stride_from * data->channels_from; - size_t offset_to = ((size_t)scanline) * data->stride_to * data->channels_from; + size_t offset_from = size_t(scanline) * data->stride_from * data->channels_from; + size_t offset_to = size_t(scanline) * data->stride_to * data->channels_from; IMB_buffer_float_from_float(data->rect_to + offset_to, data->rect_from + offset_from, data->channels_from, @@ -544,7 +544,7 @@ void IMB_buffer_float_from_float_threaded(float *rect_to, int stride_to, int stride_from) { - if (((size_t)width) * height < 64 * 64) { + if (size_t(width) * height < 64 * 64) { IMB_buffer_float_from_float(rect_to, rect_from, channels_from, @@ -585,8 +585,8 @@ void IMB_buffer_float_from_float_mask(float *rect_to, if (channels_from == 1) { /* single channel input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y; + float *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from++, to += 4) { if (*mask++ == FILTER_MASK_USED) { @@ -598,8 +598,8 @@ void IMB_buffer_float_from_float_mask(float *rect_to, else if (channels_from == 3) { /* RGB input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y * 3; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 3; + float *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from += 3, to += 4) { if (*mask++ == FILTER_MASK_USED) { @@ -612,8 +612,8 @@ void IMB_buffer_float_from_float_mask(float *rect_to, else if (channels_from == 4) { /* RGBA input */ for (y = 0; y < height; y++) { - const float *from = rect_from + ((size_t)stride_from) * y * 4; - float *to = rect_to + ((size_t)stride_to) * y * 4; + const float *from = rect_from + size_t(stride_from) * y * 4; + float *to = rect_to + size_t(stride_to) * y * 4; for (x = 0; x < width; x++, from += 4, to += 4) { if (*mask++ == FILTER_MASK_USED) { @@ -643,8 +643,8 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, /* always RGBA input */ for (y = 0; y < height; y++) { - const uchar *from = rect_from + ((size_t)stride_from) * y * 4; - uchar *to = rect_to + ((size_t)stride_to) * y * 4; + const uchar *from = rect_from + size_t(stride_from) * y * 4; + uchar *to = rect_to + size_t(stride_to) * y * 4; if (profile_to == profile_from) { /* same profile, copy */ @@ -696,27 +696,27 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, void IMB_rect_from_float(ImBuf *ibuf) { /* verify we have a float buffer */ - if (ibuf->rect_float == NULL) { + if (ibuf->rect_float == nullptr) { return; } /* create byte rect if it didn't exist yet */ - if (ibuf->rect == NULL) { + if (ibuf->rect == nullptr) { if (imb_addrectImBuf(ibuf) == 0) { return; } } - const char *from_colorspace = (ibuf->float_colorspace == NULL) ? + const char *from_colorspace = (ibuf->float_colorspace == nullptr) ? IMB_colormanagement_role_colorspace_name_get( COLOR_ROLE_SCENE_LINEAR) : ibuf->float_colorspace->name; - const char *to_colorspace = (ibuf->rect_colorspace == NULL) ? + const char *to_colorspace = (ibuf->rect_colorspace == nullptr) ? IMB_colormanagement_role_colorspace_name_get( COLOR_ROLE_DEFAULT_BYTE) : ibuf->rect_colorspace->name; - float *buffer = MEM_dupallocN(ibuf->rect_float); + float *buffer = static_cast(MEM_dupallocN(ibuf->rect_float)); /* first make float buffer in byte space */ const bool predivide = IMB_alpha_affects_rgb(ibuf); @@ -751,9 +751,9 @@ void IMB_float_from_rect_ex(struct ImBuf *dst, const struct ImBuf *src, const rcti *region_to_update) { - BLI_assert_msg(dst->rect_float != NULL, + BLI_assert_msg(dst->rect_float != nullptr, "Destination buffer should have a float buffer assigned."); - BLI_assert_msg(src->rect != NULL, "Source buffer should have a byte buffer assigned."); + BLI_assert_msg(src->rect != nullptr, "Source buffer should have a byte buffer assigned."); BLI_assert_msg(dst->x == src->x, "Source and destination buffer should have the same dimension"); BLI_assert_msg(dst->y == src->y, "Source and destination buffer should have the same dimension"); BLI_assert_msg(dst->channels = 4, "Destination buffer should have 4 channels."); @@ -807,7 +807,7 @@ void IMB_float_from_rect(ImBuf *ibuf) float *rect_float; /* verify if we byte and float buffers */ - if (ibuf->rect == NULL) { + if (ibuf->rect == nullptr) { return; } @@ -816,11 +816,11 @@ void IMB_float_from_rect(ImBuf *ibuf) * interfere with other parts of blender */ rect_float = ibuf->rect_float; - if (rect_float == NULL) { + if (rect_float == nullptr) { const size_t size = IMB_get_rect_len(ibuf) * sizeof(float[4]); - rect_float = MEM_callocN(size, "IMB_float_from_rect"); + rect_float = static_cast(MEM_callocN(size, "IMB_float_from_rect")); - if (rect_float == NULL) { + if (rect_float == nullptr) { return; } @@ -862,7 +862,7 @@ void IMB_color_to_bw(ImBuf *ibuf) void IMB_buffer_float_unpremultiply(float *buf, int width, int height) { - size_t total = ((size_t)width) * height; + size_t total = size_t(width) * height; float *fp = buf; while (total--) { premul_to_straight_v4(fp); @@ -872,7 +872,7 @@ void IMB_buffer_float_unpremultiply(float *buf, int width, int height) void IMB_buffer_float_premultiply(float *buf, int width, int height) { - size_t total = ((size_t)width) * height; + size_t total = size_t(width) * height; float *fp = buf; while (total--) { straight_to_premul_v4(fp); diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c deleted file mode 100644 index 4548104214d..00000000000 --- a/source/blender/imbuf/intern/filetype.c +++ /dev/null @@ -1,240 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup imbuf - */ - -#include - -#include "BLI_utildefines.h" - -#include "IMB_filetype.h" -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" - -#include "IMB_colormanagement.h" - -#include "oiio/openimageio_api.h" - -#ifdef WITH_OPENEXR -# include "openexr/openexr_api.h" -#endif - -const ImFileType IMB_FILE_TYPES[] = { - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_jpeg, - .load = imb_load_jpeg, - .load_filepath = NULL, - .load_filepath_thumbnail = imb_thumbnail_jpeg, - .save = imb_savejpeg, - .flag = 0, - .filetype = IMB_FTYPE_JPG, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_png, - .load = imb_load_png, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_png, - .flag = 0, - .filetype = IMB_FTYPE_PNG, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_bmp, - .load = imb_load_bmp, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_bmp, - .flag = 0, - .filetype = IMB_FTYPE_BMP, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_tga, - .load = imb_load_tga, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_tga, - .flag = 0, - .filetype = IMB_FTYPE_TGA, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_iris, - .load = imb_loadiris, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_saveiris, - .flag = 0, - .filetype = IMB_FTYPE_IMAGIC, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, -#ifdef WITH_CINEON - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_dpx, - .load = imb_load_dpx, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_dpx, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_DPX, - .default_save_role = COLOR_ROLE_DEFAULT_FLOAT, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_cineon, - .load = imb_load_cineon, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_cineon, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_CINEON, - .default_save_role = COLOR_ROLE_DEFAULT_FLOAT, - }, -#endif - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_tiff, - .load = imb_load_tiff, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_tiff, - .flag = 0, - .filetype = IMB_FTYPE_TIF, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_hdr, - .load = imb_load_hdr, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_hdr, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_RADHDR, - .default_save_role = COLOR_ROLE_DEFAULT_FLOAT, - }, -#ifdef WITH_OPENEXR - { - .init = imb_initopenexr, - .exit = imb_exitopenexr, - .is_a = imb_is_a_openexr, - .load = imb_load_openexr, - .load_filepath = NULL, - .load_filepath_thumbnail = imb_load_filepath_thumbnail_openexr, - .save = imb_save_openexr, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_OPENEXR, - .default_save_role = COLOR_ROLE_DEFAULT_FLOAT, - }, -#endif -#ifdef WITH_OPENJPEG - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_jp2, - .load = imb_load_jp2, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = imb_save_jp2, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_JP2, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, -#endif - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_dds, - .load = imb_load_dds, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = NULL, - .flag = 0, - .filetype = IMB_FTYPE_DDS, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_psd, - .load = imb_load_psd, - .load_filepath = NULL, - .load_filepath_thumbnail = NULL, - .save = NULL, - .flag = IM_FTYPE_FLOAT, - .filetype = IMB_FTYPE_PSD, - .default_save_role = COLOR_ROLE_DEFAULT_FLOAT, - }, -#ifdef WITH_WEBP - { - .init = NULL, - .exit = NULL, - .is_a = imb_is_a_webp, - .load = imb_loadwebp, - .load_filepath = NULL, - .load_filepath_thumbnail = imb_load_filepath_thumbnail_webp, - .save = imb_savewebp, - .flag = 0, - .filetype = IMB_FTYPE_WEBP, - .default_save_role = COLOR_ROLE_DEFAULT_BYTE, - }, -#endif - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0}, -}; - -const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[ARRAY_SIZE(IMB_FILE_TYPES) - 1]; - -const ImFileType *IMB_file_type_from_ftype(int ftype) -{ - for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { - if (ftype == type->filetype) { - return type; - } - } - return NULL; -} - -const ImFileType *IMB_file_type_from_ibuf(const ImBuf *ibuf) -{ - return IMB_file_type_from_ftype(ibuf->ftype); -} - -void imb_filetypes_init(void) -{ - const ImFileType *type; - - for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { - if (type->init) { - type->init(); - } - } -} - -void imb_filetypes_exit(void) -{ - const ImFileType *type; - - for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { - if (type->exit) { - type->exit(); - } - } -} diff --git a/source/blender/imbuf/intern/filetype.cc b/source/blender/imbuf/intern/filetype.cc new file mode 100644 index 00000000000..ba5971ae1f5 --- /dev/null +++ b/source/blender/imbuf/intern/filetype.cc @@ -0,0 +1,240 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup imbuf + */ + +#include + +#include "BLI_utildefines.h" + +#include "IMB_filetype.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "IMB_colormanagement.h" + +#include "oiio/openimageio_api.h" + +#ifdef WITH_OPENEXR +# include "openexr/openexr_api.h" +#endif + +const ImFileType IMB_FILE_TYPES[] = { + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_jpeg, + /*load*/ imb_load_jpeg, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ imb_thumbnail_jpeg, + /*save*/ imb_savejpeg, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_JPG, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_png, + /*load*/ imb_load_png, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_png, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_PNG, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_bmp, + /*load*/ imb_load_bmp, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_bmp, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_BMP, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_tga, + /*load*/ imb_load_tga, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_tga, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_TGA, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_iris, + /*load*/ imb_loadiris, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_saveiris, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_IMAGIC, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, +#ifdef WITH_CINEON + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_dpx, + /*load*/ imb_load_dpx, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_dpx, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_DPX, + /*default_save_role*/ COLOR_ROLE_DEFAULT_FLOAT, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_cineon, + /*load*/ imb_load_cineon, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_cineon, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_CINEON, + /*default_save_role*/ COLOR_ROLE_DEFAULT_FLOAT, + }, +#endif + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_tiff, + /*load*/ imb_load_tiff, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_tiff, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_TIF, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_hdr, + /*load*/ imb_load_hdr, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_hdr, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_RADHDR, + /*default_save_role*/ COLOR_ROLE_DEFAULT_FLOAT, + }, +#ifdef WITH_OPENEXR + { + /*init*/ imb_initopenexr, + /*exit*/ imb_exitopenexr, + /*is_a*/ imb_is_a_openexr, + /*load*/ imb_load_openexr, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ imb_load_filepath_thumbnail_openexr, + /*save*/ imb_save_openexr, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_OPENEXR, + /*default_save_role*/ COLOR_ROLE_DEFAULT_FLOAT, + }, +#endif +#ifdef WITH_OPENJPEG + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_jp2, + /*load*/ imb_load_jp2, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ imb_save_jp2, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_JP2, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, +#endif + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_dds, + /*load*/ imb_load_dds, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ nullptr, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_DDS, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_psd, + /*load*/ imb_load_psd, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ nullptr, + /*save*/ nullptr, + /*flag*/ IM_FTYPE_FLOAT, + /*filetype*/ IMB_FTYPE_PSD, + /*default_save_role*/ COLOR_ROLE_DEFAULT_FLOAT, + }, +#ifdef WITH_WEBP + { + /*init*/ nullptr, + /*exit*/ nullptr, + /*is_a*/ imb_is_a_webp, + /*load*/ imb_loadwebp, + /*load_filepath*/ nullptr, + /*load_filepath_thumbnail*/ imb_load_filepath_thumbnail_webp, + /*save*/ imb_savewebp, + /*flag*/ 0, + /*filetype*/ IMB_FTYPE_WEBP, + /*default_save_role*/ COLOR_ROLE_DEFAULT_BYTE, + }, +#endif + {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, 0, 0}, +}; + +const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[ARRAY_SIZE(IMB_FILE_TYPES) - 1]; + +const ImFileType *IMB_file_type_from_ftype(int ftype) +{ + for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { + if (ftype == type->filetype) { + return type; + } + } + return nullptr; +} + +const ImFileType *IMB_file_type_from_ibuf(const ImBuf *ibuf) +{ + return IMB_file_type_from_ftype(ibuf->ftype); +} + +void imb_filetypes_init(void) +{ + const ImFileType *type; + + for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { + if (type->init) { + type->init(); + } + } +} + +void imb_filetypes_exit(void) +{ + const ImFileType *type; + + for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { + if (type->exit) { + type->exit(); + } + } +} diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.cc similarity index 95% rename from source/blender/imbuf/intern/filter.c rename to source/blender/imbuf/intern/filter.cc index 67de467bd93..9a6a1e4e82a 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.cc @@ -313,7 +313,7 @@ void IMB_mask_filter_extend(char *mask, int width, int height) rowlen = width; /* make a copy, to prevent flooding */ - temprect = MEM_dupallocN(mask); + temprect = static_cast(MEM_dupallocN(mask)); for (y = 1; y <= height; y++) { /* setup rows */ @@ -391,11 +391,12 @@ static int check_pixel_assigned( if (index >= 0) { const int alpha_index = depth * index + (depth - 1); - if (mask != NULL) { + if (mask != nullptr) { res = mask[index] != 0 ? 1 : 0; } else if ((is_float && ((const float *)buffer)[alpha_index] != 0.0f) || - (!is_float && ((const uchar *)buffer)[alpha_index] != 0)) { + (!is_float && ((const uchar *)buffer)[alpha_index] != 0)) + { res = 1; } } @@ -409,11 +410,11 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) const int height = ibuf->y; const int depth = 4; /* always 4 channels */ const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(uchar); - const size_t bsize = ((size_t)width) * height * depth * chsize; - const bool is_float = (ibuf->rect_float != NULL); + const size_t bsize = size_t(width) * height * depth * chsize; + const bool is_float = (ibuf->rect_float != nullptr); void *dstbuf = (void *)MEM_dupallocN(ibuf->rect_float ? (void *)ibuf->rect_float : (void *)ibuf->rect); - char *dstmask = mask == NULL ? NULL : (char *)MEM_dupallocN(mask); + char *dstmask = mask == nullptr ? nullptr : (char *)MEM_dupallocN(mask); void *srcbuf = ibuf->rect_float ? (void *)ibuf->rect_float : (void *)ibuf->rect; char *srcmask = mask; int cannot_early_out = 1, r, n, k, i, j, c; @@ -426,7 +427,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) k = 0; for (i = -n; i <= n; i++) { for (j = -n; j <= n; j++) { - weight[k++] = sqrt((float)i * i + j * j); + weight[k++] = sqrt(float(i) * i + j * j); } } #endif @@ -464,7 +465,8 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) check_pixel_assigned( srcbuf, srcmask, filter_make_index(x, y - 1, width, height), depth, is_float) || check_pixel_assigned( - srcbuf, srcmask, filter_make_index(x, y + 1, width, height), depth, is_float)) { + srcbuf, srcmask, filter_make_index(x, y + 1, width, height), depth, is_float)) + { for (i = -n; i <= n; i++) { for (j = -n; j <= n; j++) { if (i != 0 || j != 0) { @@ -478,7 +480,7 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) } else { for (c = 0; c < depth; c++) { - tmp[c] = (float)((const uchar *)srcbuf)[depth * tmpindex + c]; + tmp[c] = float(((const uchar *)srcbuf)[depth * tmpindex + c]); } } @@ -508,11 +510,11 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) ((uchar *)dstbuf)[depth * index + c] = acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : - (uchar)roundf(acc[c])); + uchar(roundf(acc[c]))); } } - if (dstmask != NULL) { + if (dstmask != nullptr) { dstmask[index] = FILTER_MASK_MARGIN; /* assigned */ } cannot_early_out = 1; @@ -524,14 +526,14 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) /* keep the original buffer up to date. */ memcpy(srcbuf, dstbuf, bsize); - if (dstmask != NULL) { - memcpy(srcmask, dstmask, ((size_t)width) * height); + if (dstmask != nullptr) { + memcpy(srcmask, dstmask, size_t(width) * height); } } /* free memory */ MEM_freeN(dstbuf); - if (dstmask != NULL) { + if (dstmask != nullptr) { MEM_freeN(dstmask); } } @@ -663,7 +665,7 @@ void IMB_premultiply_rect_float(float *rect_float, int channels, int w, int h) void IMB_premultiply_alpha(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -696,7 +698,7 @@ void IMB_unpremultiply_rect(uint *rect, char planes, int w, int h) for (y = 0; y < h; y++) { for (x = 0; x < w; x++, cp += 4) { - val = cp[3] != 0 ? 1.0f / (float)cp[3] : 1.0f; + val = cp[3] != 0 ? 1.0f / float(cp[3]) : 1.0f; cp[0] = unit_float_to_uchar_clamp(cp[0] * val); cp[1] = unit_float_to_uchar_clamp(cp[1] * val); cp[2] = unit_float_to_uchar_clamp(cp[2] * val); @@ -725,7 +727,7 @@ void IMB_unpremultiply_rect_float(float *rect_float, int channels, int w, int h) void IMB_unpremultiply_alpha(ImBuf *ibuf) { - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.cc similarity index 83% rename from source/blender/imbuf/intern/imageprocess.c rename to source/blender/imbuf/intern/imageprocess.cc index f4775fa5fe8..8d875fb09ec 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.cc @@ -61,7 +61,7 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf) static void pixel_from_buffer(const struct ImBuf *ibuf, uchar **outI, float **outF, int x, int y) { - size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x; + size_t offset = size_t(ibuf->x) * y * 4 + 4 * x; if (ibuf->rect) { *outI = (uchar *)ibuf->rect + offset; @@ -89,10 +89,10 @@ void bicubic_interpolation_color( void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) { - uchar *outI = NULL; - float *outF = NULL; + uchar *outI = nullptr; + float *outF = nullptr; - if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) { + if (in == nullptr || (in->rect == nullptr && in->rect_float == nullptr)) { return; } @@ -109,7 +109,7 @@ void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xo * \{ */ void bilinear_interpolation_color_fl( - const struct ImBuf *in, uchar UNUSED(outI[4]), float outF[4], float u, float v) + const struct ImBuf *in, uchar /*outI*/[4], float outF[4], float u, float v) { BLI_assert(outF); BLI_assert(in->rect_float); @@ -117,7 +117,7 @@ void bilinear_interpolation_color_fl( } void bilinear_interpolation_color_char( - const struct ImBuf *in, uchar outI[4], float UNUSED(outF[4]), float u, float v) + const struct ImBuf *in, uchar outI[4], float /*outF*/[4], float u, float v) { BLI_assert(outI); BLI_assert(in->rect); @@ -148,10 +148,10 @@ void bilinear_interpolation_color_wrap( /* ImBuf in must have a valid rect or rect_float, assume this is already checked */ - x1 = (int)floor(u); - x2 = (int)ceil(u); - y1 = (int)floor(v); - y2 = (int)ceil(v); + x1 = int(floor(u)); + x2 = int(ceil(u)); + y1 = int(floor(v)); + y2 = int(ceil(v)); /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) { @@ -182,10 +182,10 @@ void bilinear_interpolation_color_wrap( if (outF) { /* sample including outside of edges of image */ - row1 = in->rect_float + ((size_t)in->x) * y1 * 4 + 4 * x1; - row2 = in->rect_float + ((size_t)in->x) * y2 * 4 + 4 * x1; - row3 = in->rect_float + ((size_t)in->x) * y1 * 4 + 4 * x2; - row4 = in->rect_float + ((size_t)in->x) * y2 * 4 + 4 * x2; + row1 = in->rect_float + size_t(in->x) * y1 * 4 + 4 * x1; + row2 = in->rect_float + size_t(in->x) * y2 * 4 + 4 * x1; + row3 = in->rect_float + size_t(in->x) * y1 * 4 + 4 * x2; + row4 = in->rect_float + size_t(in->x) * y2 * 4 + 4 * x2; outF[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0]; outF[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1]; @@ -197,10 +197,10 @@ void bilinear_interpolation_color_wrap( } if (outI) { /* sample including outside of edges of image */ - row1I = (uchar *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x1; - row2I = (uchar *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x1; - row3I = (uchar *)in->rect + ((size_t)in->x) * y1 * 4 + 4 * x2; - row4I = (uchar *)in->rect + ((size_t)in->x) * y2 * 4 + 4 * x2; + row1I = (uchar *)in->rect + size_t(in->x) * y1 * 4 + 4 * x1; + row2I = (uchar *)in->rect + size_t(in->x) * y2 * 4 + 4 * x1; + row3I = (uchar *)in->rect + size_t(in->x) * y1 * 4 + 4 * x2; + row4I = (uchar *)in->rect + size_t(in->x) * y2 * 4 + 4 * x2; /* Tested with white images and this should not wrap back to zero. */ outI[0] = roundf(ma_mb * row1I[0] + a_mb * row3I[0] + ma_b * row2I[0] + a_b * row4I[0]); @@ -212,10 +212,10 @@ void bilinear_interpolation_color_wrap( void bilinear_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) { - uchar *outI = NULL; - float *outF = NULL; + uchar *outI = nullptr; + float *outF = nullptr; - if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) { + if (in == nullptr || (in->rect == nullptr && in->rect_float == nullptr)) { return; } @@ -232,13 +232,13 @@ void bilinear_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int x * \{ */ void nearest_interpolation_color_char( - const struct ImBuf *in, uchar outI[4], float UNUSED(outF[4]), float u, float v) + const struct ImBuf *in, uchar outI[4], float /*outF*/[4], float u, float v) { BLI_assert(outI); BLI_assert(in->rect); /* ImBuf in must have a valid rect or rect_float, assume this is already checked */ - int x1 = (int)(u); - int y1 = (int)(v); + int x1 = int(u); + int y1 = int(v); /* sample area entirely outside image? */ if (x1 < 0 || x1 >= in->x || y1 < 0 || y1 >= in->y) { @@ -246,7 +246,7 @@ void nearest_interpolation_color_char( return; } - const size_t offset = ((size_t)in->x * y1 + x1) * 4; + const size_t offset = (size_t(in->x) * y1 + x1) * 4; const uchar *dataI = (uchar *)in->rect + offset; outI[0] = dataI[0]; outI[1] = dataI[1]; @@ -255,13 +255,13 @@ void nearest_interpolation_color_char( } void nearest_interpolation_color_fl( - const struct ImBuf *in, uchar UNUSED(outI[4]), float outF[4], float u, float v) + const struct ImBuf *in, uchar /*outI*/[4], float outF[4], float u, float v) { BLI_assert(outF); BLI_assert(in->rect_float); /* ImBuf in must have a valid rect or rect_float, assume this is already checked */ - int x1 = (int)(u); - int y1 = (int)(v); + int x1 = int(u); + int y1 = int(v); /* sample area entirely outside image? */ if (x1 < 0 || x1 >= in->x || y1 < 0 || y1 >= in->y) { @@ -269,7 +269,7 @@ void nearest_interpolation_color_fl( return; } - const size_t offset = ((size_t)in->x * y1 + x1) * 4; + const size_t offset = (size_t(in->x) * y1 + x1) * 4; const float *dataF = in->rect_float + offset; copy_v4_v4(outF, dataF); } @@ -294,8 +294,8 @@ void nearest_interpolation_color_wrap( /* ImBuf in must have a valid rect or rect_float, assume this is already checked */ - x = (int)floor(u); - y = (int)floor(v); + x = int(floor(u)); + y = int(floor(v)); x = x % in->x; y = y % in->y; @@ -308,14 +308,14 @@ void nearest_interpolation_color_wrap( y += in->y; } - dataI = (uchar *)in->rect + ((size_t)in->x) * y * 4 + 4 * x; + dataI = (uchar *)in->rect + size_t(in->x) * y * 4 + 4 * x; if (outI) { outI[0] = dataI[0]; outI[1] = dataI[1]; outI[2] = dataI[2]; outI[3] = dataI[3]; } - dataF = in->rect_float + ((size_t)in->x) * y * 4 + 4 * x; + dataF = in->rect_float + size_t(in->x) * y * 4 + 4 * x; if (outF) { outF[0] = dataF[0]; outF[1] = dataF[1]; @@ -326,10 +326,10 @@ void nearest_interpolation_color_wrap( void nearest_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xout, int yout) { - uchar *outI = NULL; - float *outF = NULL; + uchar *outI = nullptr; + float *outF = nullptr; - if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) { + if (in == nullptr || (in->rect == nullptr && in->rect_float == nullptr)) { return; } @@ -366,7 +366,7 @@ void IMB_processor_apply_threaded( int total_tasks = (buffer_lines + lines_per_task - 1) / lines_per_task; int i, start_line; - task_pool = BLI_task_pool_create(do_thread, TASK_PRIORITY_HIGH); + task_pool = BLI_task_pool_create(reinterpret_cast(do_thread), TASK_PRIORITY_HIGH); handles = MEM_callocN(handle_size * total_tasks, "processor apply threaded handles"); @@ -385,7 +385,7 @@ void IMB_processor_apply_threaded( init_handle(handle, start_line, lines_per_current_task, init_customdata); - BLI_task_pool_push(task_pool, processor_apply_func, handle, false, NULL); + BLI_task_pool_push(task_pool, processor_apply_func, handle, false, nullptr); start_line += lines_per_task; } @@ -405,9 +405,9 @@ typedef struct ScanlineGlobalData { static void processor_apply_parallel(void *__restrict userdata, const int scanline, - const TaskParallelTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict /*tls*/) { - ScanlineGlobalData *data = userdata; + ScanlineGlobalData *data = static_cast(userdata); data->do_thread(data->custom_data, scanline); } @@ -416,10 +416,9 @@ void IMB_processor_apply_threaded_scanlines(int total_scanlines, void *custom_data) { TaskParallelSettings settings; - ScanlineGlobalData data = { - .do_thread = do_thread, - .custom_data = custom_data, - }; + ScanlineGlobalData data = {}; + data.do_thread = do_thread; + data.custom_data = custom_data; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(0, total_scanlines, &data, processor_apply_parallel, &settings); @@ -433,7 +432,7 @@ void IMB_processor_apply_threaded_scanlines(int total_scanlines, void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3]) { - size_t a = ((size_t)x) * y; + size_t a = size_t(x) * y; float *fp = rect_float; while (a--) { @@ -447,7 +446,7 @@ void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[ void IMB_alpha_under_color_byte(uchar *rect, int x, int y, const float backcol[3]) { - size_t a = ((size_t)x) * y; + size_t a = size_t(x) * y; uchar *cp = rect; while (a--) { @@ -483,11 +482,11 @@ void IMB_alpha_under_color_byte(uchar *rect, int x, int y, const float backcol[3 void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4]) { if (ibuf->rect_float) { - nearest_interpolation_color(ibuf, NULL, color, x, y); + nearest_interpolation_color(ibuf, nullptr, color, x, y); } else { uchar byte_color[4]; - nearest_interpolation_color(ibuf, byte_color, NULL, x, y); + nearest_interpolation_color(ibuf, byte_color, nullptr, x, y); rgba_uchar_to_float(color, byte_color); if (make_linear_rgb) { IMB_colormanagement_colorspace_to_scene_linear_v4(color, false, ibuf->rect_colorspace); diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.cc similarity index 84% rename from source/blender/imbuf/intern/indexer.c rename to source/blender/imbuf/intern/indexer.cc index 2936f9758c0..345e909a491 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.cc @@ -16,6 +16,7 @@ #include "BLI_math.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utils.h" #include "BLI_threads.h" #include "BLI_utildefines.h" #ifdef _WIN32 @@ -25,6 +26,7 @@ #include "PIL_time.h" #include "IMB_anim.h" +#include "IMB_imbuf.h" #include "IMB_indexer.h" #include "imbuf.h" @@ -33,18 +35,21 @@ #endif #ifdef WITH_FFMPEG +extern "C" { # include "ffmpeg_compat.h" # include +} #endif static const char binary_header_str[] = "BlenMIdx"; static const char temp_ext[] = "_part"; -static const int proxy_sizes[] = {IMB_PROXY_25, IMB_PROXY_50, IMB_PROXY_75, IMB_PROXY_100}; +static const IMB_Proxy_Size proxy_sizes[] = { + IMB_PROXY_25, IMB_PROXY_50, IMB_PROXY_75, IMB_PROXY_100}; static const float proxy_fac[] = {0.25, 0.50, 0.75, 1.00}; #ifdef WITH_FFMPEG -static int tc_types[] = { +static IMB_Timecode_Type tc_types[] = { IMB_TC_RECORD_RUN, IMB_TC_FREE_RUN, IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN, @@ -58,29 +63,29 @@ static int tc_types[] = { * - time code index functions * ---------------------------------------------------------------------- */ -anim_index_builder *IMB_index_builder_create(const char *name) +anim_index_builder *IMB_index_builder_create(const char *filepath) { - anim_index_builder *rv = MEM_callocN(sizeof(struct anim_index_builder), "index builder"); + anim_index_builder *rv = MEM_cnew("index builder"); - fprintf(stderr, "Starting work on index: %s\n", name); + fprintf(stderr, "Starting work on index: %s\n", filepath); - BLI_strncpy(rv->name, name, sizeof(rv->name)); - BLI_strncpy(rv->temp_name, name, sizeof(rv->temp_name)); + BLI_strncpy(rv->filepath, filepath, sizeof(rv->filepath)); - strcat(rv->temp_name, temp_ext); + BLI_strncpy(rv->filepath_temp, filepath, sizeof(rv->filepath_temp)); + BLI_string_join(rv->filepath_temp, sizeof(rv->filepath_temp), filepath, temp_ext); - BLI_make_existing_file(rv->temp_name); + BLI_file_ensure_parent_dir_exists(rv->filepath_temp); - rv->fp = BLI_fopen(rv->temp_name, "wb"); + rv->fp = BLI_fopen(rv->filepath_temp, "wb"); if (!rv->fp) { fprintf(stderr, "Couldn't open index target: %s! " "Index build broken!\n", - rv->temp_name); + rv->filepath_temp); MEM_freeN(rv); - return NULL; + return nullptr; } fprintf(rv->fp, @@ -139,50 +144,50 @@ void IMB_index_builder_finish(anim_index_builder *fp, int rollback) fclose(fp->fp); if (rollback) { - unlink(fp->temp_name); + unlink(fp->filepath_temp); } else { - unlink(fp->name); - BLI_rename(fp->temp_name, fp->name); + unlink(fp->filepath); + BLI_rename(fp->filepath_temp, fp->filepath); } MEM_freeN(fp); } -struct anim_index *IMB_indexer_open(const char *name) +struct anim_index *IMB_indexer_open(const char *filepath) { char header[13]; struct anim_index *idx; - FILE *fp = BLI_fopen(name, "rb"); + FILE *fp = BLI_fopen(filepath, "rb"); int i; if (!fp) { - return NULL; + return nullptr; } if (fread(header, 12, 1, fp) != 1) { - fprintf(stderr, "Couldn't read indexer file: %s\n", name); + fprintf(stderr, "Couldn't read indexer file: %s\n", filepath); fclose(fp); - return NULL; + return nullptr; } header[12] = 0; if (memcmp(header, binary_header_str, 8) != 0) { - fprintf(stderr, "Error reading %s: Binary file type string mismatch\n", name); + fprintf(stderr, "Error reading %s: Binary file type string mismatch\n", filepath); fclose(fp); - return NULL; + return nullptr; } if (atoi(header + 9) != INDEX_FILE_VERSION) { - fprintf(stderr, "Error reading %s: File version mismatch\n", name); + fprintf(stderr, "Error reading %s: File version mismatch\n", filepath); fclose(fp); - return NULL; + return nullptr; } - idx = MEM_callocN(sizeof(struct anim_index), "anim_index"); + idx = MEM_cnew("anim_index"); - BLI_strncpy(idx->name, name, sizeof(idx->name)); + BLI_strncpy(idx->filepath, filepath, sizeof(idx->filepath)); fseek(fp, 0, SEEK_END); @@ -195,8 +200,8 @@ struct anim_index *IMB_indexer_open(const char *name) fseek(fp, 12, SEEK_SET); - idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * idx->num_entries, - "anim_index_entries"); + idx->entries = static_cast( + MEM_callocN(sizeof(anim_index_entry) * idx->num_entries, "anim_index_entries")); size_t items_read = 0; for (i = 0; i < idx->num_entries; i++) { @@ -208,11 +213,11 @@ struct anim_index *IMB_indexer_open(const char *name) } if (UNLIKELY(items_read != idx->num_entries * 5)) { - fprintf(stderr, "Error: Element data size mismatch in: %s\n", name); + fprintf(stderr, "Error: Element data size mismatch in: %s\n", filepath); MEM_freeN(idx->entries); MEM_freeN(idx); fclose(fp); - return NULL; + return nullptr; } if ((ENDIAN_ORDER == B_ENDIAN) != (header[8] == 'V')) { @@ -378,7 +383,7 @@ static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_l if (!anim->index_dir[0]) { char filename[FILE_MAXFILE]; char dirname[FILE_MAXDIR]; - BLI_split_dirfile(anim->name, dirname, filename, index_dir_len, sizeof(filename)); + BLI_path_split_dir_file(anim->filepath, dirname, sizeof(dirname), filename, sizeof(filename)); BLI_path_join(index_dir, index_dir_len, dirname, "BL_proxy", filename); } else { @@ -386,11 +391,9 @@ static void get_index_dir(struct anim *anim, char *index_dir, size_t index_dir_l } } -void IMB_anim_get_fname(struct anim *anim, char *file, int size) +void IMB_anim_get_filename(struct anim *anim, char *filename, int filename_maxncpy) { - char filename[FILE_MAXFILE]; - BLI_split_dirfile(anim->name, file, filename, size, sizeof(filename)); - BLI_strncpy(file, filename, size); + BLI_path_split_file_part(anim->filepath, filename, filename_maxncpy); } static bool get_proxy_filepath(struct anim *anim, @@ -413,16 +416,12 @@ static bool get_proxy_filepath(struct anim *anim, BLI_snprintf(stream_suffix, sizeof(stream_suffix), "_st%d", anim->streamindex); } - BLI_snprintf(proxy_name, - sizeof(proxy_name), - name, - (int)(proxy_fac[i] * 100), - stream_suffix, - anim->suffix); + BLI_snprintf( + proxy_name, sizeof(proxy_name), name, int(proxy_fac[i] * 100), stream_suffix, anim->suffix); get_index_dir(anim, index_dir, sizeof(index_dir)); - if (BLI_path_ncmp(anim->name, index_dir, FILE_MAXDIR) == 0) { + if (BLI_path_ncmp(anim->filepath, index_dir, FILE_MAXDIR) == 0) { return false; } @@ -482,15 +481,15 @@ struct proxy_output_ctx { struct SwsContext *sws_ctx; AVFrame *frame; int cfra; - int proxy_size; + IMB_Proxy_Size proxy_size; int orig_height; struct anim *anim; }; static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( - struct anim *anim, AVStream *st, int proxy_size, int width, int height, int quality) + struct anim *anim, AVStream *st, IMB_Proxy_Size proxy_size, int width, int height, int quality) { - struct proxy_output_ctx *rv = MEM_callocN(sizeof(struct proxy_output_ctx), "alloc_proxy_output"); + proxy_output_ctx *rv = MEM_cnew("alloc_proxy_output"); char filepath[FILE_MAX]; @@ -498,18 +497,18 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( rv->anim = anim; get_proxy_filepath(rv->anim, rv->proxy_size, filepath, true); - if (!BLI_make_existing_file(filepath)) { - return NULL; + if (!BLI_file_ensure_parent_dir_exists(filepath)) { + return nullptr; } rv->of = avformat_alloc_context(); - rv->of->oformat = av_guess_format("avi", NULL, NULL); + rv->of->oformat = av_guess_format("avi", nullptr, nullptr); rv->of->url = av_strdup(filepath); fprintf(stderr, "Starting work on proxy: %s\n", rv->of->url); - rv->st = avformat_new_stream(rv->of, NULL); + rv->st = avformat_new_stream(rv->of, nullptr); rv->st->id = 0; rv->codec = avcodec_find_encoder(AV_CODEC_ID_H264); @@ -523,7 +522,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( avcodec_free_context(&rv->c); avformat_free_context(rv->of); MEM_freeN(rv); - return NULL; + return nullptr; } rv->c->width = width; @@ -550,7 +549,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( const int crf_range_max = 17; int crf = round_fl_to_int((quality / 100.0f) * (crf_range_max - crf_range_min) + crf_range_min); - AVDictionary *codec_opts = NULL; + AVDictionary *codec_opts = nullptr; /* High quality preset value. */ av_dict_set_int(&codec_opts, "crf", crf, 0); /* Prefer smaller file-size. Presets from `veryslow` to `veryfast` produce output with very @@ -582,38 +581,46 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( int ret = avio_open(&rv->of->pb, filepath, AVIO_FLAG_WRITE); if (ret < 0) { + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Couldn't open IO: %s\n" "Proxy not built!\n", - av_err2str(ret)); + error_str); avcodec_free_context(&rv->c); avformat_free_context(rv->of); MEM_freeN(rv); - return NULL; + return nullptr; } ret = avcodec_open2(rv->c, rv->codec, &codec_opts); if (ret < 0) { + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Couldn't open codec: %s\n" "Proxy not built!\n", - av_err2str(ret)); + error_str); avcodec_free_context(&rv->c); avformat_free_context(rv->of); MEM_freeN(rv); - return NULL; + return nullptr; } rv->orig_height = st->codecpar->height; if (st->codecpar->width != width || st->codecpar->height != height || - st->codecpar->format != rv->c->pix_fmt) { + st->codecpar->format != rv->c->pix_fmt) + { rv->frame = av_frame_alloc(); av_image_fill_arrays(rv->frame->data, rv->frame->linesize, - MEM_mallocN(av_image_get_buffer_size(rv->c->pix_fmt, width, height, 1), - "alloc proxy output frame"), + static_cast(MEM_mallocN( + av_image_get_buffer_size(rv->c->pix_fmt, width, height, 1), + "alloc proxy output frame")), rv->c->pix_fmt, width, height, @@ -625,22 +632,25 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( rv->sws_ctx = sws_getContext(st->codecpar->width, rv->orig_height, - st->codecpar->format, + AVPixelFormat(st->codecpar->format), width, height, rv->c->pix_fmt, SWS_FAST_BILINEAR | SWS_PRINT_INFO, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); } - ret = avformat_write_header(rv->of, NULL); + ret = avformat_write_header(rv->of, nullptr); if (ret < 0) { + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Couldn't write header: %s\n" "Proxy not built!\n", - av_err2str(ret)); + error_str); if (rv->frame) { av_frame_free(&rv->frame); @@ -649,7 +659,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( avcodec_free_context(&rv->c); avformat_free_context(rv->of); MEM_freeN(rv); - return NULL; + return nullptr; } return rv; @@ -662,7 +672,8 @@ static void add_to_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, AVFrame *fr } if (ctx->sws_ctx && frame && - (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3])) { + (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3])) + { sws_scale(ctx->sws_ctx, (const uint8_t *const *)frame->data, frame->linesize, @@ -681,7 +692,10 @@ static void add_to_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, AVFrame *fr int ret = avcodec_send_frame(ctx->c, frame); if (ret < 0) { /* Can't send frame to encoder. This shouldn't happen. */ - fprintf(stderr, "Can't send video frame: %s\n", av_err2str(ret)); + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + + fprintf(stderr, "Can't send video frame: %s\n", error_str); return; } AVPacket *packet = av_packet_alloc(); @@ -694,11 +708,14 @@ static void add_to_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, AVFrame *fr break; } if (ret < 0) { + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Error encoding proxy frame %d for '%s': %s\n", ctx->cfra - 1, ctx->of->url, - av_err2str(ret)); + error_str); break; } @@ -710,12 +727,15 @@ static void add_to_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, AVFrame *fr int write_ret = av_interleaved_write_frame(ctx->of, packet); if (write_ret != 0) { + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, write_ret); + fprintf(stderr, "Error writing proxy frame %d " "into '%s': %s\n", ctx->cfra - 1, ctx->of->url, - av_err2str(write_ret)); + error_str); break; } } @@ -734,7 +754,7 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, int rollback) if (!rollback) { /* Flush the remaining packets. */ - add_to_proxy_output_ffmpeg(ctx, NULL); + add_to_proxy_output_ffmpeg(ctx, nullptr); } avcodec_flush_buffers(ctx->c); @@ -786,8 +806,8 @@ typedef struct FFmpegIndexBuilderContext { struct proxy_output_ctx *proxy_ctx[IMB_PROXY_MAX_SLOT]; anim_index_builder *indexer[IMB_TC_MAX_SLOT]; - IMB_Timecode_Type tcs_in_use; - IMB_Proxy_Size proxy_sizes_in_use; + int tcs_in_use; + int proxy_sizes_in_use; uint64_t seek_pos; uint64_t seek_pos_pts; @@ -806,13 +826,13 @@ typedef struct FFmpegIndexBuilderContext { } FFmpegIndexBuilderContext; static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, - IMB_Timecode_Type tcs_in_use, - IMB_Proxy_Size proxy_sizes_in_use, + int tcs_in_use, + int proxy_sizes_in_use, int quality, bool build_only_on_bad_performance) { - FFmpegIndexBuilderContext *context = MEM_callocN(sizeof(FFmpegIndexBuilderContext), - "FFmpeg index builder context"); + FFmpegIndexBuilderContext *context = MEM_cnew( + "FFmpeg index builder context"); int num_proxy_sizes = IMB_PROXY_MAX_SLOT; int num_indexers = IMB_TC_MAX_SLOT; int i, streamcount; @@ -826,15 +846,15 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, memset(context->proxy_ctx, 0, sizeof(context->proxy_ctx)); memset(context->indexer, 0, sizeof(context->indexer)); - if (avformat_open_input(&context->iFormatCtx, anim->name, NULL, NULL) != 0) { + if (avformat_open_input(&context->iFormatCtx, anim->filepath, nullptr, nullptr) != 0) { MEM_freeN(context); - return NULL; + return nullptr; } - if (avformat_find_stream_info(context->iFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(context->iFormatCtx, nullptr) < 0) { avformat_close_input(&context->iFormatCtx); MEM_freeN(context); - return NULL; + return nullptr; } streamcount = anim->streamindex; @@ -855,20 +875,20 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, if (context->videoStream == -1) { avformat_close_input(&context->iFormatCtx); MEM_freeN(context); - return NULL; + return nullptr; } context->iStream = context->iFormatCtx->streams[context->videoStream]; context->iCodec = avcodec_find_decoder(context->iStream->codecpar->codec_id); - if (context->iCodec == NULL) { + if (context->iCodec == nullptr) { avformat_close_input(&context->iFormatCtx); MEM_freeN(context); - return NULL; + return nullptr; } - context->iCodecCtx = avcodec_alloc_context3(NULL); + context->iCodecCtx = avcodec_alloc_context3(nullptr); avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar); context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT; @@ -886,11 +906,11 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, context->iCodecCtx->thread_type = FF_THREAD_SLICE; } - if (avcodec_open2(context->iCodecCtx, context->iCodec, NULL) < 0) { + if (avcodec_open2(context->iCodecCtx, context->iCodec, nullptr) < 0) { avformat_close_input(&context->iFormatCtx); avcodec_free_context(&context->iCodecCtx); MEM_freeN(context); - return NULL; + return nullptr; } for (i = 0; i < num_proxy_sizes; i++) { @@ -902,17 +922,18 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, context->iCodecCtx->height * proxy_fac[i], quality); if (!context->proxy_ctx[i]) { - proxy_sizes_in_use &= ~proxy_sizes[i]; + proxy_sizes_in_use &= ~int(proxy_sizes[i]); } } } - if (context->proxy_ctx[0] == NULL && context->proxy_ctx[1] == NULL && - context->proxy_ctx[2] == NULL && context->proxy_ctx[3] == NULL) { + if (context->proxy_ctx[0] == nullptr && context->proxy_ctx[1] == nullptr && + context->proxy_ctx[2] == nullptr && context->proxy_ctx[3] == nullptr) + { avformat_close_input(&context->iFormatCtx); avcodec_free_context(&context->iCodecCtx); MEM_freeN(context); - return NULL; /* Nothing to transcode. */ + return nullptr; /* Nothing to transcode. */ } for (i = 0; i < num_indexers; i++) { @@ -923,7 +944,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, context->indexer[i] = IMB_index_builder_create(filepath); if (!context->indexer[i]) { - tcs_in_use &= ~tc_types[i]; + tcs_in_use &= ~int(tc_types[i]); } } } @@ -1022,13 +1043,13 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, stream_size = avio_size(context->iFormatCtx->pb); - context->frame_rate = av_q2d(av_guess_frame_rate(context->iFormatCtx, context->iStream, NULL)); + context->frame_rate = av_q2d( + av_guess_frame_rate(context->iFormatCtx, context->iStream, nullptr)); context->pts_time_base = av_q2d(context->iStream->time_base); while (av_read_frame(context->iFormatCtx, next_packet) >= 0) { - float next_progress = (float)(int)floor( - ((double)next_packet->pos) * 100 / ((double)stream_size) + 0.5) / - 100; + float next_progress = + float(int(floor(double(next_packet->pos) * 100 / double(stream_size) + 0.5))) / 100; if (*progress != next_progress) { *progress = next_progress; @@ -1049,7 +1070,9 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, break; } if (ret < 0) { - fprintf(stderr, "Error decoding proxy frame: %s\n", av_err2str(ret)); + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Error decoding proxy frame: %s\n", error_str); break; } @@ -1070,12 +1093,12 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, } /* process pictures still stuck in decoder engine after EOF - * according to ffmpeg docs using NULL packets. + * according to ffmpeg docs using nullptr packets. * * At least, if we haven't already stopped... */ if (!*stop) { - int ret = avcodec_send_packet(context->iCodecCtx, NULL); + int ret = avcodec_send_packet(context->iCodecCtx, nullptr); while (ret >= 0) { ret = avcodec_receive_frame(context->iCodecCtx, in_frame); @@ -1085,7 +1108,9 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, break; } if (ret < 0) { - fprintf(stderr, "Error flushing proxy frame: %s\n", av_err2str(ret)); + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Error flushing proxy frame: %s\n", error_str); break; } index_rebuild_ffmpeg_proc_decoded_frame(context, next_packet, in_frame); @@ -1123,7 +1148,9 @@ static int indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex } if (ret < 0) { - fprintf(stderr, "Error decoding proxy frame: %s\n", av_err2str(ret)); + char error_str[AV_ERROR_MAX_STRING_SIZE]; + av_make_error_string(error_str, AV_ERROR_MAX_STRING_SIZE, ret); + fprintf(stderr, "Error decoding proxy frame: %s\n", error_str); break; } frames_decoded++; @@ -1224,7 +1251,7 @@ typedef struct FallbackIndexBuilderContext { struct anim *anim; AviMovie *proxy_ctx[IMB_PROXY_MAX_SLOT]; - IMB_Proxy_Size proxy_sizes_in_use; + int proxy_sizes_in_use; } FallbackIndexBuilderContext; static AviMovie *alloc_proxy_output_avi( @@ -1243,15 +1270,15 @@ static AviMovie *alloc_proxy_output_avi( x = width; y = height; - framerate = (double)frs_sec / (double)frs_sec_base; + framerate = double(frs_sec) / double(frs_sec_base); - avi = MEM_mallocN(sizeof(AviMovie), "avimovie"); + avi = MEM_cnew("avimovie"); format = AVI_FORMAT_MJPEG; if (AVI_open_compress(filepath, avi, 1, format) != AVI_ERROR_NONE) { MEM_freeN(avi); - return NULL; + return nullptr; } AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x); @@ -1266,8 +1293,8 @@ static AviMovie *alloc_proxy_output_avi( } static IndexBuildContext *index_fallback_create_context(struct anim *anim, - IMB_Timecode_Type UNUSED(tcs_in_use), - IMB_Proxy_Size proxy_sizes_in_use, + int /*tcs_in_use*/, + int proxy_sizes_in_use, int quality) { FallbackIndexBuilderContext *context; @@ -1279,10 +1306,10 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, * so no proxies... */ if (proxy_sizes_in_use == IMB_PROXY_NONE) { - return NULL; + return nullptr; } - context = MEM_callocN(sizeof(FallbackIndexBuilderContext), "fallback index builder context"); + context = MEM_cnew("fallback index builder context"); context->anim = anim; context->proxy_sizes_in_use = proxy_sizes_in_use; @@ -1294,7 +1321,7 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, char filepath[FILE_MAX]; get_proxy_filepath(anim, proxy_sizes[i], filepath, true); - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); context->proxy_ctx[i] = alloc_proxy_output_avi( anim, filepath, anim->x * proxy_fac[i], anim->y * proxy_fac[i], quality); @@ -1342,7 +1369,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context, for (pos = 0; pos < count; pos++) { struct ImBuf *ibuf = IMB_anim_absolute(anim, pos, IMB_TC_NONE, IMB_PROXY_NONE); struct ImBuf *tmp_ibuf = IMB_dupImBuf(ibuf); - float next_progress = (float)pos / (float)count; + float next_progress = float(pos) / float(count); if (*progress != next_progress) { *progress = next_progress; @@ -1369,7 +1396,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context, AVI_write_frame(context->proxy_ctx[i], pos, AVI_FORMAT_RGB32, s_ibuf->rect, x * y * 4); /* note that libavi free's the buffer... */ - s_ibuf->rect = NULL; + s_ibuf->rect = nullptr; IMB_freeImBuf(s_ibuf); } @@ -1388,14 +1415,14 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context, IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecode_Type tcs_in_use, - IMB_Proxy_Size proxy_sizes_in_use, + int proxy_sizes_in_use, int quality, const bool overwrite, GSet *file_list, bool build_only_on_bad_performance) { - IndexBuildContext *context = NULL; - IMB_Proxy_Size proxy_sizes_to_build = proxy_sizes_in_use; + IndexBuildContext *context = nullptr; + int proxy_sizes_to_build = proxy_sizes_in_use; int i; /* Don't generate the same file twice! */ @@ -1405,14 +1432,14 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, if (proxy_size & proxy_sizes_to_build) { char filename[FILE_MAX]; if (get_proxy_filepath(anim, proxy_size, filename, false) == false) { - return NULL; + return nullptr; } void **filename_key_p; if (!BLI_gset_ensure_p_ex(file_list, filename, &filename_key_p)) { *filename_key_p = BLI_strdup(filename); } else { - proxy_sizes_to_build &= ~proxy_size; + proxy_sizes_to_build &= ~int(proxy_size); printf("Proxy: %s already registered for generation, skipping\n", filename); } } @@ -1420,7 +1447,7 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, } if (!overwrite) { - IMB_Proxy_Size built_proxies = IMB_anim_proxy_get_existing(anim); + int built_proxies = IMB_anim_proxy_get_existing(anim); if (built_proxies != 0) { for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) { @@ -1428,7 +1455,7 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, if (proxy_size & built_proxies) { char filename[FILE_MAX]; if (get_proxy_filepath(anim, proxy_size, filename, false) == false) { - return NULL; + return nullptr; } printf("Skipping proxy: %s\n", filename); } @@ -1440,7 +1467,7 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, fflush(stdout); if (proxy_sizes_to_build == 0) { - return NULL; + return nullptr; } switch (anim->curtype) { @@ -1521,14 +1548,14 @@ void IMB_free_indices(struct anim *anim) for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) { if (anim->proxy_anim[i]) { IMB_close_anim(anim->proxy_anim[i]); - anim->proxy_anim[i] = NULL; + anim->proxy_anim[i] = nullptr; } } for (i = 0; i < IMB_TC_MAX_SLOT; i++) { if (anim->curr_idx[i]) { IMB_indexer_close(anim->curr_idx[i]); - anim->curr_idx[i] = NULL; + anim->curr_idx[i] = nullptr; } } @@ -1552,7 +1579,7 @@ struct anim *IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size) int i = IMB_proxy_size_to_array_index(preview_size); if (i < 0) { - return NULL; + return nullptr; } if (anim->proxy_anim[i]) { @@ -1560,7 +1587,7 @@ struct anim *IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size) } if (anim->proxies_tried & preview_size) { - return NULL; + return nullptr; } get_proxy_filepath(anim, preview_size, filepath, false); @@ -1579,7 +1606,7 @@ struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc) int i = IMB_timecode_to_array_index(tc); if (i < 0) { - return NULL; + return nullptr; } if (anim->curr_idx[i]) { @@ -1587,7 +1614,7 @@ struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc) } if (anim->indices_tried & tc) { - return NULL; + return nullptr; } get_tc_filename(anim, tc, filepath); @@ -1610,17 +1637,17 @@ int IMB_anim_index_get_frame_index(struct anim *anim, IMB_Timecode_Type tc, int return IMB_indexer_get_frame_index(idx, position); } -IMB_Proxy_Size IMB_anim_proxy_get_existing(struct anim *anim) +int IMB_anim_proxy_get_existing(struct anim *anim) { const int num_proxy_sizes = IMB_PROXY_MAX_SLOT; - IMB_Proxy_Size existing = 0; + int existing = IMB_PROXY_NONE; int i; for (i = 0; i < num_proxy_sizes; i++) { IMB_Proxy_Size proxy_size = proxy_sizes[i]; char filename[FILE_MAX]; get_proxy_filepath(anim, proxy_size, filename, false); if (BLI_exists(filename)) { - existing |= proxy_size; + existing |= int(proxy_size); } } return existing; diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.cc similarity index 91% rename from source/blender/imbuf/intern/iris.c rename to source/blender/imbuf/intern/iris.cc index cec6913c211..7fec0f62036 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.cc @@ -45,7 +45,7 @@ BLI_STATIC_ASSERT(sizeof(IMAGE) == HEADER_SIZE, "Invalid header size"); #define GINTLUM (156) #define BINTLUM (21) -#define ILUM(r, g, b) ((int)(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8) +#define ILUM(r, g, b) (int(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8) #define OFFSET_R 0 /* this is byte order dependent */ #define OFFSET_G 1 @@ -119,7 +119,7 @@ static ushort getshort(MFileOffset *inf) buf = MFILE_DATA(inf); MFILE_STEP(inf, 2); - return ((ushort)buf[0] << 8) + ((ushort)buf[1] << 0); + return (ushort(buf[0]) << 8) + (ushort(buf[1]) << 0); } static uint getlong(MFileOffset *mofs) @@ -129,7 +129,7 @@ static uint getlong(MFileOffset *mofs) buf = MFILE_DATA(mofs); MFILE_STEP(mofs, 4); - return ((uint)buf[0] << 24) + ((uint)buf[1] << 16) + ((uint)buf[2] << 8) + ((uint)buf[3] << 0); + return (uint(buf[0]) << 24) + (uint(buf[1]) << 16) + (uint(buf[2]) << 8) + (uint(buf[3]) << 0); } static void putshort(FILE *outf, ushort val) @@ -210,7 +210,7 @@ static void test_endian_zbuf(struct ImBuf *ibuf) return; #endif - if (ibuf->zbuf == NULL) { + if (ibuf->zbuf == nullptr) { return; } @@ -239,25 +239,25 @@ bool imb_is_a_iris(const uchar *mem, size_t size) struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { - uint *base, *lptr = NULL; - float *fbase, *fptr = NULL; + uint *base, *lptr = nullptr; + float *fbase, *fptr = nullptr; uint *zbase, *zptr; const uchar *rledat; const uchar *mem_end = mem + size; MFileOffset _inf_data = {mem, 0}, *inf = &_inf_data; IMAGE image; int bpp, rle, cur, badorder; - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; uchar dirty_flag = 0; if (!imb_is_a_iris(mem, size)) { - return NULL; + return nullptr; } /* Could be part of the magic check above, * by convention this check only requests the size needed to read it's magic though. */ if (size < HEADER_SIZE) { - return NULL; + return nullptr; } /* OCIO_TODO: only tested with 1 byte per pixel, not sure how to test with other settings */ @@ -266,18 +266,18 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors readheader(inf, &image); if (image.imagic != IMAGIC) { fprintf(stderr, "longimagedata: bad magic number in image file\n"); - return NULL; + return nullptr; } rle = ISRLE(image.type); bpp = BPP(image.type); if (!ELEM(bpp, 1, 2)) { fprintf(stderr, "longimagedata: image must have 1 or 2 byte per pix chan\n"); - return NULL; + return nullptr; } - if ((uint)image.zsize > 8) { + if (uint(image.zsize) > 8) { fprintf(stderr, "longimagedata: channels over 8 not supported\n"); - return NULL; + return nullptr; } const int xsize = image.xsize; @@ -293,11 +293,11 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors } if (rle) { - size_t tablen = (size_t)ysize * (size_t)zsize * sizeof(int); + size_t tablen = size_t(ysize) * size_t(zsize) * sizeof(int); MFILE_SEEK(inf, HEADER_SIZE); - uint *starttab = MEM_mallocN(tablen, "iris starttab"); - uint *lengthtab = MEM_mallocN(tablen, "iris endtab"); + uint *starttab = static_cast(MEM_mallocN(tablen, "iris starttab")); + uint *lengthtab = static_cast(MEM_mallocN(tablen, "iris endtab")); #define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p) \ if (UNLIKELY((p) > mem_end)) { \ @@ -430,7 +430,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors MEM_freeN(lengthtab); if (!ibuf) { - return NULL; + return nullptr; } } else { @@ -506,7 +506,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors #undef MFILE_CAPACITY_AT_PTR_OK_OR_FAIL fail_uncompressed: if (!ibuf) { - return NULL; + return nullptr; } } @@ -515,7 +515,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors if (image.zsize == 1) { rect = (uchar *)ibuf->rect; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { rect[0] = 255; rect[1] = rect[2] = rect[3]; rect += 4; @@ -524,7 +524,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors else if (image.zsize == 2) { /* Gray-scale with alpha. */ rect = (uchar *)ibuf->rect; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { rect[0] = rect[2]; rect[1] = rect[2] = rect[3]; rect += 4; @@ -533,7 +533,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors else if (image.zsize == 3) { /* add alpha */ rect = (uchar *)ibuf->rect; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { rect[0] = 255; rect += 4; } @@ -543,7 +543,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors if (image.zsize == 1) { fbase = ibuf->rect_float; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { fbase[0] = 1; fbase[1] = fbase[2] = fbase[3]; fbase += 4; @@ -552,7 +552,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors else if (image.zsize == 2) { /* Gray-scale with alpha. */ fbase = ibuf->rect_float; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { fbase[0] = fbase[2]; fbase[1] = fbase[2] = fbase[3]; fbase += 4; @@ -561,7 +561,7 @@ struct ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colors else if (image.zsize == 3) { /* add alpha */ fbase = ibuf->rect_float; - for (size_t x = (size_t)ibuf->x * (size_t)ibuf->y; x > 0; x--) { + for (size_t x = size_t(ibuf->x) * size_t(ibuf->y); x > 0; x--) { fbase[0] = 1; fbase += 4; } @@ -601,7 +601,7 @@ static void interleaverow2(float *lptr, const uchar *cptr, int z, int n) { lptr += z; while (n--) { - *lptr = ((cptr[0] << 8) | (cptr[1] << 0)) / (float)0xFFFF; + *lptr = ((cptr[0] << 8) | (cptr[1] << 0)) / float(0xFFFF); cptr += 2; lptr += 4; } @@ -642,20 +642,20 @@ static int expandrow2( iptr_next = iptr + (count * 2); EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next); while (count >= 8) { - optr[0 * 4] = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF; - optr[1 * 4] = ((iptr[2] << 8) | (iptr[3] << 0)) / (float)0xFFFF; - optr[2 * 4] = ((iptr[4] << 8) | (iptr[5] << 0)) / (float)0xFFFF; - optr[3 * 4] = ((iptr[6] << 8) | (iptr[7] << 0)) / (float)0xFFFF; - optr[4 * 4] = ((iptr[8] << 8) | (iptr[9] << 0)) / (float)0xFFFF; - optr[5 * 4] = ((iptr[10] << 8) | (iptr[11] << 0)) / (float)0xFFFF; - optr[6 * 4] = ((iptr[12] << 8) | (iptr[13] << 0)) / (float)0xFFFF; - optr[7 * 4] = ((iptr[14] << 8) | (iptr[15] << 0)) / (float)0xFFFF; + optr[0 * 4] = ((iptr[0] << 8) | (iptr[1] << 0)) / float(0xFFFF); + optr[1 * 4] = ((iptr[2] << 8) | (iptr[3] << 0)) / float(0xFFFF); + optr[2 * 4] = ((iptr[4] << 8) | (iptr[5] << 0)) / float(0xFFFF); + optr[3 * 4] = ((iptr[6] << 8) | (iptr[7] << 0)) / float(0xFFFF); + optr[4 * 4] = ((iptr[8] << 8) | (iptr[9] << 0)) / float(0xFFFF); + optr[5 * 4] = ((iptr[10] << 8) | (iptr[11] << 0)) / float(0xFFFF); + optr[6 * 4] = ((iptr[12] << 8) | (iptr[13] << 0)) / float(0xFFFF); + optr[7 * 4] = ((iptr[14] << 8) | (iptr[15] << 0)) / float(0xFFFF); optr += 8 * 4; iptr += 8 * 2; count -= 8; } while (count--) { - *optr = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF; + *optr = ((iptr[0] << 8) | (iptr[1] << 0)) / float(0xFFFF); iptr += 2; optr += 4; } @@ -664,7 +664,7 @@ static int expandrow2( else { iptr_next = iptr + 2; EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next); - pixel_f = ((iptr[0] << 8) | (iptr[1] << 0)) / (float)0xFFFF; + pixel_f = ((iptr[0] << 8) | (iptr[1] << 0)) / float(0xFFFF); iptr = iptr_next; while (count >= 8) { @@ -722,7 +722,7 @@ static int expandrow( if (!(count = (pixel & 0x7f))) { return false; } - const uchar *optr_next = optr + ((int)count * 4); + const uchar *optr_next = optr + (int(count) * 4); EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next); if (pixel & 0x80) { @@ -783,7 +783,7 @@ fail: /** * \param filepath: The file path to write to. * \param lptr: an array of integers to an iris image file (each int represents one pixel). - * \param zptr: depth-buffer (optional, may be NULL). + * \param zptr: depth-buffer (optional, may be nullptr). * \param xsize: with width of the pixel-array. * \param ysize: height of the pixel-array. * \param zsize: specifies what kind of image file to write out. @@ -965,7 +965,7 @@ bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags) short zsize; zsize = (ibuf->planes + 7) >> 3; - if (flags & IB_zbuf && ibuf->zbuf != NULL) { + if (flags & IB_zbuf && ibuf->zbuf != nullptr) { zsize = 8; } diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.cc similarity index 91% rename from source/blender/imbuf/intern/jp2.c rename to source/blender/imbuf/intern/jp2.cc index 66ede02641c..02bddcd4fdf 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.cc @@ -101,11 +101,11 @@ static void info_callback(const char *msg, void *client_data) #endif #define PIXEL_LOOPER_BEGIN(_rect) \ - for (y = h - 1; y != (uint)(-1); y--) { \ + for (y = h - 1; y != uint(-1); y--) { \ for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += 4) { #define PIXEL_LOOPER_BEGIN_CHANNELS(_rect, _channels) \ - for (y = h - 1; y != (uint)(-1); y--) { \ + for (y = h - 1; y != uint(-1); y--) { \ for (i = y * w, i_next = (y + 1) * w; i < i_next; i++, _rect += _channels) { #define PIXEL_LOOPER_END \ @@ -123,14 +123,14 @@ struct BufInfo { OPJ_OFF_T len; }; -static void opj_read_from_buffer_free(void *UNUSED(p_user_data)) +static void opj_read_from_buffer_free(void * /*p_user_data*/) { /* NOP. */ } static OPJ_SIZE_T opj_read_from_buffer(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) { - struct BufInfo *p_file = p_user_data; + struct BufInfo *p_file = static_cast(p_user_data); OPJ_UINT32 l_nb_read; if (p_file->cur + p_nb_bytes < p_file->buf + p_file->len) { @@ -158,7 +158,7 @@ static OPJ_SIZE_T opj_write_from_buffer(void *p_buffer, OPJ_SIZE_T p_nb_bytes, v static OPJ_OFF_T opj_skip_from_buffer(OPJ_OFF_T p_nb_bytes, void *p_user_data) { - struct BufInfo *p_file = p_user_data; + struct BufInfo *p_file = static_cast(p_user_data); if (p_file->cur + p_nb_bytes < p_file->buf + p_file->len) { p_file->cur += p_nb_bytes; return p_nb_bytes; @@ -169,7 +169,7 @@ static OPJ_OFF_T opj_skip_from_buffer(OPJ_OFF_T p_nb_bytes, void *p_user_data) static OPJ_BOOL opj_seek_from_buffer(OPJ_OFF_T p_nb_bytes, void *p_user_data) { - struct BufInfo *p_file = p_user_data; + struct BufInfo *p_file = static_cast(p_user_data); if (p_nb_bytes < p_file->len) { p_file->cur = p_file->buf + p_nb_bytes; return OPJ_TRUE; @@ -187,8 +187,8 @@ static opj_stream_t *opj_stream_create_from_buffer(struct BufInfo *p_file, OPJ_BOOL p_is_read_stream) { opj_stream_t *l_stream = opj_stream_create(p_size, p_is_read_stream); - if (l_stream == NULL) { - return NULL; + if (l_stream == nullptr) { + return nullptr; } opj_stream_set_user_data(l_stream, p_file, opj_read_from_buffer_free); opj_stream_set_user_data_length(l_stream, p_file->len); @@ -210,13 +210,13 @@ static opj_stream_t *opj_stream_create_from_buffer(struct BufInfo *p_file, static void opj_free_from_file(void *p_user_data) { - FILE *f = p_user_data; + FILE *f = static_cast(p_user_data); fclose(f); } static OPJ_UINT64 opj_get_data_length_from_file(void *p_user_data) { - FILE *p_file = p_user_data; + FILE *p_file = static_cast(p_user_data); OPJ_OFF_T file_length = 0; fseek(p_file, 0, SEEK_END); @@ -228,20 +228,20 @@ static OPJ_UINT64 opj_get_data_length_from_file(void *p_user_data) static OPJ_SIZE_T opj_read_from_file(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) { - FILE *p_file = p_user_data; + FILE *p_file = static_cast(p_user_data); OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, p_file); return l_nb_read ? l_nb_read : (OPJ_SIZE_T)-1; } static OPJ_SIZE_T opj_write_from_file(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) { - FILE *p_file = p_user_data; + FILE *p_file = static_cast(p_user_data); return fwrite(p_buffer, 1, p_nb_bytes, p_file); } static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, void *p_user_data) { - FILE *p_file = p_user_data; + FILE *p_file = static_cast(p_user_data); if (fseek(p_file, p_nb_bytes, SEEK_CUR)) { return -1; } @@ -250,7 +250,7 @@ static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, void *p_user_data) static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, void *p_user_data) { - FILE *p_file = p_user_data; + FILE *p_file = static_cast(p_user_data); if (fseek(p_file, p_nb_bytes, SEEK_SET)) { return OPJ_FALSE; } @@ -268,14 +268,14 @@ static opj_stream_t *opj_stream_create_from_file(const char *filepath, FILE **r_file) { FILE *p_file = BLI_fopen(filepath, p_is_read_stream ? "rb" : "wb"); - if (p_file == NULL) { - return NULL; + if (p_file == nullptr) { + return nullptr; } opj_stream_t *l_stream = opj_stream_create(p_size, p_is_read_stream); - if (l_stream == NULL) { + if (l_stream == nullptr) { fclose(p_file); - return NULL; + return nullptr; } opj_stream_set_user_data(l_stream, p_file, opj_free_from_file); @@ -302,11 +302,10 @@ ImBuf *imb_load_jp2(const uchar *mem, size_t size, int flags, char colorspace[IM { const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem, size) : OPJ_CODEC_UNKNOWN; - struct BufInfo buf_wrapper = { - .buf = mem, - .cur = mem, - .len = size, - }; + struct BufInfo buf_wrapper = {}; + buf_wrapper.buf = mem; + buf_wrapper.cur = mem; + buf_wrapper.len = OPJ_OFF_T(size); opj_stream_t *stream = opj_stream_create_from_buffer( &buf_wrapper, OPJ_J2K_STREAM_CHUNK_SIZE, true); ImBuf *ibuf = imb_load_jp2_stream(stream, format, flags, colorspace); @@ -316,17 +315,17 @@ ImBuf *imb_load_jp2(const uchar *mem, size_t size, int flags, char colorspace[IM ImBuf *imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) { - FILE *p_file = NULL; + FILE *p_file = nullptr; uchar mem[JP2_FILEHEADER_SIZE]; opj_stream_t *stream = opj_stream_create_from_file( filepath, OPJ_J2K_STREAM_CHUNK_SIZE, true, &p_file); if (stream) { - return NULL; + return nullptr; } if (fread(mem, sizeof(mem), 1, p_file) != sizeof(mem)) { opj_stream_destroy(stream); - return NULL; + return nullptr; } fseek(p_file, 0, SEEK_SET); @@ -343,10 +342,10 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, char colorspace[IM_MAX_SPACE]) { if (format == OPJ_CODEC_UNKNOWN) { - return NULL; + return nullptr; } - struct ImBuf *ibuf = NULL; + struct ImBuf *ibuf = nullptr; bool use_float = false; /* for precision higher than 8 use float */ bool use_alpha = false; @@ -359,8 +358,8 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, opj_dparameters_t parameters; /* decompression parameters */ - opj_image_t *image = NULL; - opj_codec_t *codec = NULL; /* handle to a decompressor */ + opj_image_t *image = nullptr; + opj_codec_t *codec = nullptr; /* handle to a decompressor */ /* both 8, 12 and 16 bit JP2Ks are default to standard byte colorspace */ colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); @@ -438,7 +437,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, ibuf = IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect); - if (ibuf == NULL) { + if (ibuf == nullptr) { goto finally; } @@ -455,13 +454,13 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, if (image->numcomps < 3) { r = image->comps[0].data; - a = (use_alpha) ? image->comps[1].data : NULL; + a = (use_alpha) ? image->comps[1].data : nullptr; /* Gray-scale 12bits+ */ if (use_alpha) { a = image->comps[1].data; PIXEL_LOOPER_BEGIN (rect_float) { - rect_float[0] = rect_float[1] = rect_float[2] = (float)(r[i] + signed_offsets[0]) / + rect_float[0] = rect_float[1] = rect_float[2] = float(r[i] + signed_offsets[0]) / float_divs[0]; rect_float[3] = (a[i] + signed_offsets[1]) / float_divs[1]; } @@ -469,7 +468,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, } else { PIXEL_LOOPER_BEGIN (rect_float) { - rect_float[0] = rect_float[1] = rect_float[2] = (float)(r[i] + signed_offsets[0]) / + rect_float[0] = rect_float[1] = rect_float[2] = float(r[i] + signed_offsets[0]) / float_divs[0]; rect_float[3] = 1.0f; } @@ -485,18 +484,18 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, if (use_alpha) { a = image->comps[3].data; PIXEL_LOOPER_BEGIN (rect_float) { - rect_float[0] = (float)(r[i] + signed_offsets[0]) / float_divs[0]; - rect_float[1] = (float)(g[i] + signed_offsets[1]) / float_divs[1]; - rect_float[2] = (float)(b[i] + signed_offsets[2]) / float_divs[2]; - rect_float[3] = (float)(a[i] + signed_offsets[3]) / float_divs[3]; + rect_float[0] = float(r[i] + signed_offsets[0]) / float_divs[0]; + rect_float[1] = float(g[i] + signed_offsets[1]) / float_divs[1]; + rect_float[2] = float(b[i] + signed_offsets[2]) / float_divs[2]; + rect_float[3] = float(a[i] + signed_offsets[3]) / float_divs[3]; } PIXEL_LOOPER_END; } else { PIXEL_LOOPER_BEGIN (rect_float) { - rect_float[0] = (float)(r[i] + signed_offsets[0]) / float_divs[0]; - rect_float[1] = (float)(g[i] + signed_offsets[1]) / float_divs[1]; - rect_float[2] = (float)(b[i] + signed_offsets[2]) / float_divs[2]; + rect_float[0] = float(r[i] + signed_offsets[0]) / float_divs[0]; + rect_float[1] = float(g[i] + signed_offsets[1]) / float_divs[1]; + rect_float[2] = float(b[i] + signed_offsets[2]) / float_divs[2]; rect_float[3] = 1.0f; } PIXEL_LOOPER_END; @@ -508,7 +507,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, if (image->numcomps < 3) { r = image->comps[0].data; - a = (use_alpha) ? image->comps[1].data : NULL; + a = (use_alpha) ? image->comps[1].data : nullptr; /* Gray-scale. */ if (use_alpha) { @@ -587,11 +586,11 @@ static opj_image_t *rawtoimage(const char *filename, # define UPSAMPLE_8_TO_16(_val) ((_val << 8) + _val) # define DOWNSAMPLE_FLOAT_TO_8BIT(_val) \ - (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val))) + (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : int(255.0f * (_val))) # define DOWNSAMPLE_FLOAT_TO_12BIT(_val) \ - (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val))) + (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : int(4095.0f * (_val))) # define DOWNSAMPLE_FLOAT_TO_16BIT(_val) \ - (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val))) + (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : int(65535.0f * (_val))) #else BLI_INLINE int UPSAMPLE_8_TO_12(const uchar _val) @@ -605,15 +604,15 @@ BLI_INLINE int UPSAMPLE_8_TO_16(const uchar _val) BLI_INLINE int DOWNSAMPLE_FLOAT_TO_8BIT(const float _val) { - return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : (int)(255.0f * (_val))); + return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 255 : int(255.0f * (_val))); } BLI_INLINE int DOWNSAMPLE_FLOAT_TO_12BIT(const float _val) { - return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : (int)(4095.0f * (_val))); + return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 4095 : int(4095.0f * (_val))); } BLI_INLINE int DOWNSAMPLE_FLOAT_TO_16BIT(const float _val) { - return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : (int)(65535.0f * (_val))); + return (_val) <= 0.0f ? 0 : ((_val) >= 1.0f ? 65535 : int(65535.0f * (_val))); } #endif @@ -745,17 +744,17 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, for (i = 0; i < parameters->tcp_numlayers; i++) { temp_rate = 0; if (img_fol->rates[i] == 0) { - parameters->tcp_rates[0] = (float)(image->numcomps * image->comps[0].w * - image->comps[0].h * image->comps[0].prec) / + parameters->tcp_rates[0] = float(image->numcomps * image->comps[0].w * + image->comps[0].h * image->comps[0].prec) / (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy); } else { - temp_rate = (float)(image->numcomps * image->comps[0].w * image->comps[0].h * - image->comps[0].prec) / + temp_rate = float(image->numcomps * image->comps[0].w * image->comps[0].h * + image->comps[0].prec) / (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy); if (temp_rate > CINEMA_24_CS) { - parameters->tcp_rates[i] = (float)(image->numcomps * image->comps[0].w * - image->comps[0].h * image->comps[0].prec) / + parameters->tcp_rates[i] = float(image->numcomps * image->comps[0].w * + image->comps[0].h * image->comps[0].prec) / (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy); } @@ -771,17 +770,17 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters, for (i = 0; i < parameters->tcp_numlayers; i++) { temp_rate = 0; if (img_fol->rates[i] == 0) { - parameters->tcp_rates[0] = (float)(image->numcomps * image->comps[0].w * - image->comps[0].h * image->comps[0].prec) / + parameters->tcp_rates[0] = float(image->numcomps * image->comps[0].w * + image->comps[0].h * image->comps[0].prec) / (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy); } else { - temp_rate = (float)(image->numcomps * image->comps[0].w * image->comps[0].h * - image->comps[0].prec) / + temp_rate = float(image->numcomps * image->comps[0].w * image->comps[0].h * + image->comps[0].prec) / (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy); if (temp_rate > CINEMA_48_CS) { - parameters->tcp_rates[0] = (float)(image->numcomps * image->comps[0].w * - image->comps[0].h * image->comps[0].prec) / + parameters->tcp_rates[0] = float(image->numcomps * image->comps[0].w * + image->comps[0].h * image->comps[0].prec) / (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy); } @@ -817,7 +816,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) int *r, *g, *b, *a; /* matching 'opj_image_comp.data' type */ OPJ_COLOR_SPACE color_space; opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */ - opj_image_t *image = NULL; + opj_image_t *image = nullptr; float (*chanel_colormanage_cb)(float); @@ -898,7 +897,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) image = opj_image_create(numcomps, &cmptparm[0], color_space); if (!image) { printf("Error: opj_image_create() failed\n"); - return NULL; + return nullptr; } /* set image offset and reference grid */ @@ -915,11 +914,11 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) r = image->comps[0].data; g = image->comps[1].data; b = image->comps[2].data; - a = (numcomps == 4) ? image->comps[3].data : NULL; + a = (numcomps == 4) ? image->comps[3].data : nullptr; if (rect_float && rect_uchar && prec == 8) { /* No need to use the floating point buffer, just write the 8 bits from the char buffer */ - rect_float = NULL; + rect_float = nullptr; } if (rect_float) { @@ -1185,8 +1184,8 @@ bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int flags); bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags) { opj_stream_t *stream = opj_stream_create_from_file( - filepath, OPJ_J2K_STREAM_CHUNK_SIZE, false, NULL); - if (stream == NULL) { + filepath, OPJ_J2K_STREAM_CHUNK_SIZE, false, nullptr); + if (stream == nullptr) { return 0; } const bool ok = imb_save_jp2_stream(ibuf, stream, flags); @@ -1195,12 +1194,12 @@ bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags) } /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ -bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(flags)) +bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int /*flags*/) { int quality = ibuf->foptions.quality; opj_cparameters_t parameters; /* compression parameters */ - opj_image_t *image = NULL; + opj_image_t *image = nullptr; /* set encoding parameters to default values */ opj_set_default_encoder_parameters(¶meters); @@ -1215,7 +1214,7 @@ bool imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(fl image = ibuftoimage(ibuf, ¶meters); - opj_codec_t *codec = NULL; + opj_codec_t *codec = nullptr; bool ok = false; /* JP2 format output */ { diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.cc similarity index 93% rename from source/blender/imbuf/intern/jpeg.c rename to source/blender/imbuf/intern/jpeg.cc index e2d49cad374..5556ea006c4 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" #include "BLI_fileops.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -131,7 +132,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) if (num_bytes > 0) { /* prevent skipping over file end */ - size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes : + size_t skip_size = size_t(num_bytes) <= src->pub.bytes_in_buffer ? num_bytes : src->pub.bytes_in_buffer; src->pub.next_input_byte = src->pub.next_input_byte + skip_size; @@ -148,7 +149,7 @@ static void memory_source(j_decompress_ptr cinfo, const uchar *buffer, size_t si { my_src_ptr src; - if (cinfo->src == NULL) { /* first time for this JPEG object? */ + if (cinfo->src == nullptr) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small)( (j_common_ptr)cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr)); } @@ -209,7 +210,7 @@ static void memory_source(j_decompress_ptr cinfo, const uchar *buffer, size_t si */ #define INPUT_2BYTES(cinfo, V, action) \ MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; \ - V = (uint)GETJOCTET(*next_input_byte++) << 8; \ + V = uint(GETJOCTET(*next_input_byte++)) << 8; \ MAKE_BYTE_AVAIL(cinfo, action); \ bytes_in_buffer--; \ V += GETJOCTET(*next_input_byte++);) @@ -257,10 +258,10 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, size_t *r_height) { JSAMPARRAY row_pointer; - JSAMPLE *buffer = NULL; + JSAMPLE *buffer = nullptr; int row_stride; int x, y, depth, r, g, b, k; - struct ImBuf *ibuf = NULL; + struct ImBuf *ibuf = nullptr; uchar *rect; jpeg_saved_marker_ptr marker; char *str, *key, *value; @@ -288,9 +289,9 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, if (max_size > 0) { /* `libjpeg` can more quickly decompress while scaling down to 1/2, 1/4, 1/8, * while `libjpeg-turbo` can also do 3/8, 5/8, etc. But max is 1/8. */ - float scale = (float)max_size / MAX2(cinfo->image_width, cinfo->image_height); + float scale = float(max_size) / MAX2(cinfo->image_width, cinfo->image_height); cinfo->scale_denom = 8; - cinfo->scale_num = max_uu(1, min_uu(8, ceill(scale * (float)cinfo->scale_denom))); + cinfo->scale_num = max_uu(1, min_uu(8, ceill(scale * float(cinfo->scale_denom)))); cinfo->dct_method = JDCT_FASTEST; cinfo->dither_mode = JDITHER_ORDERED; } @@ -304,7 +305,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, jpeg_abort_decompress(cinfo); ibuf = IMB_allocImBuf(x, y, 8 * depth, 0); } - else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect)) == NULL) { + else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect)) == nullptr) { jpeg_abort_decompress(cinfo); } else { @@ -452,7 +453,7 @@ ImBuf *imb_load_jpeg(const uchar *buffer, size_t size, int flags, char colorspac ImBuf *ibuf; if (!imb_is_a_jpeg(buffer, size)) { - return NULL; + return nullptr; } colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); @@ -466,13 +467,13 @@ ImBuf *imb_load_jpeg(const uchar *buffer, size_t size, int flags, char colorspac * We need to clean up the JPEG object, close the input file, and return. */ jpeg_destroy_decompress(cinfo); - return NULL; + return nullptr; } jpeg_create_decompress(cinfo); memory_source(cinfo, buffer, size); - ibuf = ibJpegImageFromCinfo(cinfo, flags, -1, NULL, NULL); + ibuf = ibJpegImageFromCinfo(cinfo, flags, -1, nullptr, nullptr); return ibuf; } @@ -492,7 +493,7 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath, { struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; - FILE *infile = NULL; + FILE *infile = nullptr; colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); @@ -505,28 +506,30 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath, * We need to clean up the JPEG object, close the input file, and return. */ jpeg_destroy_decompress(cinfo); - return NULL; + return nullptr; } - if ((infile = BLI_fopen(filepath, "rb")) == NULL) { + if ((infile = BLI_fopen(filepath, "rb")) == nullptr) { fprintf(stderr, "can't open %s\n", filepath); - return NULL; + return nullptr; } /* If file contains an embedded thumbnail, let's return that instead. */ if ((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI) && - (fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_APP1)) { + (fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_APP1)) + { /* This is a JPEG in EXIF format (SOI + APP1), not JFIF (SOI + APP0). */ uint i = JPEG_APP1_MAX; /* All EXIF data is within this 64K header segment. Skip ahead until next SOI for thumbnail. */ while (!((fgetc(infile) == JPEG_MARKER_MSB) && (fgetc(infile) == JPEG_MARKER_SOI)) && - !feof(infile) && i--) { + !feof(infile) && i--) + { } if (i > 0 && !feof(infile)) { /* We found a JPEG thumbnail inside this image. */ - ImBuf *ibuf = NULL; - uchar *buffer = MEM_callocN(JPEG_APP1_MAX, "thumbbuffer"); + ImBuf *ibuf = nullptr; + uchar *buffer = static_cast(MEM_callocN(JPEG_APP1_MAX, "thumbbuffer")); /* Just put SOI directly in buffer rather than seeking back 2 bytes. */ buffer[0] = JPEG_MARKER_MSB; buffer[1] = JPEG_MARKER_SOI; @@ -560,7 +563,7 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath, static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) { - JSAMPLE *buffer = NULL; + JSAMPLE *buffer = nullptr; JSAMPROW row_pointer[1]; uchar *rect; int x, y; @@ -575,11 +578,11 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) neogeo_word->quality = ibuf->foptions.quality; jpeg_write_marker(cinfo, 0xe1, (JOCTET *)neogeo, 10); if (ibuf->metadata) { - IDProperty *prop; + /* Static storage array for the short metadata. */ char static_text[1024]; const int static_text_size = ARRAY_SIZE(static_text); - for (prop = ibuf->metadata->data.group.first; prop; prop = prop->next) { + LISTBASE_FOREACH (IDProperty *, prop, &ibuf->metadata->data.group) { if (prop->type == IDP_STRING) { int text_len; if (STREQ(prop->name, "None")) { @@ -589,10 +592,10 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) char *text = static_text; int text_size = static_text_size; /* 7 is for Blender, 2 colon separators, length of property - * name and property value, followed by the NULL-terminator. */ + * name and property value, followed by the nullptr-terminator. */ const int text_length_required = 7 + 2 + strlen(prop->name) + strlen(IDP_String(prop)) + 1; if (text_length_required <= static_text_size) { - text = MEM_mallocN(text_length_required, "jpeg metadata field"); + text = static_cast(MEM_mallocN(text_length_required, "jpeg metadata field")); text_size = text_length_required; } @@ -619,8 +622,8 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) } } - row_pointer[0] = MEM_mallocN(sizeof(JSAMPLE) * cinfo->input_components * cinfo->image_width, - "jpeg row_pointer"); + row_pointer[0] = static_cast(MEM_mallocN( + sizeof(JSAMPLE) * cinfo->input_components * cinfo->image_width, "jpeg row_pointer")); for (y = ibuf->y - 1; y >= 0; y--) { rect = (uchar *)(ibuf->rect + y * ibuf->x); @@ -718,7 +721,7 @@ static bool save_stdjpeg(const char *name, struct ImBuf *ibuf) struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo; struct my_error_mgr jerr; - if ((outfile = BLI_fopen(name, "wb")) == NULL) { + if ((outfile = BLI_fopen(name, "wb")) == nullptr) { return 0; } diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.cc similarity index 80% rename from source/blender/imbuf/intern/metadata.c rename to source/blender/imbuf/intern/metadata.cc index 30bf8fccabb..b97e95529ad 100644 --- a/source/blender/imbuf/intern/metadata.c +++ b/source/blender/imbuf/intern/metadata.cc @@ -8,6 +8,7 @@ #include #include +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -24,7 +25,7 @@ void IMB_metadata_ensure(struct IDProperty **metadata) { - if (*metadata != NULL) { + if (*metadata != nullptr) { return; } @@ -34,7 +35,7 @@ void IMB_metadata_ensure(struct IDProperty **metadata) void IMB_metadata_free(struct IDProperty *metadata) { - if (metadata == NULL) { + if (metadata == nullptr) { return; } @@ -48,7 +49,7 @@ bool IMB_metadata_get_field(struct IDProperty *metadata, { IDProperty *prop; - if (metadata == NULL) { + if (metadata == nullptr) { return false; } @@ -75,25 +76,26 @@ void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const BLI_assert(metadata); IDProperty *prop = IDP_GetPropertyFromGroup(metadata, key); - if (prop != NULL && prop->type != IDP_STRING) { + if (prop != nullptr && prop->type != IDP_STRING) { IDP_FreeFromGroup(metadata, prop); - prop = NULL; + prop = nullptr; } - if (prop == NULL) { - prop = IDP_NewString(value, key, 0); + if (prop) { + IDP_AssignString(prop, value); + } + else if (prop == nullptr) { + prop = IDP_NewString(value, key); IDP_AddToGroup(metadata, prop); } - - IDP_AssignString(prop, value, 0); } void IMB_metadata_foreach(struct ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata) { - if (ibuf->metadata == NULL) { + if (ibuf->metadata == nullptr) { return; } - for (IDProperty *prop = ibuf->metadata->data.group.first; prop != NULL; prop = prop->next) { + LISTBASE_FOREACH (IDProperty *, prop, &ibuf->metadata->data.group) { callback(prop->name, IDP_String(prop), userdata); } } diff --git a/source/blender/imbuf/intern/module.c b/source/blender/imbuf/intern/module.cc similarity index 100% rename from source/blender/imbuf/intern/module.c rename to source/blender/imbuf/intern/module.cc diff --git a/source/blender/imbuf/intern/oiio/openimageio_support.cc b/source/blender/imbuf/intern/oiio/openimageio_support.cc index c5e958bfc77..34bd9225182 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_support.cc +++ b/source/blender/imbuf/intern/oiio/openimageio_support.cc @@ -222,7 +222,7 @@ static ImBuf *get_oiio_ibuf(ImageInput *in, const ReadContext &ctx, char colorsp /* Transfer metadata to the ibuf if necessary. */ if (ctx.flags & IB_metadata) { IMB_metadata_ensure(&ibuf->metadata); - ibuf->flags |= (spec.extra_attribs.empty()) ? 0 : IB_metadata; + ibuf->flags |= spec.extra_attribs.empty() ? 0 : IB_metadata; for (const auto &attrib : spec.extra_attribs) { IMB_metadata_set_field(ibuf->metadata, attrib.name().c_str(), attrib.get_string().c_str()); @@ -377,7 +377,8 @@ ImageSpec imb_create_write_spec(const WriteContext &ctx, int file_channels, Type if (ctx.ibuf->metadata) { for (IDProperty *prop = static_cast(ctx.ibuf->metadata->data.group.first); prop; - prop = prop->next) { + prop = prop->next) + { if (prop->type == IDP_STRING) { /* If this property has a prefixed name (oiio:, tiff:, etc.) and it belongs to * oiio or a different format, then skip. */ @@ -385,7 +386,8 @@ ImageSpec imb_create_write_spec(const WriteContext &ctx, int file_channels, Type std::string prefix(prop->name, colon); Strutil::to_lower(prefix); if (prefix == "oiio" || - (!STREQ(prefix.c_str(), ctx.file_format) && OIIO::is_imageio_format_name(prefix))) { + (!STREQ(prefix.c_str(), ctx.file_format) && OIIO::is_imageio_format_name(prefix))) + { /* Skip this attribute. */ continue; } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 00baceff4ac..82982f9d38c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -824,7 +824,7 @@ static void imb_exr_insert_view_name(char *name_full, const char *passname, cons BLI_assert(!ELEM(name_full, passname, viewname)); if (viewname == nullptr || viewname[0] == '\0') { - BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)nullptr)->name)); + BLI_strncpy(name_full, passname, sizeof(ExrChannel::name)); return; } @@ -1686,14 +1686,16 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data) /* we can have RGB(A), XYZ(W), UVA */ if (ELEM(pass->totchan, 3, 4)) { if (pass->chan[0]->chan_id == 'B' || pass->chan[1]->chan_id == 'B' || - pass->chan[2]->chan_id == 'B') { + pass->chan[2]->chan_id == 'B') + { lookup[uint('R')] = 0; lookup[uint('G')] = 1; lookup[uint('B')] = 2; lookup[uint('A')] = 3; } else if (pass->chan[0]->chan_id == 'Y' || pass->chan[1]->chan_id == 'Y' || - pass->chan[2]->chan_id == 'Y') { + pass->chan[2]->chan_id == 'Y') + { lookup[uint('X')] = 0; lookup[uint('Y')] = 1; lookup[uint('Z')] = 2; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.cc similarity index 89% rename from source/blender/imbuf/intern/readimage.c rename to source/blender/imbuf/intern/readimage.cc index bc472457896..1e8bae62ac7 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.cc @@ -35,7 +35,7 @@ static void imb_handle_alpha(ImBuf *ibuf, char effective_colorspace[IM_MAX_SPACE]) { if (colorspace) { - if (ibuf->rect != NULL && ibuf->rect_float == NULL) { + if (ibuf->rect != nullptr && ibuf->rect_float == nullptr) { /* byte buffer is never internally converted to some standard space, * store pointer to its color space descriptor instead */ @@ -88,9 +88,9 @@ ImBuf *IMB_ibImageFromMemory( const ImFileType *type; char effective_colorspace[IM_MAX_SPACE] = ""; - if (mem == NULL) { - fprintf(stderr, "%s: NULL pointer\n", __func__); - return NULL; + if (mem == nullptr) { + fprintf(stderr, "%s: nullptr pointer\n", __func__); + return nullptr; } if (colorspace) { @@ -111,7 +111,7 @@ ImBuf *IMB_ibImageFromMemory( fprintf(stderr, "%s: unknown file-format (%s)\n", __func__, descr); } - return NULL; + return nullptr; } ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const char *descr) @@ -121,7 +121,7 @@ ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const size_t size; if (file == -1) { - return NULL; + return nullptr; } size = BLI_file_descriptor_size(file); @@ -129,12 +129,12 @@ ImBuf *IMB_loadifffile(int file, int flags, char colorspace[IM_MAX_SPACE], const imb_mmap_lock(); BLI_mmap_file *mmap_file = BLI_mmap_open(file); imb_mmap_unlock(); - if (mmap_file == NULL) { + if (mmap_file == nullptr) { fprintf(stderr, "%s: couldn't get mapping %s\n", __func__, descr); - return NULL; + return nullptr; } - mem = BLI_mmap_get_pointer(mmap_file); + mem = static_cast(BLI_mmap_get_pointer(mmap_file)); ibuf = IMB_ibImageFromMemory(mem, size, flags, colorspace, descr); @@ -154,13 +154,13 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { - return NULL; + return nullptr; } ibuf = IMB_loadifffile(file, flags, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } close(file); @@ -173,11 +173,11 @@ struct ImBuf *IMB_thumb_load_image(const char *filepath, char colorspace[IM_MAX_SPACE]) { const ImFileType *type = IMB_file_type_from_ftype(IMB_ispic_type(filepath)); - if (type == NULL) { - return NULL; + if (type == nullptr) { + return nullptr; } - ImBuf *ibuf = NULL; + ImBuf *ibuf = nullptr; int flags = IB_rect | IB_metadata; /* Size of the original image. */ size_t width = 0; @@ -195,8 +195,8 @@ struct ImBuf *IMB_thumb_load_image(const char *filepath, else { /* Skip images of other types if over 100MB. */ const size_t file_size = BLI_file_size(filepath); - if (file_size != (size_t)-1 && file_size > THUMB_SIZE_MAX) { - return NULL; + if (file_size != size_t(-1) && file_size > THUMB_SIZE_MAX) { + return nullptr; } ibuf = IMB_loadiffname(filepath, flags, colorspace); if (ibuf) { @@ -233,13 +233,13 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { - return NULL; + return nullptr; } ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); } close(file); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.cc similarity index 92% rename from source/blender/imbuf/intern/rectop.c rename to source/blender/imbuf/intern/rectop.cc index 65bbb4a7be2..42c783aab09 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.cc @@ -202,14 +202,14 @@ void IMB_blend_color_float(float dst[4], static void rect_crop_4bytes(void **buf_p, const int size_src[2], const rcti *crop) { - if (*buf_p == NULL) { + if (*buf_p == nullptr) { return; } const int size_dst[2] = { BLI_rcti_size_x(crop) + 1, BLI_rcti_size_y(crop) + 1, }; - uint *src = *buf_p; + uint *src = static_cast(*buf_p); uint *dst = src + crop->ymin * size_src[0] + crop->xmin; for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) { memmove(src, dst, sizeof(uint) * size_dst[0]); @@ -219,14 +219,14 @@ static void rect_crop_4bytes(void **buf_p, const int size_src[2], const rcti *cr static void rect_crop_16bytes(void **buf_p, const int size_src[2], const rcti *crop) { - if (*buf_p == NULL) { + if (*buf_p == nullptr) { return; } const int size_dst[2] = { BLI_rcti_size_x(crop) + 1, BLI_rcti_size_y(crop) + 1, }; - uint(*src)[4] = *buf_p; + uint(*src)[4] = static_cast(*buf_p); uint(*dst)[4] = src + crop->ymin * size_src[0] + crop->xmin; for (int y = 0; y < size_dst[1]; y++, src += size_dst[0], dst += size_src[0]) { memmove(src, dst, sizeof(uint[4]) * size_dst[0]); @@ -266,7 +266,7 @@ void IMB_rect_crop(ImBuf *ibuf, const rcti *crop) */ static void rect_realloc_4bytes(void **buf_p, const uint size[2]) { - if (*buf_p == NULL) { + if (*buf_p == nullptr) { return; } MEM_freeN(*buf_p); @@ -275,7 +275,7 @@ static void rect_realloc_4bytes(void **buf_p, const uint size[2]) static void rect_realloc_16bytes(void **buf_p, const uint size[2]) { - if (*buf_p == NULL) { + if (*buf_p == nullptr) { return; } MEM_freeN(*buf_p); @@ -313,7 +313,7 @@ void IMB_rectclip(ImBuf *dbuf, { int tmp; - if (dbuf == NULL) { + if (dbuf == nullptr) { return; } @@ -378,7 +378,7 @@ static void imb_rectclip3(ImBuf *dbuf, { int tmp; - if (dbuf == NULL) { + if (dbuf == nullptr) { return; } @@ -471,9 +471,9 @@ void IMB_rectcpy(ImBuf *dbuf, IMB_rectblend(dbuf, dbuf, sbuf, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, 0, destx, desty, @@ -508,16 +508,16 @@ void IMB_rectblend(ImBuf *dbuf, IMB_BlendMode mode, bool accumulate) { - uint *drect = NULL, *orect = NULL, *srect = NULL, *dr, * or, *sr; - float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf; + uint *drect = nullptr, *orect = nullptr, *srect = nullptr, *dr, *outr, *sr; + float *drectf = nullptr, *orectf = nullptr, *srectf = nullptr, *drf, *orf, *srf; const ushort *cmaskrect = curvemask, *cmr; ushort *dmaskrect = dmask, *dmr; const ushort *texmaskrect = texmask, *tmr; int srcskip, destskip, origskip, x; - IMB_blend_func func = NULL; - IMB_blend_func_float func_float = NULL; + IMB_blend_func func = nullptr; + IMB_blend_func_float func_float = nullptr; - if (dbuf == NULL || obuf == NULL) { + if (dbuf == nullptr || obuf == nullptr) { return; } @@ -537,16 +537,16 @@ void IMB_rectblend(ImBuf *dbuf, const bool do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float); if (do_char) { - drect = dbuf->rect + ((size_t)desty) * dbuf->x + destx; - orect = obuf->rect + ((size_t)origy) * obuf->x + origx; + drect = dbuf->rect + size_t(desty) * dbuf->x + destx; + orect = obuf->rect + size_t(origy) * obuf->x + origx; } if (do_float) { - drectf = dbuf->rect_float + (((size_t)desty) * dbuf->x + destx) * 4; - orectf = obuf->rect_float + (((size_t)origy) * obuf->x + origx) * 4; + drectf = dbuf->rect_float + (size_t(desty) * dbuf->x + destx) * 4; + orectf = obuf->rect_float + (size_t(origy) * obuf->x + origx) * 4; } if (dmaskrect) { - dmaskrect += ((size_t)origy) * obuf->x + origx; + dmaskrect += size_t(origy) * obuf->x + origx; } destskip = dbuf->x; @@ -554,19 +554,19 @@ void IMB_rectblend(ImBuf *dbuf, if (sbuf) { if (do_char) { - srect = sbuf->rect + ((size_t)srcy) * sbuf->x + srcx; + srect = sbuf->rect + size_t(srcy) * sbuf->x + srcx; } if (do_float) { - srectf = sbuf->rect_float + (((size_t)srcy) * sbuf->x + srcx) * 4; + srectf = sbuf->rect_float + (size_t(srcy) * sbuf->x + srcx) * 4; } srcskip = sbuf->x; if (cmaskrect) { - cmaskrect += ((size_t)srcy) * sbuf->x + srcx; + cmaskrect += size_t(srcy) * sbuf->x + srcx; } if (texmaskrect) { - texmaskrect += ((size_t)srcy) * sbuf->x + srcx; + texmaskrect += size_t(srcy) * sbuf->x + srcx; } } else { @@ -752,7 +752,7 @@ void IMB_rectblend(ImBuf *dbuf, for (; height > 0; height--) { if (do_char) { dr = drect; - or = orect; + outr = orect; sr = srect; if (cmaskrect) { @@ -763,7 +763,7 @@ void IMB_rectblend(ImBuf *dbuf, /* destination mask present, do max alpha masking */ if (dmaskrect) { dmr = dmaskrect; - for (x = width; x > 0; x--, dr++, or ++, sr++, dmr++, cmr++) { + for (x = width; x > 0; x--, dr++, outr++, sr++, dmr++, cmr++) { uchar *src = (uchar *)sr; float mask_lim = mask_max * (*cmr); @@ -795,11 +795,11 @@ void IMB_rectblend(ImBuf *dbuf, if (mode == IMB_BLEND_INTERPOLATE) { mask_src[3] = src[3]; blend_color_interpolate_byte( - (uchar *)dr, (uchar *) or, mask_src, mask / 65535.0f); + (uchar *)dr, (uchar *)outr, mask_src, mask / 65535.0f); } else { mask_src[3] = divide_round_i(src[3] * mask, 65535); - func((uchar *)dr, (uchar *) or, mask_src); + func((uchar *)dr, (uchar *)outr, mask_src); } } } @@ -808,12 +808,12 @@ void IMB_rectblend(ImBuf *dbuf, } /* no destination mask buffer, do regular blend with masktexture if present */ else { - for (x = width; x > 0; x--, dr++, or ++, sr++, cmr++) { + for (x = width; x > 0; x--, dr++, outr++, sr++, cmr++) { uchar *src = (uchar *)sr; - float mask = (float)mask_max * (float)(*cmr); + float mask = float(mask_max) * float(*cmr); if (texmaskrect) { - mask *= ((float)(*tmr++) / 65535.0f); + mask *= (float(*tmr++) / 65535.0f); } mask = min_ff(mask, 65535.0); @@ -828,11 +828,11 @@ void IMB_rectblend(ImBuf *dbuf, if (mode == IMB_BLEND_INTERPOLATE) { mask_src[3] = src[3]; blend_color_interpolate_byte( - (uchar *)dr, (uchar *) or, mask_src, mask / 65535.0f); + (uchar *)dr, (uchar *)outr, mask_src, mask / 65535.0f); } else { mask_src[3] = divide_round_i(src[3] * mask, 65535); - func((uchar *)dr, (uchar *) or, mask_src); + func((uchar *)dr, (uchar *)outr, mask_src); } } } @@ -845,9 +845,9 @@ void IMB_rectblend(ImBuf *dbuf, } else { /* regular blending */ - for (x = width; x > 0; x--, dr++, or ++, sr++) { + for (x = width; x > 0; x--, dr++, outr++, sr++) { if (((uchar *)sr)[3]) { - func((uchar *)dr, (uchar *) or, (uchar *)sr); + func((uchar *)dr, (uchar *)outr, (uchar *)sr); } } } @@ -908,10 +908,10 @@ void IMB_rectblend(ImBuf *dbuf, /* no destination mask buffer, do regular blend with masktexture if present */ else { for (x = width; x > 0; x--, drf += 4, orf += 4, srf += 4, cmr++) { - float mask = (float)mask_max * (float)(*cmr); + float mask = float(mask_max) * float(*cmr); if (texmaskrect) { - mask *= ((float)(*tmr++) / 65535.0f); + mask *= (float(*tmr++) / 65535.0f); } mask = min_ff(mask, 65535.0); @@ -1004,7 +1004,7 @@ void IMB_rectblend_threaded(ImBuf *dbuf, IMB_BlendMode mode, bool accumulate) { - if (((size_t)width) * height < 64 * 64) { + if (size_t(width) * height < 64 * 64) { IMB_rectblend(dbuf, obuf, sbuf, @@ -1053,10 +1053,10 @@ void IMB_rectfill(ImBuf *drect, const float col[4]) uint *rrect = drect->rect; char ccol[4]; - ccol[0] = (int)(col[0] * 255); - ccol[1] = (int)(col[1] * 255); - ccol[2] = (int)(col[2] * 255); - ccol[3] = (int)(col[3] * 255); + ccol[0] = int(col[0] * 255); + ccol[1] = int(col[1] * 255); + ccol[2] = int(col[2] * 255); + ccol[3] = int(col[3] * 255); num = drect->x * drect->y; for (; num > 0; num--) { @@ -1104,11 +1104,12 @@ void IMB_rectfill_area_replace( return; } - uchar col_char[4] = {col[0] * 255, col[1] * 255, col[2] * 255, col[3] * 255}; + uchar col_char[4] = { + uchar(col[0] * 255), uchar(col[1] * 255), uchar(col[2] * 255), uchar(col[3] * 255)}; for (int y = y1; y < y2; y++) { for (int x = x1; x < x2; x++) { - size_t offset = ((size_t)ibuf->x) * y * 4 + 4 * x; + size_t offset = size_t(ibuf->x) * y * 4 + 4 * x; if (ibuf->rect) { uchar *rrect = (uchar *)ibuf->rect + offset; @@ -1191,10 +1192,10 @@ void buf_rectfill_area(uchar *rect, } else { int alphatest; - pixel[0] = (char)((fr + ((float)pixel[0] * aich)) * 255.0f); - pixel[1] = (char)((fg + ((float)pixel[1] * aich)) * 255.0f); - pixel[2] = (char)((fb + ((float)pixel[2] * aich)) * 255.0f); - pixel[3] = (char)((alphatest = ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255); + pixel[0] = char((fr + (float(pixel[0]) * aich)) * 255.0f); + pixel[1] = char((fg + (float(pixel[1]) * aich)) * 255.0f); + pixel[2] = char((fb + (float(pixel[2]) * aich)) * 255.0f); + pixel[3] = char((alphatest = (int(pixel[3]) + alphaint)) < 255 ? alphatest : 255); } } } diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.cc similarity index 85% rename from source/blender/imbuf/intern/rotate.c rename to source/blender/imbuf/intern/rotate.cc index 7081bf2ad26..037eabca045 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.cc @@ -17,7 +17,7 @@ void IMB_flipy(struct ImBuf *ibuf) { size_t x_size, y_size; - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -31,7 +31,7 @@ void IMB_flipy(struct ImBuf *ibuf) top = ibuf->rect; bottom = top + ((y_size - 1) * x_size); - line = MEM_mallocN(stride, "linebuf"); + line = static_cast(MEM_mallocN(stride, "linebuf")); y_size >>= 1; @@ -47,7 +47,7 @@ void IMB_flipy(struct ImBuf *ibuf) } if (ibuf->rect_float) { - float *topf = NULL, *bottomf = NULL, *linef = NULL; + float *topf = nullptr, *bottomf = nullptr, *linef = nullptr; x_size = ibuf->x; y_size = ibuf->y; @@ -56,7 +56,7 @@ void IMB_flipy(struct ImBuf *ibuf) topf = ibuf->rect_float; bottomf = topf + 4 * ((y_size - 1) * x_size); - linef = MEM_mallocN(stride, "linebuf"); + linef = static_cast(MEM_mallocN(stride, "linebuf")); y_size >>= 1; @@ -77,7 +77,7 @@ void IMB_flipx(struct ImBuf *ibuf) int x, y, xr, xl, yi; float px_f[4]; - if (ibuf == NULL) { + if (ibuf == nullptr) { return; } @@ -86,7 +86,7 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect) { for (yi = y - 1; yi >= 0; yi--) { - const size_t x_offset = (size_t)x * yi; + const size_t x_offset = size_t(x) * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { SWAP(uint, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]); } @@ -95,7 +95,7 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { - const size_t x_offset = (size_t)x * yi; + const size_t x_offset = size_t(x) * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { memcpy(&px_f, &ibuf->rect_float[(x_offset + xr) * 4], sizeof(float[4])); memcpy(&ibuf->rect_float[(x_offset + xr) * 4], diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.cc similarity index 86% rename from source/blender/imbuf/intern/scaling.c rename to source/blender/imbuf/intern/scaling.cc index 6332310f43c..e8a659734e7 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.cc @@ -28,8 +28,8 @@ static void imb_half_x_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) float af, rf, gf, bf, *p1f, *_p1f, *destf; bool do_rect, do_float; - do_rect = (ibuf1->rect != NULL); - do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL); + do_rect = (ibuf1->rect != nullptr); + do_float = (ibuf1->rect_float != nullptr && ibuf2->rect_float != nullptr); _p1 = (uchar *)ibuf1->rect; dest = (uchar *)ibuf2->rect; @@ -83,11 +83,11 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) { struct ImBuf *ibuf2; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } if (ibuf1->x <= 1) { @@ -95,8 +95,8 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) } ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, ibuf1->y, ibuf1->planes, ibuf1->flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } imb_half_x_no_alloc(ibuf2, ibuf1); @@ -110,19 +110,19 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1) int *p1, *dest, i, col, do_rect, do_float; float *p1f, *destf; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } - do_rect = (ibuf1->rect != NULL); - do_float = (ibuf1->rect_float != NULL); + do_rect = (ibuf1->rect != nullptr); + do_float = (ibuf1->rect_float != nullptr); ibuf2 = IMB_allocImBuf(2 * ibuf1->x, ibuf1->y, ibuf1->planes, ibuf1->flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } p1 = (int *)ibuf1->rect; @@ -153,11 +153,11 @@ struct ImBuf *IMB_double_x(struct ImBuf *ibuf1) { struct ImBuf *ibuf2; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } ibuf2 = IMB_double_fast_x(ibuf1); @@ -173,11 +173,11 @@ static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) int x, y; float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf; - p1 = p2 = NULL; - p1f = p2f = NULL; + p1 = p2 = nullptr; + p1f = p2f = nullptr; - const bool do_rect = (ibuf1->rect != NULL); - const bool do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL); + const bool do_rect = (ibuf1->rect != nullptr); + const bool do_float = (ibuf1->rect_float != nullptr && ibuf2->rect_float != nullptr); _p1 = (uchar *)ibuf1->rect; dest = (uchar *)ibuf2->rect; @@ -236,11 +236,11 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) { struct ImBuf *ibuf2; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } if (ibuf1->y <= 1) { @@ -248,8 +248,8 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) } ibuf2 = IMB_allocImBuf(ibuf1->x, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } imb_half_y_no_alloc(ibuf2, ibuf1); @@ -264,19 +264,19 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) float *p1f, *dest1f, *dest2f; int x, y; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } - const bool do_rect = (ibuf1->rect != NULL); - const bool do_float = (ibuf1->rect_float != NULL); + const bool do_rect = (ibuf1->rect != nullptr); + const bool do_float = (ibuf1->rect_float != nullptr); ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } p1 = (int *)ibuf1->rect; @@ -308,11 +308,11 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1) { struct ImBuf *ibuf2; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL) { - return NULL; + if (ibuf1->rect == nullptr) { + return nullptr; } ibuf2 = IMB_double_fast_y(ibuf1); @@ -345,9 +345,9 @@ MINLINE void premul_ushort_to_straight_uchar(uchar *result, const ushort color[4 else { ushort alpha = color[3] / 256; - result[0] = unit_ushort_to_uchar((ushort)(color[0] / alpha * 256)); - result[1] = unit_ushort_to_uchar((ushort)(color[1] / alpha * 256)); - result[2] = unit_ushort_to_uchar((ushort)(color[2] / alpha * 256)); + result[0] = unit_ushort_to_uchar(ushort(color[0] / alpha * 256)); + result[1] = unit_ushort_to_uchar(ushort(color[1] / alpha * 256)); + result[2] = unit_ushort_to_uchar(ushort(color[2] / alpha * 256)); result[3] = unit_ushort_to_uchar(color[3]); } } @@ -355,10 +355,10 @@ MINLINE void premul_ushort_to_straight_uchar(uchar *result, const ushort color[4 void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) { int x, y; - const bool do_rect = (ibuf1->rect != NULL); - const bool do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL); + const bool do_rect = (ibuf1->rect != nullptr); + const bool do_float = (ibuf1->rect_float != nullptr) && (ibuf2->rect_float != nullptr); - if (do_rect && (ibuf2->rect == NULL)) { + if (do_rect && (ibuf2->rect == nullptr)) { imb_addrectImBuf(ibuf2); } @@ -387,10 +387,10 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) straight_uchar_to_premul_ushort(p1i + 4, cp1 + 4); straight_uchar_to_premul_ushort(p2i + 4, cp2 + 4); - desti[0] = ((uint)p1i[0] + p2i[0] + p1i[4] + p2i[4]) >> 2; - desti[1] = ((uint)p1i[1] + p2i[1] + p1i[5] + p2i[5]) >> 2; - desti[2] = ((uint)p1i[2] + p2i[2] + p1i[6] + p2i[6]) >> 2; - desti[3] = ((uint)p1i[3] + p2i[3] + p1i[7] + p2i[7]) >> 2; + desti[0] = (uint(p1i[0]) + p2i[0] + p1i[4] + p2i[4]) >> 2; + desti[1] = (uint(p1i[1]) + p2i[1] + p1i[5] + p2i[5]) >> 2; + desti[2] = (uint(p1i[2]) + p2i[2] + p1i[6] + p2i[6]) >> 2; + desti[3] = (uint(p1i[3]) + p2i[3] + p1i[7] + p2i[7]) >> 2; premul_ushort_to_straight_uchar(dest, desti); @@ -433,11 +433,11 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1) { struct ImBuf *ibuf2; - if (ibuf1 == NULL) { - return NULL; + if (ibuf1 == nullptr) { + return nullptr; } - if (ibuf1->rect == NULL && ibuf1->rect_float == NULL) { - return NULL; + if (ibuf1->rect == nullptr && ibuf1->rect_float == nullptr) { + return nullptr; } if (ibuf1->x <= 1) { @@ -448,8 +448,8 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1) } ibuf2 = IMB_allocImBuf((ibuf1->x) / 2, (ibuf1->y) / 2, ibuf1->planes, ibuf1->flags); - if (ibuf2 == NULL) { - return NULL; + if (ibuf2 == nullptr) { + return nullptr; } imb_onehalf_no_alloc(ibuf2, ibuf1); @@ -462,8 +462,8 @@ ImBuf *IMB_onehalf(struct ImBuf *ibuf1) static void enlarge_picture_byte( uchar *src, uchar *dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double)(dst_width - 1.0) / (double)(src_width - 1.001); - double ratioy = (double)(dst_height - 1.0) / (double)(src_height - 1.001); + double ratiox = double(dst_width - 1.0) / double(src_width - 1.001); + double ratioy = double(dst_height - 1.0) / double(src_height - 1.001); uintptr_t x_src, dx_src, x_dst; uintptr_t y_src, dy_src, y_dst; @@ -526,15 +526,15 @@ struct scale_outpix_byte { static void shrink_picture_byte( uchar *src, uchar *dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double)(dst_width) / (double)(src_width); - double ratioy = (double)(dst_height) / (double)(src_height); + double ratiox = double(dst_width) / double(src_width); + double ratioy = double(dst_height) / double(src_height); uintptr_t x_src, dx_dst, x_dst; uintptr_t y_src, dy_dst, y_dst; intptr_t y_counter; uchar *dst_begin = dst; - struct scale_outpix_byte *dst_line1 = NULL; - struct scale_outpix_byte *dst_line2 = NULL; + struct scale_outpix_byte *dst_line1 = nullptr; + struct scale_outpix_byte *dst_line2 = nullptr; dst_line1 = (struct scale_outpix_byte *)MEM_callocN( (dst_width + 1) * sizeof(struct scale_outpix_byte), "shrink_picture_byte 1"); @@ -648,8 +648,8 @@ static void q_scale_byte( static void enlarge_picture_float( float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double)(dst_width - 1.0) / (double)(src_width - 1.001); - double ratioy = (double)(dst_height - 1.0) / (double)(src_height - 1.001); + double ratiox = double(dst_width - 1.0) / double(src_width - 1.001); + double ratioy = double(dst_height - 1.0) / double(src_height - 1.001); uintptr_t x_dst; uintptr_t y_dst; double x_src, dx_src; @@ -660,26 +660,26 @@ static void enlarge_picture_float( y_src = 0; for (y_dst = 0; y_dst < dst_height; y_dst++) { - float *line1 = src + ((int)y_src) * 4 * src_width; + float *line1 = src + int(y_src) * 4 * src_width; const float *line2 = line1 + 4 * src_width; - const float weight1y = (float)(1.0 - (y_src - (int)y_src)); + const float weight1y = float(1.0 - (y_src - int(y_src))); const float weight2y = 1.0f - weight1y; - if ((int)y_src == src_height - 1) { + if (int(y_src) == src_height - 1) { line2 = line1; } x_src = 0; for (x_dst = 0; x_dst < dst_width; x_dst++) { - const float weight1x = (float)(1.0 - (x_src - (int)x_src)); - const float weight2x = (float)(1.0f - weight1x); + const float weight1x = float(1.0 - (x_src - int(x_src))); + const float weight2x = float(1.0f - weight1x); const float w11 = weight1y * weight1x; const float w21 = weight2y * weight1x; const float w12 = weight1y * weight2x; const float w22 = weight2y * weight2x; - uintptr_t x = ((int)x_src) * 4; + uintptr_t x = int(x_src) * 4; *dst++ = line1[x] * w11 + line2[x] * w21 + line1[4 + x] * w12 + line2[4 + x] * w22; @@ -710,8 +710,8 @@ struct scale_outpix_float { static void shrink_picture_float( const float *src, float *dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double)(dst_width) / (double)(src_width); - double ratioy = (double)(dst_height) / (double)(src_height); + double ratiox = double(dst_width) / double(src_width); + double ratioy = double(dst_height) / double(src_height); uintptr_t x_src; uintptr_t y_src; float dx_dst, x_dst; @@ -734,14 +734,14 @@ static void shrink_picture_float( y_counter = 1.0; for (y_src = 0; y_src < src_height; y_src++) { const float *line = src + y_src * 4 * src_width; - uintptr_t weight1y = 1.0f - (y_dst - (int)y_dst); + uintptr_t weight1y = 1.0f - (y_dst - int(y_dst)); uintptr_t weight2y = 1.0f - weight1y; x_dst = 0; for (x_src = 0; x_src < src_width; x_src++) { - uintptr_t weight1x = 1.0f - (x_dst - (int)x_dst); + uintptr_t weight1x = 1.0f - (x_dst - int(x_dst)); uintptr_t weight2x = 1.0f - weight1x; - uintptr_t x = (int)x_dst; + uintptr_t x = int(x_dst); float w; @@ -855,7 +855,7 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) } if (ibuf->rect) { - uchar *newrect = MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect"); + uchar *newrect = static_cast(MEM_mallocN(sizeof(int) * newx * newy, "q_scale rect")); q_scale_byte((uchar *)ibuf->rect, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectImBuf(ibuf); @@ -863,7 +863,8 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) ibuf->rect = (uint *)newrect; } if (ibuf->rect_float) { - float *newrect = MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat"); + float *newrect = static_cast( + MEM_mallocN(sizeof(float[4]) * newx * newy, "q_scale rectfloat")); q_scale_float(ibuf->rect_float, newrect, ibuf->x, ibuf->y, newx, newy); imb_freerectfloatImBuf(ibuf); ibuf->mall |= IB_rectfloat; @@ -877,8 +878,8 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy) static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) { - const bool do_rect = (ibuf->rect != NULL); - const bool do_float = (ibuf->rect_float != NULL); + const bool do_rect = (ibuf->rect != nullptr); + const bool do_float = (ibuf->rect_float != nullptr); const size_t rect_size = IMB_get_rect_len(ibuf) * 4; uchar *rect, *_newrect, *newrect; @@ -886,8 +887,8 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) float sample, add, val[4], nval[4], valf[4], nvalf[4]; int x, y; - rectf = _newrectf = newrectf = NULL; - rect = _newrect = newrect = NULL; + rectf = _newrectf = newrectf = nullptr; + rect = _newrect = newrect = nullptr; nval[0] = nval[1] = nval[2] = nval[3] = 0.0f; nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f; @@ -896,14 +897,15 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) } if (do_rect) { - _newrect = MEM_mallocN(sizeof(uchar[4]) * newx * ibuf->y, "scaledownx"); - if (_newrect == NULL) { + _newrect = static_cast(MEM_mallocN(sizeof(uchar[4]) * newx * ibuf->y, "scaledownx")); + if (_newrect == nullptr) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaledownxf"); - if (_newrectf == NULL) { + _newrectf = static_cast( + MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaledownxf")); + if (_newrectf == nullptr) { if (_newrect) { MEM_freeN(_newrect); } @@ -1018,8 +1020,8 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx) static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) { - const bool do_rect = (ibuf->rect != NULL); - const bool do_float = (ibuf->rect_float != NULL); + const bool do_rect = (ibuf->rect != nullptr); + const bool do_float = (ibuf->rect_float != nullptr); const size_t rect_size = IMB_get_rect_len(ibuf) * 4; uchar *rect, *_newrect, *newrect; @@ -1027,8 +1029,8 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) float sample, add, val[4], nval[4], valf[4], nvalf[4]; int x, y, skipx; - rectf = _newrectf = newrectf = NULL; - rect = _newrect = newrect = NULL; + rectf = _newrectf = newrectf = nullptr; + rect = _newrect = newrect = nullptr; nval[0] = nval[1] = nval[2] = nval[3] = 0.0f; nvalf[0] = nvalf[1] = nvalf[2] = nvalf[3] = 0.0f; @@ -1037,14 +1039,15 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) } if (do_rect) { - _newrect = MEM_mallocN(sizeof(uchar[4]) * newy * ibuf->x, "scaledowny"); - if (_newrect == NULL) { + _newrect = static_cast(MEM_mallocN(sizeof(uchar[4]) * newy * ibuf->x, "scaledowny")); + if (_newrect == nullptr) { return ibuf; } } if (do_float) { - _newrectf = MEM_mallocN(sizeof(float[4]) * newy * ibuf->x, "scaledownyf"); - if (_newrectf == NULL) { + _newrectf = static_cast( + MEM_mallocN(sizeof(float[4]) * newy * ibuf->x, "scaledownyf")); + if (_newrectf == nullptr) { if (_newrect) { MEM_freeN(_newrect); } @@ -1160,29 +1163,29 @@ static ImBuf *scaledowny(struct ImBuf *ibuf, int newy) static ImBuf *scaleupx(struct ImBuf *ibuf, int newx) { - uchar *rect, *_newrect = NULL, *newrect; - float *rectf, *_newrectf = NULL, *newrectf; + uchar *rect, *_newrect = nullptr, *newrect; + float *rectf, *_newrectf = nullptr, *newrectf; int x, y; bool do_rect = false, do_float = false; - if (ibuf == NULL) { - return NULL; + if (ibuf == nullptr) { + return nullptr; } - if (ibuf->rect == NULL && ibuf->rect_float == NULL) { + if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) { return ibuf; } if (ibuf->rect) { do_rect = true; - _newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx"); - if (_newrect == NULL) { + _newrect = static_cast(MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx")); + if (_newrect == nullptr) { return ibuf; } } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaleupxf"); - if (_newrectf == NULL) { + _newrectf = static_cast(MEM_mallocN(sizeof(float[4]) * newx * ibuf->y, "scaleupxf")); + if (_newrectf == nullptr) { if (_newrect) { MEM_freeN(_newrect); } @@ -1362,29 +1365,29 @@ static ImBuf *scaleupx(struct ImBuf *ibuf, int newx) static ImBuf *scaleupy(struct ImBuf *ibuf, int newy) { - uchar *rect, *_newrect = NULL, *newrect; - float *rectf, *_newrectf = NULL, *newrectf; + uchar *rect, *_newrect = nullptr, *newrect; + float *rectf, *_newrectf = nullptr, *newrectf; int x, y, skipx; bool do_rect = false, do_float = false; - if (ibuf == NULL) { - return NULL; + if (ibuf == nullptr) { + return nullptr; } - if (ibuf->rect == NULL && ibuf->rect_float == NULL) { + if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) { return ibuf; } if (ibuf->rect) { do_rect = true; - _newrect = MEM_mallocN(ibuf->x * newy * sizeof(int), "scaleupy"); - if (_newrect == NULL) { + _newrect = static_cast(MEM_mallocN(ibuf->x * newy * sizeof(int), "scaleupy")); + if (_newrect == nullptr) { return ibuf; } } if (ibuf->rect_float) { do_float = true; - _newrectf = MEM_mallocN(sizeof(float[4]) * ibuf->x * newy, "scaleupyf"); - if (_newrectf == NULL) { + _newrectf = static_cast(MEM_mallocN(sizeof(float[4]) * ibuf->x * newy, "scaleupyf")); + if (_newrectf == nullptr) { if (_newrect) { MEM_freeN(_newrect); } @@ -1565,21 +1568,22 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy) static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) { - int *zbuf, *newzbuf, *_newzbuf = NULL; - float *zbuf_float, *newzbuf_float, *_newzbuf_float = NULL; + int *zbuf, *newzbuf, *_newzbuf = nullptr; + float *zbuf_float, *newzbuf_float, *_newzbuf_float = nullptr; int x, y; int ofsx, ofsy, stepx, stepy; if (ibuf->zbuf) { - _newzbuf = MEM_mallocN(newx * newy * sizeof(int), __func__); - if (_newzbuf == NULL) { + _newzbuf = static_cast(MEM_mallocN(newx * newy * sizeof(int), __func__)); + if (_newzbuf == nullptr) { IMB_freezbufImBuf(ibuf); } } if (ibuf->zbuf_float) { - _newzbuf_float = MEM_mallocN((size_t)newx * newy * sizeof(float), __func__); - if (_newzbuf_float == NULL) { + _newzbuf_float = static_cast( + MEM_mallocN(size_t(newx) * newy * sizeof(float), __func__)); + if (_newzbuf_float == nullptr) { IMB_freezbuffloatImBuf(ibuf); } } @@ -1632,10 +1636,10 @@ bool IMB_scaleImBuf(struct ImBuf *ibuf, uint newx, uint newy) { BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } - if (ibuf->rect == NULL && ibuf->rect_float == NULL) { + if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) { return false; } @@ -1683,14 +1687,14 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, uint newx, uint newy) bool do_float = false, do_rect = false; size_t ofsx, ofsy, stepx, stepy; - rect = NULL; - _newrect = NULL; - newrect = NULL; - rectf = NULL; - _newrectf = NULL; - newrectf = NULL; + rect = nullptr; + _newrect = nullptr; + newrect = nullptr; + rectf = nullptr; + _newrectf = nullptr; + newrectf = nullptr; - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } if (ibuf->rect) { @@ -1708,16 +1712,17 @@ bool IMB_scalefastImBuf(struct ImBuf *ibuf, uint newx, uint newy) } if (do_rect) { - _newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf"); - if (_newrect == NULL) { + _newrect = static_cast(MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf")); + if (_newrect == nullptr) { return false; } newrect = _newrect; } if (do_float) { - _newrectf = MEM_mallocN(sizeof(float[4]) * newx * newy, "scalefastimbuf f"); - if (_newrectf == NULL) { + _newrectf = static_cast( + MEM_mallocN(sizeof(float[4]) * newx * newy, "scalefastimbuf f")); + if (_newrectf == nullptr) { if (_newrect) { MEM_freeN(_newrect); } @@ -1818,16 +1823,16 @@ static void *do_scale_thread(void *data_v) ScaleThreadData *data = (ScaleThreadData *)data_v; ImBuf *ibuf = data->ibuf; int i; - float factor_x = (float)ibuf->x / data->newx; - float factor_y = (float)ibuf->y / data->newy; + float factor_x = float(ibuf->x) / data->newx; + float factor_y = float(ibuf->y) / data->newy; for (i = 0; i < data->tot_line; i++) { int y = data->start_line + i; int x; for (x = 0; x < data->newx; x++) { - float u = (float)x * factor_x; - float v = (float)y * factor_y; + float u = float(x) * factor_x; + float v = float(y) * factor_y; int offset = y * data->newx + x; if (data->byte_buffer) { @@ -1843,14 +1848,14 @@ static void *do_scale_thread(void *data_v) } } - return NULL; + return nullptr; } void IMB_scaleImBuf_threaded(ImBuf *ibuf, uint newx, uint newy) { BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); - ScaleTreadInitData init_data = {NULL}; + ScaleTreadInitData init_data = {nullptr}; /* prepare initialization data */ init_data.ibuf = ibuf; @@ -1859,13 +1864,13 @@ void IMB_scaleImBuf_threaded(ImBuf *ibuf, uint newx, uint newy) init_data.newy = newy; if (ibuf->rect) { - init_data.byte_buffer = MEM_mallocN(4 * newx * newy * sizeof(char), - "threaded scale byte buffer"); + init_data.byte_buffer = static_cast( + MEM_mallocN(4 * newx * newy * sizeof(char), "threaded scale byte buffer")); } if (ibuf->rect_float) { - init_data.float_buffer = MEM_mallocN(ibuf->channels * newx * newy * sizeof(float), - "threaded scale float buffer"); + init_data.float_buffer = static_cast( + MEM_mallocN(ibuf->channels * newx * newy * sizeof(float), "threaded scale float buffer")); } /* actual scaling threads */ diff --git a/source/blender/imbuf/intern/stereoimbuf.c b/source/blender/imbuf/intern/stereoimbuf.cc similarity index 94% rename from source/blender/imbuf/intern/stereoimbuf.c rename to source/blender/imbuf/intern/stereoimbuf.cc index b99850254e0..61117646e38 100644 --- a/source/blender/imbuf/intern/stereoimbuf.c +++ b/source/blender/imbuf/intern/stereoimbuf.cc @@ -165,7 +165,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, switch (mode) { case S3D_INTERLACE_ROW: { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { float *to = rect_to + stride_to * y * channels; const float *from[2] = { @@ -186,7 +186,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_right + stride_from * y, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) { to[0] = from[i][0]; i = !i; @@ -201,7 +201,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_right + stride_from * y * 3, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) { copy_v3_v3(to, from[i]); i = !i; @@ -216,7 +216,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_right + stride_from * y * channels, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) { copy_v4_v4(to, from[i]); i = !i; @@ -227,7 +227,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } case S3D_INTERLACE_CHECKERBOARD: { if (channels == 1) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { float *to = rect_to + stride_to * y; const float *from[2] = { @@ -243,7 +243,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } } else if (channels == 3) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { float *to = rect_to + stride_to * y * 3; const float *from[2] = { @@ -259,7 +259,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } } else if (channels == 4) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { float *to = rect_to + stride_to * y * 4; const float *from[2] = { @@ -288,7 +288,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, switch (mode) { case S3D_INTERLACE_ROW: { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { uchar *to = rect_to + stride_to * y * channels; const uchar *from[2] = { @@ -308,7 +308,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_left + stride_from * y, rect_right + stride_from * y, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) { to[0] = from[i][0]; i = !i; @@ -322,7 +322,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_left + stride_from * y * 3, rect_right + stride_from * y * 3, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) { copy_v3_v3_uchar(to, from[i]); i = !i; @@ -336,7 +336,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, rect_left + stride_from * y * 4, rect_right + stride_from * y * 4, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) { copy_v4_v4_uchar(to, from[i]); i = !i; @@ -347,7 +347,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } case S3D_INTERLACE_CHECKERBOARD: { if (channels == 1) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { uchar *to = rect_to + stride_to * y; const uchar *from[2] = { @@ -363,7 +363,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } } else if (channels == 3) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { uchar *to = rect_to + stride_to * y * 3; const uchar *from[2] = { @@ -379,7 +379,7 @@ static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, } } else if (channels == 4) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { uchar *to = rect_to + stride_to * y * 4; const uchar *from[2] = { @@ -414,7 +414,7 @@ static void imb_stereo3d_write_sidebyside(const Stereo3DData *s3d, const bool cr const int stride_from = width; const int stride_to = width * 2; - const int l = (int)crosseyed; + const int l = int(crosseyed); const int r = !l; if (s3d->is_float) { @@ -703,16 +703,25 @@ int *IMB_stereo3d_from_rect(const ImageFormatData *im_format, int *rect_right) { int *rect_result; - Stereo3DData s3d_data = {{NULL}}; + Stereo3DData s3d_data = {{nullptr}}; size_t width, height; const bool is_float = im_format->depth > 8; IMB_stereo3d_write_dimensions( im_format->stereo3d_format.display_mode, false, x, y, &width, &height); - rect_result = MEM_mallocN(channels * sizeof(int) * width * height, __func__); + rect_result = static_cast(MEM_mallocN(channels * sizeof(int) * width * height, __func__)); - imb_stereo3d_data_init( - &s3d_data, is_float, x, y, channels, rect_left, rect_right, rect_result, NULL, NULL, NULL); + imb_stereo3d_data_init(&s3d_data, + is_float, + x, + y, + channels, + rect_left, + rect_right, + rect_result, + nullptr, + nullptr, + nullptr); imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format); imb_stereo3d_squeeze_rect(rect_result, &im_format->stereo3d_format, x, y, channels); @@ -727,22 +736,23 @@ float *IMB_stereo3d_from_rectf(const ImageFormatData *im_format, float *rectf_right) { float *rectf_result; - Stereo3DData s3d_data = {{NULL}}; + Stereo3DData s3d_data = {{nullptr}}; size_t width, height; const bool is_float = im_format->depth > 8; IMB_stereo3d_write_dimensions( im_format->stereo3d_format.display_mode, false, x, y, &width, &height); - rectf_result = MEM_mallocN(channels * sizeof(float) * width * height, __func__); + rectf_result = static_cast( + MEM_mallocN(channels * sizeof(float) * width * height, __func__)); imb_stereo3d_data_init(&s3d_data, is_float, x, y, channels, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, rectf_left, rectf_right, rectf_result); @@ -754,8 +764,8 @@ float *IMB_stereo3d_from_rectf(const ImageFormatData *im_format, ImBuf *IMB_stereo3d_ImBuf(const ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *ibuf_right) { - ImBuf *ibuf_stereo = NULL; - Stereo3DData s3d_data = {{NULL}}; + ImBuf *ibuf_stereo = nullptr; + Stereo3DData s3d_data = {{nullptr}}; size_t width, height; const bool is_float = im_format->depth > 8; @@ -796,11 +806,12 @@ static void imb_stereo3d_write_doit(Stereo3DData *s3d_data, const Stereo3dFormat { switch (s3d->display_mode) { case S3D_DISPLAY_ANAGLYPH: - imb_stereo3d_write_anaglyph(s3d_data, s3d->anaglyph_type); + imb_stereo3d_write_anaglyph(s3d_data, eStereo3dAnaglyphType(s3d->anaglyph_type)); break; case S3D_DISPLAY_INTERLACE: - imb_stereo3d_write_interlace( - s3d_data, s3d->interlace_type, (s3d->flag & S3D_INTERLACE_SWAP) != 0); + imb_stereo3d_write_interlace(s3d_data, + eStereo3dInterlaceType(s3d->interlace_type), + (s3d->flag & S3D_INTERLACE_SWAP) != 0); break; case S3D_DISPLAY_SIDEBYSIDE: imb_stereo3d_write_sidebyside(s3d_data, (s3d->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0); @@ -936,7 +947,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, switch (mode) { case S3D_INTERLACE_ROW: { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const float *from = rect_from + stride_from * y * channels; float *to[2] = { @@ -957,7 +968,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_right + stride_to * y, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) { to[i][0] = from[0]; i = !i; @@ -972,7 +983,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_right + stride_to * y * 3, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) { copy_v3_v3(to[i], from); i = !i; @@ -987,7 +998,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_right + stride_to * y * channels, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) { copy_v4_v4(to[i], from); i = !i; @@ -998,7 +1009,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } case S3D_INTERLACE_CHECKERBOARD: { if (channels == 1) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const float *from = rect_from + stride_from * y; float *to[2] = { @@ -1014,7 +1025,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } } else if (channels == 3) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const float *from = rect_from + stride_from * y * 3; float *to[2] = { @@ -1030,7 +1041,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } } else if (channels == 4) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const float *from = rect_from + stride_from * y * 4; float *to[2] = { @@ -1059,7 +1070,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, switch (mode) { case S3D_INTERLACE_ROW: { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from * y * channels; uchar *to[2] = { @@ -1079,7 +1090,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_left + stride_to * y, rect_right + stride_to * y, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) { to[i][0] = from[0]; i = !i; @@ -1093,7 +1104,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_left + stride_to * y * 3, rect_right + stride_to * y * 3, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) { copy_v3_v3_uchar(to[i], from); i = !i; @@ -1107,7 +1118,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, rect_left + stride_to * y * 4, rect_right + stride_to * y * 4, }; - char i = (char)swap; + char i = char(swap); for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) { copy_v4_v4_uchar(to[i], from); i = !i; @@ -1118,7 +1129,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } case S3D_INTERLACE_CHECKERBOARD: { if (channels == 1) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from * y; uchar *to[2] = { @@ -1134,7 +1145,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } } else if (channels == 3) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from * y * 3; uchar *to[2] = { @@ -1150,7 +1161,7 @@ static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, } } else if (channels == 4) { - char i = (char)swap; + char i = char(swap); for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from * y * 4; uchar *to[2] = { @@ -1185,7 +1196,7 @@ static void imb_stereo3d_read_sidebyside(const Stereo3DData *s3d, const bool cro const int stride_from = width * 2; const int stride_to = width; - const int l = (int)crosseyed; + const int l = int(crosseyed); const int r = !l; if (s3d->is_float) { @@ -1279,10 +1290,10 @@ void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, ImBuf **r_ibuf_left, ImBuf **r_ibuf_right) { - Stereo3DData s3d_data = {{NULL}}; + Stereo3DData s3d_data = {{nullptr}}; ImBuf *ibuf_left, *ibuf_right; size_t width, height; - const bool is_float = (ibuf_stereo3d->rect_float != NULL); + const bool is_float = (ibuf_stereo3d->rect_float != nullptr); IMB_stereo3d_read_dimensions(s3d->display_mode, ((s3d->flag & S3D_SQUEEZED_FRAME) == 0), @@ -1364,11 +1375,12 @@ static void imb_stereo3d_read_doit(Stereo3DData *s3d_data, const Stereo3dFormat { switch (s3d->display_mode) { case S3D_DISPLAY_ANAGLYPH: - imb_stereo3d_read_anaglyph(s3d_data, s3d->anaglyph_type); + imb_stereo3d_read_anaglyph(s3d_data, eStereo3dAnaglyphType(s3d->anaglyph_type)); break; case S3D_DISPLAY_INTERLACE: - imb_stereo3d_read_interlace( - s3d_data, s3d->interlace_type, (s3d->flag & S3D_INTERLACE_SWAP) != 0); + imb_stereo3d_read_interlace(s3d_data, + eStereo3dInterlaceType(s3d->interlace_type), + (s3d->flag & S3D_INTERLACE_SWAP) != 0); break; case S3D_DISPLAY_SIDEBYSIDE: imb_stereo3d_read_sidebyside(s3d_data, (s3d->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0); diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.cc similarity index 90% rename from source/blender/imbuf/intern/thumbs.c rename to source/blender/imbuf/intern/thumbs.cc index 061288b90a8..1901ed02e22 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.cc @@ -176,7 +176,7 @@ static void escape_uri_string(const char *string, escaped_string_size -= 1; for (q = escaped_string, p = string; (*p != '\0') && escaped_string_size; p++) { - c = (uchar)*p; + c = uchar(*p); if (!ACCEPTABLE(c)) { if (escaped_string_size < 3) { @@ -201,7 +201,7 @@ static void escape_uri_string(const char *string, /* --- End of adapted code from glib. --- */ -static bool thumbhash_from_path(const char *UNUSED(path), ThumbSource source, char *r_hash) +static bool thumbhash_from_path(const char * /*path*/, ThumbSource source, char *r_hash) { switch (source) { case THB_SOURCE_FONT: @@ -227,7 +227,7 @@ static bool uri_from_filename(const char *path, char *uri) return 0; } /* on windows, using always uppercase drive/volume letter in uri */ - vol[0] = (uchar)toupper(path[0]); + vol[0] = uchar(toupper(path[0])); vol[1] = ':'; vol[2] = '\0'; strcat(orig_uri, vol); @@ -277,12 +277,12 @@ static bool thumbpathname_from_uri( static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len) { - thumbpathname_from_uri(uri, NULL, 0, thumb, thumb_len, THB_FAIL); + thumbpathname_from_uri(uri, nullptr, 0, thumb, thumb_len, THB_FAIL); } static bool thumbpath_from_uri(const char *uri, char *path, const int path_len, ThumbSize size) { - return thumbpathname_from_uri(uri, path, path_len, NULL, 0, size); + return thumbpathname_from_uri(uri, path, path_len, nullptr, 0, size); } void IMB_thumb_makedirs(void) @@ -332,7 +332,7 @@ static ImBuf *thumb_create_ex(const char *file_path, tsize = 1; break; default: - return NULL; /* unknown size */ + return nullptr; /* unknown size */ } if (get_thumb_dir(tdir, size)) { @@ -340,21 +340,21 @@ static ImBuf *thumb_create_ex(const char *file_path, // thumb[8] = '\0'; /* shorten for tempname, not needed anymore */ BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb); if (BLI_path_ncmp(file_path, tdir, sizeof(tdir)) == 0) { - return NULL; + return nullptr; } if (size == THB_FAIL) { img = IMB_allocImBuf(1, 1, 32, IB_rect | IB_metadata); if (!img) { - return NULL; + return nullptr; } } else { if (ELEM(source, THB_SOURCE_IMAGE, THB_SOURCE_BLEND, THB_SOURCE_FONT)) { /* only load if we didn't give an image */ - if (img == NULL) { + if (img == nullptr) { switch (source) { case THB_SOURCE_IMAGE: - img = IMB_thumb_load_image(file_path, tsize, NULL); + img = IMB_thumb_load_image(file_path, tsize, nullptr); break; case THB_SOURCE_BLEND: img = IMB_thumb_load_blend(file_path, blen_group, blen_id); @@ -367,18 +367,18 @@ static ImBuf *thumb_create_ex(const char *file_path, } } - if (img != NULL) { + if (img != nullptr) { if (BLI_stat(file_path, &info) != -1) { BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime); } } } else if (THB_SOURCE_MOVIE == source) { - struct anim *anim = NULL; - anim = IMB_open_anim(file_path, IB_rect | IB_metadata, 0, NULL); - if (anim != NULL) { + struct anim *anim = nullptr; + anim = IMB_open_anim(file_path, IB_rect | IB_metadata, 0, nullptr); + if (anim != nullptr) { img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); - if (img == NULL) { + if (img == nullptr) { printf("not an anim; %s\n", file_path); } else { @@ -392,17 +392,17 @@ static ImBuf *thumb_create_ex(const char *file_path, } } if (!img) { - return NULL; + return nullptr; } if (img->x > tsize || img->y > tsize) { - float scale = MIN2((float)tsize / (float)img->x, (float)tsize / (float)img->y); + float scale = MIN2(float(tsize) / float(img->x), float(tsize) / float(img->y)); /* Scaling down must never assign zero width/height, see: #89868. */ - short ex = MAX2(1, (short)(img->x * scale)); - short ey = MAX2(1, (short)(img->y * scale)); + short ex = MAX2(1, short(img->x * scale)); + short ey = MAX2(1, short(img->y * scale)); /* Save some time by only scaling byte buf */ if (img->rect_float) { - if (img->rect == NULL) { + if (img->rect == nullptr) { IMB_rect_from_float(img); } imb_freerectfloatImBuf(img); @@ -449,16 +449,16 @@ static ImBuf *thumb_create_or_fail(const char *file_path, ThumbSource source) { ImBuf *img = thumb_create_ex( - file_path, uri, thumb, use_hash, hash, blen_group, blen_id, size, source, NULL); + file_path, uri, thumb, use_hash, hash, blen_group, blen_id, size, source, nullptr); if (!img) { /* thumb creation failed, write fail thumb */ img = thumb_create_ex( - file_path, uri, thumb, use_hash, hash, blen_group, blen_id, THB_FAIL, source, NULL); + file_path, uri, thumb, use_hash, hash, blen_group, blen_id, THB_FAIL, source, nullptr); if (img) { /* we don't need failed thumb anymore */ IMB_freeImBuf(img); - img = NULL; + img = nullptr; } } @@ -471,25 +471,25 @@ ImBuf *IMB_thumb_create(const char *filepath, ThumbSize size, ThumbSource source char thumb_name[40]; if (!uri_from_filename(filepath, uri)) { - return NULL; + return nullptr; } thumbname_from_uri(uri, thumb_name, sizeof(thumb_name)); return thumb_create_ex( - filepath, uri, thumb_name, false, THUMB_DEFAULT_HASH, NULL, NULL, size, source, img); + filepath, uri, thumb_name, false, THUMB_DEFAULT_HASH, nullptr, nullptr, size, source, img); } ImBuf *IMB_thumb_read(const char *filepath, ThumbSize size) { char thumb[FILE_MAX]; char uri[URI_MAX]; - ImBuf *img = NULL; + ImBuf *img = nullptr; if (!uri_from_filename(filepath, uri)) { - return NULL; + return nullptr; } if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { - img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL); + img = IMB_loadiffname(thumb, IB_rect | IB_metadata, nullptr); } return img; @@ -522,8 +522,8 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source const char *file_path; const char *path; BLI_stat_t st; - ImBuf *img = NULL; - char *blen_group = NULL, *blen_id = NULL; + ImBuf *img = nullptr; + char *blen_group = nullptr, *blen_id = nullptr; path = file_path = filepath; if (source == THB_SOURCE_BLEND) { @@ -531,7 +531,7 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source if (blen_group) { if (!blen_id) { /* No preview for blen groups */ - return NULL; + return nullptr; } file_path = path_buff; /* path needs to be a valid file! */ } @@ -539,10 +539,10 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source } if (BLI_stat(file_path, &st) == -1) { - return NULL; + return nullptr; } if (!uri_from_filename(path, uri)) { - return NULL; + return nullptr; } if (thumbpath_from_uri(uri, thumb_path, sizeof(thumb_path), THB_FAIL)) { /* failure thumb exists, don't try recreating */ @@ -552,18 +552,19 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source BLI_delete(thumb_path, false, false); } else { - return NULL; + return nullptr; } } } if (thumbpathname_from_uri( - uri, thumb_path, sizeof(thumb_path), thumb_name, sizeof(thumb_name), size)) { + uri, thumb_path, sizeof(thumb_path), thumb_name, sizeof(thumb_name), size)) + { if (BLI_path_ncmp(path, thumb_path, sizeof(thumb_path)) == 0) { - img = IMB_loadiffname(path, IB_rect, NULL); + img = IMB_loadiffname(path, IB_rect, nullptr); } else { - img = IMB_loadiffname(thumb_path, IB_rect | IB_metadata, NULL); + img = IMB_loadiffname(thumb_path, IB_rect | IB_metadata, nullptr); if (img) { bool regenerate = false; @@ -583,7 +584,8 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source if (use_hash && !regenerate) { if (IMB_metadata_get_field( - img->metadata, "X-Blender::Hash", thumb_hash_curr, sizeof(thumb_hash_curr))) { + img->metadata, "X-Blender::Hash", thumb_hash_curr, sizeof(thumb_hash_curr))) + { regenerate = !STREQ(thumb_hash, thumb_hash_curr); } else { @@ -594,7 +596,7 @@ ImBuf *IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source if (regenerate) { /* recreate all thumbs */ IMB_freeImBuf(img); - img = NULL; + img = nullptr; IMB_thumb_delete(path, THB_NORMAL); IMB_thumb_delete(path, THB_LARGE); IMB_thumb_delete(path, THB_FAIL); @@ -641,13 +643,13 @@ void IMB_thumb_locks_acquire(void) BLI_thread_lock(LOCK_IMAGE); if (thumb_locks.lock_counter == 0) { - BLI_assert(thumb_locks.locked_paths == NULL); + BLI_assert(thumb_locks.locked_paths == nullptr); thumb_locks.locked_paths = BLI_gset_str_new(__func__); BLI_condition_init(&thumb_locks.cond); } thumb_locks.lock_counter++; - BLI_assert(thumb_locks.locked_paths != NULL); + BLI_assert(thumb_locks.locked_paths != nullptr); BLI_assert(thumb_locks.lock_counter > 0); BLI_thread_unlock(LOCK_IMAGE); } @@ -655,12 +657,12 @@ void IMB_thumb_locks_acquire(void) void IMB_thumb_locks_release(void) { BLI_thread_lock(LOCK_IMAGE); - BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0)); + BLI_assert((thumb_locks.locked_paths != nullptr) && (thumb_locks.lock_counter > 0)); thumb_locks.lock_counter--; if (thumb_locks.lock_counter == 0) { BLI_gset_free(thumb_locks.locked_paths, MEM_freeN); - thumb_locks.locked_paths = NULL; + thumb_locks.locked_paths = nullptr; BLI_condition_end(&thumb_locks.cond); } @@ -672,7 +674,7 @@ void IMB_thumb_path_lock(const char *path) void *key = BLI_strdup(path); BLI_thread_lock(LOCK_IMAGE); - BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0)); + BLI_assert((thumb_locks.locked_paths != nullptr) && (thumb_locks.lock_counter > 0)); if (thumb_locks.locked_paths) { while (!BLI_gset_add(thumb_locks.locked_paths, key)) { @@ -688,7 +690,7 @@ void IMB_thumb_path_unlock(const char *path) const void *key = path; BLI_thread_lock(LOCK_IMAGE); - BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0)); + BLI_assert((thumb_locks.locked_paths != nullptr) && (thumb_locks.lock_counter > 0)); if (thumb_locks.locked_paths) { if (!BLI_gset_remove(thumb_locks.locked_paths, key, MEM_freeN)) { diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.cc similarity index 89% rename from source/blender/imbuf/intern/thumbs_blend.c rename to source/blender/imbuf/intern/thumbs_blend.cc index 0269c904d8c..68398a2da2d 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.cc @@ -34,12 +34,13 @@ static ImBuf *imb_thumb_load_from_blend_id(const char *blen_path, const char *blen_group, const char *blen_id) { - ImBuf *ima = NULL; - BlendFileReadReport bf_reports = {.reports = NULL}; + ImBuf *ima = nullptr; + BlendFileReadReport bf_reports = {}; + bf_reports.reports = nullptr; struct BlendHandle *libfiledata = BLO_blendhandle_from_file(blen_path, &bf_reports); - if (libfiledata == NULL) { - return NULL; + if (libfiledata == nullptr) { + return nullptr; } int idcode = BKE_idtype_idcode_from_name(blen_group); @@ -56,7 +57,7 @@ static ImBuf *imb_thumb_load_from_blend_id(const char *blen_path, static ImBuf *imb_thumb_load_from_blendfile(const char *blen_path) { BlendThumbnail *data = BLO_thumbnail_from_file(blen_path); - ImBuf *ima = BKE_main_thumbnail_to_imbuf(NULL, data); + ImBuf *ima = BKE_main_thumbnail_to_imbuf(nullptr, data); if (data) { MEM_freeN(data); diff --git a/source/blender/imbuf/intern/thumbs_font.c b/source/blender/imbuf/intern/thumbs_font.cc similarity index 98% rename from source/blender/imbuf/intern/thumbs_font.c rename to source/blender/imbuf/intern/thumbs_font.cc index 64f6741a34b..ccf8b23d36b 100644 --- a/source/blender/imbuf/intern/thumbs_font.c +++ b/source/blender/imbuf/intern/thumbs_font.cc @@ -29,7 +29,7 @@ struct ImBuf *IMB_thumb_load_font(const char *filename, uint x, uint y) if (!BLF_thumb_preview(filename, (uchar *)ibuf->rect, ibuf->x, ibuf->y, ibuf->channels)) { IMB_freeImBuf(ibuf); - ibuf = NULL; + ibuf = nullptr; } return ibuf; diff --git a/source/blender/imbuf/intern/transform.cc b/source/blender/imbuf/intern/transform.cc index 312ed69db00..35fe4bc4a6e 100644 --- a/source/blender/imbuf/intern/transform.cc +++ b/source/blender/imbuf/intern/transform.cc @@ -127,7 +127,8 @@ struct TransformUserData { int2(src_crop.xmax, src_crop.ymin), int2(src_crop.xmin, src_crop.ymax), int2(src_crop.xmax, src_crop.ymax), - }) { + }) + { float3 dst_co = math::transform_point(inverse, float3(src_coords.x, src_coords.y, 0.0f)); BLI_rcti_do_minmax_v(&rect, int2(dst_co) + margin); BLI_rcti_do_minmax_v(&rect, int2(dst_co) - margin); @@ -381,17 +382,20 @@ class Sampler { void sample(const ImBuf *source, const double2 &uv, SampleType &r_sample) { if constexpr (Filter == IMB_FILTER_BILINEAR && std::is_same_v && - NumChannels == 4) { + NumChannels == 4) + { const double2 wrapped_uv = uv_wrapper.modify_uv(source, uv); bilinear_interpolation_color_fl(source, nullptr, r_sample.data(), UNPACK2(wrapped_uv)); } else if constexpr (Filter == IMB_FILTER_NEAREST && std::is_same_v && - NumChannels == 4) { + NumChannels == 4) + { const double2 wrapped_uv = uv_wrapper.modify_uv(source, uv); nearest_interpolation_color_char(source, r_sample.data(), nullptr, UNPACK2(wrapped_uv)); } else if constexpr (Filter == IMB_FILTER_BILINEAR && std::is_same_v && - NumChannels == 4) { + NumChannels == 4) + { const double2 wrapped_uv = uv_wrapper.modify_uv(source, uv); bilinear_interpolation_color_char(source, r_sample.data(), nullptr, UNPACK2(wrapped_uv)); } @@ -481,19 +485,23 @@ class ChannelConverter { copy_v4_v4_uchar(pixel_pointer.get_pointer(), sample.data()); } else if constexpr (std::is_same_v && SourceNumChannels == 4 && - DestinationNumChannels == 4) { + DestinationNumChannels == 4) + { copy_v4_v4(pixel_pointer.get_pointer(), sample.data()); } else if constexpr (std::is_same_v && SourceNumChannels == 3 && - DestinationNumChannels == 4) { + DestinationNumChannels == 4) + { copy_v4_fl4(pixel_pointer.get_pointer(), sample[0], sample[1], sample[2], 1.0f); } else if constexpr (std::is_same_v && SourceNumChannels == 2 && - DestinationNumChannels == 4) { + DestinationNumChannels == 4) + { copy_v4_fl4(pixel_pointer.get_pointer(), sample[0], sample[1], 0.0f, 1.0f); } else if constexpr (std::is_same_v && SourceNumChannels == 1 && - DestinationNumChannels == 4) { + DestinationNumChannels == 4) + { copy_v4_fl4(pixel_pointer.get_pointer(), sample[0], sample[0], sample[0], 1.0f); } else { @@ -510,7 +518,8 @@ class ChannelConverter { pixel_pointer.get_pointer(), pixel_pointer.get_pointer(), sample.data(), mix_factor); } else if constexpr (std::is_same_v && SourceNumChannels == 4 && - DestinationNumChannels == 4) { + DestinationNumChannels == 4) + { blend_color_interpolate_float( pixel_pointer.get_pointer(), pixel_pointer.get_pointer(), sample.data(), mix_factor); } diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.cc similarity index 92% rename from source/blender/imbuf/intern/util.c rename to source/blender/imbuf/intern/util.cc index 1543ac1c7f2..286d8dfde83 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.cc @@ -30,12 +30,15 @@ # include "BKE_global.h" /* G.debug */ +extern "C" { # include # include # include # include # include "ffmpeg_compat.h" +} + #endif #define UTIL_DEBUG 0 @@ -56,13 +59,13 @@ const char *imb_ext_image[] = { #ifdef WITH_WEBP ".webp", #endif - NULL, + nullptr, }; const char *imb_ext_movie[] = { ".avi", ".flc", ".mov", ".movie", ".mp4", ".m4v", ".m2v", ".m2t", ".m2ts", ".mts", ".ts", ".mv", ".avs", ".wmv", ".ogv", ".ogg", ".r3d", ".dv", ".mpeg", ".mpg", - ".mpg2", ".vob", ".mkv", ".flv", ".divx", ".xvid", ".mxf", ".webm", NULL, + ".mpg2", ".vob", ".mkv", ".flv", ".divx", ".xvid", ".mxf", ".webm", nullptr, }; /** Sort of wrong having audio extensions in imbuf. */ @@ -82,7 +85,7 @@ const char *imb_ext_audio[] = { ".aiff", ".m4a", ".mka", - NULL, + nullptr, }; /* Increased from 32 to 64 because of the bitmaps header size. */ @@ -119,7 +122,7 @@ static ssize_t imb_ispic_read_header_from_filepath(const char *filepath, uchar b int IMB_ispic_type_from_memory(const uchar *buf, const size_t buf_size) { for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { - if (type->is_a != NULL) { + if (type->is_a != nullptr) { if (type->is_a(buf, buf_size)) { return type->filetype; } @@ -136,7 +139,7 @@ int IMB_ispic_type(const char *filepath) if (buf_size <= 0) { return IMB_FTYPE_NONE; } - return IMB_ispic_type_from_memory(buf, (size_t)buf_size); + return IMB_ispic_type_from_memory(buf, size_t(buf_size)); } bool IMB_ispic_type_matches(const char *filepath, int filetype) @@ -148,12 +151,12 @@ bool IMB_ispic_type_matches(const char *filepath, int filetype) } const ImFileType *type = IMB_file_type_from_ftype(filetype); - if (type != NULL) { + if (type != nullptr) { /* Requesting to load a type that can't check its own header doesn't make sense. * Keep the check for developers. */ - BLI_assert(type->is_a != NULL); - if (type->is_a != NULL) { - return type->is_a(buf, (size_t)buf_size); + BLI_assert(type->is_a != nullptr); + if (type->is_a != nullptr) { + return type->is_a(buf, size_t(buf_size)); } } return false; @@ -231,7 +234,7 @@ const char *IMB_ffmpeg_last_error(void) static int isffmpeg(const char *filepath) { - AVFormatContext *pFormatCtx = NULL; + AVFormatContext *pFormatCtx = nullptr; uint i; int videoStream; const AVCodec *pCodec; @@ -249,18 +252,19 @@ static int isffmpeg(const char *filepath) ".exr", ".cin", ".wav", - NULL)) { + nullptr)) + { return 0; } - if (avformat_open_input(&pFormatCtx, filepath, NULL, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, filepath, nullptr, nullptr) != 0) { if (UTIL_DEBUG) { fprintf(stderr, "isffmpeg: av_open_input_file failed\n"); } return 0; } - if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) { if (UTIL_DEBUG) { fprintf(stderr, "isffmpeg: avformat_find_stream_info failed\n"); } @@ -276,7 +280,8 @@ static int isffmpeg(const char *filepath) videoStream = -1; for (i = 0; i < pFormatCtx->nb_streams; i++) { if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codecpar && - (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) { + (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) + { videoStream = i; break; } @@ -291,7 +296,7 @@ static int isffmpeg(const char *filepath) /* Find the decoder for the video stream */ pCodec = avcodec_find_decoder(codec_par->codec_id); - if (pCodec == NULL) { + if (pCodec == nullptr) { avformat_close_input(&pFormatCtx); return 0; } diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.cc similarity index 93% rename from source/blender/imbuf/intern/util_gpu.c rename to source/blender/imbuf/intern/util_gpu.cc index 5128776d0d6..885f1ce87d0 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.cc @@ -32,7 +32,8 @@ static bool imb_is_grayscale_texture_format_compatible(const ImBuf *ibuf) * to the scene color space can be uploaded as single channel textures. */ if (IMB_colormanagement_space_is_data(ibuf->rect_colorspace) || IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) || - IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) { + IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) + { return true; }; return false; @@ -44,7 +45,7 @@ static void imb_gpu_get_format(const ImBuf *ibuf, eGPUDataFormat *r_data_format, eGPUTextureFormat *r_texture_format) { - const bool float_rect = (ibuf->rect_float != NULL); + const bool float_rect = (ibuf->rect_float != nullptr); const bool is_grayscale = use_grayscale && imb_is_grayscale_texture_format_compatible(ibuf); if (float_rect) { @@ -56,7 +57,8 @@ static void imb_gpu_get_format(const ImBuf *ibuf, } else { if (IMB_colormanagement_space_is_data(ibuf->rect_colorspace) || - IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) { + IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) + { /* Non-color data or scene linear, just store buffer as is. */ *r_data_format = GPU_DATA_UBYTE; *r_texture_format = (is_grayscale) ? GPU_R8 : GPU_RGBA8; @@ -112,7 +114,7 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, const bool store_premultiplied, bool *r_freedata) { - bool is_float_rect = (ibuf->rect_float != NULL); + bool is_float_rect = (ibuf->rect_float != nullptr); const bool is_grayscale = imb_is_grayscale_texture_format_compatible(ibuf); void *data_rect = (is_float_rect) ? (void *)ibuf->rect_float : (void *)ibuf->rect; bool freedata = false; @@ -125,8 +127,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, data_rect = MEM_mallocN(sizeof(float[4]) * ibuf->x * ibuf->y, __func__); *r_freedata = freedata = true; - if (data_rect == NULL) { - return NULL; + if (data_rect == nullptr) { + return nullptr; } IMB_colormanagement_imbuf_to_float_texture( @@ -142,14 +144,15 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, /* Non-color data, just store buffer as is. */ } else if (IMB_colormanagement_space_is_srgb(ibuf->rect_colorspace) || - IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) { + IMB_colormanagement_space_is_scene_linear(ibuf->rect_colorspace)) + { /* sRGB or scene linear, store as byte texture that the GPU can decode directly. */ data_rect = MEM_mallocN( (is_grayscale ? sizeof(float[4]) : sizeof(uchar[4])) * ibuf->x * ibuf->y, __func__); *r_freedata = freedata = true; - if (data_rect == NULL) { - return NULL; + if (data_rect == nullptr) { + return nullptr; } /* Texture storage of images is defined by the alpha mode of the image. The @@ -174,8 +177,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, *r_freedata = freedata = true; is_float_rect = true; - if (data_rect == NULL) { - return NULL; + if (data_rect == nullptr) { + return nullptr; } /* Texture storage of images is defined by the alpha mode of the image. The @@ -189,8 +192,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, } if (do_rescale) { - uint *rect = (is_float_rect) ? NULL : (uint *)data_rect; - float *rect_float = (is_float_rect) ? (float *)data_rect : NULL; + uint *rect = (is_float_rect) ? nullptr : (uint *)data_rect; + float *rect_float = (is_float_rect) ? (float *)data_rect : nullptr; ImBuf *scale_ibuf = IMB_allocFromBuffer(rect, rect_float, ibuf->x, ibuf->y, 4); IMB_scaleImBuf(scale_ibuf, UNPACK2(rescale_size)); @@ -202,8 +205,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, data_rect = (is_float_rect) ? (void *)scale_ibuf->rect_float : (void *)scale_ibuf->rect; *r_freedata = freedata = true; /* Steal the rescaled buffer to avoid double free. */ - scale_ibuf->rect_float = NULL; - scale_ibuf->rect = NULL; + scale_ibuf->rect_float = nullptr; + scale_ibuf->rect = nullptr; IMB_freeImBuf(scale_ibuf); } @@ -217,8 +220,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, *r_freedata = freedata = true; } - if (data_rect == NULL) { - return NULL; + if (data_rect == nullptr) { + return nullptr; } int buffer_size = do_rescale ? rescale_size[0] * rescale_size[1] : ibuf->x * ibuf->y; @@ -258,7 +261,7 @@ GPUTexture *IMB_touch_gpu_texture(const char *name, tex_format, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, - NULL); + nullptr); } else { tex = GPU_texture_create_2d(name, @@ -267,7 +270,7 @@ GPUTexture *IMB_touch_gpu_texture(const char *name, 9999, tex_format, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, - NULL); + nullptr); } GPU_texture_swizzle_set(tex, imb_gpu_get_swizzle(ibuf)); @@ -310,17 +313,17 @@ GPUTexture *IMB_create_gpu_texture(const char *name, bool use_high_bitdepth, bool use_premult) { - GPUTexture *tex = NULL; + GPUTexture *tex = nullptr; int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]); /* Correct the smaller size to maintain the original aspect ratio of the image. */ if (do_rescale && ibuf->x != ibuf->y) { if (size[0] > size[1]) { - size[1] = (int)(ibuf->y * ((float)size[0] / ibuf->x)); + size[1] = int(ibuf->y * (float(size[0]) / ibuf->x)); } else { - size[0] = (int)(ibuf->x * ((float)size[1] / ibuf->y)); + size[0] = int(ibuf->x * (float(size[1]) / ibuf->y)); } } @@ -344,7 +347,7 @@ GPUTexture *IMB_create_gpu_texture(const char *name, GPU_TEXTURE_USAGE_GENERAL, ibuf->dds_data.data); - if (tex != NULL) { + if (tex != nullptr) { return tex; } @@ -366,8 +369,8 @@ GPUTexture *IMB_create_gpu_texture(const char *name, 9999, tex_format, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, - NULL); - if (tex == NULL) { + nullptr); + if (tex == nullptr) { size[0] = max_ii(1, size[0] / 2); size[1] = max_ii(1, size[1] / 2); tex = GPU_texture_create_2d(name, @@ -375,10 +378,10 @@ GPUTexture *IMB_create_gpu_texture(const char *name, 9999, tex_format, GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, - NULL); + nullptr); do_rescale = true; } - BLI_assert(tex != NULL); + BLI_assert(tex != nullptr); void *data = imb_gpu_get_data(ibuf, do_rescale, size, use_premult, &freebuf); GPU_texture_update(tex, data_format, data); diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.cc similarity index 82% rename from source/blender/imbuf/intern/webp.c rename to source/blender/imbuf/intern/webp.cc index abf915b1b8e..03fea1d3660 100644 --- a/source/blender/imbuf/intern/webp.c +++ b/source/blender/imbuf/intern/webp.cc @@ -31,7 +31,7 @@ bool imb_is_a_webp(const uchar *buf, size_t size) { - if (WebPGetInfo(buf, size, NULL, NULL)) { + if (WebPGetInfo(buf, size, nullptr, nullptr)) { return true; } return false; @@ -40,7 +40,7 @@ bool imb_is_a_webp(const uchar *buf, size_t size) ImBuf *imb_loadwebp(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { if (!imb_is_a_webp(mem, size)) { - return NULL; + return nullptr; } colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); @@ -48,15 +48,15 @@ ImBuf *imb_loadwebp(const uchar *mem, size_t size, int flags, char colorspace[IM WebPBitstreamFeatures features; if (WebPGetFeatures(mem, size, &features) != VP8_STATUS_OK) { fprintf(stderr, "WebP: Failed to parse features\n"); - return NULL; + return nullptr; } const int planes = features.has_alpha ? 32 : 24; ImBuf *ibuf = IMB_allocImBuf(features.width, features.height, planes, 0); - if (ibuf == NULL) { + if (ibuf == nullptr) { fprintf(stderr, "WebP: Failed to allocate image memory\n"); - return NULL; + return nullptr; } if ((flags & IB_test) == 0) { @@ -64,8 +64,9 @@ ImBuf *imb_loadwebp(const uchar *mem, size_t size, int flags, char colorspace[IM imb_addrectImBuf(ibuf); /* Flip the image during decoding to match Blender. */ uchar *last_row = (uchar *)(ibuf->rect + (ibuf->y - 1) * ibuf->x); - if (WebPDecodeRGBAInto(mem, size, last_row, (size_t)(ibuf->x) * ibuf->y * 4, -4 * ibuf->x) == - NULL) { + if (WebPDecodeRGBAInto(mem, size, last_row, size_t(ibuf->x) * ibuf->y * 4, -4 * ibuf->x) == + nullptr) + { fprintf(stderr, "WebP: Failed to decode image\n"); } } @@ -74,7 +75,7 @@ ImBuf *imb_loadwebp(const uchar *mem, size_t size, int flags, char colorspace[IM } struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, - const int UNUSED(flags), + const int /*flags*/, const size_t max_thumb_size, char colorspace[], size_t *r_width, @@ -82,7 +83,7 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, { const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { - return NULL; + return nullptr; } const size_t data_size = BLI_file_descriptor_size(file); @@ -91,38 +92,39 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, BLI_mmap_file *mmap_file = BLI_mmap_open(file); imb_mmap_unlock(); close(file); - if (mmap_file == NULL) { - return NULL; + if (mmap_file == nullptr) { + return nullptr; } - const uchar *data = BLI_mmap_get_pointer(mmap_file); + const uchar *data = static_cast(BLI_mmap_get_pointer(mmap_file)); WebPDecoderConfig config; if (!data || !WebPInitDecoderConfig(&config) || - WebPGetFeatures(data, data_size, &config.input) != VP8_STATUS_OK) { + WebPGetFeatures(data, data_size, &config.input) != VP8_STATUS_OK) + { fprintf(stderr, "WebP: Invalid file\n"); imb_mmap_lock(); BLI_mmap_free(mmap_file); imb_mmap_unlock(); - return NULL; + return nullptr; } /* Return full size of the image. */ - *r_width = (size_t)config.input.width; - *r_height = (size_t)config.input.height; + *r_width = size_t(config.input.width); + *r_height = size_t(config.input.height); - const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height); - const int dest_w = MAX2((int)(config.input.width * scale), 1); - const int dest_h = MAX2((int)(config.input.height * scale), 1); + const float scale = float(max_thumb_size) / MAX2(config.input.width, config.input.height); + const int dest_w = MAX2(int(config.input.width * scale), 1); + const int dest_h = MAX2(int(config.input.height * scale), 1); colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect); - if (ibuf == NULL) { + if (ibuf == nullptr) { fprintf(stderr, "WebP: Failed to allocate image memory\n"); imb_mmap_lock(); BLI_mmap_free(mmap_file); imb_mmap_unlock(); - return NULL; + return nullptr; } config.options.no_fancy_upsampling = 1; @@ -136,14 +138,14 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, config.output.colorspace = MODE_RGBA; config.output.u.RGBA.rgba = (uint8_t *)ibuf->rect; config.output.u.RGBA.stride = 4 * ibuf->x; - config.output.u.RGBA.size = (size_t)(config.output.u.RGBA.stride * ibuf->y); + config.output.u.RGBA.size = size_t(config.output.u.RGBA.stride * ibuf->y); if (WebPDecode(data, data_size, &config) != VP8_STATUS_OK) { fprintf(stderr, "WebP: Failed to decode image\n"); imb_mmap_lock(); BLI_mmap_free(mmap_file); imb_mmap_unlock(); - return NULL; + return nullptr; } /* Free the output buffer. */ @@ -156,7 +158,7 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, return ibuf; } -bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags)) +bool imb_savewebp(struct ImBuf *ibuf, const char *name, int /*flags*/) { const int bytesperpixel = (ibuf->planes + 7) >> 3; uchar *encoded_data, *last_row; @@ -166,7 +168,8 @@ bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags)) /* We must convert the ImBuf RGBA buffer to RGB as WebP expects a RGB buffer. */ const size_t num_pixels = ibuf->x * ibuf->y; const uint8_t *rgba_rect = (uint8_t *)ibuf->rect; - uint8_t *rgb_rect = MEM_mallocN(sizeof(uint8_t) * num_pixels * 3, "webp rgb_rect"); + uint8_t *rgb_rect = static_cast( + MEM_mallocN(sizeof(uint8_t) * num_pixels * 3, "webp rgb_rect")); for (int i = 0; i < num_pixels; i++) { rgb_rect[i * 3 + 0] = rgba_rect[i * 4 + 0]; rgb_rect[i * 3 + 1] = rgba_rect[i * 4 + 1]; @@ -202,7 +205,7 @@ bool imb_savewebp(struct ImBuf *ibuf, const char *name, int UNUSED(flags)) return false; } - if (encoded_data != NULL) { + if (encoded_data != nullptr) { FILE *fp = BLI_fopen(name, "wb"); if (!fp) { free(encoded_data); diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.cc similarity index 90% rename from source/blender/imbuf/intern/writeimage.c rename to source/blender/imbuf/intern/writeimage.cc index d2c0b61c1c5..9d970c7317e 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.cc @@ -25,13 +25,13 @@ bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags) BLI_assert(!BLI_path_is_rel(filepath)); - if (ibuf == NULL) { + if (ibuf == nullptr) { return false; } ibuf->flags = flags; const ImFileType *type = IMB_file_type_from_ibuf(ibuf); - if (type == NULL || type->save == NULL) { + if (type == nullptr || type->save == nullptr) { fprintf(stderr, "Couldn't save picture.\n"); return false; } @@ -42,7 +42,7 @@ bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags) * have already created this byte buffer. This is a basic fallback for other * cases where we do not have a specific desired output colorspace. */ if (!(type->flag & IM_FTYPE_FLOAT)) { - if (ibuf->rect == NULL && ibuf->rect_float) { + if (ibuf->rect == nullptr && ibuf->rect_float) { ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE); IMB_rect_from_float(ibuf); } diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index 84fcffa3b96..74c606208da 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -537,7 +537,8 @@ static void get_loop_normals(struct Mesh *mesh, /* If all polygons are smooth shaded, and there are no custom normals, we don't need to export * normals at all. This is also done by other software, see #71246. */ if (!has_flat_shaded_poly && !CustomData_has_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL) && - (mesh->flag & ME_AUTOSMOOTH) == 0) { + (mesh->flag & ME_AUTOSMOOTH) == 0) + { return; } diff --git a/source/blender/io/alembic/intern/abc_reader_camera.cc b/source/blender/io/alembic/intern/abc_reader_camera.cc index e7a319730b6..6db1c9827b1 100644 --- a/source/blender/io/alembic/intern/abc_reader_camera.cc +++ b/source/blender/io/alembic/intern/abc_reader_camera.cc @@ -69,7 +69,8 @@ void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_ ICompoundProperty customDataContainer = m_schema.getUserProperties(); if (customDataContainer.valid() && customDataContainer.getPropertyHeader("stereoDistance") && - customDataContainer.getPropertyHeader("eyeSeparation")) { + customDataContainer.getPropertyHeader("eyeSeparation")) + { IFloatProperty convergence_plane(customDataContainer, "stereoDistance"); IFloatProperty eye_separation(customDataContainer, "eyeSeparation"); diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 4c673260802..6f9ee4c88c5 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -143,8 +143,8 @@ static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data) const P3fArraySamplePtr &positions = mesh_data.positions; if (config.use_vertex_interpolation && config.weight != 0.0f && - mesh_data.ceil_positions != nullptr && - mesh_data.ceil_positions->size() == positions->size()) { + mesh_data.ceil_positions != nullptr && mesh_data.ceil_positions->size() == positions->size()) + { read_mverts_interp(vert_positions, positions, mesh_data.ceil_positions, config.weight); BKE_mesh_tag_positions_changed(config.mesh); return; @@ -732,7 +732,8 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, * This prevents crash from #49813. * TODO(kevin): perhaps find a better way to do this? */ if (face_counts->size() != existing_mesh->totpoly || - face_indices->size() != existing_mesh->totloop) { + face_indices->size() != existing_mesh->totloop) + { settings.read_flag = MOD_MESHSEQ_READ_VERT; if (err_str) { @@ -882,8 +883,8 @@ static void read_vertex_creases(Mesh *mesh, const Int32ArraySamplePtr &indices, const FloatArraySamplePtr &sharpnesses) { - if (!(indices && sharpnesses && indices->size() == sharpnesses->size() && - indices->size() != 0)) { + if (!(indices && sharpnesses && indices->size() == sharpnesses->size() && indices->size() != 0)) + { return; } @@ -1065,7 +1066,8 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh, * This prevents crash from #49813. * TODO(kevin): perhaps find a better way to do this? */ if (face_counts->size() != existing_mesh->totpoly || - face_indices->size() != existing_mesh->totloop) { + face_indices->size() != existing_mesh->totloop) + { settings.read_flag = MOD_MESHSEQ_READ_VERT; if (err_str) { diff --git a/source/blender/io/avi/AVI_avi.h b/source/blender/io/avi/AVI_avi.h index 0857b9191b2..7315977548e 100644 --- a/source/blender/io/avi/AVI_avi.h +++ b/source/blender/io/avi/AVI_avi.h @@ -25,6 +25,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + #include "BLI_sys_types.h" #include /* for FILE */ @@ -217,12 +221,12 @@ typedef enum { /** * Test whether this is an avi-format. */ -bool AVI_is_avi(const char *name); +bool AVI_is_avi(const char *filepath); /** * Open a compressed file, decompress it into memory. */ -AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...); +AviError AVI_open_compress(char *filepath, AviMovie *movie, int streams, ...); /** * Finalize a compressed output stream. @@ -259,7 +263,7 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num); /** * Open a movie stream from file. */ -AviError AVI_open_movie(const char *name, AviMovie *movie); +AviError AVI_open_movie(const char *filepath, AviMovie *movie); /** * Read a frame from a movie stream. @@ -279,3 +283,7 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...); * Unused but still external */ AviError AVI_print_error(AviError error); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/io/avi/intern/avi.c b/source/blender/io/avi/intern/avi.c index 3da93f51cfc..b33612faa81 100644 --- a/source/blender/io/avi/intern/avi.c +++ b/source/blender/io/avi/intern/avi.c @@ -184,7 +184,7 @@ AviError AVI_print_error(AviError in_error) return in_error; } -bool AVI_is_avi(const char *name) +bool AVI_is_avi(const char *filepath) { int temp, fcca, j; AviMovie movie = {NULL}; @@ -195,7 +195,7 @@ bool AVI_is_avi(const char *name) DEBUG_PRINT("opening movie\n"); movie.type = AVI_MOVIE_READ; - movie.fp = BLI_fopen(name, "rb"); + movie.fp = BLI_fopen(filepath, "rb"); movie.offset_table = NULL; if (movie.fp == NULL) { @@ -211,7 +211,8 @@ bool AVI_is_avi(const char *name) if (GET_FCC(movie.fp) != FCC("AVI ") || GET_FCC(movie.fp) != FCC("LIST") || !GET_FCC(movie.fp) || GET_FCC(movie.fp) != FCC("hdrl") || (movie.header->fcc = GET_FCC(movie.fp)) != FCC("avih") || - !(movie.header->size = GET_FCC(movie.fp))) { + !(movie.header->size = GET_FCC(movie.fp))) + { DEBUG_PRINT("bad initial header info\n"); fclose(movie.fp); return 0; @@ -250,7 +251,8 @@ bool AVI_is_avi(const char *name) if (GET_FCC(movie.fp) != FCC("LIST") || !GET_FCC(movie.fp) || GET_FCC(movie.fp) != FCC("strl") || (movie.streams[temp].sh.fcc = GET_FCC(movie.fp)) != FCC("strh") || - !(movie.streams[temp].sh.size = GET_FCC(movie.fp))) { + !(movie.streams[temp].sh.size = GET_FCC(movie.fp))) + { DEBUG_PRINT("bad stream header information\n"); MEM_freeN(movie.streams); @@ -265,7 +267,8 @@ bool AVI_is_avi(const char *name) if (movie.streams[temp].sh.Type == FCC("vids")) { if (fcca == FCC("DIB ") || fcca == FCC("RGB ") || fcca == FCC("rgb ") || - fcca == FCC("RAW ") || fcca == 0) { + fcca == FCC("RAW ") || fcca == 0) + { movie.streams[temp].format = AVI_FORMAT_AVI_RGB; } else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { @@ -331,7 +334,8 @@ bool AVI_is_avi(const char *name) if (movie.streams[temp].format == AVI_FORMAT_AVI_RGB) { if (fcca == FCC("DIB ") || fcca == FCC("RGB ") || fcca == FCC("rgb ") || - fcca == FCC("RAW ") || fcca == 0) { + fcca == FCC("RAW ") || fcca == 0) + { /* pass */ } else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { @@ -375,7 +379,7 @@ bool AVI_is_avi(const char *name) return (movie_tracks != 0); } -AviError AVI_open_movie(const char *name, AviMovie *movie) +AviError AVI_open_movie(const char *filepath, AviMovie *movie) { int temp, fcca, size, j; @@ -384,7 +388,7 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) memset(movie, 0, sizeof(AviMovie)); movie->type = AVI_MOVIE_READ; - movie->fp = BLI_fopen(name, "rb"); + movie->fp = BLI_fopen(filepath, "rb"); movie->offset_table = NULL; if (movie->fp == NULL) { @@ -400,7 +404,8 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) if (GET_FCC(movie->fp) != FCC("AVI ") || GET_FCC(movie->fp) != FCC("LIST") || !GET_FCC(movie->fp) || GET_FCC(movie->fp) != FCC("hdrl") || (movie->header->fcc = GET_FCC(movie->fp)) != FCC("avih") || - !(movie->header->size = GET_FCC(movie->fp))) { + !(movie->header->size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad initial header info\n"); return AVI_ERROR_FORMAT; } @@ -437,7 +442,8 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) if (GET_FCC(movie->fp) != FCC("LIST") || !GET_FCC(movie->fp) || GET_FCC(movie->fp) != FCC("strl") || (movie->streams[temp].sh.fcc = GET_FCC(movie->fp)) != FCC("strh") || - !(movie->streams[temp].sh.size = GET_FCC(movie->fp))) { + !(movie->streams[temp].sh.size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad stream header information\n"); return AVI_ERROR_FORMAT; } @@ -449,7 +455,8 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) if (movie->streams[temp].sh.Type == FCC("vids")) { if (fcca == FCC("DIB ") || fcca == FCC("RGB ") || fcca == FCC("rgb ") || - fcca == FCC("RAW ") || fcca == 0) { + fcca == FCC("RAW ") || fcca == 0) + { movie->streams[temp].format = AVI_FORMAT_AVI_RGB; } else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { @@ -511,7 +518,8 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) if (movie->streams[temp].format == AVI_FORMAT_AVI_RGB) { if (fcca == FCC("DIB ") || fcca == FCC("RGB ") || fcca == FCC("rgb ") || - fcca == FCC("RAW ") || fcca == 0) { + fcca == FCC("RAW ") || fcca == 0) + { /* pass */ } else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { @@ -692,7 +700,7 @@ AviError AVI_close(AviMovie *movie) return AVI_ERROR_NONE; } -AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) +AviError AVI_open_compress(char *filepath, AviMovie *movie, int streams, ...) { va_list ap; AviList list; @@ -703,7 +711,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) int64_t junk_pos; movie->type = AVI_MOVIE_WRITE; - movie->fp = BLI_fopen(name, "wb"); + movie->fp = BLI_fopen(filepath, "wb"); movie->index_entries = 0; diff --git a/source/blender/io/collada/AnimationClipExporter.cpp b/source/blender/io/collada/AnimationClipExporter.cpp index a59418c6b18..39542282ebc 100644 --- a/source/blender/io/collada/AnimationClipExporter.cpp +++ b/source/blender/io/collada/AnimationClipExporter.cpp @@ -10,8 +10,8 @@ void AnimationClipExporter::exportAnimationClips(Scene *sce) std::map clips; std::vector>::iterator anim_meta_entry; - for (anim_meta_entry = anim_meta.begin(); anim_meta_entry != anim_meta.end(); - ++anim_meta_entry) { + for (anim_meta_entry = anim_meta.begin(); anim_meta_entry != anim_meta.end(); ++anim_meta_entry) + { std::vector entry = *anim_meta_entry; std::string action_id = entry[0]; std::string action_name = entry[1]; diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index d1568be3b24..6c116a4ab17 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -101,7 +101,8 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) bez.h1 = bez.h2 = HD_AUTO; if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER || - curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) { + curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) + { COLLADAFW::FloatOrDoubleArray &intan = curve->getInTangentValues(); COLLADAFW::FloatOrDoubleArray &outtan = curve->getOutTangentValues(); @@ -715,7 +716,8 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi * Reason: old blender versions stored spot_size in radians (was a bug) */ if (this->import_from_version.empty() || - BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) { + BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) + { fcurve_deg_to_rad(fcu); } } @@ -1888,7 +1890,8 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, COLLADAFW::Transformation::ROTATE, COLLADAFW::Transformation::SCALE, COLLADAFW::Transformation::TRANSLATE, - COLLADAFW::Transformation::MATRIX)) { + COLLADAFW::Transformation::MATRIX)) + { fprintf(stderr, "animation of transformation %d is not supported yet\n", type); return false; } diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 7de08f89b7d..2bfd67c4095 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -624,7 +624,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin) COLLADAFW::Node *node = *ri; /* for shared armature check if bone tree is already created */ if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), node) != - skin_root_joints.end()) { + skin_root_joints.end()) + { continue; } @@ -1011,7 +1012,7 @@ void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count) { - char bone_name_esc[sizeof(((Bone *)nullptr)->name) * 2]; + char bone_name_esc[sizeof(Bone::name) * 2]; BLI_str_escape(bone_name_esc, bc_get_joint_name(node), sizeof(bone_name_esc)); BLI_snprintf(joint_path, count, "pose.bones[\"%s\"]", bone_name_esc); } diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 98e4febe814..7339dbfe273 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -275,8 +275,8 @@ int DocumentExporter::exportCurrentScene() /* */ ArmatureExporter arm_exporter(blender_context, writer, this->export_settings); ControllerExporter controller_exporter(blender_context, writer, this->export_settings); - if (bc_has_object_type(export_set, OB_ARMATURE) || - this->export_settings.get_include_shapekeys()) { + if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings.get_include_shapekeys()) + { controller_exporter.export_controllers(); } diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index fc6316e97a8..0468d0a3949 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -599,7 +599,8 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, pair_iter = object_map.equal_range(node_id); for (std::multimap::iterator it2 = pair_iter.first; it2 != pair_iter.second; - it2++) { + it2++) + { Object *source_ob = (Object *)it2->second; COLLADAFW::Node *source_node = node_map[node_id]; ob = create_instance_node(source_ob, source_node, node, sce, is_library_node); @@ -934,7 +935,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) char absolute_path[FILE_MAX]; const char *workpath; - BLI_split_dir_part(this->import_settings->filepath, dir, sizeof(dir)); + BLI_path_split_dir_part(this->import_settings->filepath, dir, sizeof(dir)); BLI_path_join(absolute_path, sizeof(absolute_path), dir, imagepath.c_str()); if (BLI_exists(absolute_path)) { workpath = absolute_path; diff --git a/source/blender/io/collada/ErrorHandler.cpp b/source/blender/io/collada/ErrorHandler.cpp index f60c027a1e2..18a7fe4d7d6 100644 --- a/source/blender/io/collada/ErrorHandler.cpp +++ b/source/blender/io/collada/ErrorHandler.cpp @@ -37,7 +37,8 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) error_message = parserError.getErrorMessage(); if (parserError.getErrorType() == - GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) { + GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) + { if (STREQ(parserError.getElement(), "effect")) { isError = false; } @@ -45,9 +46,11 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) else if (parserError.getErrorType() == GeneratedSaxParser::ParserError:: - ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) { + ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) + { if (!(STREQ(parserError.getElement(), "extra") && - STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract"))) { + STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract"))) + { isError = false; } } @@ -59,7 +62,8 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) } else if (parserError.getErrorType() == - GeneratedSaxParser::ParserError::ERROR_REQUIRED_ATTRIBUTE_MISSING) { + GeneratedSaxParser::ParserError::ERROR_REQUIRED_ATTRIBUTE_MISSING) + { isError = true; } diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 671591fae1a..0062dbac995 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -61,7 +61,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) char export_file[FILE_MAX]; /* Destination folder for exported assets */ - BLI_split_dir_part(this->export_settings.get_filepath(), export_dir, sizeof(export_dir)); + BLI_path_split_dir_part(this->export_settings.get_filepath(), export_dir, sizeof(export_dir)); if (is_generated || is_dirty || use_copies || is_packed) { @@ -72,8 +72,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) BLI_path_join(export_path, sizeof(export_path), export_dir, export_file); - /* make dest directory if it doesn't exist */ - BLI_make_existing_file(export_path); + BLI_file_ensure_parent_dir_exists(export_path); } if (is_generated || is_dirty || is_packed) { diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 6071e429b0a..22cc7d9066b 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -682,7 +682,8 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, if (ELEM(collada_meshtype, COLLADAFW::MeshPrimitive::POLYLIST, COLLADAFW::MeshPrimitive::POLYGONS, - COLLADAFW::MeshPrimitive::TRIANGLES)) { + COLLADAFW::MeshPrimitive::TRIANGLES)) + { COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp; uint start_index = 0; diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 579bba3839a..1e83c8be72a 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -769,7 +769,7 @@ void bc_enable_fcurves(bAction *act, char *bone_name) char prefix[200]; if (bone_name) { - char bone_name_esc[sizeof(((Bone *)nullptr)->name) * 2]; + char bone_name_esc[sizeof(Bone::name) * 2]; BLI_str_escape(bone_name_esc, bone_name, sizeof(bone_name_esc)); BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name_esc); } @@ -865,7 +865,8 @@ bool bc_has_animations(Object *ob) /* Check for object, light and camera transform animations */ if ((bc_getSceneObjectAction(ob) && bc_getSceneObjectAction(ob)->curves.first) || (bc_getSceneLightAction(ob) && bc_getSceneLightAction(ob)->curves.first) || - (bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first)) { + (bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first)) + { return true; } @@ -964,7 +965,8 @@ void bc_create_restpose_mat(BCExportSettings &export_settings, if (!has_custom_props(bone, export_settings.get_keep_bind_info(), "restpose_loc") && !has_custom_props(bone, export_settings.get_keep_bind_info(), "restpose_rot") && - !has_custom_props(bone, export_settings.get_keep_bind_info(), "restpose_scale")) { + !has_custom_props(bone, export_settings.get_keep_bind_info(), "restpose_scale")) + { /* No need */ copy_m4_m4(to_mat, from_mat); return; diff --git a/source/blender/io/common/intern/path_util.cc b/source/blender/io/common/intern/path_util.cc index 337923dc837..5ca6d2b1979 100644 --- a/source/blender/io/common/intern/path_util.cc +++ b/source/blender/io/common/intern/path_util.cc @@ -67,7 +67,7 @@ void path_reference_copy(const Set> ©_se if (0 == BLI_path_cmp_normalized(src, dst)) { continue; /* Source and dest are the same. */ } - if (!BLI_make_existing_file(dst)) { + if (!BLI_file_ensure_parent_dir_exists(dst)) { fprintf(stderr, "Can't make directory for '%s', not copying\n", dst); continue; } diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index e9378e6c225..583f6f4ce84 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -156,7 +156,8 @@ void GpencilExporterPDF::export_gpencil_layers() const float stroke_opacity = stroke_color_[3] * stroke_average_opacity_get() * gpl->opacity; if ((fill_opacity < GPENCIL_ALPHA_OPACITY_THRESH) && - (stroke_opacity < GPENCIL_ALPHA_OPACITY_THRESH)) { + (stroke_opacity < GPENCIL_ALPHA_OPACITY_THRESH)) + { continue; } diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc b/source/blender/io/usd/intern/usd_asset_utils.cc index c5f5528bed0..1c38aa4c8dd 100644 --- a/source/blender/io/usd/intern/usd_asset_utils.cc +++ b/source/blender/io/usd/intern/usd_asset_utils.cc @@ -64,10 +64,10 @@ static std::string get_asset_base_name(const char *src_path) src_path); return src_path; } - BLI_split_file_part(split.second.c_str(), base_name, sizeof(base_name)); + BLI_path_split_file_part(split.second.c_str(), base_name, sizeof(base_name)); } else { - BLI_split_file_part(src_path, base_name, sizeof(base_name)); + BLI_path_split_file_part(src_path, base_name, sizeof(base_name)); } return base_name; diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index cb38edf988f..e1928ea585f 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -84,10 +84,14 @@ static void report_job_duration(const ExportJobData *data) static bool perform_usdz_conversion(const ExportJobData *data) { char usdc_temp_dir[FILE_MAX], usdc_file[FILE_MAX]; - BLI_split_dirfile(data->unarchived_filepath, usdc_temp_dir, usdc_file, FILE_MAX, FILE_MAX); + BLI_path_split_dir_file(data->unarchived_filepath, + usdc_temp_dir, + sizeof(usdc_temp_dir), + usdc_file, + sizeof(usdc_file)); char usdz_file[FILE_MAX]; - BLI_split_file_part(data->usdz_filepath, usdz_file, FILE_MAX); + BLI_path_split_file_part(data->usdz_filepath, usdz_file, FILE_MAX); char original_working_dir_buff[FILE_MAX]; char *original_working_dir = BLI_current_working_dir(original_working_dir_buff, @@ -251,7 +255,7 @@ static void export_endjob_usdz_cleanup(const ExportJobData *data) } char dir[FILE_MAX]; - BLI_split_dir_part(data->unarchived_filepath, dir, FILE_MAX); + BLI_path_split_dir_part(data->unarchived_filepath, dir, FILE_MAX); char usdc_temp_dir[FILE_MAX]; BLI_path_join(usdc_temp_dir, FILE_MAX, BKE_tempdir_session(), "USDZ", SEP_STR); @@ -292,7 +296,7 @@ static void create_temp_path_for_usdz_export(const char *filepath, blender::io::usd::ExportJobData *job) { char file[FILE_MAX]; - BLI_split_file_part(filepath, file, FILE_MAX); + BLI_path_split_file_part(filepath, file, FILE_MAX); char *usdc_file = BLI_str_replaceN(file, ".usdz", ".usdc"); char usdc_temp_filepath[FILE_MAX]; diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index 5de28d0f197..d26c183acd0 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -125,7 +125,8 @@ static pxr::SdfLayerHandle get_layer_handle(const pxr::UsdAttribute &attribute) { for (auto PropertySpec : attribute.GetPropertyStack(pxr::UsdTimeCode::EarliestTime())) { if (PropertySpec->HasDefaultValue() || - PropertySpec->GetLayer()->GetNumTimeSamplesForPath(PropertySpec->GetPath()) > 0) { + PropertySpec->GetLayer()->GetNumTimeSamplesForPath(PropertySpec->GetPath()) > 0) + { return PropertySpec->GetLayer(); } } @@ -212,7 +213,8 @@ static float get_opacity_threshold(const pxr::UsdShadeShader &usd_shader, pxr::VtValue val; if (opacity_threshold_input.GetAttr().HasAuthoredValue() && - opacity_threshold_input.GetAttr().Get(&val)) { + opacity_threshold_input.GetAttr().Get(&val)) + { return val.Get(); } @@ -272,7 +274,8 @@ static void set_viewport_material_props(Material *mtl, const pxr::UsdShadeShader if (pxr::UsdShadeInput diffuse_color_input = usd_preview.GetInput(usdtokens::diffuseColor)) { pxr::VtValue val; if (diffuse_color_input.GetAttr().HasAuthoredValue() && - diffuse_color_input.GetAttr().Get(&val) && val.IsHolding()) { + diffuse_color_input.GetAttr().Get(&val) && val.IsHolding()) + { pxr::GfVec3f color = val.UncheckedGet(); mtl->r = color[0]; mtl->g = color[1]; @@ -283,7 +286,8 @@ static void set_viewport_material_props(Material *mtl, const pxr::UsdShadeShader if (pxr::UsdShadeInput metallic_input = usd_preview.GetInput(usdtokens::metallic)) { pxr::VtValue val; if (metallic_input.GetAttr().HasAuthoredValue() && metallic_input.GetAttr().Get(&val) && - val.IsHolding()) { + val.IsHolding()) + { mtl->metallic = val.Get(); } } @@ -291,7 +295,8 @@ static void set_viewport_material_props(Material *mtl, const pxr::UsdShadeShader if (pxr::UsdShadeInput roughness_input = usd_preview.GetInput(usdtokens::roughness)) { pxr::VtValue val; if (roughness_input.GetAttr().HasAuthoredValue() && roughness_input.GetAttr().Get(&val) && - val.IsHolding()) { + val.IsHolding()) + { mtl->roughness = val.Get(); } } @@ -456,7 +461,8 @@ void USDMaterialReader::set_principled_node_inputs(bNode *principled, } if (pxr::UsdShadeInput clearcoat_roughness_input = usd_shader.GetInput( - usdtokens::clearcoatRoughness)) { + usdtokens::clearcoatRoughness)) + { set_node_input( clearcoat_roughness_input, principled, "Clearcoat Roughness", ntree, column, &context); } @@ -750,7 +756,8 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader, } if (import_textures && params_.import_textures_mode == USD_TEX_IMPORT_PACK && - !BKE_image_has_packedfile(image)) { + !BKE_image_has_packedfile(image)) + { BKE_image_packfiles(nullptr, image, ID_BLEND_PATH(bmain_, &image->id)); if (BLI_is_dir(temp_textures_dir())) { BLI_delete(temp_textures_dir(), true, true); diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 79c382581e1..96b14a48f90 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -93,7 +93,8 @@ static void assign_materials(Main *bmain, for (std::map::const_iterator it = mat_index_map.begin(); it != mat_index_map.end(); - ++it) { + ++it) + { Material *assigned_mat = blender::io::usd::find_existing_material( it->first, params, mat_name_to_mat, usd_path_to_mat_name); @@ -336,7 +337,8 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo } /* Early out if not first load and UVs aren't animated. */ if (!load_uvs && primvar_varying_map_.find(uv_token) != primvar_varying_map_.end() && - !primvar_varying_map_.at(uv_token)) { + !primvar_varying_map_.at(uv_token)) + { continue; } @@ -378,9 +380,9 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo const UVSample &sample = uv_primvars[layer_idx]; - if (!ELEM(sample.interpolation, - pxr::UsdGeomTokens->faceVarying, - pxr::UsdGeomTokens->vertex)) { + if (!ELEM( + sample.interpolation, pxr::UsdGeomTokens->faceVarying, pxr::UsdGeomTokens->vertex)) + { std::cerr << "WARNING: unexpected interpolation type " << sample.interpolation << " for uv " << layer->name << std::endl; continue; @@ -433,7 +435,8 @@ void USDMeshReader::read_color_data_all_primvars(Mesh *mesh, const double motion if (!ELEM(type, pxr::SdfValueTypeNames->Color3hArray, pxr::SdfValueTypeNames->Color3fArray, - pxr::SdfValueTypeNames->Color3dArray)) { + pxr::SdfValueTypeNames->Color3dArray)) + { continue; } @@ -494,7 +497,8 @@ void USDMeshReader::read_color_data_primvar(Mesh *mesh, (interp == pxr::UsdGeomTokens->varying && usd_colors.size() != mesh->totloop) || (interp == pxr::UsdGeomTokens->vertex && usd_colors.size() != mesh->totvert) || (interp == pxr::UsdGeomTokens->constant && usd_colors.size() != 1) || - (interp == pxr::UsdGeomTokens->uniform && usd_colors.size() != mesh->totpoly)) { + (interp == pxr::UsdGeomTokens->uniform && usd_colors.size() != mesh->totpoly)) + { WM_reportf(RPT_WARNING, "USD Import: color attribute value '%s' count inconsistent with interpolation type", color_primvar.GetName().GetText()); @@ -509,7 +513,8 @@ void USDMeshReader::read_color_data_primvar(Mesh *mesh, if (ELEM(interp, pxr::UsdGeomTokens->varying, pxr::UsdGeomTokens->faceVarying, - pxr::UsdGeomTokens->uniform)) { + pxr::UsdGeomTokens->uniform)) + { color_domain = ATTR_DOMAIN_CORNER; } @@ -531,7 +536,8 @@ void USDMeshReader::read_color_data_primvar(Mesh *mesh, else { /* Check for situations that allow for a straight-forward copy by index. */ if ((ELEM(interp, pxr::UsdGeomTokens->vertex)) || - (color_domain == ATTR_DOMAIN_CORNER && !is_left_handed_)) { + (color_domain == ATTR_DOMAIN_CORNER && !is_left_handed_)) + { for (int i = 0; i < usd_colors.size(); i++) { ColorGeometry4f color = ColorGeometry4f( usd_colors[i][0], usd_colors[i][1], usd_colors[i][2], 1.0f); @@ -756,7 +762,8 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings, /* Process point normals after reading polys. */ if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0 && - normal_interpolation_ == pxr::UsdGeomTokens->vertex) { + normal_interpolation_ == pxr::UsdGeomTokens->vertex) + { process_normals_vertex_varying(mesh); } @@ -899,7 +906,8 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, if (ELEM(type, pxr::SdfValueTypeNames->TexCoord2hArray, pxr::SdfValueTypeNames->TexCoord2fArray, - pxr::SdfValueTypeNames->TexCoord2dArray)) { + pxr::SdfValueTypeNames->TexCoord2dArray)) + { is_uv = true; } /* In some cases, the st primvar is stored as float2 values. */ diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc index 6dfd75064be..b2d763f6b48 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.cc +++ b/source/blender/io/usd/intern/usd_reader_stage.cc @@ -88,8 +88,9 @@ USDPrimReader *USDStageReader::create_reader_if_allowed(const pxr::UsdPrim &prim return new USDMeshReader(prim, params_, settings_); } #if PXR_VERSION >= 2111 - if (params_.import_lights && (prim.IsA() || - prim.IsA())) { + if (params_.import_lights && + (prim.IsA() || prim.IsA())) + { #else if (params_.import_lights && prim.IsA()) { #endif @@ -336,7 +337,8 @@ void USDStageReader::import_all_materials(Main *bmain) } if (blender::io::usd::find_existing_material( - prim.GetPath(), params_, settings_.mat_name_to_mat, settings_.usd_path_to_mat_name)) { + prim.GetPath(), params_, settings_.mat_name_to_mat, settings_.usd_path_to_mat_name)) + { /* The material already exists. */ continue; } @@ -362,7 +364,8 @@ void USDStageReader::fake_users_for_unused_materials() /* Iterate over the imported materials and set a fake user for any unused * materials. */ for (const std::pair &path_mat_pair : - settings_.usd_path_to_mat_name) { + settings_.usd_path_to_mat_name) + { std::map::iterator mat_it = settings_.mat_name_to_mat.find( path_mat_pair.second); diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index e120bbe1683..a18e7ff08df 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -47,6 +47,7 @@ static const pxr::TfToken primvar_float2("UsdPrimvarReader_float2", pxr::TfToken static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal); static const pxr::TfToken specular("specular", pxr::TfToken::Immortal); static const pxr::TfToken opacity("opacity", pxr::TfToken::Immortal); +static const pxr::TfToken opacityThreshold("opacityThreshold", pxr::TfToken::Immortal); static const pxr::TfToken surface("surface", pxr::TfToken::Immortal); static const pxr::TfToken perspective("perspective", pxr::TfToken::Immortal); static const pxr::TfToken orthographic("orthographic", pxr::TfToken::Immortal); @@ -144,6 +145,8 @@ void create_usd_preview_surface_material(const USDExporterContext &usd_export_co const InputSpecMap &input_map = preview_surface_input_map(); + bool has_opacity = false; + /* Set the preview surface inputs. */ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { @@ -167,6 +170,10 @@ void create_usd_preview_surface_material(const USDExporterContext &usd_export_co preview_surface.CreateInput(input_spec.input_name, input_spec.input_type) .ConnectToSource(created_shader.ConnectableAPI(), input_spec.source_name); set_normal_texture_range(created_shader, input_spec); + + if (input_spec.input_name == usdtokens::opacity) { + has_opacity = true; + } } else if (input_spec.set_default_value) { /* Set hardcoded value. */ @@ -203,6 +210,15 @@ void create_usd_preview_surface_material(const USDExporterContext &usd_export_co create_uvmap_shader( usd_export_context, input_node, usd_material, created_shader, default_uv_sampler); } + + /* Set opacityThreshold if an alpha cutout is used. */ + if (has_opacity) { + if ((material->blend_method == MA_BM_CLIP) && (material->alpha_threshold > 0.0)) { + pxr::UsdShadeInput opacity_threshold_input = preview_surface.CreateInput( + usdtokens::opacityThreshold, pxr::SdfValueTypeNames->Float); + opacity_threshold_input.GetAttr().Set(pxr::VtValue(material->alpha_threshold)); + } + } } void set_normal_texture_range(pxr::UsdShadeShader &usd_shader, const InputSpec &input_spec) @@ -399,7 +415,7 @@ static void export_in_memory_texture(Image *ima, char file_name[FILE_MAX]; if (strlen(ima->filepath) > 0) { get_absolute_path(ima, image_abs_path); - BLI_split_file_part(image_abs_path, file_name, FILE_MAX); + BLI_path_split_file_part(image_abs_path, file_name, FILE_MAX); } else { /* Use the image name for the file name. */ @@ -614,7 +630,7 @@ static std::string get_tex_image_asset_path(bNode *node, char exp_path[FILE_MAX]; char file_path[FILE_MAX]; - BLI_split_file_part(path.c_str(), file_path, FILE_MAX); + BLI_path_split_file_part(path.c_str(), file_path, FILE_MAX); if (export_params.relative_paths) { BLI_path_join(exp_path, FILE_MAX, ".", "textures", file_path); @@ -628,7 +644,7 @@ static std::string get_tex_image_asset_path(bNode *node, } char dir_path[FILE_MAX]; - BLI_split_dir_part(stage_path.c_str(), dir_path, FILE_MAX); + BLI_path_split_dir_part(stage_path.c_str(), dir_path, FILE_MAX); BLI_path_join(exp_path, FILE_MAX, dir_path, "textures", file_path); } BLI_str_replace_char(exp_path, '\\', '/'); @@ -683,7 +699,7 @@ static void copy_tiled_textures(Image *ima, src_tile_path, udim_pattern, tile_format, tile->tile_number); char dest_filename[FILE_MAXFILE]; - BLI_split_file_part(src_tile_path, dest_filename, sizeof(dest_filename)); + BLI_path_split_file_part(src_tile_path, dest_filename, sizeof(dest_filename)); char dest_tile_path[FILE_MAX]; BLI_path_join(dest_tile_path, FILE_MAX, dest_dir.c_str(), dest_filename); @@ -718,7 +734,7 @@ static void copy_single_file(Image *ima, const std::string &dest_dir, const bool get_absolute_path(ima, source_path); char file_name[FILE_MAX]; - BLI_split_file_part(source_path, file_name, FILE_MAX); + BLI_path_split_file_part(source_path, file_name, FILE_MAX); char dest_path[FILE_MAX]; BLI_path_join(dest_path, FILE_MAX, dest_dir.c_str(), file_name); @@ -764,7 +780,7 @@ static void export_texture(bNode *node, } char usd_dir_path[FILE_MAX]; - BLI_split_dir_part(stage_path.c_str(), usd_dir_path, FILE_MAX); + BLI_path_split_dir_part(stage_path.c_str(), usd_dir_path, FILE_MAX); char tex_dir_path[FILE_MAX]; BLI_path_join(tex_dir_path, FILE_MAX, usd_dir_path, "textures", SEP_STR); diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index e4c5332c6ee..5b4c5bec528 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -82,7 +82,8 @@ void USDGenericMeshWriter::write_custom_data(const Mesh *mesh, pxr::UsdGeomMesh [&](const bke::AttributeIDRef &attribute_id, const bke::AttributeMetaData &meta_data) { /* Color data. */ if (ELEM(meta_data.domain, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_POINT) && - ELEM(meta_data.data_type, CD_PROP_BYTE_COLOR, CD_PROP_COLOR)) { + ELEM(meta_data.data_type, CD_PROP_BYTE_COLOR, CD_PROP_COLOR)) + { write_color_data(mesh, usd_mesh, attribute_id, meta_data); } @@ -281,7 +282,8 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh) } if (!usd_mesh_data.corner_indices.empty() && - usd_mesh_data.corner_indices.size() == usd_mesh_data.corner_sharpnesses.size()) { + usd_mesh_data.corner_indices.size() == usd_mesh_data.corner_sharpnesses.size()) + { pxr::UsdAttribute attr_corner_indices = usd_mesh.CreateCornerIndicesAttr(pxr::VtValue(), true); pxr::UsdAttribute attr_corner_sharpnesses = usd_mesh.CreateCornerSharpnessesAttr( pxr::VtValue(), true); diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc index c985f1d061f..8f964e83888 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.cc +++ b/source/blender/io/usd/intern/usd_writer_volume.cc @@ -99,7 +99,8 @@ std::optional USDVolumeWriter::resolve_vdb_file(const Volume *volum vdb_file_path = construct_vdb_file_path(volume); if (!BKE_volume_save( - volume, usd_export_context_.bmain, nullptr, vdb_file_path.value_or("").c_str())) { + volume, usd_export_context_.bmain, nullptr, vdb_file_path.value_or("").c_str())) + { return std::nullopt; } } @@ -123,11 +124,11 @@ std::optional USDVolumeWriter::construct_vdb_file_path(const Volume char usd_directory_path[FILE_MAX]; char usd_file_name[FILE_MAXFILE]; - BLI_split_dirfile(usd_file_path.c_str(), - usd_directory_path, - usd_file_name, - sizeof(usd_directory_path), - sizeof(usd_file_name)); + BLI_path_split_dir_file(usd_file_path.c_str(), + usd_directory_path, + sizeof(usd_directory_path), + usd_file_name, + sizeof(usd_file_name)); if (usd_directory_path[0] == '\0' || usd_file_name[0] == '\0') { return std::nullopt; @@ -137,7 +138,7 @@ std::optional USDVolumeWriter::construct_vdb_file_path(const Volume char vdb_directory_path[FILE_MAX]; BLI_strncpy(vdb_directory_path, usd_directory_path, FILE_MAX); - strcat(vdb_directory_path, vdb_directory_name); + BLI_strncat(vdb_directory_path, vdb_directory_name, sizeof(vdb_directory_path)); BLI_dir_create_recursive(vdb_directory_path); char vdb_file_name[FILE_MAXFILE]; @@ -146,9 +147,9 @@ std::optional USDVolumeWriter::construct_vdb_file_path(const Volume if (!timecode.IsDefault()) { const int frame = int(timecode.GetValue()); const int num_frame_digits = frame == 0 ? 1 : integer_digits_i(abs(frame)); - BLI_path_frame(vdb_file_name, frame, num_frame_digits); + BLI_path_frame(vdb_file_name, sizeof(vdb_file_name), frame, num_frame_digits); } - strcat(vdb_file_name, ".vdb"); + BLI_strncat(vdb_file_name, ".vdb", sizeof(vdb_file_name)); char vdb_file_path[FILE_MAX]; BLI_path_join(vdb_file_path, sizeof(vdb_file_path), vdb_directory_path, vdb_file_name); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 575977559d9..d12d8797920 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -172,7 +172,11 @@ void OBJWriter::write_mtllib_name(const StringRefNull mtl_filepath) const /* Split .MTL file path into parent directory and filename. */ char mtl_file_name[FILE_MAXFILE]; char mtl_dir_name[FILE_MAXDIR]; - BLI_split_dirfile(mtl_filepath.data(), mtl_dir_name, mtl_file_name, FILE_MAXDIR, FILE_MAXFILE); + BLI_path_split_dir_file(mtl_filepath.data(), + mtl_dir_name, + sizeof(mtl_dir_name), + mtl_file_name, + sizeof(mtl_file_name)); FormatHandler fh; fh.write_obj_mtllib(mtl_file_name); fh.write_to_file(outfile_); @@ -610,8 +614,8 @@ void MTLWriter::write_bsdf_properties(const MTLMaterial &mtl, bool write_pbr) if (mtl.aniso_rot >= 0.0f) { fmt_handler_.write_mtl_float("anisor", mtl.aniso_rot); } - if (mtl.transmit_color.x > 0.0f || mtl.transmit_color.y > 0.0f || - mtl.transmit_color.z > 0.0f) { + if (mtl.transmit_color.x > 0.0f || mtl.transmit_color.y > 0.0f || mtl.transmit_color.z > 0.0f) + { fmt_handler_.write_mtl_float3( "Tf", mtl.transmit_color.x, mtl.transmit_color.y, mtl.transmit_color.z); } @@ -667,7 +671,7 @@ void MTLWriter::write_materials(const char *blen_filepath, } char blen_filedir[PATH_MAX]; - BLI_split_dir_part(blen_filepath, blen_filedir, PATH_MAX); + BLI_path_split_dir_part(blen_filepath, blen_filedir, PATH_MAX); BLI_path_slash_native(blen_filedir); BLI_path_normalize(blen_filedir); diff --git a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc index 3e9db71ea08..235d7eaa6e6 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc @@ -286,7 +286,7 @@ void export_frame(Depsgraph *depsgraph, const OBJExportParams &export_params, co mtl_writer->write_header(export_params.blen_filepath); char dest_dir[PATH_MAX]; if (export_params.file_base_for_tests[0] == '\0') { - BLI_split_dir_part(export_params.filepath, dest_dir, PATH_MAX); + BLI_path_split_dir_part(export_params.filepath, dest_dir, PATH_MAX); } else { BLI_strncpy(dest_dir, export_params.file_base_for_tests, PATH_MAX); @@ -306,7 +306,7 @@ bool append_frame_to_filename(const char *filepath, const int frame, char *r_fil BLI_strncpy(r_filepath_with_frames, filepath, FILE_MAX); BLI_path_extension_strip(r_filepath_with_frames); const int digits = frame == 0 ? 1 : integer_digits_i(abs(frame)); - BLI_path_frame(r_filepath_with_frames, frame, digits); + BLI_path_frame(r_filepath_with_frames, FILE_MAX, frame, digits); return BLI_path_extension_replace(r_filepath_with_frames, FILE_MAX, ".obj"); } diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index 0e02fd9336e..881afc8009c 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -83,7 +83,8 @@ static void geom_add_vertex(const char *p, const char *end, GlobalVertices &r_gl /* If we don't have vertex colors yet, or the previous vertex * was without color, we need to start a new vertex colors block. */ if (blocks.is_empty() || (blocks.last().start_vertex_index + blocks.last().colors.size() != - r_global_vertices.vertices.size() - 1)) { + r_global_vertices.vertices.size() - 1)) + { GlobalVertices::VertexColorsBlock block; block.start_vertex_index = r_global_vertices.vertices.size() - 1; blocks.append(block); @@ -118,7 +119,8 @@ static void geom_add_mrgb_colors(const char *p, const char *end, GlobalVertices /* If we don't have vertex colors yet, or the previous vertex * was without color, we need to start a new vertex colors block. */ if (blocks.is_empty() || (blocks.last().start_vertex_index + blocks.last().colors.size() != - r_global_vertices.vertices.size())) { + r_global_vertices.vertices.size())) + { GlobalVertices::VertexColorsBlock block; block.start_vertex_index = r_global_vertices.vertices.size(); blocks.append(block); @@ -287,7 +289,8 @@ static void geom_add_polygon(Geometry *geom, global_vertices.vert_normals.size() : -1; if (corner.vertex_normal_index < 0 || - corner.vertex_normal_index >= global_vertices.vert_normals.size()) { + corner.vertex_normal_index >= global_vertices.vert_normals.size()) + { fprintf(stderr, "Invalid normal index %i (valid range [0, %zu)), ignoring face\n", corner.vertex_normal_index, @@ -386,7 +389,8 @@ static void geom_add_curve_parameters(Geometry *geom, const char *p, const char static void geom_update_group(const StringRef rest_line, std::string &r_group_name) { if (rest_line.find("off") != string::npos || rest_line.find("null") != string::npos || - rest_line.find("default") != string::npos) { + rest_line.find("default") != string::npos) + { /* Set group for future elements like faces or curves to empty. */ r_group_name = ""; return; @@ -470,10 +474,10 @@ static void use_all_vertices_if_no_faces(Geometry *geom, const GlobalVertices &global_vertices) { if (!global_vertices.vertices.is_empty() && geom && geom->geom_type_ == GEOM_MESH) { - if (std::all_of( - all_geometries.begin(), all_geometries.end(), [](const std::unique_ptr &g) { - return g->get_vertex_count() == 0; - })) { + if (std::all_of(all_geometries.begin(), + all_geometries.end(), + [](const std::unique_ptr &g) { return g->get_vertex_count() == 0; })) + { geom->track_all_vertices(global_vertices.vertices.size()); } } @@ -578,7 +582,8 @@ void OBJParser::parse(Vector> &r_all_geometries, /* If we don't have a material index assigned yet, get one. * It means "usemtl" state came from the previous object. */ if (state_material_index == -1 && !state_material_name.empty() && - curr_geom->material_indices_.is_empty()) { + curr_geom->material_indices_.is_empty()) + { curr_geom->material_indices_.add_new(state_material_name, 0); curr_geom->material_order_.append(state_material_name); state_material_index = 0; @@ -705,7 +710,8 @@ static MTLTexMapType mtl_line_start_to_texture_type(const char *&p, const char * return MTLTexMapType::Emission; } if (parse_keyword(p, end, "bump") || parse_keyword(p, end, "map_Bump") || - parse_keyword(p, end, "map_bump")) { + parse_keyword(p, end, "map_bump")) + { return MTLTexMapType::Normal; } if (parse_keyword(p, end, "map_Pr")) { @@ -835,7 +841,7 @@ void OBJParser::add_default_mtl_library() BLI_path_extension_replace(mtl_file_path, sizeof(mtl_file_path), ".mtl"); if (BLI_exists(mtl_file_path)) { char mtl_file_base[FILE_MAX]; - BLI_split_file_part(mtl_file_path, mtl_file_base, sizeof(mtl_file_base)); + BLI_path_split_file_part(mtl_file_path, mtl_file_base, sizeof(mtl_file_base)); add_mtl_library(mtl_file_base); } } @@ -843,9 +849,9 @@ void OBJParser::add_default_mtl_library() MTLParser::MTLParser(StringRefNull mtl_library, StringRefNull obj_filepath) { char obj_file_dir[FILE_MAXDIR]; - BLI_split_dir_part(obj_filepath.data(), obj_file_dir, FILE_MAXDIR); + BLI_path_split_dir_part(obj_filepath.data(), obj_file_dir, FILE_MAXDIR); BLI_path_join(mtl_file_path_, FILE_MAX, obj_file_dir, mtl_library.data()); - BLI_split_dir_part(mtl_file_path_, mtl_dir_path_, FILE_MAXDIR); + BLI_path_split_dir_part(mtl_file_path_, mtl_dir_path_, FILE_MAXDIR); } void MTLParser::parse_and_store(Map> &r_materials) 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 358f1e8fc24..f700a2d7124 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -283,7 +283,8 @@ void MeshFromGeometry::create_uv_verts(Mesh *mesh) for (int idx = 0; idx < curr_face.corner_count_; ++idx) { const PolyCorner &curr_corner = mesh_geometry_.face_corners_[curr_face.start_index_ + idx]; if (curr_corner.uv_vert_index >= 0 && - curr_corner.uv_vert_index < global_vertices_.uv_vertices.size()) { + curr_corner.uv_vert_index < global_vertices_.uv_vertices.size()) + { uv_map.span[tot_loop_idx] = global_vertices_.uv_vertices[curr_corner.uv_vert_index]; added_uv = true; } @@ -396,7 +397,8 @@ void MeshFromGeometry::create_colors(Mesh *mesh) /* Find which vertex color block is for this mesh (if any). */ for (const auto &block : global_vertices_.vertex_colors) { if (mesh_geometry_.vertex_index_min_ >= block.start_vertex_index && - mesh_geometry_.vertex_index_max_ < block.start_vertex_index + block.colors.size()) { + mesh_geometry_.vertex_index_max_ < block.start_vertex_index + block.colors.size()) + { /* This block is suitable, use colors from it. */ CustomDataLayer *color_layer = BKE_id_attribute_new( &mesh->id, "Color", CD_PROP_COLOR, ATTR_DOMAIN_POINT, nullptr); diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc index ba55a249f89..059692ab768 100644 --- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc @@ -279,7 +279,7 @@ class obj_exporter_regression_test : public obj_exporter_test { strncpy(params.filepath, out_file_path.c_str(), FILE_MAX - 1); params.blen_filepath = bfile->main->filepath; std::string golden_file_path = blender::tests::flags_test_asset_dir() + SEP_STR + golden_obj; - BLI_split_dir_part( + BLI_path_split_dir_part( golden_file_path.c_str(), params.file_base_for_tests, sizeof(params.file_base_for_tests)); export_frame(depsgraph, params, out_file_path.c_str()); std::string output_str = read_temp_file_in_string(out_file_path); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 6346abf4211..cdb102482fc 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -248,35 +248,35 @@ typedef struct IDOverrideLibraryPropertyOperation { /* IDOverrideLibraryPropertyOperation->operation. */ enum { /* Basic operations. */ - IDOVERRIDE_LIBRARY_OP_NOOP = 0, /* Special value, forbids any overriding. */ + LIBOVERRIDE_OP_NOOP = 0, /* Special value, forbids any overriding. */ - IDOVERRIDE_LIBRARY_OP_REPLACE = 1, /* Fully replace local value by reference one. */ + LIBOVERRIDE_OP_REPLACE = 1, /* Fully replace local value by reference one. */ /* Numeric-only operations. */ - IDOVERRIDE_LIBRARY_OP_ADD = 101, /* Add local value to reference one. */ + LIBOVERRIDE_OP_ADD = 101, /* Add local value to reference one. */ /* Subtract local value from reference one (needed due to unsigned values etc.). */ - IDOVERRIDE_LIBRARY_OP_SUBTRACT = 102, + LIBOVERRIDE_OP_SUBTRACT = 102, /* Multiply reference value by local one (more useful than diff for scales and the like). */ - IDOVERRIDE_LIBRARY_OP_MULTIPLY = 103, + LIBOVERRIDE_OP_MULTIPLY = 103, /* Collection-only operations. */ - IDOVERRIDE_LIBRARY_OP_INSERT_AFTER = 201, /* Insert after given reference's subitem. */ - IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE = 202, /* Insert before given reference's subitem. */ + LIBOVERRIDE_OP_INSERT_AFTER = 201, /* Insert after given reference's subitem. */ + LIBOVERRIDE_OP_INSERT_BEFORE = 202, /* Insert before given reference's subitem. */ /* We can add more if needed (move, delete, ...). */ }; /* IDOverrideLibraryPropertyOperation->flag. */ enum { /** User cannot remove that override operation. */ - IDOVERRIDE_LIBRARY_FLAG_MANDATORY = 1 << 0, + LIBOVERRIDE_OP_FLAG_MANDATORY = 1 << 0, /** User cannot change that override operation. */ - IDOVERRIDE_LIBRARY_FLAG_LOCKED = 1 << 1, + LIBOVERRIDE_OP_FLAG_LOCKED = 1 << 1, /** * For overrides of ID pointers: this override still matches (follows) the hierarchy of the * reference linked data. */ - IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE = 1 << 8, + LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE = 1 << 8, }; /** A single overridden property, contain all operations on this one. */ @@ -308,10 +308,10 @@ typedef struct IDOverrideLibraryProperty { /* IDOverrideLibraryProperty->tag and IDOverrideLibraryPropertyOperation->tag. */ enum { /** This override property (operation) is unused and should be removed by cleanup process. */ - IDOVERRIDE_LIBRARY_TAG_UNUSED = 1 << 0, + LIBOVERRIDE_PROP_OP_TAG_UNUSED = 1 << 0, /** This override property is forbidden and should be restored to its linked reference value. */ - IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE = 1 << 1, + LIBOVERRIDE_PROP_TAG_NEEDS_RETORE = 1 << 1, }; # @@ -324,13 +324,19 @@ typedef struct IDOverrideLibraryRuntime { /* IDOverrideLibraryRuntime->tag. */ enum { /** This override needs to be reloaded. */ - IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RELOAD = 1 << 0, + LIBOVERRIDE_TAG_NEEDS_RELOAD = 1 << 0, /** * This override contains properties with forbidden changes, which should be restored to their * linked reference value. */ - IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE = 1 << 1, + LIBOVERRIDE_TAG_NEEDS_RESTORE = 1 << 1, + + /** + * This override is detected as being cut from its hierarchy root. Temporarily used during + * resync process. + */ + LIBOVERRIDE_TAG_RESYNC_ISOLATED_FROM_ROOT = 1 << 2, }; /* Main container for all overriding data info of a data-block. */ @@ -364,12 +370,12 @@ enum { * The override data-block should not be considered as part of an override hierarchy (generally * because it was created as an single override, outside of any hierarchy consideration). */ - IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY = 1 << 0, + LIBOVERRIDE_FLAG_NO_HIERARCHY = 1 << 0, /** * The override ID is required for the system to work (because of ID dependencies), but is not * seen as editable by the user. */ - IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED = 1 << 1, + LIBOVERRIDE_FLAG_SYSTEM_DEFINED = 1 << 1, }; /* watch it: Sequence has identical beginning. */ @@ -778,19 +784,19 @@ enum { * * RESET_NEVER */ - LIB_TAG_OVERRIDE_LIBRARY_REFOK = 1 << 6, + LIB_TAG_LIBOVERRIDE_REFOK = 1 << 6, /** * ID needs an auto-diffing execution, if enabled (only for library overrides). * * RESET_NEVER */ - LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH = 1 << 7, + LIB_TAG_LIBOVERRIDE_AUTOREFRESH = 1 << 7, /** * ID is a library override that needs re-sync to its linked reference. * * RESET_NEVER */ - LIB_TAG_LIB_OVERRIDE_NEED_RESYNC = 1 << 8, + LIB_TAG_LIBOVERRIDE_NEED_RESYNC = 1 << 8, /** * Short-life tags used during specific processes, like blend-file reading. diff --git a/source/blender/makesdna/DNA_mask_types.h b/source/blender/makesdna/DNA_mask_types.h index a9010c78402..ceed7a43ed8 100644 --- a/source/blender/makesdna/DNA_mask_types.h +++ b/source/blender/makesdna/DNA_mask_types.h @@ -22,6 +22,8 @@ extern "C" { typedef struct Mask { ID id; struct AnimData *adt; + /* runtime (must be immediately after id for utilities to use it). */ + DrawDataList drawdata; /** Mask layers. */ ListBase masklayers; /** Index of active mask layer (-1 == None). */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 8245637943a..41ca249505a 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -770,15 +770,15 @@ enum { CMP_NODE_INPAINT_SIMPLE = 0, }; -enum { +typedef enum CMPNodeMaskFlags { /* CMP_NODEFLAG_MASK_AA = (1 << 0), */ /* DEPRECATED */ - CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1), - CMP_NODEFLAG_MASK_MOTION_BLUR = (1 << 2), + CMP_NODE_MASK_FLAG_NO_FEATHER = (1 << 1), + CMP_NODE_MASK_FLAG_MOTION_BLUR = (1 << 2), /* We may want multiple aspect options, exposed as an rna enum. */ - CMP_NODEFLAG_MASK_FIXED = (1 << 8), - CMP_NODEFLAG_MASK_FIXED_SCENE = (1 << 9), -}; + CMP_NODE_MASK_FLAG_SIZE_FIXED = (1 << 8), + CMP_NODE_MASK_FLAG_SIZE_FIXED_SCENE = (1 << 9), +} CMPNodeMaskFlags; enum { CMP_NODEFLAG_BLUR_VARIABLE_SIZE = (1 << 0), @@ -2096,18 +2096,24 @@ typedef enum CMPNodeGlareType { CMP_NODE_GLARE_GHOST = 3, } CMPNodeGlareType; +/* Stabilize 2D node. Stored in custom1. */ +typedef enum CMPNodeStabilizeInterpolation { + CMP_NODE_STABILIZE_INTERPOLATION_NEAREST = 0, + CMP_NODE_STABILIZE_INTERPOLATION_BILINEAR = 1, + CMP_NODE_STABILIZE_INTERPOLATION_BICUBIC = 2, +} CMPNodeStabilizeInterpolation; + +/* Stabilize 2D node. Stored in custom2. */ +typedef enum CMPNodeStabilizeInverse { + CMP_NODE_STABILIZE_FLAG_INVERSE = 1, +} CMPNodeStabilizeInverse; + /* Plane track deform node. */ enum { CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR = 1, }; -/* Stabilization node. */ - -enum { - CMP_NODEFLAG_STABILIZE_INVERSE = 1, -}; - /* Set Alpha Node. */ /** #NodeSetAlpha.mode */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 81ea41a52d2..3cda093e0dc 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2192,7 +2192,7 @@ extern const char *RE_engine_id_CYCLES; #define BASE_EDITABLE(v3d, base) \ (BASE_VISIBLE(v3d, base) && !ID_IS_LINKED((base)->object) && \ (!ID_IS_OVERRIDE_LIBRARY_REAL((base)->object) || \ - ((base)->object->id.override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) == 0)) + ((base)->object->id.override_library->flag & LIBOVERRIDE_FLAG_SYSTEM_DEFINED) == 0)) #define BASE_SELECTED_EDITABLE(v3d, base) \ (BASE_EDITABLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0)) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index b75bf5383de..b914f40ca65 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -1485,7 +1485,8 @@ static int compress_reconstruct_steps(ReconstructStep *steps, const int old_step if (prev_step->data.memcpy.old_offset + prev_step->data.memcpy.size == step->data.memcpy.old_offset && prev_step->data.memcpy.new_offset + prev_step->data.memcpy.size == - step->data.memcpy.new_offset) { + step->data.memcpy.new_offset) + { prev_step->data.memcpy.size += step->data.memcpy.size; break; } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 0728f69b449..15eae50be51 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -776,7 +776,8 @@ static int convert_include(const char *filepath) const char *md1_prev = md1; while (match_identifier_and_advance(&md1, "struct") || match_identifier_and_advance(&md1, "unsigned") || - match_identifier_and_advance(&md1, "const")) { + match_identifier_and_advance(&md1, "const")) + { if (UNLIKELY(!ELEM(*md1, '\0', ' '))) { /* This will happen with: `unsigned(*value)[3]` which isn't supported. */ fprintf(stderr, diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 2864720a7be..df72ae7b48e 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -550,7 +550,8 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); { \ CollectionPropertyIterator rna_macro_iter; \ for (RNA_collection_begin(sptr, propname, &rna_macro_iter); rna_macro_iter.valid; \ - RNA_property_collection_next(&rna_macro_iter)) { \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PointerRNA itemptr = rna_macro_iter.ptr; #define RNA_END \ @@ -563,7 +564,8 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); { \ CollectionPropertyIterator rna_macro_iter; \ for (RNA_property_collection_begin(sptr, prop, &rna_macro_iter); rna_macro_iter.valid; \ - RNA_property_collection_next(&rna_macro_iter)) { \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PointerRNA itemptr = rna_macro_iter.ptr; #define RNA_PROP_END \ @@ -578,7 +580,8 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); for (RNA_property_collection_begin( \ sptr, RNA_struct_iterator_property((sptr)->type), &rna_macro_iter); \ rna_macro_iter.valid; \ - RNA_property_collection_next(&rna_macro_iter)) { \ + RNA_property_collection_next(&rna_macro_iter)) \ + { \ PropertyRNA *prop = (PropertyRNA *)rna_macro_iter.ptr.data; #define RNA_STRUCT_BEGIN_SKIP_RNA_TYPE(sptr, prop) \ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 3cf32a878dc..a53e06aedd7 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -711,8 +711,8 @@ static char *rna_def_property_get_func( if (prop->type == PROP_INT) { IntPropertyRNA *iprop = (IntPropertyRNA *)prop; /* Only UI_BTYPE_NUM_SLIDER is implemented and that one can't have a softmin of zero. */ - if ((iprop->ui_scale_type == PROP_SCALE_LOG) && - (iprop->hardmin <= 0 || iprop->softmin <= 0)) { + if ((iprop->ui_scale_type == PROP_SCALE_LOG) && (iprop->hardmin <= 0 || iprop->softmin <= 0)) + { CLOG_ERROR( &LOG, "\"%s.%s\", range for log scale <= 0.", srna->identifier, prop->identifier); DefRNA.error = true; @@ -807,7 +807,8 @@ static char *rna_def_property_get_func( if (STR_ELEM(manualfunc, "rna_iterator_listbase_get", "rna_iterator_array_get", - "rna_iterator_array_dereference_get")) { + "rna_iterator_array_dereference_get")) + { fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType", @@ -2048,7 +2049,8 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) * array get/next function, we can be sure it is an actual array */ if (cprop->next && cprop->get) { if (STREQ((const char *)cprop->next, "rna_iterator_array_next") && - STREQ((const char *)cprop->get, "rna_iterator_array_get")) { + STREQ((const char *)cprop->get, "rna_iterator_array_get")) + { prop->flag_internal |= PROP_INTERN_RAW_ARRAY; } } @@ -2389,7 +2391,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property const char *collection_funcs = "DefaultCollectionFunctions"; if (!(dp->prop->flag & PROP_IDPROPERTY || dp->prop->flag_internal & PROP_INTERN_BUILTIN) && - cprop->property.srna) { + cprop->property.srna) + { collection_funcs = (char *)cprop->property.srna; } @@ -2987,8 +2990,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA else if (type == PROP_POINTER || dparm->prop->arraydimension) { ptrstr = "*"; } - else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && - !(flag & PROP_THICK_WRAP)) { + else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && !(flag & PROP_THICK_WRAP)) + { ptrstr = "*"; /* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack, * but type name for string props is already (char *), so leave empty */ diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 2c7ccd09a89..add466bb887 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -73,38 +73,38 @@ const EnumPropertyItem rna_enum_id_type_items[] = { }; static const EnumPropertyItem rna_enum_override_library_property_operation_items[] = { - {IDOVERRIDE_LIBRARY_OP_NOOP, + {LIBOVERRIDE_OP_NOOP, "NOOP", 0, "No-Op", "Does nothing, prevents adding actual overrides (NOT USED)"}, - {IDOVERRIDE_LIBRARY_OP_REPLACE, + {LIBOVERRIDE_OP_REPLACE, "REPLACE", 0, "Replace", "Replace value of reference by overriding one"}, - {IDOVERRIDE_LIBRARY_OP_ADD, + {LIBOVERRIDE_OP_ADD, "DIFF_ADD", 0, "Differential", "Stores and apply difference between reference and local value (NOT USED)"}, - {IDOVERRIDE_LIBRARY_OP_SUBTRACT, + {LIBOVERRIDE_OP_SUBTRACT, "DIFF_SUB", 0, "Differential", "Stores and apply difference between reference and local value (NOT USED)"}, - {IDOVERRIDE_LIBRARY_OP_MULTIPLY, + {LIBOVERRIDE_OP_MULTIPLY, "FACT_MULTIPLY", 0, "Factor", "Stores and apply multiplication factor between reference and local value (NOT USED)"}, - {IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, + {LIBOVERRIDE_OP_INSERT_AFTER, "INSERT_AFTER", 0, "Insert After", "Insert a new item into collection after the one referenced in subitem_reference_name or " "_index"}, - {IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE, + {LIBOVERRIDE_OP_INSERT_BEFORE, "INSERT_BEFORE", 0, "Insert Before", @@ -579,7 +579,8 @@ int rna_ID_is_runtime_editable(PointerRNA *ptr, const char **r_info) ID *id = (ID *)ptr->data; /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */ if (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_TEMP_MAIN | LIB_TAG_LOCALIZED | - LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_COPIED_ON_WRITE)) { + LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_COPIED_ON_WRITE)) + { *r_info = "Cannot edit 'runtime' status of non-blendfile data-blocks, as they are by definition " "always runtime"; @@ -594,7 +595,8 @@ bool rna_ID_is_runtime_get(PointerRNA *ptr) ID *id = (ID *)ptr->data; /* TODO: This should be abstracted in a BKE function or define, somewhat related to #88555. */ if (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_TEMP_MAIN | LIB_TAG_LOCALIZED | - LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_COPIED_ON_WRITE)) { + LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT | LIB_TAG_COPIED_ON_WRITE)) + { return true; } @@ -1141,7 +1143,8 @@ static void rna_ImagePreview_is_custom_set(PointerRNA *ptr, int value, enum eIco } if ((value && (prv_img->flag[size] & PRV_USER_EDITED)) || - (!value && !(prv_img->flag[size] & PRV_USER_EDITED))) { + (!value && !(prv_img->flag[size] & PRV_USER_EDITED))) + { return; } @@ -1407,7 +1410,8 @@ static void rna_ImagePreview_icon_reload(PreviewImage *prv) { /* will lazy load on next use, but only in case icon is not user-modified! */ if (!(prv->flag[ICON_SIZE_ICON] & PRV_USER_EDITED) && - !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED)) { + !(prv->flag[ICON_SIZE_PREVIEW] & PRV_USER_EDITED)) + { BKE_previewimg_clear(prv); } } @@ -1685,12 +1689,12 @@ static void rna_def_ID_override_library_property_operation(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem override_library_property_flag_items[] = { - {IDOVERRIDE_LIBRARY_FLAG_MANDATORY, + {LIBOVERRIDE_OP_FLAG_MANDATORY, "MANDATORY", 0, "Mandatory", "For templates, prevents the user from removing predefined operation (NOT USED)"}, - {IDOVERRIDE_LIBRARY_FLAG_LOCKED, + {LIBOVERRIDE_OP_FLAG_LOCKED, "LOCKED", 0, "Locked", @@ -1706,7 +1710,7 @@ static void rna_def_ID_override_library_property_operation(BlenderRNA *brna) prop = RNA_def_enum(srna, "operation", rna_enum_override_library_property_operation_items, - IDOVERRIDE_LIBRARY_OP_REPLACE, + LIBOVERRIDE_OP_REPLACE, "Operation", "What override operation is performed"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* For now. */ @@ -1780,7 +1784,7 @@ static void rna_def_ID_override_library_property_operations(BlenderRNA *brna, Pr parm = RNA_def_enum(func, "operation", rna_enum_override_library_property_operation_items, - IDOVERRIDE_LIBRARY_OP_REPLACE, + LIBOVERRIDE_OP_REPLACE, "Operation", "What override operation is performed"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); @@ -1927,7 +1931,7 @@ static void rna_def_ID_override_library(BlenderRNA *brna) "Whether this library override is defined as part of a library " "hierarchy, or as a single, isolated and autonomous override"); RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LIBOVERRIDE_FLAG_NO_HIERARCHY); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); prop = RNA_def_boolean(srna, @@ -1937,7 +1941,7 @@ static void rna_def_ID_override_library(BlenderRNA *brna) "Whether this library override exists only for the override hierarchy, " "or if it is actually editable by the user"); RNA_def_property_update(prop, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); - RNA_def_property_boolean_sdna(prop, NULL, "flag", IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LIBOVERRIDE_FLAG_SYSTEM_DEFINED); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); prop = RNA_def_collection(srna, diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index c9c57eee4cd..6001dca7d2d 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -71,12 +71,13 @@ void RNA_init(void) BLENDER_RNA.structs_len = 0; for (srna = static_cast(BLENDER_RNA.structs.first); srna; - srna = static_cast(srna->cont.next)) { + srna = static_cast(srna->cont.next)) + { if (!srna->cont.prophash) { srna->cont.prophash = BLI_ghash_str_new("RNA_init gh"); - for (prop = static_cast(srna->cont.properties.first); prop; - prop = prop->next) { + for (prop = static_cast(srna->cont.properties.first); prop; prop = prop->next) + { if (!(prop->flag_internal & PROP_INTERN_BUILTIN)) { BLI_ghash_insert(srna->cont.prophash, (void *)prop->identifier, prop); } @@ -93,7 +94,8 @@ void RNA_exit(void) StructRNA *srna; for (srna = static_cast(BLENDER_RNA.structs.first); srna; - srna = static_cast(srna->cont.next)) { + srna = static_cast(srna->cont.next)) + { if (srna->cont.prophash) { BLI_ghash_free(srna->cont.prophash, nullptr, nullptr); srna->cont.prophash = nullptr; @@ -735,7 +737,8 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier) PropertyRNA *r_prop = nullptr; PointerRNA r_ptr; /* only support single level props */ if (RNA_path_resolve_property(ptr, identifier, &r_ptr, &r_prop) && (r_ptr.type == ptr->type) && - (r_ptr.data == ptr->data)) { + (r_ptr.data == ptr->data)) + { return r_prop; } } @@ -989,7 +992,8 @@ bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, last = end - 1; for (c = start; c != end; c++) { if (((*c >= 'A' && *c <= 'Z') || ((c != start) && (*c >= '0' && *c <= '9')) || - ((c != start) && (c != last) && (*c == '_'))) == 0) { + ((c != start) && (c != last) && (*c == '_'))) == 0) + { BKE_reportf(reports, eReportType(report_level), "'%s' doesn't have upper case alpha-numeric prefix", @@ -1003,7 +1007,8 @@ bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, last = end - 1; for (c = start; c != end; c++) { if (((*c >= 'A' && *c <= 'Z') || (*c >= 'a' && *c <= 'z') || (*c >= '0' && *c <= '9') || - ((c != start) && (c != last) && (*c == '_'))) == 0) { + ((c != start) && (c != last) && (*c == '_'))) == 0) + { BKE_reportf(reports, eReportType(report_level), "'%s' doesn't have an alpha-numeric suffix", @@ -1142,7 +1147,8 @@ char RNA_property_array_item_char(PropertyRNA *prop, int index) PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION, - PROP_COORDS)) { + PROP_COORDS)) + { return vectoritem[index]; } if ((index < 4) && ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { @@ -1178,7 +1184,8 @@ int RNA_property_array_item_index(PropertyRNA *prop, char name) PROP_XYZ_LENGTH, PROP_EULER, PROP_VELOCITY, - PROP_ACCELERATION)) { + PROP_ACCELERATION)) + { switch (name) { case 'x': return 0; @@ -2095,7 +2102,7 @@ static void rna_property_update( ((ContextPropUpdateFunc)prop->update)(C, ptr, prop); } else { - (reinterpret_cast(reinterpret_cast(prop->update)))(C, ptr); + reinterpret_cast(reinterpret_cast(prop->update))(C, ptr); } } } @@ -2155,7 +2162,8 @@ static void rna_property_update( * is updated with custom nodes. */ if ((prop->flag & PROP_IDPROPERTY) != 0 && (ptr->owner_id != nullptr) && - (GS(ptr->owner_id->name) == ID_NT)) { + (GS(ptr->owner_id->name) == ID_NT)) + { WM_main_add_notifier(NC_MATERIAL | ND_SHADING, nullptr); } } @@ -3387,7 +3395,7 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val if ((idprop = rna_idproperty_check(&prop, ptr))) { /* both IDP_STRING_SUB_BYTE / IDP_STRING_SUB_UTF8 */ - IDP_AssignString(idprop, value, RNA_property_string_maxlength(prop) - 1); + IDP_AssignStringMaxSize(idprop, value, RNA_property_string_maxlength(prop)); rna_idproperty_touch(idprop); } else if (sprop->set) { @@ -3401,8 +3409,9 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val group = RNA_struct_idprops(ptr, 1); if (group) { - IDP_AddToGroup(group, - IDP_NewString(value, prop->identifier, RNA_property_string_maxlength(prop))); + IDP_AddToGroup( + group, + IDP_NewStringMaxSize(value, prop->identifier, RNA_property_string_maxlength(prop))); } } } @@ -3730,7 +3739,8 @@ void RNA_property_pointer_set(PointerRNA *ptr, /* RNA property. */ else if (pprop->set) { if (!((prop->flag & PROP_NEVER_NULL) && ptr_value.data == nullptr) && - !((prop->flag & PROP_ID_SELF_CHECK) && ptr->owner_id == ptr_value.owner_id)) { + !((prop->flag & PROP_ID_SELF_CHECK) && ptr->owner_id == ptr_value.owner_id)) + { pprop->set(ptr, ptr_value, reports); } } @@ -4383,7 +4393,8 @@ int RNA_property_collection_raw_array(PointerRNA *ptr, BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); if (!(prop->flag_internal & PROP_INTERN_RAW_ARRAY) || - !(itemprop->flag_internal & PROP_INTERN_RAW_ACCESS)) { + !(itemprop->flag_internal & PROP_INTERN_RAW_ACCESS)) + { return 0; } @@ -4600,7 +4611,8 @@ static int rna_raw_access(ReportList *reports, if (((itemtype == PROP_INT) && (in.type == PROP_RAW_INT)) || ((itemtype == PROP_BOOLEAN) && (in.type == PROP_RAW_BOOLEAN)) || - ((itemtype == PROP_FLOAT) && (in.type == PROP_RAW_FLOAT))) { + ((itemtype == PROP_FLOAT) && (in.type == PROP_RAW_FLOAT))) + { /* avoid creating temporary buffer if the data type match */ needconv = 0; } @@ -5872,7 +5884,8 @@ char *RNA_property_as_string( for (RNA_property_collection_begin(ptr, prop, &collect_iter); (i < max_prop_length) && collect_iter.valid; - RNA_property_collection_next(&collect_iter), i++) { + RNA_property_collection_next(&collect_iter), i++) + { PointerRNA itemptr = collect_iter.ptr; if (i != 0) { diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index af13171f202..cbccd431044 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -244,7 +244,7 @@ bool RNA_property_copy( } IDOverrideLibraryPropertyOperation opop = { - .operation = IDOVERRIDE_LIBRARY_OP_REPLACE, + .operation = LIBOVERRIDE_OP_REPLACE, .subitem_reference_index = index, .subitem_local_index = index, }; @@ -336,7 +336,8 @@ static int rna_property_override_diff(Main *bmain, BLI_assert(!ELEM(NULL, prop_a, prop_b)); if (prop_a->rnaprop->flag_override & PROPOVERRIDE_NO_COMPARISON || - prop_b->rnaprop->flag_override & PROPOVERRIDE_NO_COMPARISON) { + prop_b->rnaprop->flag_override & PROPOVERRIDE_NO_COMPARISON) + { return 0; } @@ -416,7 +417,8 @@ static int rna_property_override_diff(Main *bmain, eRNAOverrideMatch diff_flags = flags; if (!RNA_property_overridable_get(&prop_a->ptr, prop_a->rawprop) || (!ELEM(RNA_property_type(prop_a->rawprop), PROP_POINTER, PROP_COLLECTION) && - !RNA_property_editable_flag(&prop_a->ptr, prop_a->rawprop))) { + !RNA_property_editable_flag(&prop_a->ptr, prop_a->rawprop))) + { diff_flags &= ~RNA_OVERRIDE_COMPARE_CREATE; } const int diff = override_diff( @@ -479,7 +481,8 @@ static bool rna_property_override_operation_store(Main *bmain, } if (ptr_storage != NULL && prop_storage->magic == RNA_MAGIC && - !ELEM(prop_storage->override_store, NULL, override_store)) { + !ELEM(prop_storage->override_store, NULL, override_store)) + { override_store = NULL; } @@ -495,10 +498,9 @@ static bool rna_property_override_operation_store(Main *bmain, LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { /* Only needed for diff operations. */ - if (!ELEM(opop->operation, - IDOVERRIDE_LIBRARY_OP_ADD, - IDOVERRIDE_LIBRARY_OP_SUBTRACT, - IDOVERRIDE_LIBRARY_OP_MULTIPLY)) { + if (!ELEM( + opop->operation, LIBOVERRIDE_OP_ADD, LIBOVERRIDE_OP_SUBTRACT, LIBOVERRIDE_OP_MULTIPLY)) + { continue; } @@ -512,7 +514,8 @@ static bool rna_property_override_operation_store(Main *bmain, len_local, len_reference, len_storage, - opop)) { + opop)) + { changed = true; } } @@ -537,11 +540,12 @@ static bool rna_property_override_operation_apply(Main *bmain, const short override_op = opop->operation; if (!BKE_lib_override_library_property_operation_operands_validate( - opop, ptr_dst, ptr_src, ptr_storage, prop_dst, prop_src, prop_storage)) { + opop, ptr_dst, ptr_src, ptr_storage, prop_dst, prop_src, prop_storage)) + { return false; } - if (override_op == IDOVERRIDE_LIBRARY_OP_NOOP) { + if (override_op == LIBOVERRIDE_OP_NOOP) { return true; } @@ -567,7 +571,8 @@ static bool rna_property_override_operation_apply(Main *bmain, } if (ptr_storage && prop_storage->magic == RNA_MAGIC && - !ELEM(prop_storage->override_apply, NULL, override_apply)) { + !ELEM(prop_storage->override_apply, NULL, override_apply)) + { override_apply = NULL; } @@ -676,7 +681,8 @@ bool RNA_struct_override_matches(Main *bmain, iterprop = RNA_struct_iterator_property(ptr_local->type); for (RNA_property_collection_begin(ptr_local, iterprop, &iter); iter.valid; - RNA_property_collection_next(&iter)) { + RNA_property_collection_next(&iter)) + { PropertyRNA *rawprop = iter.ptr.data; PropertyRNAOrID prop_local; @@ -690,7 +696,8 @@ bool RNA_struct_override_matches(Main *bmain, BLI_assert(prop_local.is_idprop == prop_reference.is_idprop); if ((prop_local.is_idprop && prop_local.idprop == NULL) || - (prop_reference.is_idprop && prop_reference.idprop == NULL)) { + (prop_reference.is_idprop && prop_reference.idprop == NULL)) + { continue; } @@ -766,7 +773,7 @@ bool RNA_struct_override_matches(Main *bmain, IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(override, rna_path); if (ignore_overridden && op != NULL) { - BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); if (rna_path != rna_path_buffer) { MEM_freeN(rna_path); @@ -810,20 +817,20 @@ bool RNA_struct_override_matches(Main *bmain, IDOverrideLibraryPropertyOperation *opop = op ? op->operations.first : NULL; if (op != NULL) { - BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); } if ((do_restore || do_tag_for_restore) && (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) == 0) { /* We are allowed to restore to reference's values. */ - if (ELEM(NULL, op, opop) || opop->operation == IDOVERRIDE_LIBRARY_OP_NOOP) { + if (ELEM(NULL, op, opop) || opop->operation == LIBOVERRIDE_OP_NOOP) { if (RNA_property_editable(ptr_local, rawprop)) { /* This property should be restored to its reference value. This should not be done * here, since this code may be called from non-main thread (modifying data through RNA * is not thread safe). */ if (do_restore) { IDOverrideLibraryPropertyOperation opop_tmp = { - .operation = IDOVERRIDE_LIBRARY_OP_REPLACE, + .operation = LIBOVERRIDE_OP_REPLACE, .subitem_reference_index = -1, .subitem_local_index = -1, }; @@ -846,17 +853,17 @@ bool RNA_struct_override_matches(Main *bmain, if (op == NULL) { /* An override property is needed, create a temp one if necessary. */ op = BKE_lib_override_library_property_get(override, rna_path, NULL); - BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, true); + BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_OP_TAG_UNUSED, true); } IDOverrideLibraryPropertyOperation *opop_restore = BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, false, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, false, NULL, NULL); /* Do not use `BKE_lib_override_library_operations_tag` here, as the property may be * a valid one that has other operations that needs to remain (e.g. from a template, * a NOOP operation to enforce no change on that property, etc.). */ - op->tag |= IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE; - opop_restore->tag |= IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE; - override->runtime->tag |= IDOVERRIDE_LIBRARY_RUNTIME_TAG_NEEDS_RESTORE; + op->tag |= LIBOVERRIDE_PROP_TAG_NEEDS_RETORE; + opop_restore->tag |= LIBOVERRIDE_PROP_TAG_NEEDS_RETORE; + override->runtime->tag |= LIBOVERRIDE_TAG_NEEDS_RESTORE; if (r_report_flags) { *r_report_flags |= RNA_OVERRIDE_MATCH_RESULT_RESTORE_TAGGED; @@ -939,7 +946,8 @@ bool RNA_struct_override_store(Main *bmain, PropertyRNA *prop_reference, *prop_local; if (RNA_path_resolve_property(ptr_local, op->rna_path, &data_local, &prop_local) && - RNA_path_resolve_property(ptr_reference, op->rna_path, &data_reference, &prop_reference)) { + RNA_path_resolve_property(ptr_reference, op->rna_path, &data_reference, &prop_reference)) + { PointerRNA data_storage; PropertyRNA *prop_storage = NULL; @@ -956,7 +964,8 @@ bool RNA_struct_override_store(Main *bmain, prop_reference, prop_local, prop_storage, - op)) { + op)) + { changed = true; } } @@ -988,7 +997,8 @@ static void rna_porperty_override_collection_subitem_lookup( RNA_property_type(prop_src) != PROP_COLLECTION || (prop_storage != NULL && RNA_property_type(prop_storage) != PROP_COLLECTION)) || (opop->subitem_local_name == NULL && opop->subitem_reference_name == NULL && - opop->subitem_local_index == -1 && opop->subitem_reference_index == -1)) { + opop->subitem_local_index == -1 && opop->subitem_reference_index == -1)) + { return; } @@ -1002,7 +1012,8 @@ static void rna_porperty_override_collection_subitem_lookup( ptr_src, prop_src, opop->subitem_local_name, private_ptr_item_src); if (opop->subitem_reference_name != NULL && RNA_property_collection_lookup_string( - ptr_dst, prop_dst, opop->subitem_reference_name, private_ptr_item_dst)) { + ptr_dst, prop_dst, opop->subitem_reference_name, private_ptr_item_dst)) + { /* This is rather fragile, but the fact that local override IDs may have a different name * than their linked reference makes it necessary. * Basically, here we are considering that if we cannot find the original linked ID in @@ -1071,7 +1082,8 @@ static void rna_porperty_override_collection_subitem_lookup( * modifier...) in a collection that supports it. */ if ((*r_ptr_item_dst)->type == NULL && ((opop->subitem_reference_name != NULL && opop->subitem_reference_name[0] != '\0') || - opop->subitem_reference_index != -1)) { + opop->subitem_reference_index != -1)) + { CLOG_INFO(&LOG, 2, "Failed to find destination sub-item '%s' (%d) of '%s' in new override data '%s'", @@ -1082,7 +1094,8 @@ static void rna_porperty_override_collection_subitem_lookup( } if ((*r_ptr_item_src)->type == NULL && ((opop->subitem_local_name != NULL && opop->subitem_local_name[0] != '\0') || - opop->subitem_local_index != -1)) { + opop->subitem_local_index != -1)) + { CLOG_INFO(&LOG, 2, "Failed to find source sub-item '%s' (%d) of '%s' in old override data '%s'", @@ -1107,7 +1120,7 @@ static void rna_property_override_check_resync(Main *bmain, BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_owner_src)); /* If the owner ID is not part of an override hierarchy, there is no possible resync. */ - if (id_owner_src->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) { + if (id_owner_src->override_library->flag & LIBOVERRIDE_FLAG_NO_HIERARCHY) { return; } @@ -1132,8 +1145,9 @@ static void rna_property_override_check_resync(Main *bmain, * NOTE: Here we are testing if `id_owner` is referencing itself, in that case the new * override copy generated by `BKE_lib_override_library_update` will already have its * self-references updated to itself, instead of still pointing to its linked source. */ - (id_dst->lib == id_src->lib && id_dst != id_owner_dst))) { - id_owner_dst->tag |= LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + (id_dst->lib == id_src->lib && id_dst != id_owner_dst))) + { + id_owner_dst->tag |= LIB_TAG_LIBOVERRIDE_NEED_RESYNC; if (ID_IS_LINKED(id_owner_src)) { id_owner_src->lib->tag |= LIBRARY_TAG_RESYNC_REQUIRED; } @@ -1155,13 +1169,13 @@ static void rna_property_override_apply_ex(Main *bmain, const bool do_insert) { LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (opop->operation == IDOVERRIDE_LIBRARY_OP_NOOP) { + if (opop->operation == LIBOVERRIDE_OP_NOOP) { continue; } - if (!do_insert != !ELEM(opop->operation, - IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, - IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) { + if (!do_insert != + !ELEM(opop->operation, LIBOVERRIDE_OP_INSERT_AFTER, LIBOVERRIDE_OP_INSERT_BEFORE)) + { if (!do_insert) { CLOG_INFO(&LOG, 5, "Skipping insert override operations in first pass (%s)", op->rna_path); } @@ -1198,7 +1212,8 @@ static void rna_property_override_apply_ex(Main *bmain, ptr_item_dst, ptr_item_src, ptr_item_storage, - opop)) { + opop)) + { CLOG_INFO(&LOG, 4, "Failed to apply '%s' override operation on %s\n", @@ -1226,12 +1241,12 @@ void RNA_struct_override_apply(Main *bmain, bool do_insert = false; for (int i = 0; i < (do_restore_only ? 1 : 2); i++, do_insert = true) { LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { - if (do_restore_only && (op->tag % IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) == 0) { + if (do_restore_only && (op->tag % LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) == 0) { continue; } /* That tag should only exist for short lifespan when restoring values from reference linked * data. */ - BLI_assert((op->tag & IDOVERRIDE_LIBRARY_PROPERTY_TAG_NEEDS_RETORE) == 0 || do_restore_only); + BLI_assert((op->tag & LIBOVERRIDE_PROP_TAG_NEEDS_RETORE) == 0 || do_restore_only); /* Simplified for now! */ PointerRNA data_src, data_dst; @@ -1241,7 +1256,8 @@ void RNA_struct_override_apply(Main *bmain, if (!(RNA_path_resolve_property_and_item_pointer( ptr_dst, op->rna_path, &data_dst, &prop_dst, &data_item_dst) && RNA_path_resolve_property_and_item_pointer( - ptr_src, op->rna_path, &data_src, &prop_src, &data_item_src))) { + ptr_src, op->rna_path, &data_src, &prop_src, &data_item_src))) + { CLOG_INFO(&LOG, 4, "Failed to apply library override operation to '%s.%s' " @@ -1265,10 +1281,12 @@ void RNA_struct_override_apply(Main *bmain, /* Check if an overridden ID pointer supposed to be in sync with linked data gets out of * sync. */ if ((flag & RNA_OVERRIDE_APPLY_FLAG_SKIP_RESYNC_CHECK) == 0 && - (ptr_dst->owner_id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0) { + (ptr_dst->owner_id->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) == 0) + { if (op->rna_prop_type == PROP_POINTER && (((IDOverrideLibraryPropertyOperation *)op->operations.first)->flag & - IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) != 0) { + LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) != 0) + { BLI_assert(RNA_struct_is_ID(RNA_property_pointer_type(&data_src, prop_src))); BLI_assert(ptr_src->owner_id == rna_property_override_property_real_id_owner(bmain, &data_src, NULL, NULL)); @@ -1288,7 +1306,7 @@ void RNA_struct_override_apply(Main *bmain, rna_property_override_property_real_id_owner(bmain, &data_dst, NULL, NULL)); LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if ((opop->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { + if ((opop->flag & LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { continue; } @@ -1322,7 +1340,8 @@ void RNA_struct_override_apply(Main *bmain, if ((flag & RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS) != 0 && op->rna_prop_type == PROP_POINTER && (((IDOverrideLibraryPropertyOperation *)op->operations.first)->flag & - IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { + LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) + { BLI_assert(ptr_src->owner_id == rna_property_override_property_real_id_owner(bmain, &data_src, NULL, NULL)); BLI_assert(ptr_dst->owner_id == @@ -1479,10 +1498,10 @@ eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, bmain, ptr, prop, index, false, NULL); if (opop != NULL) { override_status |= RNA_OVERRIDE_STATUS_OVERRIDDEN; - if (opop->flag & IDOVERRIDE_LIBRARY_FLAG_MANDATORY) { + if (opop->flag & LIBOVERRIDE_OP_FLAG_MANDATORY) { override_status |= RNA_OVERRIDE_STATUS_MANDATORY; } - if (opop->flag & IDOVERRIDE_LIBRARY_FLAG_LOCKED) { + if (opop->flag & LIBOVERRIDE_OP_FLAG_LOCKED) { override_status |= RNA_OVERRIDE_STATUS_LOCKED; } } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index af484a85d00..d2919143f56 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -718,7 +718,7 @@ bool rna_AnimaData_override_apply(Main *bmain, IDOverrideLibraryPropertyOperation *opop) { BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE && + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on animdata pointer"); UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop); @@ -757,7 +757,7 @@ bool rna_NLA_tracks_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && + BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER && "Unsupported RNA override operation on constraints collection"); AnimData *anim_data_dst = (AnimData *)ptr_dst->data; @@ -765,7 +765,10 @@ bool rna_NLA_tracks_override_apply(Main *bmain, /* Remember that insertion operations are defined and stored in correct order, which means that * even if we insert several items in a row, we always insert first one, then second one, etc. - * So we should always find 'anchor' track in both _src *and* _dst. */ + * So we should always find 'anchor' track in both _src *and* _dst. + * + * This is only true however is NLA tracks do not get removed from linked data. Otherwise, an + * index-based reference may lead to lost data. */ NlaTrack *nla_track_anchor = NULL; # if 0 /* This is not working so well with index-based insertion, especially in case some tracks get @@ -785,7 +788,7 @@ bool rna_NLA_tracks_override_apply(Main *bmain, } if (nla_track_src == NULL) { - BLI_assert(nla_track_src != NULL); + /* Can happen if tracks were removed from linked data. */ return false; } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 9505031bb76..f5b156962b8 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1041,7 +1041,8 @@ static void rna_BrushGpencilSettings_default_eraser_update(Main *bmain, /* disable default eraser in all brushes */ for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) { if ((brush != brush_cur) && (brush->ob_mode == OB_MODE_PAINT_GPENCIL) && - (brush->gpencil_tool == GPAINT_TOOL_ERASE)) { + (brush->gpencil_tool == GPAINT_TOOL_ERASE)) + { brush->gpencil_settings->flag &= ~GP_BRUSH_DEFAULT_ERASER; } } diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index a1aa3261747..464f228f668 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -160,7 +160,7 @@ static bool rna_Camera_background_images_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert_msg(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, + BLI_assert_msg(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER, "Unsupported RNA override operation on background images collection"); Camera *cam_dst = (Camera *)ptr_dst->owner_id; diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c index 74e1f74d486..89773e43238 100644 --- a/source/blender/makesrna/intern/rna_collection.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -175,7 +175,7 @@ static bool rna_Collection_objects_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE && + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on collections' objects"); UNUSED_VARS_NDEBUG(opop); @@ -309,7 +309,7 @@ static bool rna_Collection_children_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE && + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on collections' children"); UNUSED_VARS_NDEBUG(opop); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 2c0e854480b..3c1df5ed112 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -705,7 +705,8 @@ static float rna_CurveMapping_evaluateF(struct CurveMapping *cumap, float value) { if (&cumap->cm[0] != cuma && &cumap->cm[1] != cuma && &cumap->cm[2] != cuma && - &cumap->cm[3] != cuma) { + &cumap->cm[3] != cuma) + { BKE_report(reports, RPT_ERROR, "CurveMapping does not own CurveMap"); return 0.0f; } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 58acc49aefe..3c02d480f78 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2814,7 +2814,8 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, int dnaoffset = 0; if (lengthpropname[0] == 0 || - rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember, &dnaoffset)) { + rna_find_sdna_member(DefRNA.sdna, structname, lengthpropname, &smember, &dnaoffset)) + { if (lengthpropname[0] == 0) { dp->dnalengthfixed = prop->totarraylength; prop->arraydimension = 0; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index f681af20979..a0c65a48fe1 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -839,6 +839,12 @@ static void rna_FModifier_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * rna_tag_animation_update(bmain, id); } +static void rna_fModifier_name_set(PointerRNA *ptr, const char *value) +{ + FModifier *fcm = (FModifier *)ptr->data; + BKE_fmodifier_name_set(fcm, value); +} + static void rna_FModifier_verify_data_update(Main *bmain, Scene *scene, PointerRNA *ptr) { FModifier *fcm = (FModifier *)ptr->data; @@ -1749,12 +1755,12 @@ static void rna_def_fmodifier(BlenderRNA *brna) RNA_def_struct_refine_func(srna, "rna_FModifierType_refine"); RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve"); -# if 0 /* XXX not used yet */ /* name */ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_fModifier_name_set"); + RNA_def_property_ui_text(prop, "Name", "F-Curve Modifier name"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL); RNA_def_struct_name_property(srna, prop); - RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier"); -# endif /* XXX not used yet */ /* type */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 545d4268edd..4b9849d4177 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -614,7 +614,8 @@ static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED /* Support for deprecated .raw format. */ FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data; if (fds->cache_data_format == FLUID_DOMAIN_FILE_RAW || - fds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) { + fds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) + { tmp.value = FLUID_DOMAIN_FILE_RAW; tmp.identifier = "RAW"; tmp.name = N_("Raw Cache"); diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c index b7cefe257c6..f4154f149ab 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c @@ -958,7 +958,8 @@ const EnumPropertyItem *gpencil_build_time_mode_filter(bContext *UNUSED(C), int totitem = 0; for (const EnumPropertyItem *item = gpencil_build_time_mode_items; item->identifier != NULL; - item++) { + item++) + { if (is_concurrent && (item->value == GP_BUILD_TIMEMODE_DRAWSPEED)) { continue; } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 3afa5383aaa..ebf5cd849e2 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -43,7 +43,8 @@ static void rna_ImagePackedFile_save(ImagePackedFile *imapf, Main *bmain, Report { if (BKE_packedfile_write_to_file( reports, BKE_main_blendfile_path(bmain), imapf->filepath, imapf->packedfile, 0) != - RET_OK) { + RET_OK) + { BKE_reportf(reports, RPT_ERROR, "Could not save packed file to disk as '%s'", imapf->filepath); } } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index c8d14f0d642..809ccb93bcd 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2654,7 +2654,7 @@ static bool rna_Mesh_materials_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert_msg(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE, + BLI_assert_msg(opop->operation == LIBOVERRIDE_OP_REPLACE, "Unsupported RNA override operation on collections' objects"); UNUSED_VARS_NDEBUG(opop); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index dae7d8f3b06..28ca9a2e872 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -920,7 +920,7 @@ static bool rna_HookModifier_object_override_apply(Main *bmain, IDOverrideLibraryPropertyOperation *opop) { BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE && + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on Hook modifier target object pointer"); UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop); @@ -1370,7 +1370,8 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf( } } else if (STREQ(RNA_property_identifier(prop), "layers_vcol_vert_select_src") || - STREQ(RNA_property_identifier(prop), "layers_vcol_loop_select_src")) { + STREQ(RNA_property_identifier(prop), "layers_vcol_loop_select_src")) + { Object *ob_src = dtmd->ob_source; if (ob_src) { @@ -1487,7 +1488,8 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_dst_itemf( } } else if (STREQ(RNA_property_identifier(prop), "layers_vcol_vert_select_dst") || - STREQ(RNA_property_identifier(prop), "layers_vcol_loop_select_dst")) { + STREQ(RNA_property_identifier(prop), "layers_vcol_loop_select_dst")) + { int multilayer_index = STREQ(RNA_property_identifier(prop), "layers_vcol_vert_select_dst") ? DT_MULTILAYER_INDEX_VCOL_VERT : DT_MULTILAYER_INDEX_VCOL_LOOP; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 2399cfe74e3..210c163f876 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2190,15 +2190,18 @@ static void rna_GeometryNodeCompare_data_type_update(Main *bmain, Scene *scene, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL, NODE_COMPARE_COLOR_BRIGHTER, - NODE_COMPARE_COLOR_DARKER)) { + NODE_COMPARE_COLOR_DARKER)) + { node_storage->operation = NODE_COMPARE_EQUAL; } else if (node_storage->data_type == SOCK_STRING && - !ELEM(node_storage->operation, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL)) { + !ELEM(node_storage->operation, NODE_COMPARE_EQUAL, NODE_COMPARE_NOT_EQUAL)) + { node_storage->operation = NODE_COMPARE_EQUAL; } else if (node_storage->data_type != SOCK_RGBA && - ELEM(node_storage->operation, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER)) { + ELEM(node_storage->operation, NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER)) + { node_storage->operation = NODE_COMPARE_EQUAL; } @@ -8280,7 +8283,7 @@ static void def_cmp_stabilize2d(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom2", CMP_NODEFLAG_STABILIZE_INVERSE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", CMP_NODE_STABILIZE_FLAG_INVERSE); RNA_def_property_ui_text( prop, "Invert", "Invert stabilization to re-introduce motion to the frame"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -8317,8 +8320,8 @@ static void def_cmp_mask(StructRNA *srna) static const EnumPropertyItem aspect_type_items[] = { {0, "SCENE", 0, "Scene Size", ""}, - {CMP_NODEFLAG_MASK_FIXED, "FIXED", 0, "Fixed", "Use pixel size for the buffer"}, - {CMP_NODEFLAG_MASK_FIXED_SCENE, + {CMP_NODE_MASK_FLAG_SIZE_FIXED, "FIXED", 0, "Fixed", "Use pixel size for the buffer"}, + {CMP_NODE_MASK_FLAG_SIZE_FIXED_SCENE, "FIXED_SCENE", 0, "Fixed/Scene", @@ -8334,12 +8337,12 @@ static void def_cmp_mask(StructRNA *srna) RNA_def_property_ui_text(prop, "Mask", ""); prop = RNA_def_property(srna, "use_feather", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_NO_FEATHER); + RNA_def_property_boolean_negative_sdna(prop, NULL, "custom1", CMP_NODE_MASK_FLAG_NO_FEATHER); RNA_def_property_ui_text(prop, "Feather", "Use feather information from the mask"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_MOTION_BLUR); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODE_MASK_FLAG_MOTION_BLUR); RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled motion blur of the mask"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f7a83915ed2..1d510dc3768 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -653,7 +653,7 @@ static bool rna_Object_parent_override_apply(Main *bmain, IDOverrideLibraryPropertyOperation *opop) { BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0); - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE && + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE && "Unsupported RNA override operation on object parent pointer"); UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop); @@ -1683,7 +1683,7 @@ bool rna_Object_constraints_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && + BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER && "Unsupported RNA override operation on constraints collection"); Object *ob_dst = (Object *)ptr_dst->owner_id; @@ -1738,8 +1738,8 @@ static void rna_Object_modifier_remove(Object *object, PointerRNA *md_ptr) { ModifierData *md = md_ptr->data; - if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == - false) { + if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == false) + { /* error is already set */ return; } @@ -1811,7 +1811,7 @@ bool rna_Object_modifiers_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && + BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER && "Unsupported RNA override operation on modifiers collection"); Object *ob_dst = (Object *)ptr_dst->owner_id; @@ -1927,7 +1927,7 @@ bool rna_Object_greasepencil_modifiers_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && + BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER && "Unsupported RNA override operation on modifiers collection"); Object *ob_dst = (Object *)ptr_dst->owner_id; diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 386b7d60aa9..ec86553ea7c 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -606,7 +606,8 @@ static void rna_Object_ray_cast(Object *ob, if (!bb || (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) && - distmin <= distance)) { + distmin <= distance)) + { BVHTreeFromMesh treeData = {NULL}; /* No need to managing allocation or freeing of the BVH data. @@ -627,7 +628,8 @@ static void rna_Object_ray_cast(Object *ob, 0.0f, &hit, treeData.raycast_callback, - &treeData) != -1) { + &treeData) != -1) + { if (hit.dist <= distance) { *r_success = success = true; @@ -685,7 +687,8 @@ static void rna_Object_closest_point_on_mesh(Object *ob, nearest.dist_sq = distance * distance; if (BLI_bvhtree_find_nearest( - treeData.tree, origin, &nearest, treeData.nearest_callback, &treeData) != -1) { + treeData.tree, origin, &nearest, treeData.nearest_callback, &treeData) != -1) + { *r_success = true; copy_v3_v3(r_location, nearest.co); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 8c5f96c1bdb..59c0667ce02 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -257,7 +257,7 @@ bool rna_Cache_use_disk_cache_override_apply(Main *UNUSED(bmain), IDOverrideLibraryPropertyOperation *opop) { BLI_assert(RNA_property_type(prop_dst) == PROP_BOOLEAN); - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE); + BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE); UNUSED_VARS_NDEBUG(opop); RNA_property_boolean_set(ptr_dst, prop_dst, RNA_property_boolean_get(ptr_src, prop_src)); @@ -310,7 +310,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P } if (use_new_name) { - BLI_filename_make_safe(cache->name); + BLI_path_make_safe_filename(cache->name); if (pid2 && cache->flag & PTCACHE_DISK_CACHE) { char old_name[80]; @@ -667,7 +667,8 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), /* In the case of specific force-fields that are using the #EffectorData's normal, we need to * rebuild mesh and BVH-tree for #SurfaceModifier to work correctly. */ if (ELEM(ob->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) || - ob->pd->forcefield == PFIELD_GUIDE) { + ob->pd->forcefield == PFIELD_GUIDE) + { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -841,8 +842,8 @@ static char *rna_EffectorWeight_path(const PointerRNA *ptr) md = (ModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid); if (md) { FluidModifierData *fmd = (FluidModifierData *)md; - if (fmd->type == MOD_FLUID_TYPE_DOMAIN && fmd->domain && - fmd->domain->effector_weights == ew) { + if (fmd->type == MOD_FLUID_TYPE_DOMAIN && fmd->domain && fmd->domain->effector_weights == ew) + { char name_esc[sizeof(md->name) * 2]; BLI_str_escape(name_esc, md->name, sizeof(name_esc)); return BLI_sprintfN("modifiers[\"%s\"].domain_settings.effector_weights", name_esc); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index aa186aa4750..2dbca3d6acb 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -396,7 +396,8 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle, /* get uvco */ if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME) && - !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) { + !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) + { const MFace *mface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MFACE); const MTFace *mtface = CustomData_get_layer(&modifier->mesh_final->fdata, CD_MTFACE); diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc index a878acd5b77..8539f8d628b 100644 --- a/source/blender/makesrna/intern/rna_path.cc +++ b/source/blender/makesrna/intern/rna_path.cc @@ -489,8 +489,9 @@ static bool rna_path_parse(const PointerRNA *ptr, *r_item_ptr = nextptr; } - if (prop_elem && (prop_elem->ptr.data != curptr.data || prop_elem->prop != prop || - prop_elem->index != index)) { + if (prop_elem && + (prop_elem->ptr.data != curptr.data || prop_elem->prop != prop || prop_elem->index != index)) + { prop_elem = MEM_cnew(__func__); prop_elem->ptr = curptr; prop_elem->prop = prop; @@ -811,7 +812,8 @@ static char *rna_idp_path(PointerRNA *ptr, link.index = -1; for (i = 0, iter = static_cast(haystack->data.group.first); iter; - iter = iter->next, i++) { + iter = iter->next, i++) + { if (needle == iter) { /* found! */ link.name = iter->name; link.index = -1; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 174c6220018..e1aa16cbbed 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -659,7 +659,7 @@ bool rna_PoseChannel_constraints_override_apply(Main *bmain, PointerRNA *UNUSED(ptr_item_storage), IDOverrideLibraryPropertyOperation *opop) { - BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && + BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER && "Unsupported RNA override operation on constraints collection"); bPoseChannel *pchan_dst = (bPoseChannel *)ptr_dst->data; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index cc59603bc53..f116126cc97 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -756,7 +756,8 @@ static const EnumPropertyItem *rna_Property_tags_itemf(bContext *UNUSED(C), for (const EnumPropertyItem *struct_tags = RNA_struct_property_tag_defines(srna); struct_tags != NULL && struct_tags->identifier != NULL; - struct_tags++) { + struct_tags++) + { memcpy(&tmp, struct_tags, sizeof(tmp)); RNA_enum_item_add(&prop_tags, &totitem, &tmp); } @@ -989,7 +990,8 @@ static const EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, } if ((eprop->item_fn == NULL) || (eprop->item_fn == rna_EnumProperty_default_itemf) || - (ptr->type == &RNA_EnumProperty) || (C == NULL)) { + (ptr->type == &RNA_EnumProperty) || (C == NULL)) + { if (eprop->item) { return eprop->item; } @@ -1322,7 +1324,8 @@ static bool rna_property_override_diff_propptr_validate_diffing(PointerRNA *prop } if (propname_a != NULL && propname_b != NULL) { if (propname_a_len != propname_b_len || propname_a[0] != propname_b[0] || - !STREQ(propname_a, propname_b)) { + !STREQ(propname_a, propname_b)) + { is_valid_for_diffing = false; // printf("%s: different names\n", rna_path ? rna_path : ""); } @@ -1418,9 +1421,10 @@ static int rna_property_override_diff_propptr(Main *bmain, IDOverrideLibraryPropertyOperation *opop = NULL; if (created || rna_itemname_a != NULL || rna_itemname_b != NULL || - rna_itemindex_a != -1 || rna_itemindex_b != -1) { + rna_itemindex_a != -1 || rna_itemindex_b != -1) + { opop = BKE_lib_override_library_property_operation_get(op, - IDOVERRIDE_LIBRARY_OP_REPLACE, + LIBOVERRIDE_OP_REPLACE, rna_itemname_b, rna_itemname_a, rna_itemindex_b, @@ -1430,14 +1434,14 @@ static int rna_property_override_diff_propptr(Main *bmain, &created); /* Do not use BKE_lib_override_library_operations_tag here, we do not want to validate * as used all of its operations. */ - op->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; - opop->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; + op->tag &= ~LIBOVERRIDE_PROP_OP_TAG_UNUSED; + opop->tag &= ~LIBOVERRIDE_PROP_OP_TAG_UNUSED; if (r_report_flag && created) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } } else { - BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); + BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); } if (is_id && no_ownership) { @@ -1459,10 +1463,11 @@ static int rna_property_override_diff_propptr(Main *bmain, if (ELEM(NULL, id_a, id_b)) { /* In case one of the pointer is NULL and not the other, we consider that the * override is not matching its reference anymore. */ - opop->flag &= ~IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + opop->flag &= ~LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE; } - else if ((owner_id_a->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) != 0 || - (owner_id_b->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) != 0) { + else if ((owner_id_a->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) != 0 || + (owner_id_b->tag & LIB_TAG_LIBOVERRIDE_NEED_RESYNC) != 0) + { /* In case one of the owner of the checked property is tagged as needing resync, do * not change the 'match reference' status of its ID pointer properties overrides, * since many non-matching ones are likely due to missing resync. */ @@ -1473,13 +1478,13 @@ static int rna_property_override_diff_propptr(Main *bmain, id_a->name); } else if (id_a->override_library != NULL && id_a->override_library->reference == id_b) { - opop->flag |= IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + opop->flag |= LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE; } else if (id_b->override_library != NULL && id_b->override_library->reference == id_a) { - opop->flag |= IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + opop->flag |= LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE; } else { - opop->flag &= ~IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + opop->flag &= ~LIBOVERRIDE_OP_FLAG_IDPOINTER_MATCH_REFERENCE; } } } @@ -1501,7 +1506,8 @@ static int rna_property_override_diff_propptr(Main *bmain, * Note that we do not need the RNA path for insertion operations. */ if (rna_path) { if ((rna_itemname_a != NULL && rna_itemname_a[0] != '\0') && - (rna_itemname_b != NULL && rna_itemname_b[0] != '\0')) { + (rna_itemname_b != NULL && rna_itemname_b[0] != '\0')) + { BLI_assert(STREQ(rna_itemname_a, rna_itemname_b)); char esc_item_name[RNA_PATH_BUFFSIZE]; @@ -1534,7 +1540,8 @@ static int rna_property_override_diff_propptr(Main *bmain, uint index; for (index = rna_itemindex_a; index > 0 && item_index_buff_len < sizeof(item_index_buff); - index /= 10) { + index /= 10) + { item_index_buff[item_index_buff_len++] = '0' + (char)(index % 10); } BLI_assert(index == 0); @@ -1657,7 +1664,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (*r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1686,7 +1693,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { /* If not yet overridden... */ BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1718,7 +1725,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag && created) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1747,7 +1754,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { /* If not yet overridden... */ BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1779,7 +1786,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1808,7 +1815,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { /* If not yet overridden... */ BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1829,7 +1836,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { /* If not yet overridden... */ BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1861,7 +1868,7 @@ int rna_property_override_diff_default(Main *bmain, if (op != NULL && created) { /* If not yet overridden... */ BKE_lib_override_library_property_operation_get( - op, IDOVERRIDE_LIBRARY_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); + op, LIBOVERRIDE_OP_REPLACE, NULL, NULL, -1, -1, true, NULL, NULL); if (r_report_flag) { *r_report_flag |= RNA_OVERRIDE_MATCH_RESULT_CREATED; } @@ -1938,9 +1945,7 @@ int rna_property_override_diff_default(Main *bmain, op = BKE_lib_override_library_property_find(override, rna_path); if (op != NULL) { LISTBASE_FOREACH_MUTABLE (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { - if (ELEM(opop->operation, - IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, - IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) { + if (ELEM(opop->operation, LIBOVERRIDE_OP_INSERT_AFTER, LIBOVERRIDE_OP_INSERT_BEFORE)) { BKE_lib_override_library_property_operation_delete(op, opop); } } @@ -2036,7 +2041,7 @@ int rna_property_override_diff_default(Main *bmain, op = BKE_lib_override_library_property_get(override, rna_path, &created); BKE_lib_override_library_property_operation_get(op, - IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, + LIBOVERRIDE_OP_INSERT_AFTER, no_prop_name ? NULL : prev_propname_a, no_prop_name ? NULL : propname_a, idx_a - 1, @@ -2085,7 +2090,8 @@ int rna_property_override_diff_default(Main *bmain, prev_propname_a[0] = '\0'; if (propname_a != NULL && BLI_strncpy_rlen(prev_propname_a, propname_a, sizeof(buff_prev_a)) >= - sizeof(buff_prev_a) - 1) { + sizeof(buff_prev_a) - 1) + { prev_propname_a = BLI_strdup(propname_a); } if (propname_a != buff_a) { @@ -2167,10 +2173,8 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), const bool is_array = len_local > 0; const int index = is_array ? opop->subitem_reference_index : 0; - if (!ELEM(opop->operation, - IDOVERRIDE_LIBRARY_OP_ADD, - IDOVERRIDE_LIBRARY_OP_SUBTRACT, - IDOVERRIDE_LIBRARY_OP_MULTIPLY)) { + if (!ELEM(opop->operation, LIBOVERRIDE_OP_ADD, LIBOVERRIDE_OP_SUBTRACT, LIBOVERRIDE_OP_MULTIPLY)) + { return changed; } @@ -2200,12 +2204,11 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), RNA_property_int_get_array(ptr_reference, prop_reference, array_a); switch (opop->operation) { - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: { - const int fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1 : -1; - const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? - IDOVERRIDE_LIBRARY_OP_SUBTRACT : - IDOVERRIDE_LIBRARY_OP_ADD; + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: { + const int fac = opop->operation == LIBOVERRIDE_OP_ADD ? 1 : -1; + const int other_op = opop->operation == LIBOVERRIDE_OP_ADD ? LIBOVERRIDE_OP_SUBTRACT : + LIBOVERRIDE_OP_ADD; bool do_set = true; array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : @@ -2220,7 +2223,7 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), if (array_b[j] < prop_min || array_b[j] > prop_max) { /* We failed to find a suitable diff op, * fall back to plain REPLACE one. */ - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; do_set = false; break; } @@ -2250,18 +2253,17 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), const int value = RNA_PROPERTY_GET_SINGLE(int, ptr_reference, prop_reference, index); switch (opop->operation) { - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: { - const int fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1 : -1; - const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? - IDOVERRIDE_LIBRARY_OP_SUBTRACT : - IDOVERRIDE_LIBRARY_OP_ADD; + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: { + const int fac = opop->operation == LIBOVERRIDE_OP_ADD ? 1 : -1; + const int other_op = opop->operation == LIBOVERRIDE_OP_ADD ? LIBOVERRIDE_OP_SUBTRACT : + LIBOVERRIDE_OP_ADD; int b = fac * (RNA_PROPERTY_GET_SINGLE(int, ptr_local, prop_local, index) - value); if (b < prop_min || b > prop_max) { opop->operation = other_op; b = -b; if (b < prop_min || b > prop_max) { - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; break; } } @@ -2290,12 +2292,11 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), RNA_property_float_get_array(ptr_reference, prop_reference, array_a); switch (opop->operation) { - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: { - const float fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1.0 : -1.0; - const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? - IDOVERRIDE_LIBRARY_OP_SUBTRACT : - IDOVERRIDE_LIBRARY_OP_ADD; + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: { + const float fac = opop->operation == LIBOVERRIDE_OP_ADD ? 1.0 : -1.0; + const int other_op = opop->operation == LIBOVERRIDE_OP_ADD ? LIBOVERRIDE_OP_SUBTRACT : + LIBOVERRIDE_OP_ADD; bool do_set = true; array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : @@ -2310,7 +2311,7 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), if (array_b[j] < prop_min || array_b[j] > prop_max) { /* We failed to find a suitable diff op, * fall back to plain REPLACE one. */ - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; do_set = false; break; } @@ -2327,7 +2328,7 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), } break; } - case IDOVERRIDE_LIBRARY_OP_MULTIPLY: { + case LIBOVERRIDE_OP_MULTIPLY: { bool do_set = true; array_b = (len_local > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_local, __func__) : @@ -2336,7 +2337,7 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), for (int i = len_local; i--;) { array_b[i] = array_a[i] == 0.0f ? array_b[i] : array_b[i] / array_a[i]; if (array_b[i] < prop_min || array_b[i] > prop_max) { - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; do_set = false; break; } @@ -2363,18 +2364,17 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), const float value = RNA_PROPERTY_GET_SINGLE(float, ptr_reference, prop_reference, index); switch (opop->operation) { - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: { - const float fac = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? 1.0f : -1.0f; - const int other_op = opop->operation == IDOVERRIDE_LIBRARY_OP_ADD ? - IDOVERRIDE_LIBRARY_OP_SUBTRACT : - IDOVERRIDE_LIBRARY_OP_ADD; + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: { + const float fac = opop->operation == LIBOVERRIDE_OP_ADD ? 1.0f : -1.0f; + const int other_op = opop->operation == LIBOVERRIDE_OP_ADD ? LIBOVERRIDE_OP_SUBTRACT : + LIBOVERRIDE_OP_ADD; float b = fac * (RNA_PROPERTY_GET_SINGLE(float, ptr_local, prop_local, index) - value); if (b < prop_min || b > prop_max) { opop->operation = other_op; b = -b; if (b < prop_min || b > prop_max) { - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; break; } } @@ -2382,11 +2382,11 @@ bool rna_property_override_store_default(Main *UNUSED(bmain), RNA_PROPERTY_SET_SINGLE(float, ptr_storage, prop_storage, index, b); break; } - case IDOVERRIDE_LIBRARY_OP_MULTIPLY: { + case LIBOVERRIDE_OP_MULTIPLY: { const float b = RNA_property_float_get_index(ptr_local, prop_local, index) / (value == 0.0f ? 1.0f : value); if (b < prop_min || b > prop_max) { - opop->operation = IDOVERRIDE_LIBRARY_OP_REPLACE; + opop->operation = LIBOVERRIDE_OP_REPLACE; break; } changed = true; @@ -2457,7 +2457,7 @@ bool rna_property_override_apply_default(Main *bmain, RNA_property_boolean_get_array(ptr_src, prop_src, array_a); switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_boolean_set_array(ptr_dst, prop_dst, array_a); break; default: @@ -2473,7 +2473,7 @@ bool rna_property_override_apply_default(Main *bmain, const bool value = RNA_PROPERTY_GET_SINGLE(boolean, ptr_src, prop_src, index); switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_PROPERTY_SET_SINGLE(boolean, ptr_dst, prop_dst, index, value); break; default: @@ -2491,18 +2491,18 @@ bool rna_property_override_apply_default(Main *bmain, array_stack_a; switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_int_get_array(ptr_src, prop_src, array_a); RNA_property_int_set_array(ptr_dst, prop_dst, array_a); break; - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: RNA_property_int_get_array(ptr_dst, prop_dst, array_a); array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b; RNA_property_int_get_array(ptr_storage, prop_storage, array_b); - if (override_op == IDOVERRIDE_LIBRARY_OP_ADD) { + if (override_op == LIBOVERRIDE_OP_ADD) { for (int i = len_dst; i--;) { array_a[i] += array_b[i]; } @@ -2532,14 +2532,14 @@ bool rna_property_override_apply_default(Main *bmain, 0; switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, index, RNA_PROPERTY_GET_SINGLE(int, ptr_src, prop_src, index)); break; - case IDOVERRIDE_LIBRARY_OP_ADD: + case LIBOVERRIDE_OP_ADD: RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, @@ -2547,7 +2547,7 @@ bool rna_property_override_apply_default(Main *bmain, RNA_PROPERTY_GET_SINGLE(int, ptr_dst, prop_dst, index) - storage_value); break; - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: + case LIBOVERRIDE_OP_SUBTRACT: RNA_PROPERTY_SET_SINGLE(int, ptr_dst, prop_dst, @@ -2570,24 +2570,24 @@ bool rna_property_override_apply_default(Main *bmain, array_stack_a; switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_float_get_array(ptr_src, prop_src, array_a); RNA_property_float_set_array(ptr_dst, prop_dst, array_a); break; - case IDOVERRIDE_LIBRARY_OP_ADD: - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: - case IDOVERRIDE_LIBRARY_OP_MULTIPLY: + case LIBOVERRIDE_OP_ADD: + case LIBOVERRIDE_OP_SUBTRACT: + case LIBOVERRIDE_OP_MULTIPLY: RNA_property_float_get_array(ptr_dst, prop_dst, array_a); array_b = (len_dst > RNA_STACK_ARRAY) ? MEM_mallocN(sizeof(*array_b) * len_dst, __func__) : array_stack_b; RNA_property_float_get_array(ptr_storage, prop_storage, array_b); - if (override_op == IDOVERRIDE_LIBRARY_OP_ADD) { + if (override_op == LIBOVERRIDE_OP_ADD) { for (int i = len_dst; i--;) { array_a[i] += array_b[i]; } } - else if (override_op == IDOVERRIDE_LIBRARY_OP_SUBTRACT) { + else if (override_op == LIBOVERRIDE_OP_SUBTRACT) { for (int i = len_dst; i--;) { array_a[i] -= array_b[i]; } @@ -2617,14 +2617,14 @@ bool rna_property_override_apply_default(Main *bmain, 0.0f; switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, index, RNA_PROPERTY_GET_SINGLE(float, ptr_src, prop_src, index)); break; - case IDOVERRIDE_LIBRARY_OP_ADD: + case LIBOVERRIDE_OP_ADD: RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, @@ -2632,7 +2632,7 @@ bool rna_property_override_apply_default(Main *bmain, RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) + storage_value); break; - case IDOVERRIDE_LIBRARY_OP_SUBTRACT: + case LIBOVERRIDE_OP_SUBTRACT: RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, @@ -2640,7 +2640,7 @@ bool rna_property_override_apply_default(Main *bmain, RNA_PROPERTY_GET_SINGLE(float, ptr_dst, prop_dst, index) - storage_value); break; - case IDOVERRIDE_LIBRARY_OP_MULTIPLY: + case LIBOVERRIDE_OP_MULTIPLY: RNA_PROPERTY_SET_SINGLE(float, ptr_dst, prop_dst, @@ -2658,7 +2658,7 @@ bool rna_property_override_apply_default(Main *bmain, const int value = RNA_property_enum_get(ptr_src, prop_src); switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_enum_set(ptr_dst, prop_dst, value); break; /* TODO: support add/sub, for bitflags? */ @@ -2672,7 +2672,7 @@ bool rna_property_override_apply_default(Main *bmain, PointerRNA value = RNA_property_pointer_get(ptr_src, prop_src); switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_pointer_set(ptr_dst, prop_dst, value, NULL); break; default: @@ -2686,7 +2686,7 @@ bool rna_property_override_apply_default(Main *bmain, char *value = RNA_property_string_get_alloc(ptr_src, prop_src, buff, sizeof(buff), NULL); switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_REPLACE: + case LIBOVERRIDE_OP_REPLACE: RNA_property_string_set(ptr_dst, prop_dst, value); break; default: @@ -2711,7 +2711,7 @@ bool rna_property_override_apply_default(Main *bmain, } switch (override_op) { - case IDOVERRIDE_LIBRARY_OP_INSERT_AFTER: { + case LIBOVERRIDE_OP_INSERT_AFTER: { PointerRNA item_ptr_src, item_ptr_ref, item_ptr_dst; int item_index_dst; bool is_valid = false; @@ -2724,7 +2724,8 @@ bool rna_property_override_apply_default(Main *bmain, prop_dst, opop->subitem_reference_name, &item_ptr_ref, - &item_index_ref)) { + &item_index_ref)) + { is_valid = true; item_index_dst = item_index_ref + 1; } @@ -2734,7 +2735,8 @@ bool rna_property_override_apply_default(Main *bmain, if (RNA_property_collection_lookup_int( ptr_src, prop_src, opop->subitem_local_index, &item_ptr_src) && RNA_property_collection_lookup_int( - ptr_dst, prop_dst, opop->subitem_reference_index, &item_ptr_ref)) { + ptr_dst, prop_dst, opop->subitem_reference_index, &item_ptr_ref)) + { item_index_dst = opop->subitem_reference_index + 1; is_valid = true; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7ad1adb66b4..dc98be848c4 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1939,10 +1939,9 @@ static void object_simplify_update(Object *ob) ob->id.tag &= ~LIB_TAG_DOIT; for (md = ob->modifiers.first; md; md = md->next) { - if (ELEM(md->type, - eModifierType_Subsurf, - eModifierType_Multires, - eModifierType_ParticleSystem)) { + if (ELEM( + md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) + { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } } @@ -2768,7 +2767,8 @@ static void rna_FFmpegSettings_codec_update(Main *UNUSED(bmain), AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP9, - AV_CODEC_ID_DNXHD)) { + AV_CODEC_ID_DNXHD)) + { /* Constant Rate Factor (CRF) setting is only available for H264, * MPEG4 and WEBM/VP9 codecs. So changing encoder quality mode to * CBR as CRF is not supported. diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index e98e8dbea74..3f460e3ecca 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -55,7 +55,8 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf # endif for (ViewLayer *view_layer = scene->view_layers.first; view_layer != NULL; - view_layer = view_layer->next) { + view_layer = view_layer->next) + { Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); BKE_scene_graph_update_for_newframe(depsgraph); } @@ -97,7 +98,7 @@ static void rna_Scene_uvedit_aspect(Scene *UNUSED(scene), Object *ob, float aspe } static void rna_SceneRender_get_frame_path( - RenderData *rd, Main *bmain, int frame, bool preview, const char *view, char *name) + RenderData *rd, Main *bmain, int frame, bool preview, const char *view, char *filepath) { const char *suffix = BKE_scene_multiview_view_suffix_get(rd, view); @@ -107,10 +108,10 @@ static void rna_SceneRender_get_frame_path( } if (BKE_imtype_is_movie(rd->im_format.imtype)) { - BKE_movie_filepath_get(name, rd, preview != 0, suffix); + BKE_movie_filepath_get(filepath, rd, preview != 0, suffix); } else { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, rd->pic, BKE_main_blendfile_path(bmain), (frame == INT_MIN) ? rd->cfra : frame, diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6013f09ddbe..49cb7cd9357 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -845,11 +845,11 @@ static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator * static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value) { Sequence *seq = (Sequence *)(ptr->data); - BLI_split_dirfile(value, - seq->strip->dir, - seq->strip->stripdata->name, - sizeof(seq->strip->dir), - sizeof(seq->strip->stripdata->name)); + BLI_path_split_dir_file(value, + seq->strip->dir, + sizeof(seq->strip->dir), + seq->strip->stripdata->name, + sizeof(seq->strip->stripdata->name)); } static void rna_Sequence_filepath_get(PointerRNA *ptr, char *value) @@ -871,7 +871,7 @@ static int rna_Sequence_filepath_length(PointerRNA *ptr) static void rna_Sequence_proxy_filepath_set(PointerRNA *ptr, const char *value) { StripProxy *proxy = (StripProxy *)(ptr->data); - BLI_split_dirfile(value, proxy->dir, proxy->file, sizeof(proxy->dir), sizeof(proxy->file)); + BLI_path_split_dir_file(value, proxy->dir, sizeof(proxy->dir), proxy->file, sizeof(proxy->file)); if (proxy->anim) { IMB_free_anim(proxy->anim); proxy->anim = NULL; @@ -971,17 +971,17 @@ static void rna_Sequence_input_2_set(PointerRNA *ptr, static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value) { Sequence *seq = (Sequence *)(ptr->data); - BLI_split_dirfile(value, + BLI_path_split_dir_file(value, seq->strip->dir, - seq->strip->stripdata->name, sizeof(seq->strip->dir), + seq->strip->stripdata->name, sizeof(seq->strip->stripdata->name)); } static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value) { StripElem *elem = (StripElem *)(ptr->data); - BLI_split_file_part(value, elem->name, sizeof(elem->name)); + BLI_path_split_file_part(value, elem->name, sizeof(elem->name)); } # endif diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 423e185ddc3..bb0888d756b 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -27,7 +27,7 @@ # include "DNA_mask_types.h" # include "DNA_sound_types.h" -# include "BLI_path_util.h" /* BLI_split_dirfile */ +# include "BLI_path_util.h" /* #BLI_path_split_dir_file */ # include "BKE_image.h" # include "BKE_mask.h" @@ -256,7 +256,7 @@ static Sequence *rna_Sequences_new_image(ID *id, Sequence *seq = SEQ_add_image_strip(bmain, scene, seqbase, &load_data); char dir[FILE_MAX], filename[FILE_MAX]; - BLI_split_dirfile(file, dir, filename, sizeof(dir), sizeof(filename)); + BLI_path_split_dir_file(file, dir, sizeof(dir), filename, sizeof(filename)); SEQ_add_image_set_directory(seq, dir); SEQ_add_image_load_file(scene, seq, 0, filename); SEQ_add_image_init_alpha_mode(seq); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index a475ccf55ba..b8cf054aeb4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1167,7 +1167,8 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA View3DShading *shading = ptr->data; if (shading->type == OB_MATERIAL || - (shading->type == OB_RENDER && !BKE_scene_uses_blender_workbench(scene))) { + (shading->type == OB_RENDER && !BKE_scene_uses_blender_workbench(scene))) + { /* When switching from workbench to render or material mode the geometry of any * active sculpt session needs to be recalculated. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { @@ -1476,11 +1477,13 @@ static const EnumPropertyItem *rna_3DViewShading_render_pass_itemf(bContext *C, EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT, EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET, EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL) && - !eevee_next_active) { + !eevee_next_active) + { } else if (!((!bloom_enabled && (item->value == EEVEE_RENDER_PASS_BLOOM || STREQ(item->name, "Effects"))) || - (!aov_available && STREQ(item->name, "Shader AOV")))) { + (!aov_available && STREQ(item->name, "Shader AOV")))) + { RNA_enum_item_add(&result, &totitem, item); } } @@ -3234,7 +3237,8 @@ static void rna_SpaceSpreadsheet_geometry_component_type_update(Main *UNUSED(bma ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE, - ATTR_DOMAIN_CORNER)) { + ATTR_DOMAIN_CORNER)) + { sspreadsheet->attribute_domain = ATTR_DOMAIN_POINT; } break; @@ -3287,7 +3291,8 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UN EnumPropertyItem *item_array = NULL; int items_len = 0; for (const EnumPropertyItem *item = rna_enum_attribute_domain_items; item->identifier != NULL; - item++) { + item++) + { if (component_type == GEO_COMPONENT_TYPE_MESH) { if (!ELEM(item->value, ATTR_DOMAIN_CORNER, diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index a4c3dab4b5d..b0c5dd9c1f5 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -310,7 +310,8 @@ static void rna_trackingPlaneMarker_frame_set(PointerRNA *ptr, int value) LISTBASE_FOREACH (MovieTrackingObject *, tracking_object, &tracking->objects) { LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, &tracking_object->plane_tracks) { if (plane_marker >= plane_track->markers && - plane_marker < plane_track->markers + plane_track->markersnr) { + plane_marker < plane_track->markers + plane_track->markersnr) + { plane_track_of_marker = plane_track; break; } diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 18c43a4496c..50bd2c1ec81 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -139,7 +139,8 @@ static void rna_uiItemR_with_popover(uiLayout *layout, return; } if ((RNA_property_type(prop) != PROP_ENUM) && - !ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) { + !ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) + { RNA_warning( "property is not an enum or color: %s.%s", RNA_struct_identifier(ptr->type), propname); return; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 2373e11d76c..40fb9b138f5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -655,7 +655,8 @@ static void rna_UserDef_viewport_lights_update(Main *bmain, Scene *scene, Pointe /* If all lights are off gpu_draw resets them all, see: #27627, * so disallow them all to be disabled. */ if (U.light_param[0].flag == 0 && U.light_param[1].flag == 0 && U.light_param[2].flag == 0 && - U.light_param[3].flag == 0) { + U.light_param[3].flag == 0) + { SolidLight *light = ptr->data; light->flag |= 1; } @@ -962,15 +963,15 @@ static void rna_StudioLights_remove(UserDef *UNUSED(userdef), StudioLight *studi BKE_studiolight_remove(studio_light); } -static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *path, int type) +static StudioLight *rna_StudioLights_load(UserDef *UNUSED(userdef), const char *filepath, int type) { - return BKE_studiolight_load(path, type); + return BKE_studiolight_load(filepath, type); } /* TODO: Make it accept arguments. */ -static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *name) +static StudioLight *rna_StudioLights_new(UserDef *userdef, const char *filepath) { - return BKE_studiolight_create(name, userdef->light_param, userdef->light_ambient); + return BKE_studiolight_create(filepath, userdef->light_param, userdef->light_ambient); } /* StudioLight.name */ @@ -990,13 +991,13 @@ static int rna_UserDef_studiolight_name_length(PointerRNA *ptr) static void rna_UserDef_studiolight_path_get(PointerRNA *ptr, char *value) { StudioLight *sl = (StudioLight *)ptr->data; - BLI_strncpy(value, sl->path, FILE_MAX); + BLI_strncpy(value, sl->filepath, FILE_MAX); } static int rna_UserDef_studiolight_path_length(PointerRNA *ptr) { StudioLight *sl = (StudioLight *)ptr->data; - return strlen(sl->path); + return strlen(sl->filepath); } /* StudioLight.path_irr_cache */ diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index bfc30737d6c..c1feae20ffe 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -99,7 +99,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte /* If not using envelopes, * create relations to individual bones for more rigging flexibility. */ if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) && - ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL_LEGACY)) { + ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL_LEGACY)) + { /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */ if ((amd->deformflag & ARM_DEF_VGROUP) != 0) { /* Enumerate groups that match existing bones. */ diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index 44b78ef370a..bac187b4f79 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -189,7 +189,8 @@ static void dm_mvert_map_doubles(int *doubles_map, /* Scan source vertices, in #SortVertsElem sorted array, * all the while maintaining the lower bound of possible doubles in target vertices. */ for (i_source = 0, sve_source = sorted_verts_source; i_source < source_verts_num; - i_source++, sve_source++) { + i_source++, sve_source++) + { int best_target_vertex = -1; float best_dist_sq = dist * dist; float sve_source_sumco; @@ -210,7 +211,8 @@ static void dm_mvert_map_doubles(int *doubles_map, /* Skip all target vertices that are more than dist3 lower in terms of sumco */ /* and advance the overall lower bound, applicable to all remaining vertices as well. */ while ((i_target_low_bound < target_verts_num) && - (sve_target_low_bound->sum_co < sve_source_sumco - dist3)) { + (sve_target_low_bound->sum_co < sve_source_sumco - dist3)) + { i_target_low_bound++; sve_target_low_bound++; } @@ -246,7 +248,8 @@ static void dm_mvert_map_doubles(int *doubles_map, !ELEM(doubles_map[best_target_vertex], -1, best_target_vertex)) { if (compare_len_v3v3(vert_positions[sve_source->vertex_num], vert_positions[doubles_map[best_target_vertex]], - dist)) { + dist)) + { best_target_vertex = doubles_map[best_target_vertex]; } else { @@ -334,7 +337,8 @@ static void mesh_merge_transform(Mesh *result, const bke::AttributeAccessor cap_attributes = cap_mesh->attributes(); if (const VArray cap_material_indices = *cap_attributes.lookup("material_index", - ATTR_DOMAIN_FACE)) { + ATTR_DOMAIN_FACE)) + { bke::MutableAttributeAccessor result_attributes = result->attributes_for_write(); bke::SpanAttributeWriter result_material_indices = result_attributes.lookup_or_add_for_write_span("material_index", ATTR_DOMAIN_FACE); @@ -509,7 +513,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, * vertices. */ if ((size_t(count) * size_t(chunk_nverts) + size_t(start_cap_nverts) + - size_t(end_cap_nverts)) > max_verts_num) { + size_t(end_cap_nverts)) > max_verts_num) + { count = 1; offset_is_too_small = true; } @@ -531,7 +536,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, * vertices. */ else if ((size_t(count) * size_t(chunk_nverts) + size_t(start_cap_nverts) + - size_t(end_cap_nverts)) > max_verts_num) { + size_t(end_cap_nverts)) > max_verts_num) + { count = 1; BKE_modifier_set_error(ctx->object, &amd->modifier, @@ -644,7 +650,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, * close enough from current vert (otherwise no mapping at all). */ if (compare_len_v3v3(result_positions[this_chunk_index], result_positions[full_doubles_map[target]], - amd->merge_dist)) { + amd->merge_dist)) + { target = full_doubles_map[target]; } else { diff --git a/source/blender/modifiers/intern/MOD_build.cc b/source/blender/modifiers/intern/MOD_build.cc index 63cb59f09c0..613fa786119 100644 --- a/source/blender/modifiers/intern/MOD_build.cc +++ b/source/blender/modifiers/intern/MOD_build.cc @@ -128,7 +128,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * const blender::int2 &edge = edges_src[i]; if (BLI_ghash_haskey(vertHash, POINTER_FROM_INT(edge[0])) && - BLI_ghash_haskey(vertHash, POINTER_FROM_INT(edge[1]))) { + BLI_ghash_haskey(vertHash, POINTER_FROM_INT(edge[1]))) + { BLI_ghash_insert(edgeHash, (void *)hash_num, (void *)hash_num_alt); BLI_ghash_insert(edgeHash2, (void *)hash_num_alt, (void *)hash_num); hash_num++; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index ee53ca9753c..600f64556ae 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -363,7 +363,8 @@ static void cuboid_do(CastModifierData *cmd, if (has_radius) { if (fabsf(tmp_co[0]) > cmd->radius || fabsf(tmp_co[1]) > cmd->radius || - fabsf(tmp_co[2]) > cmd->radius) { + fabsf(tmp_co[2]) > cmd->radius) + { continue; } } diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index aae200b3e20..7fbe7b78141 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -114,7 +114,8 @@ static void deformVerts(ModifierData *md, if (kb && kb->data != NULL) { float(*layerorco)[3]; if (!(layerorco = CustomData_get_layer_for_write( - &mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert))) { + &mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert))) + { layerorco = CustomData_add_layer( &mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, mesh_src->totvert); } diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.cc b/source/blender/modifiers/intern/MOD_correctivesmooth.cc index 04a64f525ee..24aa50ee5c9 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.cc +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.cc @@ -455,7 +455,8 @@ static void calc_tangent_spaces(const Mesh *mesh, normalize_v3(v_dir_prev); for (; next_corner != term_corner; - prev_corner = curr_corner, curr_corner = next_corner, next_corner++) { + prev_corner = curr_corner, curr_corner = next_corner, next_corner++) + { float(*ts)[3] = r_tangent_spaces[curr_corner]; /* re-use the previous value */ @@ -582,7 +583,8 @@ static void correctivesmooth_modifier_do(ModifierData *md, /* if rest bind_coords not are defined, set them (only run during bind) */ if ((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) && /* signal to recalculate, whoever sets MUST also free bind coords */ - (csmd->bind_coords_num == uint(-1))) { + (csmd->bind_coords_num == uint(-1))) + { if (DEG_is_active(depsgraph)) { BLI_assert(csmd->bind_coords == nullptr); csmd->bind_coords = static_cast(MEM_dupallocN(vertexCos)); @@ -637,7 +639,8 @@ static void correctivesmooth_modifier_do(ModifierData *md, /* check to see if our deltas are still valid */ if (!csmd->delta_cache.deltas || (csmd->delta_cache.deltas_num != corner_verts.size()) || - force_delta_cache_update) { + force_delta_cache_update) + { const float(*rest_coords)[3]; bool is_rest_coords_alloc = false; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.cc b/source/blender/modifiers/intern/MOD_datatransfer.cc index 7a1262c3098..96b79b56d18 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.cc +++ b/source/blender/modifiers/intern/MOD_datatransfer.cc @@ -182,7 +182,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * if (((result == me) || (me_positions == result_positions) || (me_edges.data() == result_edges.data())) && - (dtmd->data_types & DT_TYPES_AFFECT_MESH)) { + (dtmd->data_types & DT_TYPES_AFFECT_MESH)) + { /* We need to duplicate data here, otherwise setting custom normals, edges' sharpness, etc., * could modify org mesh, see #43671. */ result = (Mesh *)BKE_id_copy_ex(nullptr, &me_mod->id, nullptr, LIB_ID_COPY_LOCALIZE); @@ -213,7 +214,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * dtmd->mix_factor, dtmd->defgrp_name, invert_vgroup, - &reports)) { + &reports)) + { result->runtime->is_original_bmesh = false; } diff --git a/source/blender/modifiers/intern/MOD_displace.cc b/source/blender/modifiers/intern/MOD_displace.cc index d95024d7b9f..497a917194f 100644 --- a/source/blender/modifiers/intern/MOD_displace.cc +++ b/source/blender/modifiers/intern/MOD_displace.cc @@ -120,7 +120,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte bool need_transform_relation = false; if (dmd->space == MOD_DISP_SPACE_GLOBAL && - ELEM(dmd->direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ)) { + ELEM(dmd->direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ)) + { need_transform_relation = true; } @@ -175,8 +176,8 @@ static void displaceModifier_do_task(void *__restrict userdata, float(*vertexCos)[3] = data->vertexCos; float(*vert_clnors)[3] = data->vert_clnors; - const float delta_fixed = 1.0f - - dmd->midlevel; /* when no texture is used, we fallback to white */ + /* When no texture is used, we fallback to white. */ + const float delta_fixed = 1.0f - dmd->midlevel; TexResult texres; float strength = dmd->strength; @@ -322,7 +323,8 @@ static void displaceModifier_do(DisplaceModifierData *dmd, } } else if (ELEM(direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ) && - use_global_direction) { + use_global_direction) + { copy_m4_m4(local_mat, ob->object_to_world); } @@ -426,7 +428,8 @@ static void panel_draw(const bContext *C, Panel *panel) uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && - (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { + (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) + { PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); uiItemPointerR(col, ptr, @@ -449,7 +452,8 @@ static void panel_draw(const bContext *C, Panel *panel) MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, - MOD_DISP_DIR_RGB_XYZ)) { + MOD_DISP_DIR_RGB_XYZ)) + { uiItemR(col, ptr, "space", 0, nullptr, ICON_NONE); } diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index fd407883323..0bbb08fdba9 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -83,12 +83,14 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma for (; surface; surface = surface->next) { /* UVs: #CD_PROP_FLOAT2. */ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ || - surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) { + surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) + { r_cddata_masks->lmask |= CD_MASK_PROP_FLOAT2; } /* Vertex Colors: #CD_PROP_BYTE_COLOR. */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT || - surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) { + surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) + { r_cddata_masks->lmask |= CD_MASK_PROP_BYTE_COLOR; } /* Vertex Weights: #CD_MDEFORMVERT. */ diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 13d322822b5..45f7e568e13 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -76,7 +76,8 @@ Mesh *doEdgeSplit(const Mesh *mesh, EdgeSplitModifierData *emd) /* O° angle setting, we want to split on all edges. */ do_split_all || /* 2 face edge - check angle. */ - (dot_v3v3(l1->f->no, l2->f->no) < threshold)) { + (dot_v3v3(l1->f->no, l2->f->no) < threshold)) + { BM_elem_flag_enable(e, BM_ELEM_TAG); } } diff --git a/source/blender/modifiers/intern/MOD_explode.cc b/source/blender/modifiers/intern/MOD_explode.cc index f9d5f8bc037..cd6ea92bc39 100644 --- a/source/blender/modifiers/intern/MOD_explode.cc +++ b/source/blender/modifiers/intern/MOD_explode.cc @@ -950,7 +950,8 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, if ((pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) || (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) || - (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0)) { + (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0)) + { delface++; continue; } @@ -1161,7 +1162,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* 1. find faces to be exploded if needed */ if (emd->facepa == nullptr || psmd->flag & eParticleSystemFlag_Pars || emd->flag & eExplodeFlag_CalcFaces || - MEM_allocN_len(emd->facepa) / sizeof(int) != mesh->totface) { + MEM_allocN_len(emd->facepa) / sizeof(int) != mesh->totface) + { if (psmd->flag & eParticleSystemFlag_Pars) { psmd->flag &= ~eParticleSystemFlag_Pars; } diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 144c1c44077..723be5a6165 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -464,7 +464,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "object", 0, NULL, ICON_NONE); if (!RNA_pointer_is_null(&hook_object_ptr) && - RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) { + RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) + { PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data"); uiItemPointerR( col, ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE); diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc index 74e02a6c9ca..7a2ba55acf5 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc @@ -198,7 +198,8 @@ static void init_laplacian_matrix(LaplacianSystem *sys) int corner_curr = corner_term - 1; for (; corner_next != corner_term; - corner_prev = corner_curr, corner_curr = corner_next, corner_next++) { + corner_prev = corner_curr, corner_curr = corner_next, corner_next++) + { const float *v_prev = sys->vertexCos[corner_verts[corner_prev]]; const float *v_curr = sys->vertexCos[corner_verts[corner_curr]]; const float *v_next = sys->vertexCos[corner_verts[corner_next]]; @@ -255,11 +256,13 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) int corner_curr = corner_term - 1; for (; corner_next != corner_term; - corner_prev = corner_curr, corner_curr = corner_next, corner_next++) { + corner_prev = corner_curr, corner_curr = corner_next, corner_next++) + { /* Is ring if number of faces == number of edges around vertex. */ if (sys->ne_ed_num[corner_verts[corner_curr]] == sys->ne_fa_num[corner_verts[corner_curr]] && - sys->zerola[corner_verts[corner_curr]] == false) { + sys->zerola[corner_verts[corner_curr]] == false) + { EIG_linear_solver_matrix_add(sys->context, corner_verts[corner_curr], corner_verts[corner_next], @@ -272,7 +275,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) sys->vweights[corner_verts[corner_curr]]); } if (sys->ne_ed_num[corner_verts[corner_next]] == sys->ne_fa_num[corner_verts[corner_next]] && - sys->zerola[corner_verts[corner_next]] == false) { + sys->zerola[corner_verts[corner_next]] == false) + { EIG_linear_solver_matrix_add(sys->context, corner_verts[corner_next], corner_verts[corner_curr], @@ -285,7 +289,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) sys->vweights[corner_verts[corner_next]]); } if (sys->ne_ed_num[corner_verts[corner_prev]] == sys->ne_fa_num[corner_verts[corner_prev]] && - sys->zerola[corner_verts[corner_prev]] == false) { + sys->zerola[corner_verts[corner_prev]] == false) + { EIG_linear_solver_matrix_add(sys->context, corner_verts[corner_prev], corner_verts[corner_curr], @@ -306,7 +311,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) /* Is boundary */ if (sys->ne_ed_num[idv1] != sys->ne_fa_num[idv1] && sys->ne_ed_num[idv2] != sys->ne_fa_num[idv2] && sys->zerola[idv1] == false && - sys->zerola[idv2] == false) { + sys->zerola[idv2] == false) + { EIG_linear_solver_matrix_add( sys->context, idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]); EIG_linear_solver_matrix_add( diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 25bccff6670..b0553b51d15 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -621,7 +621,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, M /* Quick test to see if we can return early. */ if (!ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP) || (mesh->totvert == 0) || - BLI_listbase_is_empty(&mesh->vertex_group_names)) { + BLI_listbase_is_empty(&mesh->vertex_group_names)) + { return mesh; } diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.c index 0a812c42fe5..305bba63998 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c +++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.c @@ -227,14 +227,16 @@ bool MOD_meshcache_read_mdd_frame(FILE *fp, interp, index_range, &factor, /* read into these values */ - err_str) == false) { + err_str) == false) + { return false; } if (index_range[0] == index_range[1]) { /* read single */ if ((BLI_fseek(fp, 0, SEEK_SET) == 0) && - MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) { + MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) + { return true; } @@ -245,7 +247,8 @@ bool MOD_meshcache_read_mdd_frame(FILE *fp, if ((BLI_fseek(fp, 0, SEEK_SET) == 0) && MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) && (BLI_fseek(fp, 0, SEEK_SET) == 0) && - MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) { + MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) + { return true; } diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c index 27fea20bb13..8eb17475a50 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c @@ -196,14 +196,16 @@ bool MOD_meshcache_read_pc2_frame(FILE *fp, interp, index_range, &factor, /* read into these values */ - err_str) == false) { + err_str) == false) + { return false; } if (index_range[0] == index_range[1]) { /* read single */ if ((BLI_fseek(fp, 0, SEEK_SET) == 0) && - MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) { + MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) + { return true; } @@ -214,7 +216,8 @@ bool MOD_meshcache_read_pc2_frame(FILE *fp, if ((BLI_fseek(fp, 0, SEEK_SET) == 0) && MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) && (BLI_fseek(fp, 0, SEEK_SET) == 0) && - MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) { + MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) + { return true; } diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc index 5230facc51e..adf33bd0071 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc @@ -216,7 +216,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * * flags) and duplicate those too. * XXX(Hans): This probably isn't true anymore with various CoW improvements, etc. */ if ((me_positions.data() == mesh_positions.data()) || (me_edges.data() == mesh_edges.data()) || - (me_polys.data() == mesh_polys.data())) { + (me_polys.data() == mesh_polys.data())) + { /* We need to duplicate data here, otherwise we'll modify org mesh, see #51701. */ mesh = reinterpret_cast( BKE_id_copy_ex(nullptr, diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 655e1d826ba..938f2ccd748 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -118,8 +118,8 @@ static void add_used_ids_from_sockets(const ListBase &sockets, Set &ids) break; } case SOCK_COLLECTION: { - if (Collection *collection = - ((bNodeSocketValueCollection *)socket->default_value)->value) { + if (Collection *collection = ((bNodeSocketValueCollection *)socket->default_value)->value) + { ids.add(&collection->id); } break; @@ -671,7 +671,7 @@ static void update_input_properties_from_node_tree(const bNodeTree &tree, if (old_properties == nullptr) { if (socket.default_attribute_name && socket.default_attribute_name[0] != '\0') { - IDP_AssignString(attribute_prop, socket.default_attribute_name, MAX_NAME); + IDP_AssignStringMaxSize(attribute_prop, socket.default_attribute_name, MAX_NAME); IDP_Int(use_attribute_prop) = 1; } } @@ -705,7 +705,7 @@ static void update_output_properties_from_node_tree(const bNodeTree &tree, } const std::string idprop_name = socket.identifier + attribute_name_suffix; - IDProperty *new_prop = IDP_NewString("", idprop_name.c_str(), MAX_NAME); + IDProperty *new_prop = IDP_NewString("", idprop_name.c_str()); if (socket.description[0] != '\0') { IDPropertyUIData *ui_data = IDP_ui_data_ensure(new_prop); ui_data->description = BLI_strdup(socket.description); @@ -714,7 +714,7 @@ static void update_output_properties_from_node_tree(const bNodeTree &tree, if (old_properties == nullptr) { if (socket.default_attribute_name && socket.default_attribute_name[0] != '\0') { - IDP_AssignString(new_prop, socket.default_attribute_name, MAX_NAME); + IDP_AssignStringMaxSize(new_prop, socket.default_attribute_name, MAX_NAME); } } else { @@ -824,7 +824,8 @@ static void initialize_group_input(const bNodeTree &tree, static const lf::FunctionNode *find_viewer_lf_node(const bNode &viewer_bnode) { if (const nodes::GeometryNodesLazyFunctionGraphInfo *lf_graph_info = - nodes::ensure_geometry_nodes_lazy_function_graph(viewer_bnode.owner_tree())) { + nodes::ensure_geometry_nodes_lazy_function_graph(viewer_bnode.owner_tree())) + { return lf_graph_info->mapping.viewer_node_map.lookup_default(&viewer_bnode, nullptr); } return nullptr; @@ -832,7 +833,8 @@ static const lf::FunctionNode *find_viewer_lf_node(const bNode &viewer_bnode) static const lf::FunctionNode *find_group_lf_node(const bNode &group_bnode) { if (const nodes::GeometryNodesLazyFunctionGraphInfo *lf_graph_info = - nodes::ensure_geometry_nodes_lazy_function_graph(group_bnode.owner_tree())) { + nodes::ensure_geometry_nodes_lazy_function_graph(group_bnode.owner_tree())) + { return lf_graph_info->mapping.group_node_map.lookup_default(&group_bnode, nullptr); } return nullptr; @@ -947,7 +949,8 @@ static void find_socket_log_contexts(const NodesModifierData &nmd, const SpaceNode &snode = *reinterpret_cast(sl); if (const std::optional hash = geo_log::GeoModifierLog::get_compute_context_hash_for_node_editor( - snode, nmd.modifier.name)) { + snode, nmd.modifier.name)) + { r_socket_log_contexts.add(*hash); } } @@ -1032,7 +1035,8 @@ static Vector compute_attributes_to_store( for (const GeometryComponentType component_type : {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE, - GEO_COMPONENT_TYPE_INSTANCES}) { + GEO_COMPONENT_TYPE_INSTANCES}) + { if (!geometry.has(component_type)) { continue; } @@ -1080,14 +1084,16 @@ static void store_computed_output_attributes( /* Attempt to remove the attribute if it already exists but the domain and type don't match. * Removing the attribute won't succeed if it is built in and non-removable. */ if (meta_data.has_value() && - (meta_data->domain != store.domain || meta_data->data_type != data_type)) { + (meta_data->domain != store.domain || meta_data->data_type != data_type)) + { attributes.remove(store.name); } /* Try to create the attribute reusing the stored buffer. This will only succeed if the * attribute didn't exist before, or if it existed but was removed above. */ if (attributes.add( - store.name, store.domain, data_type, bke::AttributeInitMoveArray(store.data.data()))) { + store.name, store.domain, data_type, bke::AttributeInitMoveArray(store.data.data()))) + { continue; } @@ -1492,7 +1498,7 @@ static void attribute_search_exec_fn(bContext *C, void *data_v, void *item_v) const std::string attribute_prop_name = data.socket_identifier + attribute_name_suffix; IDProperty &name_property = *IDP_GetPropertyFromGroup(nmd->settings.properties, attribute_prop_name.c_str()); - IDP_AssignString(&name_property, item.name.c_str(), 0); + IDP_AssignString(&name_property, item.name.c_str()); ED_undo_push(C, "Assign Attribute Name"); } diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index 04c77f76ff0..0ce2be95850 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -147,7 +147,8 @@ static void mix_normals(const float mix_factor, } for (i = corner_verts.size(), no_new = nos_new, no_old = nos_old, wfac = facs; i--; - no_new++, no_old++, wfac++) { + no_new++, no_old++, wfac++) + { const float fac = facs ? *wfac * mix_factor : mix_factor; switch (mix_mode) { @@ -325,7 +326,8 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, if (do_polynors_fix && polygons_check_flip( - corner_verts, corner_edges, nos.data(), &mesh->ldata, polys, mesh->poly_normals())) { + corner_verts, corner_edges, nos.data(), &mesh->ldata, polys, mesh->poly_normals())) + { BKE_mesh_tag_face_winding_changed(mesh); } const bool *sharp_faces = static_cast( @@ -432,7 +434,8 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, if (do_polynors_fix && polygons_check_flip( - corner_verts, corner_edges, nos.data(), &mesh->ldata, polys, mesh->poly_normals())) { + corner_verts, corner_edges, nos.data(), &mesh->ldata, polys, mesh->poly_normals())) + { BKE_mesh_tag_face_winding_changed(mesh); } const bool *sharp_faces = static_cast( diff --git a/source/blender/modifiers/intern/MOD_particleinstance.cc b/source/blender/modifiers/intern/MOD_particleinstance.cc index 9948f300730..4d5006542d7 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.cc +++ b/source/blender/modifiers/intern/MOD_particleinstance.cc @@ -84,8 +84,8 @@ static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParam /* If the psys modifier is disabled we cannot use its data. * First look up the psys modifier from the object, then check if it is enabled. */ - for (ob_md = static_cast(pimd->ob->modifiers.first); ob_md; - ob_md = ob_md->next) { + for (ob_md = static_cast(pimd->ob->modifiers.first); ob_md; ob_md = ob_md->next) + { if (ob_md->type == eModifierType_ParticleSystem) { ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md; if (psmd->psys == psys) { @@ -368,7 +368,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* get particle state */ if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && - (pimd->flag & eParticleInstanceFlag_Path)) { + (pimd->flag & eParticleInstanceFlag_Path)) + { float ran = 0.0f; if (pimd->random_position != 0.0f) { ran = pimd->random_position * BLI_hash_frand(psys->seed + p); diff --git a/source/blender/modifiers/intern/MOD_particlesystem.cc b/source/blender/modifiers/intern/MOD_particlesystem.cc index 433e398a9f2..b042a1af8e9 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.cc +++ b/source/blender/modifiers/intern/MOD_particlesystem.cc @@ -201,7 +201,8 @@ static void deformVerts(ModifierData *md, * instance. */ if (had_mesh_final && (psmd->mesh_final->totvert != psmd->totdmvert || psmd->mesh_final->totedge != psmd->totdmedge || - psmd->mesh_final->totface != psmd->totdmface)) { + psmd->mesh_final->totface != psmd->totdmface)) + { psys->recalc |= ID_RECALC_PSYS_RESET; } psmd->totdmvert = psmd->mesh_final->totvert; diff --git a/source/blender/modifiers/intern/MOD_screw.cc b/source/blender/modifiers/intern/MOD_screw.cc index 17f21b6674e..dd4f6ce3971 100644 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@ -359,7 +359,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * * NOTE: smaller than `FLT_EPSILON * 100` * gives problems with float precision so its never closed. */ if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) && - fabsf(fabsf(angle) - (float(M_PI) * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3) { + fabsf(fabsf(angle) - (float(M_PI) * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3) + { close = true; step_tot--; diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 5d37fd81b0e..1341214be53 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -96,8 +96,8 @@ static void deformVerts(ModifierData *md, struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); Mesh *mesh_src = NULL; - if (ELEM(ctx->object->type, OB_MESH, OB_LATTICE) || - (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { + if (ELEM(ctx->object->type, OB_MESH, OB_LATTICE) || (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) + { /* mesh_src is needed for vgroups, but also used as ShrinkwrapCalcData.vert when projecting. * Avoid time-consuming mesh conversion for curves when not projecting. */ mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); @@ -208,7 +208,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) if (ELEM(wrap_method, MOD_SHRINKWRAP_PROJECT, MOD_SHRINKWRAP_NEAREST_SURFACE, - MOD_SHRINKWRAP_TARGET_PROJECT)) { + MOD_SHRINKWRAP_TARGET_PROJECT)) + { uiItemR(layout, ptr, "wrap_mode", 0, NULL, ICON_NONE); } diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index f0e2c87f53a..d6fd2389da8 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -532,7 +532,8 @@ static void restrictions_panel_draw(const bContext *UNUSED(C), Panel *panel) if (ELEM(deform_method, MOD_SIMPLEDEFORM_MODE_TAPER, MOD_SIMPLEDEFORM_MODE_STRETCH, - MOD_SIMPLEDEFORM_MODE_TWIST)) { + MOD_SIMPLEDEFORM_MODE_TWIST)) + { int deform_axis = RNA_enum_get(ptr, "deform_axis"); row = uiLayoutRowWithHeading(layout, true, IFACE_("Lock")); diff --git a/source/blender/modifiers/intern/MOD_skin.cc b/source/blender/modifiers/intern/MOD_skin.cc index b3bcfbb08fc..5223acd2e39 100644 --- a/source/blender/modifiers/intern/MOD_skin.cc +++ b/source/blender/modifiers/intern/MOD_skin.cc @@ -326,7 +326,8 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe) if (!frame->detached && (!BM_edge_exists(frame->verts[0], frame->verts[1]) || !BM_edge_exists(frame->verts[1], frame->verts[2]) || !BM_edge_exists(frame->verts[2], frame->verts[3]) || - !BM_edge_exists(frame->verts[3], frame->verts[0]))) { + !BM_edge_exists(frame->verts[3], frame->verts[0]))) + { frame->detached = true; } } @@ -852,7 +853,8 @@ static int calc_edge_subdivisions(const float (*vert_positions)[3], /* If either end is a branch node marked 'loose', don't subdivide * the edge (or subdivide just twice if both are branches) */ if ((v1_branch && (evs[0]->flag & MVERT_SKIN_LOOSE)) || - (v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE))) { + (v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE))) + { if (v1_branch && v2_branch) { return 2; } @@ -1469,7 +1471,8 @@ static void quad_from_tris(BMEdge *e, BMFace *adj[2], BMVert *ndx[4]) /* When the triangle edge cuts across our quad-to-be, * throw in the second triangle's vertex */ if (ELEM(tri[0][i], e->v1, e->v2) && - (tri[0][(i + 1) % 3] == e->v1 || tri[0][(i + 1) % 3] == e->v2)) { + (tri[0][(i + 1) % 3] == e->v1 || tri[0][(i + 1) % 3] == e->v2)) + { j++; ndx[j] = opp; } @@ -1548,7 +1551,8 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) /* If both triangles still free, and if they don't already * share a border with another face, output as a quad */ if (!BM_elem_flag_test(adj[0], BM_ELEM_TAG) && !BM_elem_flag_test(adj[1], BM_ELEM_TAG) && - !BM_face_share_face_check(adj[0], adj[1])) { + !BM_face_share_face_check(adj[0], adj[1])) + { add_quad_from_tris(so, e, adj); BM_elem_flag_enable(adj[0], BM_ELEM_TAG); BM_elem_flag_enable(adj[1], BM_ELEM_TAG); diff --git a/source/blender/modifiers/intern/MOD_solidify.cc b/source/blender/modifiers/intern/MOD_solidify.cc index a18650e6c4b..f216bf9683e 100644 --- a/source/blender/modifiers/intern/MOD_solidify.cc +++ b/source/blender/modifiers/intern/MOD_solidify.cc @@ -59,7 +59,8 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma /* ask for vertexgroups if we need them */ if (smd->defgrp_name[0] != '\0' || smd->shell_defgrp_name[0] != '\0' || - smd->rim_defgrp_name[0] != '\0') { + smd->rim_defgrp_name[0] != '\0') + { r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT; } } diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.cc b/source/blender/modifiers/intern/MOD_solidify_extrude.cc index 394fb1ffead..ef4d87492fe 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.cc +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.cc @@ -93,7 +93,8 @@ static void mesh_calc_hq_normal(Mesh *mesh, int i; const blender::int2 *edge; for (i = 0, edge = edges.data(), edge_ref = edge_ref_array; i < edges.size(); - i++, edge++, edge_ref++) { + i++, edge++, edge_ref++) + { /* Get the edge vert indices, and edge value (the face indices that use it) */ if (edgeref_is_init(edge_ref) && (edge_ref->p1 != -1)) { @@ -534,7 +535,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex for (uint i = 0; i < edges_num; i++) { const blender::int2 &edge = orig_edges[i]; if (!ELEM(edge_user_pairs[i][0], INVALID_UNUSED, INVALID_PAIR) && - !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) { + !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) + { const float *n0 = poly_normals[edge_user_pairs[i][0]]; const float *n1 = poly_normals[edge_user_pairs[i][1]]; sub_v3_v3v3(e, orig_vert_positions[edge[0]], orig_vert_positions[edge[1]]); @@ -744,7 +746,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex /* skip 3+ face user edges */ if ((check_non_manifold == false) || LIKELY(!BLI_BITMAP_TEST(edge_tmp_tag, poly_edges[i_curr]) && - !BLI_BITMAP_TEST(edge_tmp_tag, poly_edges[i_next]))) { + !BLI_BITMAP_TEST(edge_tmp_tag, poly_edges[i_next]))) + { vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], poly_normals[i]) * angle; } @@ -838,7 +841,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex for (i = 0; i < edges_num; i++) { const blender::int2 &edge = orig_edges[i]; if (!ELEM(edge_user_pairs[i][0], INVALID_UNUSED, INVALID_PAIR) && - !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) { + !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) + { const float *n0 = poly_normals[edge_user_pairs[i][0]]; const float *n1 = poly_normals[edge_user_pairs[i][1]]; if (do_angle_clamp) { diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc index 415334056e1..18dff6a4565 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc @@ -388,7 +388,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, bool can_merge = true; for (uint k = 0; k < edges_num && can_merge; k++) { if (k != i && edge_adj_faces_len[k] > 0 && - (ELEM(vm[orig_edges[k][0]], v1, v2) != ELEM(vm[orig_edges[k][1]], v1, v2))) { + (ELEM(vm[orig_edges[k][0]], v1, v2) != ELEM(vm[orig_edges[k][1]], v1, v2))) + { for (uint j = 0; j < edge_adj_faces[k]->faces_len && can_merge; j++) { const blender::IndexRange poly = orig_polys[edge_adj_faces[k]->faces[j]]; uint changes = 0; @@ -550,7 +551,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, for (uint k = 0; k < i_adj_faces->faces_len; k++) { for (uint l = 0; l < invalid_adj_faces->faces_len; l++) { if (i_adj_faces->faces[k] == invalid_adj_faces->faces[l] && - i_adj_faces->faces[k] != MOD_SOLIDIFY_EMPTY_TAG) { + i_adj_faces->faces[k] != MOD_SOLIDIFY_EMPTY_TAG) + { i_adj_faces->faces[k] = MOD_SOLIDIFY_EMPTY_TAG; invalid_adj_faces->faces[l] = MOD_SOLIDIFY_EMPTY_TAG; j++; @@ -974,7 +976,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, while (!edge && j < unassigned_edges_len) { edge = unassigned_edges[j++]; if (edge && last_open_edge_track && - (edge->faces[0] != last_open_edge_track || edge->faces[1] != nullptr)) { + (edge->faces[0] != last_open_edge_track || edge->faces[1] != nullptr)) + { edge = nullptr; } } @@ -1160,7 +1163,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, (g.is_orig_closed && (real_k <= (first_unique_end == -1 ? 0 : first_unique_end) + int(edges_len) || - first_split != last_split))) { + first_split != last_split))) + { const uint k = real_k % edges_len; if (!doubles[k]) { if (first_unique_end != -1 && unique_start == -1) { @@ -1457,7 +1461,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, for (uint l = 0; l < 2; l++) { NewFaceRef *face = edge->faces[l]; if (face && (first_edge == nullptr || - (first_edge->faces[0] != face && first_edge->faces[1] != face))) { + (first_edge->faces[0] != face && first_edge->faces[1] != face))) + { float ofs = face->reversed ? ofs_back_clamped : ofs_front_clamped; /* Use face_weight here to make faces thinner. */ if (do_flat_faces) { @@ -1669,7 +1674,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, for (uint l = 0; l < 2; l++) { NewFaceRef *face = edge->faces[l]; if (face && (first_edge == nullptr || - (first_edge->faces[0] != face && first_edge->faces[1] != face))) { + (first_edge->faces[0] != face && first_edge->faces[1] != face))) + { float angle = 1.0f; float ofs = face->reversed ? -ofs_back_clamped : ofs_front_clamped; /* Use face_weight here to make faces thinner. */ @@ -2050,7 +2056,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, const uint v2 = (*l)->link_edge_groups[1]->new_vert; uint insert = edge_index; if (has_singularities && ((*l)->link_edge_groups[0]->is_singularity && - (*l)->link_edge_groups[1]->is_singularity)) { + (*l)->link_edge_groups[1]->is_singularity)) + { uint j = 0; for (uint(*p)[2] = singularity_edges; j < totsingularity; p++, j++) { if (((*p)[0] == v1 && (*p)[1] == v2) || ((*p)[0] == v2 && (*p)[1] == v1)) { @@ -2525,7 +2532,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, uint valid_edges = 0; uint k = 0; while (totloop > 0 && (!fr->link_edges[totloop - 1] || - fr->link_edges[totloop - 1]->new_edge == MOD_SOLIDIFY_EMPTY_TAG)) { + fr->link_edges[totloop - 1]->new_edge == MOD_SOLIDIFY_EMPTY_TAG)) + { totloop--; } if (totloop > 0) { diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index be8b671a211..c38ec66d28f 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -130,7 +130,8 @@ static void deformVerts(ModifierData *md, if ((mesh_verts_num != surmd->runtime.verts_num) || (surmd->runtime.vert_positions_prev == NULL) || (surmd->runtime.vert_velocities == NULL) || - (cfra != surmd->runtime.cfra_prev + 1)) { + (cfra != surmd->runtime.cfra_prev + 1)) + { MEM_SAFE_FREE(surmd->runtime.vert_positions_prev); MEM_SAFE_FREE(surmd->runtime.vert_velocities); diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.cc b/source/blender/modifiers/intern/MOD_surfacedeform.cc index 775e4f17485..728cbeeb02b 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.cc +++ b/source/blender/modifiers/intern/MOD_surfacedeform.cc @@ -406,7 +406,8 @@ BLI_INLINE uint nearestVert(SDefBindCalcData *const data, const float point_co[3 const blender::int2 &edge = data->edges[index]; if (len_squared_v3v3(point_co, data->targetCos[edge[0]]) < - len_squared_v3v3(point_co, data->targetCos[edge[1]])) { + len_squared_v3v3(point_co, data->targetCos[edge[1]])) + { return edge[0]; } @@ -652,7 +653,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, * degenerate despite having passed isPolyValid). */ if (bpoly->scales[0] < FLT_EPSILON || bpoly->scales[1] < FLT_EPSILON || bpoly->edgemid_angle < FLT_EPSILON || bpoly->corner_edgemid_angles[0] < FLT_EPSILON || - bpoly->corner_edgemid_angles[1] < FLT_EPSILON) { + bpoly->corner_edgemid_angles[1] < FLT_EPSILON) + { freeBindData(bwdata); data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR; return nullptr; @@ -710,7 +712,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, /* Verify that the additional computed values are valid. */ if (bpoly->scale_mid < FLT_EPSILON || - bpoly->point_edgemid_angles[0] + bpoly->point_edgemid_angles[1] < FLT_EPSILON) { + bpoly->point_edgemid_angles[0] + bpoly->point_edgemid_angles[1] < FLT_EPSILON) + { freeBindData(bwdata); data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR; return nullptr; @@ -912,7 +915,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, } else { if (bpoly->dominant_angle_weight < FLT_EPSILON || - 1.0f - bpoly->dominant_angle_weight < FLT_EPSILON) { + 1.0f - bpoly->dominant_angle_weight < FLT_EPSILON) + { bwdata->binds_num += 1; } else { @@ -1476,7 +1480,8 @@ static void surfacedeformModifier_do(ModifierData *md, target_polys_num, target_verts_num, target, - mesh)) { + mesh)) + { smd->flags &= ~MOD_SDEF_BIND; } /* Early abort, this is binding 'call', no need to perform whole evaluation. */ diff --git a/source/blender/modifiers/intern/MOD_triangulate.cc b/source/blender/modifiers/intern/MOD_triangulate.cc index 04726f47a5a..182132abffe 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.cc +++ b/source/blender/modifiers/intern/MOD_triangulate.cc @@ -103,7 +103,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, M TriangulateModifierData *tmd = (TriangulateModifierData *)md; Mesh *result; if (!(result = triangulate_mesh( - mesh, tmd->quad_method, tmd->ngon_method, tmd->min_vertices, tmd->flag))) { + mesh, tmd->quad_method, tmd->ngon_method, tmd->min_vertices, tmd->flag))) + { return mesh; } diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c index 17eabfbbd7a..c12e3d88782 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.c +++ b/source/blender/modifiers/intern/MOD_ui_common.c @@ -155,7 +155,8 @@ static int modifier_is_simulation(const ModifierData *md) eModifierType_Fluid, eModifierType_Softbody, eModifierType_Surface, - eModifierType_DynamicPaint)) { + eModifierType_DynamicPaint)) + { return 1; } /* Particle Tab */ @@ -181,7 +182,8 @@ static bool modifier_can_delete(ModifierData *md) PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYBUBBLE, PART_FLUID_FOAMBUBBLE, - PART_FLUID_SPRAYFOAMBUBBLE)) { + PART_FLUID_SPRAYFOAMBUBBLE)) + { return false; } } @@ -231,7 +233,8 @@ static void modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v) eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth, - eModifierType_Fluid)) { + eModifierType_Fluid)) + { uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"), ICON_DUPLICATE, @@ -363,8 +366,8 @@ static void modifier_panel_header(const bContext *C, Panel *panel) buttons_number++; } /* Some modifiers can work with pre-tessellated curves only. */ - else if (ELEM( - md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { + else if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) + { /* Add button (appearing to be ON) and add tip why this can't be changed. */ sub = uiLayoutRow(row, true); uiBlock *block = uiLayoutGetBlock(sub); diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index abc6b5a5a88..9a0e8eabe0b 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -140,7 +140,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * return create_empty_mesh(input_mesh); } if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT && - vmmd->voxel_amount == 0) { + vmmd->voxel_amount == 0) + { return create_empty_mesh(input_mesh); } diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index b5fbac84257..5d10f58c464 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -252,7 +252,8 @@ static void warpModifier_do(WarpModifierData *wmd, if (wmd->falloff_type == eWarp_Falloff_None || ((fac = len_squared_v3v3(co, mat_from[3])) < falloff_radius_sq && - (fac = (wmd->falloff_radius - sqrtf(fac)) / wmd->falloff_radius))) { + (fac = (wmd->falloff_radius - sqrtf(fac)) / wmd->falloff_radius))) + { /* skip if no vert group found */ if (defgrp_index != -1) { dv = &dvert[i]; @@ -460,7 +461,8 @@ static void texture_panel_draw(const bContext *C, Panel *panel) uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && - (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { + (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) + { PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); uiItemPointerR(col, ptr, diff --git a/source/blender/modifiers/intern/MOD_wave.cc b/source/blender/modifiers/intern/MOD_wave.cc index 6ab3c1ab19b..d66d4beb452 100644 --- a/source/blender/modifiers/intern/MOD_wave.cc +++ b/source/blender/modifiers/intern/MOD_wave.cc @@ -436,7 +436,8 @@ static void texture_panel_draw(const bContext *C, Panel *panel) uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE); PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object"); if (!RNA_pointer_is_null(&texture_coords_obj_ptr) && - (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) { + (RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) + { PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data"); uiItemPointerR(col, ptr, diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc index 102e4a6a30b..fb25d6eb3d2 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.cc +++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc @@ -97,7 +97,7 @@ struct WeightedNormalData { /* Lower-level, internal processing data. */ float cached_inverse_powers_of_weight[NUM_CACHED_INVERSE_POWERS_OF_WEIGHT]; - WeightedNormalDataAggregateItem *items_data; + blender::Span items_data; ModePair *mode_pair; }; @@ -169,7 +169,8 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd, * (since a few values will be used by most cases, we cache those). */ const int loops_num = item_data->loops_num; if (loops_num < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT && - cached_inverse_powers_of_weight[loops_num] == 0.0f) { + cached_inverse_powers_of_weight[loops_num] == 0.0f) + { cached_inverse_powers_of_weight[loops_num] = 1.0f / powf(weight, loops_num); } const float inverted_n_weight = loops_num < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT ? @@ -213,9 +214,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, blender::Array loop_normals; - WeightedNormalDataAggregateItem *items_data = nullptr; - Array item_index_per_corner(corner_verts.size(), 0); - int items_num = 0; + Array items_data; + Array item_index_per_corner; if (keep_sharp) { BLI_bitmap *done_loops = BLI_BITMAP_NEW(corner_verts.size(), __func__); @@ -238,9 +238,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, &lnors_spacearr, loop_normals); - items_num = lnors_spacearr.spaces_num; - items_data = static_cast( - MEM_calloc_arrayN(size_t(items_num), sizeof(*items_data), __func__)); + item_index_per_corner.reinitialize(corner_verts.size()); + items_data = Array(lnors_spacearr.spaces_num, + WeightedNormalDataAggregateItem{}); /* In this first loop, we assign each WeightedNormalDataAggregateItem * to its smooth fan of loops (aka lnor space). */ @@ -261,6 +261,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, if (!(lnor_space->flags & MLNOR_SPACE_IS_SINGLE)) { for (LinkNode *lnode = lnor_space->loops; lnode; lnode = lnode->next) { const int ml_fan_index = POINTER_AS_INT(lnode->link); + item_index_per_corner[ml_fan_index] = item_index; BLI_BITMAP_ENABLE(done_loops, ml_fan_index); } } @@ -275,11 +276,10 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, MEM_freeN(done_loops); } else { - items_num = verts_num; - items_data = static_cast( - MEM_calloc_arrayN(size_t(items_num), sizeof(*items_data), __func__)); + items_data = Array(verts_num, + WeightedNormalDataAggregateItem{}); if (use_face_influence) { - for (int item_index = 0; item_index < items_num; item_index++) { + for (int item_index : items_data.index_range()) { items_data[item_index].curr_strength = FACE_STRENGTH_WEAK; } } @@ -322,7 +322,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, } /* Validate computed weighted normals. */ - for (int item_index = 0; item_index < items_num; item_index++) { + for (int item_index : items_data.index_range()) { if (normalize_v3(items_data[item_index].normal) < CLNORS_VALID_VEC_LEN) { zero_v3(items_data[item_index].normal); } @@ -464,7 +464,8 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData ModePair *c_angl = &corner_angle[poly.start()]; float *angl = index_angle; for (int ml_index = poly.start(); ml_index < poly.start() + poly.size(); - ml_index++, c_angl++, angl++) { + ml_index++, c_angl++, angl++) + { c_angl->val = float(M_PI) - *angl; c_angl->index = ml_index; } @@ -497,7 +498,8 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD ModePair *cmbnd = &combined[poly.start()]; float *angl = index_angle; for (int ml_index = poly.start(); ml_index < poly.start() + poly.size(); - ml_index++, cmbnd++, angl++) { + ml_index++, cmbnd++, angl++) + { /* In this case val is product of corner angle and face area. */ cmbnd->val = (float(M_PI) - *angl) * face_area; cmbnd->index = ml_index; @@ -624,7 +626,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } MEM_SAFE_FREE(wn_data.mode_pair); - MEM_SAFE_FREE(wn_data.items_data); result->runtime->is_original_bmesh = false; diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index b15b9cf75f1..e5527b0457d 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -48,15 +48,16 @@ void weightvg_do_map( /* Return immediately, if we have nothing to do! */ /* Also security checks... */ - if (!do_invert && (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL)) || - !ELEM(falloff_type, - MOD_WVG_MAPPING_CURVE, - MOD_WVG_MAPPING_SHARP, - MOD_WVG_MAPPING_SMOOTH, - MOD_WVG_MAPPING_ROOT, - MOD_WVG_MAPPING_SPHERE, - MOD_WVG_MAPPING_RANDOM, - MOD_WVG_MAPPING_STEP))) { + if (!do_invert && + (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL)) || !ELEM(falloff_type, + MOD_WVG_MAPPING_CURVE, + MOD_WVG_MAPPING_SHARP, + MOD_WVG_MAPPING_SMOOTH, + MOD_WVG_MAPPING_ROOT, + MOD_WVG_MAPPING_SPHERE, + MOD_WVG_MAPPING_RANDOM, + MOD_WVG_MAPPING_STEP))) + { return; } diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.cc b/source/blender/modifiers/intern/MOD_weightvgproximity.cc index 3ebdb24e853..c1923056efb 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.cc +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.cc @@ -67,7 +67,7 @@ **************************************/ /* Util macro. */ -#define OUT_OF_MEMORY() ((void)printf("WeightVGProximity: Out of memory.\n")) +#define OUT_OF_MEMORY() (void)printf("WeightVGProximity: Out of memory.\n") struct Vert2GeomData { /* Read-only data */ diff --git a/source/blender/nodes/NOD_math_functions.hh b/source/blender/nodes/NOD_math_functions.hh index 0641cef318e..75d5d349764 100644 --- a/source/blender/nodes/NOD_math_functions.hh +++ b/source/blender/nodes/NOD_math_functions.hh @@ -444,8 +444,8 @@ inline bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation ope switch (operation) { case NODE_VECTOR_MATH_NORMALIZE: - return dispatch(exec_preset_fast, - [](float3 in) { return normalize(in); }); /* Should be safe. */ + /* Should be safe. */ + return dispatch(exec_preset_fast, [](float3 in) { return normalize(in); }); case NODE_VECTOR_MATH_FLOOR: return dispatch(exec_preset_fast, [](float3 in) { return floor(in); }); case NODE_VECTOR_MATH_CEIL: diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index e025bcefc50..46134eebd03 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -211,7 +211,8 @@ void ntreeCompositTagRender(Scene *scene) * ideally render struct would store own main AND original G_MAIN. */ for (Scene *sce_iter = (Scene *)G_MAIN->scenes.first; sce_iter; - sce_iter = (Scene *)sce_iter->id.next) { + sce_iter = (Scene *)sce_iter->id.next) + { if (sce_iter->nodetree) { for (bNode *node : sce_iter->nodetree->all_nodes()) { if (node->id == (ID *)scene || node->type == CMP_NODE_COMPOSITE) { diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index c162a5e473a..fcd21f40a21 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -180,7 +180,8 @@ void ntreeCompositCryptomatteUpdateLayerNames(const Scene *scene, bNode *node) if (session) { for (blender::StringRef layer_name : - blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) { + blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) + { CryptomatteLayer *layer = MEM_cnew(__func__); layer_name.copy(layer->name); BLI_addtail(&n->runtime.layers, layer); @@ -201,7 +202,8 @@ void ntreeCompositCryptomatteLayerPrefix(const Scene *scene, if (session) { for (blender::StringRef layer_name : - blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) { + blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) + { if (first_layer_name.empty()) { first_layer_name = layer_name; } @@ -286,7 +288,8 @@ static bool node_poll_cryptomatte(const bNodeType * /*ntype*/, /* See node_composit_poll_rlayers. */ for (scene = static_cast(G.main->scenes.first); scene; - scene = static_cast(scene->id.next)) { + scene = static_cast(scene->id.next)) + { if (scene->nodetree == ntree) { break; } diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc index 106f89867d3..a5f52bbfe28 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.cc +++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc @@ -282,7 +282,8 @@ class RGBCurvesShaderNode : public ShaderNode { /* If the RGB curves do nothing, use a function that skips RGB computations. */ if (BKE_curvemapping_is_map_identity(curve_mapping, 0) && BKE_curvemapping_is_map_identity(curve_mapping, 1) && - BKE_curvemapping_is_map_identity(curve_mapping, 2)) { + BKE_curvemapping_is_map_identity(curve_mapping, 2)) + { GPU_stack_link(material, &bnode(), "curves_combined_only", diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.cc b/source/blender/nodes/composite/nodes/node_composite_displace.cc index 4b439213297..b38560268b0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.cc +++ b/source/blender/nodes/composite/nodes/node_composite_displace.cc @@ -105,7 +105,8 @@ class DisplaceOperation : public NodeOperation { const Result &input_x_scale = get_input("X Scale"); const Result &input_y_scale = get_input("Y Scale"); if (input_x_scale.is_single_value() && input_x_scale.get_float_value() == 0.0f && - input_y_scale.is_single_value() && input_y_scale.get_float_value() == 0.0f) { + input_y_scale.is_single_value() && input_y_scale.get_float_value() == 0.0f) + { return true; } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index fe08fb51d98..76ba859621c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -310,7 +310,8 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, RE_engine_free(engine); if ((scene->r.mode & R_EDGE_FRS) && - (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS)) { + (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS)) + { node_cmp_rlayers_register_pass( ntree, node, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc index f0a4dbd5ad3..840fcafb63f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc @@ -12,7 +12,9 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "COM_cached_mask.hh" #include "COM_node_operation.hh" +#include "COM_utilities.hh" #include "node_composite_util.hh" @@ -20,6 +22,8 @@ namespace blender::nodes::node_composite_mask_cc { +NODE_STORAGE_FUNCS(NodeMask) + static void cmp_node_mask_declare(NodeDeclarationBuilder &b) { b.add_output(N_("Mask")); @@ -66,13 +70,13 @@ static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *p uiItemR(layout, ptr, "size_source", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); - if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) { + if (node->custom1 & (CMP_NODE_MASK_FLAG_SIZE_FIXED | CMP_NODE_MASK_FLAG_SIZE_FIXED_SCENE)) { uiItemR(layout, ptr, "size_x", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); uiItemR(layout, ptr, "size_y", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); } uiItemR(layout, ptr, "use_motion_blur", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); - if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { + if (node->custom1 & CMP_NODE_MASK_FLAG_MOTION_BLUR) { uiItemR(layout, ptr, "motion_blur_samples", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); uiItemR(layout, ptr, "motion_blur_shutter", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); } @@ -86,8 +90,76 @@ class MaskOperation : public NodeOperation { void execute() override { - get_result("Mask").allocate_invalid(); - context().set_info_message("Viewport compositor setup not fully supported"); + Result &output_mask = get_result("Mask"); + if (!get_mask()) { + output_mask.allocate_invalid(); + return; + } + + const Domain domain = compute_domain(); + CachedMask &cached_mask = context().cache_manager().cached_masks.get( + context(), + get_mask(), + domain.size, + get_use_feather(), + get_motion_blur_samples(), + get_motion_blur_shutter()); + + output_mask.allocate_texture(domain); + GPU_texture_copy(output_mask.texture(), cached_mask.texture()); + } + + Domain compute_domain() override + { + return Domain(compute_size()); + } + + int2 compute_size() + { + if (get_flags() & CMP_NODE_MASK_FLAG_SIZE_FIXED) { + return get_size(); + } + + if (get_flags() & CMP_NODE_MASK_FLAG_SIZE_FIXED_SCENE) { + return get_size() * context().get_render_percentage(); + } + + return context().get_compositing_region_size(); + } + + int2 get_size() + { + return int2(node_storage(bnode()).size_x, node_storage(bnode()).size_y); + } + + bool get_use_feather() + { + return !bool(get_flags() & CMP_NODE_MASK_FLAG_NO_FEATHER); + } + + int get_motion_blur_samples() + { + return use_motion_blur() ? bnode().custom2 : 1; + } + + float get_motion_blur_shutter() + { + return bnode().custom3; + } + + bool use_motion_blur() + { + return get_flags() & CMP_NODE_MASK_FLAG_MOTION_BLUR; + } + + CMPNodeMaskFlags get_flags() + { + return static_cast(bnode().custom1); + } + + Mask *get_mask() + { + return reinterpret_cast(bnode().id); } }; @@ -110,8 +182,6 @@ void register_node_type_cmp_mask() ntype.initfunc = file_ns::node_composit_init_mask; ntype.labelfunc = file_ns::node_mask_label; ntype.get_compositor_operation = file_ns::get_compositor_operation; - ntype.realtime_compositor_unsupported_message = N_( - "Node not supported in the Viewport compositor"); node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc b/source/blender/nodes/composite/nodes/node_composite_output_file.cc index 530956f1f4f..ddd2453b278 100644 --- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc +++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc @@ -246,7 +246,8 @@ static void copy_output_file(bNodeTree * /*dst_ntree*/, bNode *dest_node, const for (src_sock = (bNodeSocket *)src_node->inputs.first, dest_sock = (bNodeSocket *)dest_node->inputs.first; src_sock && dest_sock; - src_sock = src_sock->next, dest_sock = (bNodeSocket *)dest_sock->next) { + src_sock = src_sock->next, dest_sock = (bNodeSocket *)dest_sock->next) + { dest_sock->storage = MEM_dupallocN(src_sock->storage); NodeImageMultiFileSocket *dest_sockdata = (NodeImageMultiFileSocket *)dest_sock->storage; NodeImageMultiFileSocket *src_sockdata = (NodeImageMultiFileSocket *)src_sock->storage; diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.cc b/source/blender/nodes/composite/nodes/node_composite_scale.cc index c70cbf0098c..addf3a905b2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.cc +++ b/source/blender/nodes/composite/nodes/node_composite_scale.cc @@ -126,7 +126,7 @@ class ScaleOperation : public NodeOperation { /* Scale by the render resolution percentage. */ float2 get_scale_render_percent() { - return float2(context().get_scene()->r.size / 100.0f); + return float2(context().get_render_percentage()); } float2 get_scale_render_size() diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc index 5c8a1837c86..2ddebf8a14e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.cc @@ -5,13 +5,24 @@ * \ingroup cmpnodes */ +#include "BLI_assert.h" +#include "BLI_math_angle_types.hh" +#include "BLI_math_matrix.hh" +#include "BLI_math_matrix_types.hh" +#include "BLI_math_vector_types.hh" + #include "BLT_translation.h" #include "UI_interface.h" #include "UI_resources.h" +#include "DNA_movieclip_types.h" +#include "DNA_node_types.h" + #include "BKE_context.h" #include "BKE_lib_id.h" +#include "BKE_movieclip.h" +#include "BKE_tracking.h" #include "COM_node_operation.hh" @@ -23,7 +34,9 @@ namespace blender::nodes::node_composite_stabilize2d_cc { static void cmp_node_stabilize2d_declare(NodeDeclarationBuilder &b) { - b.add_input(N_("Image")).default_value({0.8f, 0.8f, 0.8f, 1.0f}); + b.add_input(N_("Image")) + .default_value({0.8f, 0.8f, 0.8f, 1.0f}) + .compositor_domain_priority(0); b.add_output(N_("Image")); } @@ -70,8 +83,58 @@ class Stabilize2DOperation : public NodeOperation { void execute() override { - get_input("Image").pass_through(get_result("Image")); - context().set_info_message("Viewport compositor setup not fully supported"); + Result &input_image = get_input("Image"); + Result &output_image = get_result("Image"); + input_image.pass_through(output_image); + + MovieClip *movie_clip = get_movie_clip(); + if (input_image.is_single_value() || !movie_clip) { + return; + } + + const int width = input_image.domain().size.x; + const int height = input_image.domain().size.y; + const int frame_number = BKE_movieclip_remap_scene_to_clip_frame(movie_clip, + context().get_frame_number()); + + float2 translation; + float scale, rotation; + BKE_tracking_stabilization_data_get( + movie_clip, frame_number, width, height, translation, &scale, &rotation); + + float3x3 transformation = math::from_loc_rot_scale( + translation, math::AngleRadian(rotation), float2(scale)); + if (do_inverse_stabilization()) { + transformation = math::invert(transformation); + } + + output_image.transform(transformation); + output_image.get_realization_options().interpolation = get_interpolation(); + } + + Interpolation get_interpolation() + { + switch (static_cast(bnode().custom1)) { + case CMP_NODE_STABILIZE_INTERPOLATION_NEAREST: + return Interpolation::Nearest; + case CMP_NODE_STABILIZE_INTERPOLATION_BILINEAR: + return Interpolation::Bilinear; + case CMP_NODE_STABILIZE_INTERPOLATION_BICUBIC: + return Interpolation::Bicubic; + } + + BLI_assert_unreachable(); + return Interpolation::Nearest; + } + + bool do_inverse_stabilization() + { + return bnode().custom2 & CMP_NODE_STABILIZE_FLAG_INVERSE; + } + + MovieClip *get_movie_clip() + { + return (MovieClip *)bnode().id; } }; @@ -93,8 +156,6 @@ void register_node_type_cmp_stabilize2d() ntype.draw_buttons = file_ns::node_composit_buts_stabilize2d; ntype.initfunc_api = file_ns::init; ntype.get_compositor_operation = file_ns::get_compositor_operation; - ntype.realtime_compositor_unsupported_message = N_( - "Node not supported in the Viewport compositor"); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.cc b/source/blender/nodes/composite/nodes/node_composite_texture.cc index e48fc7c7c0e..32057b235c7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.cc +++ b/source/blender/nodes/composite/nodes/node_composite_texture.cc @@ -81,7 +81,7 @@ class TextureOperation : public NodeOperation { Tex *get_texture() { - return (Tex *)bnode().id; + return reinterpret_cast(bnode().id); } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc index 5863d12856a..66468a654e3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc @@ -106,7 +106,8 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN if (ELEM(node->custom1, CMP_NODE_TRACK_POSITION_RELATIVE_FRAME, - CMP_NODE_TRACK_POSITION_ABSOLUTE_FRAME)) { + CMP_NODE_TRACK_POSITION_ABSOLUTE_FRAME)) + { uiItemR(layout, ptr, "frame_relative", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); } } diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc index 188a6d916bf..5e99d3e1cdb 100644 --- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc +++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc @@ -47,13 +47,15 @@ static void node_label(const bNodeTree * /*tree*/, const bNode *node, char *labe static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) { if (!params.node_tree().typeinfo->validate_link( - static_cast(params.other_socket().type), SOCK_BOOLEAN)) { + static_cast(params.other_socket().type), SOCK_BOOLEAN)) + { return; } for (const EnumPropertyItem *item = rna_enum_node_boolean_math_items; item->identifier != nullptr; - item++) { + item++) + { if (item->name != nullptr && item->identifier[0] != '\0') { NodeBooleanMathOperation operation = static_cast(item->value); params.add_item(IFACE_(item->name), [operation](LinkSearchOpParams ¶ms) { diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 67b2c15d08e..fe18e39941c 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -128,7 +128,8 @@ static std::optional get_compare_type_for_operation( NODE_COMPARE_COLOR_BRIGHTER, NODE_COMPARE_COLOR_DARKER, NODE_COMPARE_EQUAL, - NODE_COMPARE_NOT_EQUAL)) { + NODE_COMPARE_NOT_EQUAL)) + { return SOCK_VECTOR; } return type; @@ -152,11 +153,13 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) const StringRef socket_name = params.in_out() == SOCK_IN ? "A" : "Result"; for (const EnumPropertyItem *item = rna_enum_node_compare_operation_items; item->identifier != nullptr; - item++) { + item++) + { if (item->name != nullptr && item->identifier[0] != '\0') { const NodeCompareOperation operation = NodeCompareOperation(item->value); if (const std::optional fixed_type = get_compare_type_for_operation( - type, operation)) { + type, operation)) + { params.add_item(IFACE_(item->name), SocketSearchOp{socket_name, *fixed_type, operation}); } } diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index dbdbf1e616d..c4bec7ede28 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -81,7 +81,8 @@ static bool geometry_node_tree_validate_link(eNodeSocketDatatype type_a, /* Geometry, string, object, material, texture and collection sockets can only be connected to * themselves. The other types can be converted between each other. */ if (ELEM(type_a, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT) && - ELEM(type_b, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT)) { + ELEM(type_b, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT)) + { return true; } return type_a == type_b; diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index f7f3e1bf076..d424b783b21 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -278,7 +278,8 @@ template class AccumulateFieldInput final : public bke::GeometryFiel bool is_equal_to(const fn::FieldNode &other) const override { if (const AccumulateFieldInput *other_accumulate = dynamic_cast( - &other)) { + &other)) + { return input_ == other_accumulate->input_ && group_index_ == other_accumulate->group_index_ && source_domain_ == other_accumulate->source_domain_ && @@ -392,8 +393,8 @@ static void node_geo_exec(GeoNodeExecParams params) Field group_index_field = params.extract_input>("Group Index"); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (std::is_same_v || std::is_same_v || - std::is_same_v) { + if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) + { const std::string suffix = " " + identifier_suffix(); Field input_field = params.extract_input>("Value" + suffix); if (params.output_is_required("Leading" + suffix)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc index d7b4275040b..2960240bfdf 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc @@ -85,8 +85,8 @@ static void node_geo_exec(GeoNodeExecParams params) break; } case GEO_COMPONENT_TYPE_CURVE: { - if (const CurveComponent *component = - geometry_set.get_component_for_read()) { + if (const CurveComponent *component = geometry_set.get_component_for_read()) + { const AttributeAccessor attributes = *component->attributes(); params.set_output("Point Count", attributes.domain_size(ATTR_DOMAIN_POINT)); params.set_output("Spline Count", attributes.domain_size(ATTR_DOMAIN_CURVE)); @@ -98,7 +98,8 @@ static void node_geo_exec(GeoNodeExecParams params) } case GEO_COMPONENT_TYPE_POINT_CLOUD: { if (const PointCloudComponent *component = - geometry_set.get_component_for_read()) { + geometry_set.get_component_for_read()) + { const AttributeAccessor attributes = *component->attributes(); params.set_output("Point Count", attributes.domain_size(ATTR_DOMAIN_POINT)); } @@ -109,7 +110,8 @@ static void node_geo_exec(GeoNodeExecParams params) } case GEO_COMPONENT_TYPE_INSTANCES: { if (const InstancesComponent *component = - geometry_set.get_component_for_read()) { + geometry_set.get_component_for_read()) + { const AttributeAccessor attributes = *component->attributes(); params.set_output("Instance Count", attributes.domain_size(ATTR_DOMAIN_INSTANCE)); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 494ce178ef3..5994a75185d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -135,7 +135,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } else { for (const StringRefNull name : - {"Mean", "Median", "Sum", "Min", "Max", "Range", "Standard Deviation", "Variance"}) { + {"Mean", "Median", "Sum", "Min", "Max", "Range", "Standard Deviation", "Variance"}) + { params.add_item(IFACE_(name.c_str()), [node_type, name, type](LinkSearchOpParams ¶ms) { bNode &node = params.add_node(node_type); node.custom1 = *type; diff --git a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc index 156534374f9..58997b0afd3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc @@ -456,7 +456,8 @@ class BlurAttributeFieldInput final : public bke::GeometryFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const BlurAttributeFieldInput *other_blur = dynamic_cast( - &other)) { + &other)) + { return weight_field_ == other_blur->weight_field_ && value_field_ == other_blur->value_field_ && iterations_ == other_blur->iterations_; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index 60d8539c8cb..e3758766afb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -104,7 +104,8 @@ class HandleTypeFieldInput final : public bke::CurvesFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const HandleTypeFieldInput *other_handle_selection = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return mode_ == other_handle_selection->mode_ && type_ == other_handle_selection->type_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index 559054ac2c0..3942b42b333 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -139,7 +139,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) search_link_ops_for_declarations(params, declaration.outputs); } else if (params.node_tree().typeinfo->validate_link( - eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) { + eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) + { params.add_item(IFACE_("Width"), SocketSearchOp{"Width", GEO_NODE_CURVE_PRIMITIVE_QUAD_MODE_RECTANGLE}); params.add_item(IFACE_("Height"), diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc index 402e396083c..d7224b8394d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_star.cc @@ -79,7 +79,8 @@ static void node_geo_exec(GeoNodeExecParams params) GeometrySet output = GeometrySet::create_with_curves(curves); if (AnonymousAttributeIDPtr outer_points_id = params.get_output_anonymous_attribute_id_if_needed( - "Outer Points")) { + "Outer Points")) + { create_selection_output(output.get_component_for_write(), outer_points_id); } params.set_output("Curve", std::move(output)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index 4b7a451cf14..f2ae85df8dd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -63,7 +63,8 @@ static void node_geo_exec(GeoNodeExecParams params) if (geometry::try_curves_conversion_in_place( selection, dst_type, [&]() -> bke::CurvesGeometry & { return geometry_set.get_curves_for_write()->geometry.wrap(); - })) { + })) + { return; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 385bf373755..25e33ff8ea4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -97,7 +97,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) if (params.in_out() == SOCK_IN) { if (params.node_tree().typeinfo->validate_link(eNodeSocketDatatype(params.other_socket().type), - SOCK_FLOAT)) { + SOCK_FLOAT)) + { params.add_item(IFACE_("Start (Factor)"), SocketSearchOp{"Start", GEO_NODE_CURVE_SAMPLE_FACTOR}); params.add_item(IFACE_("End (Factor)"), SocketSearchOp{"End", GEO_NODE_CURVE_SAMPLE_FACTOR}); diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc index 9eb00fd9d46..24f703e5ab3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc @@ -355,7 +355,8 @@ static bool sort_vertex_polys(const Span edges, const int corner_1 = poly_vertex_corners[i].first; const int corner_2 = poly_vertex_corners[i].second; if (edge_types[corner_edges[corner_1]] == EdgeType::Boundary && - corner_verts[corner_1] == vertex_index) { + corner_verts[corner_1] == vertex_index) + { shared_edge_i = corner_edges[corner_2]; r_sorted_corners[0] = poly_vertex_corners[i].first; std::swap(connected_polys[i], connected_polys[0]); @@ -363,7 +364,8 @@ static bool sort_vertex_polys(const Span edges, break; } if (edge_types[corner_edges[corner_2]] == EdgeType::Boundary && - corner_verts[corner_2] == vertex_index) { + corner_verts[corner_2] == vertex_index) + { shared_edge_i = corner_edges[corner_1]; r_sorted_corners[0] = poly_vertex_corners[i].second; std::swap(connected_polys[i], connected_polys[0]); @@ -564,13 +566,15 @@ static void dissolve_redundant_verts(const Span edges, const int2 &edge = edges[edge_i]; bool mark_edge = false; if (vertex_needs_dissolving( - edge[0], first_poly_index, second_poly_index, vertex_types, vert_to_poly_map)) { + edge[0], first_poly_index, second_poly_index, vertex_types, vert_to_poly_map)) + { /* This vertex is now 'removed' and should be ignored elsewhere. */ vertex_types[edge[0]] = VertexType::Loose; mark_edge = true; } if (vertex_needs_dissolving( - edge[1], first_poly_index, second_poly_index, vertex_types, vert_to_poly_map)) { + edge[1], first_poly_index, second_poly_index, vertex_types, vert_to_poly_map)) + { /* This vertex is now 'removed' and should be ignored elsewhere. */ vertex_types[edge[1]] = VertexType::Loose; mark_edge = true; @@ -625,7 +629,8 @@ static Mesh *calc_dual_mesh(const Mesh &src_mesh, threading::parallel_for(vert_to_poly_map.index_range(), 512, [&](IndexRange range) { for (const int i : range) { if (vertex_types[i] == VertexType::Loose || vertex_types[i] >= VertexType::NonManifold || - (!keep_boundaries && vertex_types[i] == VertexType::Boundary)) { + (!keep_boundaries && vertex_types[i] == VertexType::Boundary)) + { /* Bad vertex that we can't work with. */ continue; } @@ -721,7 +726,8 @@ static Mesh *calc_dual_mesh(const Mesh &src_mesh, for (const int i : IndexRange(src_mesh.totvert)) { if (vertex_types[i] == VertexType::Loose || vertex_types[i] >= VertexType::NonManifold || - (!keep_boundaries && vertex_types[i] == VertexType::Boundary)) { + (!keep_boundaries && vertex_types[i] == VertexType::Boundary)) + { /* Bad vertex that we can't work with. */ continue; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index d33d4c11c91..02f4881772d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -178,11 +178,9 @@ static void copy_attributes_without_id(const OffsetIndices offsets, const bke::AttributeAccessor src_attributes, bke::MutableAttributeAccessor dst_attributes) { - for (auto &attribute : bke::retrieve_attributes_for_transfer(src_attributes, - dst_attributes, - ATTR_DOMAIN_AS_MASK(domain), - propagation_info, - {"id"})) { + for (auto &attribute : bke::retrieve_attributes_for_transfer( + src_attributes, dst_attributes, ATTR_DOMAIN_AS_MASK(domain), propagation_info, {"id"})) + { attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); @@ -217,7 +215,8 @@ static void copy_curve_attributes_without_id( dst_curves.attributes_for_write(), ATTR_DOMAIN_MASK_ALL, propagation_info, - {"id"})) { + {"id"})) + { attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); @@ -394,7 +393,8 @@ static void copy_face_attributes_without_id( dst_attributes, ATTR_DOMAIN_MASK_ALL, propagation_info, - {"id", ".corner_vert", ".corner_edge", ".edge_verts"})) { + {"id", ".corner_vert", ".corner_edge", ".edge_verts"})) + { attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); @@ -604,7 +604,8 @@ static void copy_edge_attributes_without_id( dst_attributes, ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_EDGE, propagation_info, - {"id", ".edge_verts"})) { + {"id", ".edge_verts"})) + { attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); @@ -792,7 +793,8 @@ static void duplicate_points_curve(GeometrySet &geometry_set, new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_ALL, propagation_info, - {"id"})) { + {"id"})) + { attribute_math::convert_to_static_type(attribute.src.type(), [&](auto dummy) { using T = decltype(dummy); const Span src = attribute.src.typed(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 8b5a7652eae..394ca2e1ce0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -47,7 +47,8 @@ static void edge_paths_to_selection(const Mesh &src_mesh, for (const int i : edges.index_range()) { const int2 &edge = edges[i]; if ((selection[edge[0]] && selection[edge[1]]) && - (edge[0] == next_indices[edge[1]] || edge[1] == next_indices[edge[0]])) { + (edge[0] == next_indices[edge[1]] || edge[1] == next_indices[edge[0]])) + { r_selection[i] = true; } } @@ -106,7 +107,8 @@ class PathToEdgeSelectionFieldInput final : public bke::MeshFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const PathToEdgeSelectionFieldInput *other_field = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return other_field->start_vertices_ == start_vertices_ && other_field->next_vertex_ == next_vertex_; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 033ab8916dc..e287bb76a7e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -190,7 +190,8 @@ static MutableSpan get_orig_index_layer(Mesh &mesh, const eAttrDomain domai const bke::AttributeAccessor attributes = mesh.attributes(); CustomData &custom_data = mesh_custom_data_for_domain(mesh, domain); if (int *orig_indices = static_cast(CustomData_get_layer_for_write( - &custom_data, CD_ORIGINDEX, attributes.domain_size(domain)))) { + &custom_data, CD_ORIGINDEX, attributes.domain_size(domain)))) + { return {orig_indices, attributes.domain_size(domain)}; } return {}; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc index 585c95019cd..c830aa9f429 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc @@ -82,7 +82,8 @@ class HandlePositionFieldInput final : public bke::CurvesFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const HandlePositionFieldInput *other_handle = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return relative_ == other_handle->relative_ && left_ == other_handle->left_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc index d9fa912c94d..ff0b63f3825 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_vertices.cc @@ -125,7 +125,8 @@ class EdgePositionFieldInput final : public bke::MeshFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const EdgePositionFieldInput *other_field = dynamic_cast( - &other)) { + &other)) + { return vertex_ == other_field->vertex_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc index c93f41da71d..c801f3e8a89 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_shortest_edge_paths.cc @@ -144,7 +144,8 @@ class ShortestEdgePathsNextVertFieldInput final : public bke::MeshFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const ShortestEdgePathsNextVertFieldInput *other_field = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return other_field->end_selection_ == end_selection_ && other_field->cost_ == cost_; } return false; @@ -212,7 +213,8 @@ class ShortestEdgePathsCostFieldInput final : public bke::MeshFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const ShortestEdgePathsCostFieldInput *other_field = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return other_field->end_selection_ == end_selection_ && other_field->cost_ == cost_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index 2efde147733..59a61b6cce6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -95,7 +95,8 @@ static void add_instances_from_component( Array handle_mapping; /* Only fill #handle_mapping when it may be used below. */ if (src_instances != nullptr && - (!pick_instance.is_single() || pick_instance.get_internal_single())) { + (!pick_instance.is_single() || pick_instance.get_internal_single())) + { Span src_references = src_instances->references(); handle_mapping.reinitialize(src_references.size()); for (const int src_instance_handle : src_references.index_range()) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc index f0145741e32..193fc02924e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc @@ -72,8 +72,8 @@ static void convert_instances_to_points(GeometrySet &geometry_set, const eCustomDataType type = item.value.data_type; const GAttributeReader src = src_attributes.lookup(id); - if (selection.size() == instances.instances_num() && src.sharing_info && - src.varray.is_span()) { + if (selection.size() == instances.instances_num() && src.sharing_info && src.varray.is_span()) + { const bke::AttributeInitShared init(src.varray.get_internal_span().data(), *src.sharing_info); dst_attributes.add(id, ATTR_DOMAIN_POINT, type, init); diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc index da53297fd62..2c149565e73 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc @@ -450,8 +450,8 @@ static void interpolate_curve_attributes(bke::CurvesGeometry &child_curves, if (type == CD_PROP_STRING) { return true; } - if (guide_curve_attributes.is_builtin(id) && - !ELEM(id.name(), "radius", "tilt", "resolution")) { + if (guide_curve_attributes.is_builtin(id) && !ELEM(id.name(), "radius", "tilt", "resolution")) + { return true; } @@ -831,7 +831,8 @@ static void node_geo_exec(GeoNodeExecParams params) GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(guide_curves_geometry); if (const auto *curve_edit_data = - guide_curves_geometry.get_component_for_read()) { + guide_curves_geometry.get_component_for_read()) + { new_curves.add(*curve_edit_data); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc index ae85c1fbd92..db852a3d18f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc @@ -93,7 +93,8 @@ class MaterialSelectionFieldInput final : public bke::GeometryFieldInput { bool is_equal_to(const fn::FieldNode &other) const override { if (const MaterialSelectionFieldInput *other_material_selection = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return material_ == other_material_selection->material_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 42f2da09701..9bf744d4895 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -98,7 +98,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) return; } else if (params.node_tree().typeinfo->validate_link( - eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) { + eNodeSocketDatatype(params.other_socket().type), SOCK_FLOAT)) + { params.add_item(IFACE_("Count"), [](LinkSearchOpParams ¶ms) { bNode &node = params.add_node("GeometryNodeMeshLine"); node_storage(node).mode = GEO_NODE_MESH_LINE_MODE_OFFSET; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc index a497c612677..f35ce663a43 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc @@ -86,7 +86,8 @@ class OffsetCornerInFaceFieldInput final : public bke::MeshFieldInput { bool is_equal_to(const fn::FieldNode &other) const final { if (const OffsetCornerInFaceFieldInput *other_field = - dynamic_cast(&other)) { + dynamic_cast(&other)) + { return other_field->corner_index_ == corner_index_ && other_field->offset_ == offset_; } return false; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 26f11db005a..af2aa10178c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -86,7 +86,8 @@ void initialize_volume_component_from_points(GeoNodeExecParams ¶ms, Field radius_field = params.get_input>("Radius"); for (const GeometryComponentType type : - {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) { + {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) + { if (r_geometry_set.has(type)) { gather_point_data_from_component( radius_field, *r_geometry_set.get_component_for_read(type), positions, radii); diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index 287b18fb28f..642c71c4316 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -163,7 +163,8 @@ static void raycast_to_mesh(IndexMask mask, 0.0f, &hit, tree_data.raycast_callback, - &tree_data) != -1) { + &tree_data) != -1) + { hit_count++; if (!r_hit.is_empty()) { r_hit[i] = hit.index >= 0; diff --git a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc index b08ce192a81..f20f8dacc28 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc @@ -34,7 +34,8 @@ static void node_geo_exec(GeoNodeExecParams params) for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE, - GEO_COMPONENT_TYPE_INSTANCES}) { + GEO_COMPONENT_TYPE_INSTANCES}) + { if (geometry_set.has(type)) { /* First check if the attribute exists before getting write access, * to avoid potentially expensive unnecessary copies. */ diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc index 652368ea51f..35c8bbd5561 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc @@ -263,19 +263,18 @@ class SampleNearestFunction : public mf::MultiFunction { case GEO_COMPONENT_TYPE_MESH: { const MeshComponent &component = *static_cast(src_component_); const Mesh &mesh = *component.get_for_read(); - Array distances(mask.min_array_size()); switch (domain_) { case ATTR_DOMAIN_POINT: - get_closest_mesh_points(mesh, positions, mask, indices, distances, {}); + get_closest_mesh_points(mesh, positions, mask, indices, {}, {}); break; case ATTR_DOMAIN_EDGE: - get_closest_mesh_edges(mesh, positions, mask, indices, distances, {}); + get_closest_mesh_edges(mesh, positions, mask, indices, {}, {}); break; case ATTR_DOMAIN_FACE: - get_closest_mesh_polys(mesh, positions, mask, indices, distances, {}); + get_closest_mesh_polys(mesh, positions, mask, indices, {}, {}); break; case ATTR_DOMAIN_CORNER: - get_closest_mesh_corners(mesh, positions, mask, indices, distances, {}); + get_closest_mesh_corners(mesh, positions, mask, indices, {}, {}); break; default: break; @@ -286,8 +285,7 @@ class SampleNearestFunction : public mf::MultiFunction { const PointCloudComponent &component = *static_cast( src_component_); const PointCloud &points = *component.get_for_read(); - Array distances(mask.min_array_size()); - get_closest_pointcloud_points(points, positions, mask, indices, distances); + get_closest_pointcloud_points(points, positions, mask, indices, {}); break; } default: diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc index fe35f99c40e..ea3c7876825 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc @@ -59,7 +59,8 @@ static void node_geo_exec(GeoNodeExecParams params) for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_INSTANCES, GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, - GEO_COMPONENT_TYPE_CURVE}) { + GEO_COMPONENT_TYPE_CURVE}) + { if (geometry_set.has(type)) { set_id_in_component(geometry_set.get_component_for_write(type), selection_field, id_field); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 428bf42ae40..595f87cfa0b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -159,7 +159,8 @@ static void node_geo_exec(GeoNodeExecParams params) for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE, - GEO_COMPONENT_TYPE_INSTANCES}) { + GEO_COMPONENT_TYPE_INSTANCES}) + { if (geometry.has(type)) { set_position_in_component(geometry, type, selection_field, position_field, offset_field); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 462b332568f..9e10aa7b7f2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -160,7 +160,8 @@ static void node_geo_exec(GeoNodeExecParams params) else { geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { for (const GeometryComponentType type : - {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) { + {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) + { if (geometry_set.has(type)) { GeometryComponent &component = geometry_set.get_component_for_write(type); if (!bke::try_capture_field_on_geometry(component, name, domain, selection, field)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index f23bc101a14..027a94c544e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -333,8 +333,8 @@ static void create_attributes(GeoNodeExecParams ¶ms, { MutableAttributeAccessor attributes = instances.attributes_for_write(); - if (AnonymousAttributeIDPtr line_id = params.get_output_anonymous_attribute_id_if_needed( - "Line")) { + if (AnonymousAttributeIDPtr line_id = params.get_output_anonymous_attribute_id_if_needed("Line")) + { SpanAttributeWriter line_attribute = attributes.lookup_or_add_for_write_only_span( *line_id, ATTR_DOMAIN_INSTANCE); line_attribute.span.copy_from(layout.line_numbers); @@ -342,7 +342,8 @@ static void create_attributes(GeoNodeExecParams ¶ms, } if (AnonymousAttributeIDPtr pivot_id = params.get_output_anonymous_attribute_id_if_needed( - "Pivot Point")) { + "Pivot Point")) + { SpanAttributeWriter pivot_attribute = attributes.lookup_or_add_for_write_only_span(*pivot_id, ATTR_DOMAIN_INSTANCE); diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc index 4438e4450d3..b4816379ebb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc @@ -30,7 +30,8 @@ static bool use_translate(const float3 rotation, const float3 scale) return false; } if (compare_ff(scale.x, 1.0f, 1e-9f) != 1 || compare_ff(scale.y, 1.0f, 1e-9f) != 1 || - compare_ff(scale.z, 1.0f, 1e-9f) != 1) { + compare_ff(scale.z, 1.0f, 1e-9f) != 1) + { return false; } return true; diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc index 38817f3fefb..820f9759a17 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc @@ -129,8 +129,8 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - if (bounds_min.x == bounds_max.x || bounds_min.y == bounds_max.y || - bounds_min.z == bounds_max.z) { + if (bounds_min.x == bounds_max.x || bounds_min.y == bounds_max.y || bounds_min.z == bounds_max.z) + { params.error_message_add(NodeWarningType::Error, TIP_("Bounding box volume must be greater than 0")); params.set_default_remaining_outputs(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index 5ba2ebcc9d1..02084cf0389 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -158,11 +158,13 @@ static Mesh *create_mesh_from_volume(GeometrySet &geometry_set, GeoNodeExecParam const bke::VolumeToMeshResolution resolution = get_resolution_param(params); if (resolution.mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE && - resolution.settings.voxel_size <= 0.0f) { + resolution.settings.voxel_size <= 0.0f) + { return nullptr; } if (resolution.mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT && - resolution.settings.voxel_amount <= 0) { + resolution.settings.voxel_amount <= 0) + { return nullptr; } diff --git a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc index 1761dbda733..682e254af48 100644 --- a/source/blender/nodes/intern/geometry_nodes_lazy_function.cc +++ b/source/blender/nodes/intern/geometry_nodes_lazy_function.cc @@ -380,7 +380,8 @@ class LazyFunctionForMultiInput : public LazyFunction { const bNodeTree &btree = socket.owner_tree(); for (const bNodeLink *link : socket.directly_linked_links()) { if (link->is_muted() || !link->fromsock->is_available() || - nodeIsDanglingReroute(&btree, link->fromnode)) { + nodeIsDanglingReroute(&btree, link->fromnode)) + { continue; } inputs_.append({"Input", *base_type_}); @@ -746,8 +747,8 @@ class LazyFunctionForViewerNode : public LazyFunction { continue; } const Span links = bsocket->directly_linked_links(); - if (links.is_empty() || - nodeIsDanglingReroute(&bnode.owner_tree(), links.first()->fromnode)) { + if (links.is_empty() || nodeIsDanglingReroute(&bnode.owner_tree(), links.first()->fromnode)) + { use_field_input_ = false; inputs_.pop_last(); r_lf_index_by_bsocket[bsocket->index_in_tree()] = -1; @@ -786,15 +787,16 @@ class LazyFunctionForViewerNode : public LazyFunction { } else { geometry.modify_geometry_sets([&](GeometrySet &geometry) { - for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_MESH, - GEO_COMPONENT_TYPE_POINT_CLOUD, - GEO_COMPONENT_TYPE_CURVE}) { + for (const GeometryComponentType type : + {GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD, GEO_COMPONENT_TYPE_CURVE}) + { if (geometry.has(type)) { GeometryComponent &component = geometry.get_component_for_write(type); eAttrDomain used_domain = domain; if (used_domain == ATTR_DOMAIN_AUTO) { if (const std::optional detected_domain = - bke::try_detect_field_domain(component, field)) { + bke::try_detect_field_domain(component, field)) + { used_domain = *detected_domain; } else { @@ -902,7 +904,8 @@ class LazyFunctionForGroupNode : public LazyFunction { /* Add an attribute set input for every output geometry socket that can propagate attributes * from inputs. */ for (auto [output_index, lf_socket] : - group_lf_graph_info.mapping.attribute_set_by_geometry_output.items()) { + group_lf_graph_info.mapping.attribute_set_by_geometry_output.items()) + { const int lf_index = inputs_.append_and_get_index_as( "Attribute Set", CPPType::get(), lf::ValueUsage::Maybe); graph_inputs.append(lf_socket); @@ -1019,8 +1022,8 @@ class LazyFunctionForGroupNode : public LazyFunction { if (i < group_node_.output_sockets().size()) { return group_node_.output_socket(i).name; } - for (const auto [bsocket_index, lf_socket_index] : - lf_output_for_input_bsocket_usage_.items()) { + for (const auto [bsocket_index, lf_socket_index] : lf_output_for_input_bsocket_usage_.items()) + { if (i == lf_socket_index) { std::stringstream ss; ss << "'" << group_node_.input_socket(bsocket_index).name << "' input is used"; @@ -1163,7 +1166,8 @@ class LazyFunctionForAnonymousAttributeSetExtract : public lf::LazyFunction { const GField &field = *type_.get_field_ptr(value_or_field); field.node().for_each_field_input_recursive([&](const FieldInput &field_input) { if (const auto *attr_field_input = dynamic_cast( - &field_input)) { + &field_input)) + { if (!attributes.names) { attributes.names = std::make_shared>(); } @@ -1202,7 +1206,8 @@ class LazyFunctionForAnonymousAttributeSetJoin : public lf::LazyFunction { if (params.get_input(this->get_use_input(i))) { if (bke::AnonymousAttributeSet *set = params.try_get_input_data_ptr_or_request( - this->get_attribute_set_input(i))) { + this->get_attribute_set_input(i))) + { sets.append(set); } else { @@ -1895,7 +1900,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { break; } if (multi_input_link->is_muted() || !multi_input_link->fromsock->is_available() || - nodeIsDanglingReroute(&btree_, multi_input_link->fromnode)) { + nodeIsDanglingReroute(&btree_, multi_input_link->fromnode)) + { continue; } link_index++; @@ -2189,8 +2195,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { continue; } const bNodeSocket &target_socket = *link->tosock; - if (lf::OutputSocket *is_used_socket = - socket_is_used_map_[target_socket.index_in_tree()]) { + if (lf::OutputSocket *is_used_socket = socket_is_used_map_[target_socket.index_in_tree()]) + { target_usages.append_non_duplicates(is_used_socket); } } @@ -2389,7 +2395,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { Vector target_usages; for (const bNode *group_input_node : group_input_nodes) { if (lf::OutputSocket *lf_socket = - socket_is_used_map_[group_input_node->output_socket(i).index_in_tree()]) { + socket_is_used_map_[group_input_node->output_socket(i).index_in_tree()]) + { target_usages.append_non_duplicates(lf_socket); } } @@ -2679,8 +2686,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { required_by_geometry_socket[bsocket->index_in_tree()] |= required_attributes; bits::foreach_1_index(required_attributes, [&](const int key_index) { const AttributeReferenceKey &key = attribute_reference_keys[key_index]; - if (key.type != AttributeReferenceKeyType::Socket || - &key.bsocket->owner_node() != bnode) { + if (key.type != AttributeReferenceKeyType::Socket || &key.bsocket->owner_node() != bnode) + { r_required_propagated_to_geometry_socket[bsocket->index_in_tree()][key_index].set(); } }); @@ -2723,7 +2730,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { JoinAttibuteSetsCache join_attribute_sets_cache; for (const auto [geometry_output_bsocket, lf_attribute_set_input] : - attribute_set_propagation_map_.items()) { + attribute_set_propagation_map_.items()) + { const BoundedBitSpan required = required_propagated_to_geometry_socket[geometry_output_bsocket->index_in_tree()]; @@ -2757,7 +2765,8 @@ struct GeometryNodesLazyFunctionGraphBuilder { } }); if (lf::OutputSocket *joined_attribute_set = this->join_attribute_sets( - attribute_set_sockets, used_sockets, join_attribute_sets_cache)) { + attribute_set_sockets, used_sockets, join_attribute_sets_cache)) + { lf_graph_->add_link(*joined_attribute_set, *lf_attribute_set_input); } else { @@ -2971,7 +2980,8 @@ class UsedSocketVisualizeOptions : public lf::Graph::ToDotOptions { } } else if (lf::OutputSocket *lf_socket = builder_.output_socket_map_.lookup_default(bsocket, - nullptr)) { + nullptr)) + { socket_font_colors_.add(lf_socket, color_str); socket_name_suffixes_.add(lf_socket, suffix); } diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index c1d8a8f81b3..ca8f1ddd060 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -108,8 +108,8 @@ GeometryInfoLog::GeometryInfoLog(const GeometrySet &geometry_set) case GEO_COMPONENT_TYPE_EDIT: { const GeometryComponentEditData &edit_component = *( const GeometryComponentEditData *)component; - if (const bke::CurvesEditHints *curve_edit_hints = - edit_component.curves_edit_hints_.get()) { + if (const bke::CurvesEditHints *curve_edit_hints = edit_component.curves_edit_hints_.get()) + { EditDataInfo &info = this->edit_data_info.emplace(); info.has_deform_matrices = curve_edit_hints->deform_mats.has_value(); info.has_deformed_positions = curve_edit_hints->positions.has_value(); @@ -446,7 +446,8 @@ GeoTreeLogger &GeoModifierLog::get_local_tree_logger(const ComputeContext &compu parent_logger.children_hashes.append(compute_context.hash()); } if (const bke::NodeGroupComputeContext *node_group_compute_context = - dynamic_cast(&compute_context)) { + dynamic_cast(&compute_context)) + { tree_logger.group_node_id.emplace(node_group_compute_context->node_id()); } return tree_logger; @@ -549,7 +550,8 @@ GeoTreeLog *GeoModifierLog::get_tree_log_for_node_editor(const SpaceNode &snode) } if (const std::optional hash = GeoModifierLog::get_compute_context_hash_for_node_editor( - snode, object_and_modifier->nmd->modifier.name)) { + snode, object_and_modifier->nmd->modifier.name)) + { return &modifier_log->get_tree_log(*hash); } return nullptr; diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index b66f16f4d25..8f57851568b 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -115,7 +115,8 @@ bool nodeGroupPoll(const bNodeTree *nodetree, for (const bNode *node : grouptree->all_nodes()) { if (node->typeinfo->poll_instance && - !node->typeinfo->poll_instance(node, nodetree, r_disabled_hint)) { + !node->typeinfo->poll_instance(node, nodetree, r_disabled_hint)) + { return false; } } diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index 471e1575cc2..74dc73c84e2 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -56,7 +56,8 @@ static void node_init_input_index(bNodeSocket *sock, int *index) { /* Only consider existing link if from socket is valid! */ if (sock->link && !(sock->link->flag & NODE_LINK_MUTED) && sock->link->fromsock && - sock->link->fromsock->stack_index >= 0) { + sock->link->fromsock->stack_index >= 0) + { sock->stack_index = sock->link->fromsock->stack_index; } else { diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index a7caed7042b..f80dd433869 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -103,8 +103,8 @@ void GeoNodeExecParams::check_output_geometry_set(const GeometrySet &geometry_se { UNUSED_VARS_NDEBUG(geometry_set); #ifdef DEBUG - if (const bke::CurvesEditHints *curve_edit_hints = - geometry_set.get_curve_edit_hints_for_read()) { + if (const bke::CurvesEditHints *curve_edit_hints = geometry_set.get_curve_edit_hints_for_read()) + { /* If this is not valid, it's likely that the number of stored deformed points does not match * the number of points in the original data. */ BLI_assert(curve_edit_hints->is_valid()); diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index e88ff7255b6..c7f2266c7e6 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -473,7 +473,8 @@ static void flatten_group_do(bNodeTree *ntree, bNode *gnode) /* find external links to this input */ for (bNodeLink *tlink = static_cast(ntree->links.first); tlink != glinks_first->next; - tlink = tlink->next) { + tlink = tlink->next) + { if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) { nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock); } @@ -485,7 +486,8 @@ static void flatten_group_do(bNodeTree *ntree, bNode *gnode) /* output links */ for (bNodeLink *tlink = static_cast(ntree->links.first); tlink != glinks_first->next; - tlink = tlink->next) { + tlink = tlink->next) + { if (tlink->fromnode == gnode) { const char *identifier = tlink->fromsock->identifier; /* find internal links to this output */ @@ -515,7 +517,8 @@ static void ntree_shader_groups_flatten(bNodeTree *localtree) /* This is effectively recursive as the flattened groups will add * nodes at the end of the list, which will also get evaluated. */ for (bNode *node = static_cast(localtree->nodes.first), *node_next; node; - node = node_next) { + node = node_next) + { if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id != nullptr) { flatten_group_do(localtree, node); /* Continue even on new flattened nodes. */ @@ -544,7 +547,8 @@ static bool ntree_branch_count_and_tag_nodes(bNode *fromnode, bNode *tonode, voi { branchIterData *iter = (branchIterData *)userdata; if (fromnode->runtime->tmp_flag == -1 && - (iter->node_filter == nullptr || iter->node_filter(fromnode))) { + (iter->node_filter == nullptr || iter->node_filter(fromnode))) + { fromnode->runtime->tmp_flag = iter->node_count; iter->node_count++; } @@ -684,7 +688,8 @@ static bool ntree_weight_tree_tag_nodes(bNode *fromnode, bNode *tonode, void *us *node_count += (tonode->type == SH_NODE_MIX_SHADER) ? 4 : 1; } if (fromnode->runtime->tmp_flag == -1 && - ELEM(fromnode->type, SH_NODE_ADD_SHADER, SH_NODE_MIX_SHADER)) { + ELEM(fromnode->type, SH_NODE_ADD_SHADER, SH_NODE_MIX_SHADER)) + { fromnode->runtime->tmp_flag = *node_count; *node_count += (fromnode->type == SH_NODE_MIX_SHADER) ? 4 : 1; } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.cc b/source/blender/nodes/shader/nodes/node_shader_curves.cc index 4c81fac23e5..9933e367f90 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.cc +++ b/source/blender/nodes/shader/nodes/node_shader_curves.cc @@ -175,7 +175,8 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, /* If the RGB curves do nothing, use a function that skips RGB computations. */ if (BKE_curvemapping_is_map_identity(curve_mapping, 0) && BKE_curvemapping_is_map_identity(curve_mapping, 1) && - BKE_curvemapping_is_map_identity(curve_mapping, 2)) { + BKE_curvemapping_is_map_identity(curve_mapping, 2)) + { return GPU_stack_link(mat, node, "curves_combined_only", diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index 1e114ccee0e..80c4331a492 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -45,7 +45,8 @@ static void node_shader_buts_map_range(uiLayout *layout, bContext * /*C*/, Point uiItemR(layout, ptr, "interpolation_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); if (!ELEM(RNA_enum_get(ptr, "interpolation_type"), NODE_MAP_RANGE_SMOOTHSTEP, - NODE_MAP_RANGE_SMOOTHERSTEP)) { + NODE_MAP_RANGE_SMOOTHERSTEP)) + { uiItemR(layout, ptr, "clamp", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); } } @@ -213,7 +214,8 @@ static int gpu_shader_map_range(GPUMaterial *mat, ret = GPU_stack_link(mat, node, "map_range_linear", in, out, GPU_constant(&clamp)); } if (ret && storage.clamp && !use_vector && - !ELEM(storage.interpolation_type, NODE_MAP_RANGE_SMOOTHSTEP, NODE_MAP_RANGE_SMOOTHERSTEP)) { + !ELEM(storage.interpolation_type, NODE_MAP_RANGE_SMOOTHSTEP, NODE_MAP_RANGE_SMOOTHERSTEP)) + { GPU_link(mat, "clamp_range", out[0].link, in[3].link, in[4].link, &out[0].link); } return ret; diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index 03bd924b79a..71b43dd82de 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -46,7 +46,8 @@ class SocketSearchOp { static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams ¶ms) { if (!params.node_tree().typeinfo->validate_link( - static_cast(params.other_socket().type), SOCK_FLOAT)) { + static_cast(params.other_socket().type), SOCK_FLOAT)) + { return; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc index 2887b89b832..ce98ffb0616 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc @@ -102,7 +102,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, if (out[0].hasoutput && ima) { if (ELEM(ima->alpha_mode, IMA_ALPHA_IGNORE, IMA_ALPHA_CHANNEL_PACKED) || - IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) { + IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) + { /* Don't let alpha affect color output in these cases. */ GPU_link(mat, "color_alpha_clear", out[0].link, &out[0].link); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc index ff66b021ac2..78b3233b879 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc @@ -134,7 +134,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, if (out[0].hasoutput) { if (ELEM(ima->alpha_mode, IMA_ALPHA_IGNORE, IMA_ALPHA_CHANNEL_PACKED) || - IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) { + IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) + { /* Don't let alpha affect color output in these cases. */ GPU_link(mat, "color_alpha_clear", out[0].link, &out[0].link); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc index fb18a59fef1..589dbbd46d2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc @@ -183,7 +183,8 @@ class MusgraveFunction : public mf::MultiFunction { if (ELEM(musgrave_type, SHD_MUSGRAVE_RIDGED_MULTIFRACTAL, SHD_MUSGRAVE_HYBRID_MULTIFRACTAL, - SHD_MUSGRAVE_HETERO_TERRAIN)) { + SHD_MUSGRAVE_HETERO_TERRAIN)) + { builder.single_input("Offset"); } if (ELEM(musgrave_type, SHD_MUSGRAVE_RIDGED_MULTIFRACTAL, SHD_MUSGRAVE_HYBRID_MULTIFRACTAL)) { diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 0475b3e88bf..55f5fda3317 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -286,7 +286,8 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) return; } if (params.node_tree().typeinfo->validate_link( - static_cast(params.other_socket().type), SOCK_FLOAT)) { + static_cast(params.other_socket().type), SOCK_FLOAT)) + { params.add_item(IFACE_("Vector"), [](LinkSearchOpParams ¶ms) { bNode &node = params.add_node("ShaderNodeTexSky"); NodeTexSky *tex = (NodeTexSky *)node.storage; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 585d1071cca..42932c11241 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -57,7 +57,8 @@ static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext * /*C*/, Poi uiItemR(layout, ptr, "feature", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); int feature = RNA_enum_get(ptr, "feature"); if (!ELEM(feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS) && - RNA_enum_get(ptr, "voronoi_dimensions") != 1) { + RNA_enum_get(ptr, "voronoi_dimensions") != 1) + { uiItemR(layout, ptr, "distance", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index e303b0766d2..665395de156 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -48,19 +48,22 @@ class SocketSearchOp { static void sh_node_vector_math_gather_link_searches(GatherLinkSearchOpParams ¶ms) { if (!params.node_tree().typeinfo->validate_link( - static_cast(params.other_socket().type), SOCK_VECTOR)) { + static_cast(params.other_socket().type), SOCK_VECTOR)) + { return; } const int weight = ELEM(params.other_socket().type, SOCK_VECTOR, SOCK_RGBA) ? 0 : -1; for (const EnumPropertyItem *item = rna_enum_node_vec_math_items; item->identifier != nullptr; - item++) { + item++) + { if (item->name != nullptr && item->identifier[0] != '\0') { if ((params.in_out() == SOCK_OUT) && ELEM(item->value, NODE_VECTOR_MATH_LENGTH, NODE_VECTOR_MATH_DISTANCE, - NODE_VECTOR_MATH_DOT_PRODUCT)) { + NODE_VECTOR_MATH_DOT_PRODUCT)) + { params.add_item(IFACE_(item->name), SocketSearchOp{"Value", (NodeVectorMathOperation)item->value}, weight); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc index f72c1b4428a..9013f197a21 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc @@ -111,14 +111,16 @@ static int gpu_shader_vect_transform(GPUMaterial *mat, /* For cycles we have inverted Z */ /* TODO: pass here the correct matrices */ if (nodeprop->convert_from == SHD_VECT_TRANSFORM_SPACE_CAMERA && - nodeprop->convert_to != SHD_VECT_TRANSFORM_SPACE_CAMERA) { + nodeprop->convert_to != SHD_VECT_TRANSFORM_SPACE_CAMERA) + { GPU_link(mat, "invert_z", inputlink, &inputlink); } GPU_link(mat, func_name, inputlink, &out[0].link); if (nodeprop->convert_to == SHD_VECT_TRANSFORM_SPACE_CAMERA && - nodeprop->convert_from != SHD_VECT_TRANSFORM_SPACE_CAMERA) { + nodeprop->convert_from != SHD_VECT_TRANSFORM_SPACE_CAMERA) + { GPU_link(mat, "invert_z", out[0].link, &out[0].link); } } diff --git a/source/blender/nodes/texture/node_texture_tree.cc b/source/blender/nodes/texture/node_texture_tree.cc index 684e1d1ae21..3f84895b5d4 100644 --- a/source/blender/nodes/texture/node_texture_tree.cc +++ b/source/blender/nodes/texture/node_texture_tree.cc @@ -261,8 +261,8 @@ static void tex_free_delegates(bNodeTreeExec *exec) int th, a; for (th = 0; th < BLENDER_MAX_THREADS; th++) { - for (nts = static_cast(exec->threadstack[th].first); nts; - nts = nts->next) { + for (nts = static_cast(exec->threadstack[th].first); nts; nts = nts->next) + { for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++) { if (ns->data && !ns->is_copy) { MEM_freeN(ns->data); @@ -281,8 +281,8 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec) tex_free_delegates(exec); for (a = 0; a < BLENDER_MAX_THREADS; a++) { - for (nts = static_cast(exec->threadstack[a].first); nts; - nts = nts->next) { + for (nts = static_cast(exec->threadstack[a].first); nts; nts = nts->next) + { if (nts->stack) { MEM_freeN(nts->stack); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.cc b/source/blender/nodes/texture/nodes/node_texture_bricks.cc index c215ab68c95..f0cee1d995d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.cc +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.cc @@ -80,7 +80,8 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor CLAMP(tint, 0.0f, 1.0f); if (ins_x < mortar_thickness || ins_y < mortar_thickness || - ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness)) { + ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness)) + { copy_v4_v4(out, mortar); } else { diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index 53b65a14538..448eeb4eca9 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -47,7 +47,8 @@ static PyObject *bpy_bm_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw bool use_operators = true; if (!PyArg_ParseTupleAndKeywords( - args, kw, "|$O&:new", (char **)kwlist, PyC_ParseBool, &use_operators)) { + args, kw, "|$O&:new", (char **)kwlist, PyC_ParseBool, &use_operators)) + { return NULL; } @@ -115,7 +116,8 @@ static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args, PyC_ParseBool, &do_loop_triangles, PyC_ParseBool, - &is_destructive)) { + &is_destructive)) + { return NULL; } diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c index 5c8687fbf21..7d9ee2539c9 100644 --- a/source/blender/python/bmesh/bmesh_py_ops_call.c +++ b/source/blender/python/bmesh/bmesh_py_ops_call.c @@ -259,7 +259,8 @@ static int bpy_slot_from_py(BMesh *bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP), opname, slot_name, - "single element") == -1) { + "single element") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -283,7 +284,8 @@ static int bpy_slot_from_py(BMesh *bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP), opname, slot_name, - "element buffer") == -1) { + "element buffer") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -296,7 +298,8 @@ static int bpy_slot_from_py(BMesh *bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP), opname, slot_name, - "element buffer") == -1) { + "element buffer") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -309,7 +312,8 @@ static int bpy_slot_from_py(BMesh *bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP), opname, slot_name, - "element buffer") == -1) { + "element buffer") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } BMO_slot_buffer_from_all(bm, bmop, bmop->slots_in, slot_name, BM_FACE); @@ -328,7 +332,8 @@ static int bpy_slot_from_py(BMesh *bm, (slot->slot_subtype.elem & BM_ALL_NOLOOP), opname, slot_name, - "element buffer") == -1) { + "element buffer") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -417,7 +422,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid key in dict") == -1) { + "invalid key in dict") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -426,7 +432,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid value in dict") == -1) { + "invalid value in dict") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -448,7 +455,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid key in dict") == -1) { + "invalid key in dict") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -481,7 +489,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid key in dict") == -1) { + "invalid key in dict") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -514,7 +523,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid key in dict") == -1) { + "invalid key in dict") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -547,7 +557,8 @@ static int bpy_slot_from_py(BMesh *bm, BM_ALL_NOLOOP, opname, slot_name, - "invalid key in set") == -1) { + "invalid key in set") == -1) + { return -1; /* error is set in bpy_slot_from_py_elem_check() */ } @@ -738,7 +749,8 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) BMOperator bmop; if ((PyTuple_GET_SIZE(args) == 1) && (py_bm = (BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) && - BPy_BMesh_Check(py_bm)) { + BPy_BMesh_Check(py_bm)) + { BPY_BM_CHECK_OBJ(py_bm); bm = py_bm->bm; diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 42428282dbc..ea723bd592a 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -274,7 +274,8 @@ static int bpy_bmesh_select_mode_set(BPy_BMesh *self, PyObject *value) BPY_BM_CHECK_INT(self); if (PyC_FlagSet_ToBitfield(bpy_bm_scene_vert_edge_face_flags, value, &flag, "bm.select_mode") == - -1) { + -1) + { return -1; } if (flag == 0) { @@ -1018,8 +1019,8 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args) BPY_BM_CHECK_OBJ(self); - if (!PyArg_ParseTuple(args, "O:to_mesh", &py_mesh) || - !(me = PyC_RNA_AsPointer(py_mesh, "Mesh"))) { + if (!PyArg_ParseTuple(args, "O:to_mesh", &py_mesh) || !(me = PyC_RNA_AsPointer(py_mesh, "Mesh"))) + { return NULL; } @@ -1100,7 +1101,8 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject PyC_ParseBool, &use_vert_normal) || !(ob = PyC_RNA_AsPointer(py_object, "Object")) || - !(depsgraph = PyC_RNA_AsPointer(py_depsgraph, "Depsgraph"))) { + !(depsgraph = PyC_RNA_AsPointer(py_depsgraph, "Depsgraph"))) + { return NULL; } @@ -1206,7 +1208,8 @@ static PyObject *bpy_bmesh_from_mesh(BPy_BMesh *self, PyObject *args, PyObject * PyC_ParseBool, &use_shape_key, &shape_key_index) || - !(me = PyC_RNA_AsPointer(py_mesh, "Mesh"))) { + !(me = PyC_RNA_AsPointer(py_mesh, "Mesh"))) + { return NULL; } @@ -1303,14 +1306,9 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject BPY_BM_CHECK_OBJ(self); - if (!PyArg_ParseTupleAndKeywords(args, - kw, - "O!|$O!:transform", - (char **)kwlist, - &matrix_Type, - &mat, - &PySet_Type, - &filter)) { + if (!PyArg_ParseTupleAndKeywords( + args, kw, "O!|$O!:transform", (char **)kwlist, &matrix_Type, &mat, &PySet_Type, &filter)) + { return NULL; } @@ -1326,8 +1324,9 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject return NULL; } - if (filter != NULL && PyC_FlagSet_ToBitfield( - bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1) { + if (filter != NULL && + PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1) + { return NULL; } @@ -1367,7 +1366,8 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec BPY_BM_CHECK_OBJ(self); if (!PyArg_ParseTupleAndKeywords( - args, kw, "|$O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed)) { + args, kw, "|$O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed)) + { return NULL; } @@ -1832,7 +1832,8 @@ static PyObject *bpy_bmface_copy_from_face_interp(BPy_BMFace *self, PyObject *ar &BPy_BMFace_Type, &py_face, PyC_ParseBool, - &do_vertex)) { + &do_vertex)) + { return NULL; } @@ -1874,7 +1875,8 @@ static PyObject *bpy_bmface_copy(BPy_BMFace *self, PyObject *args, PyObject *kw) PyC_ParseBool, &do_verts, PyC_ParseBool, - &do_edges)) { + &do_edges)) + { return NULL; } @@ -2087,7 +2089,8 @@ static PyObject *bpy_bmloop_copy_from_face_interp(BPy_BMLoop *self, PyObject *ar PyC_ParseBool, &do_vertex, PyC_ParseBool, - &do_multires)) { + &do_multires)) + { return NULL; } @@ -2670,7 +2673,8 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObjec (char **)kwlist, &keyfunc, PyC_ParseBool, - &do_reverse)) { + &do_reverse)) + { return NULL; } } diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 2e77e2677b8..8ebe89e1a6b 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -203,8 +203,8 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source, #define BPY_BM_CHECK_SOURCE_OBJ(bm, errmsg, ...) \ { \ void *_args[] = {__VA_ARGS__}; \ - if (UNLIKELY(bpy_bm_generic_valid_check_source(bm, errmsg, _args, ARRAY_SIZE(_args)) == \ - -1)) { \ + if (UNLIKELY(bpy_bm_generic_valid_check_source(bm, errmsg, _args, ARRAY_SIZE(_args)) == -1)) \ + { \ return NULL; \ } \ } \ @@ -212,8 +212,8 @@ int bpy_bm_generic_valid_check_source(BMesh *bm_source, #define BPY_BM_CHECK_SOURCE_INT(bm, errmsg, ...) \ { \ void *_args[] = {__VA_ARGS__}; \ - if (UNLIKELY(bpy_bm_generic_valid_check_source(bm, errmsg, _args, ARRAY_SIZE(_args)) == \ - -1)) { \ + if (UNLIKELY(bpy_bm_generic_valid_check_source(bm, errmsg, _args, ARRAY_SIZE(_args)) == -1)) \ + { \ return -1; \ } \ } \ diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 050557e4120..667251f166c 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -1266,8 +1266,8 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj } case CD_SHAPEKEY: { float tmp_val[3]; - if (UNLIKELY(mathutils_array_parse(tmp_val, 3, 3, py_value, "BMVert[shape] = value") == - -1)) { + if (UNLIKELY(mathutils_array_parse(tmp_val, 3, 3, py_value, "BMVert[shape] = value") == -1)) + { ret = -1; } else { diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index f8ef9d1012d..cd89f37e268 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -43,12 +43,9 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec BMesh *bm; BMEdge *e_new = NULL; - if (!PyArg_ParseTuple(args, - "O!O!:vert_collapse_edge", - &BPy_BMVert_Type, - &py_vert, - &BPy_BMEdge_Type, - &py_edge)) { + if (!PyArg_ParseTuple( + args, "O!O!:vert_collapse_edge", &BPy_BMVert_Type, &py_vert, &BPy_BMEdge_Type, &py_edge)) + { return NULL; } @@ -116,7 +113,8 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje &BPy_BMEdge_Type, &py_edge, &fac, - &do_join_faces)) { + &do_join_faces)) + { return NULL; } @@ -196,12 +194,9 @@ static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args bool ok; - if (!PyArg_ParseTuple(args, - "O!O!:vert_splice", - &BPy_BMVert_Type, - &py_vert, - &BPy_BMVert_Type, - &py_vert_target)) { + if (!PyArg_ParseTuple( + args, "O!O!:vert_splice", &BPy_BMVert_Type, &py_vert, &BPy_BMVert_Type, &py_vert_target)) + { return NULL; } @@ -315,13 +310,9 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args) BMVert *v_new = NULL; BMEdge *e_new = NULL; - if (!PyArg_ParseTuple(args, - "O!O!f:edge_split", - &BPy_BMEdge_Type, - &py_edge, - &BPy_BMVert_Type, - &py_vert, - &fac)) { + if (!PyArg_ParseTuple( + args, "O!O!f:edge_split", &BPy_BMEdge_Type, &py_edge, &BPy_BMVert_Type, &py_vert, &fac)) + { return NULL; } @@ -372,7 +363,8 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args BMEdge *e_new = NULL; if (!PyArg_ParseTuple( - args, "O!|O&:edge_rotate", &BPy_BMEdge_Type, &py_edge, PyC_ParseBool, &do_ccw)) { + args, "O!|O&:edge_rotate", &BPy_BMEdge_Type, &py_edge, PyC_ParseBool, &do_ccw)) + { return NULL; } @@ -446,7 +438,8 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, PyC_ParseBool, &edge_exists, &BPy_BMEdge_Type, - &py_edge_example)) { + &py_edge_example)) + { return NULL; } @@ -460,7 +453,8 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, /* this doubles for checking that the verts are in the same mesh */ if ((l_a = BM_face_vert_share_loop(py_face->f, py_vert_a->v)) && - (l_b = BM_face_vert_share_loop(py_face->f, py_vert_b->v))) { + (l_b = BM_face_vert_share_loop(py_face->f, py_vert_b->v))) + { /* pass */ } else { @@ -564,7 +558,8 @@ static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self), (char **)kwlist, &BPy_BMFace_Type, &py_face, - &edge_seq)) { + &edge_seq)) + { return NULL; } @@ -674,12 +669,9 @@ static PyObject *bpy_bm_utils_face_vert_separate(PyObject *UNUSED(self), PyObjec BMLoop *l; BMVert *v_old, *v_new; - if (!PyArg_ParseTuple(args, - "O!O!:face_vert_separate", - &BPy_BMFace_Type, - &py_face, - &BPy_BMVert_Type, - &py_vert)) { + if (!PyArg_ParseTuple( + args, "O!O!:face_vert_separate", &BPy_BMFace_Type, &py_face, &BPy_BMVert_Type, &py_vert)) + { return NULL; } diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index eee6790f6a2..439b0c48705 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -825,7 +825,8 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject pybuffer.format); } else if (ndimensions != pybuffer.ndim || - !compare_dimensions(ndimensions, dimensions, pybuffer.shape)) { + !compare_dimensions(ndimensions, dimensions, pybuffer.shape)) + { PyErr_Format(PyExc_TypeError, "array size does not match"); } else { diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index 2b7c5ed7e55..bd86dea082b 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -123,8 +123,8 @@ static PyObject *py_blf_color(PyObject *UNUSED(self), PyObject *args) int fontid; float rgba[4]; - if (!PyArg_ParseTuple( - args, "iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) { + if (!PyArg_ParseTuple(args, "iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) + { return NULL; } @@ -361,7 +361,8 @@ static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args) float rgba[4]; if (!PyArg_ParseTuple( - args, "iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) { + args, "iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) + { return NULL; } diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index af6aad796dd..f2fe31d973e 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -608,7 +608,8 @@ static IDProperty *idp_from_PySequence(const char *name, PyObject *ob) else { const char format = PyC_StructFmt_type_from_str(buffer.format); if (PyC_StructFmt_type_is_float_any(format) || - (PyC_StructFmt_type_is_int_any(format) && buffer.itemsize == 4)) { + (PyC_StructFmt_type_is_int_any(format) && buffer.itemsize == 4)) + { use_buffer = true; } else { @@ -737,7 +738,8 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, * obviously this isn't a complete solution, but helps for common cases. */ prop_exist = IDP_GetPropertyFromGroup(group, prop->name); if ((prop_exist != NULL) && (prop_exist->type == prop->type) && - (prop_exist->subtype == prop->subtype)) { + (prop_exist->subtype == prop->subtype)) + { /* Preserve prev/next links!!! See #42593. */ prop->prev = prop_exist->prev; prop->next = prop_exist->next; diff --git a/source/blender/python/generic/idprop_py_ui_api.c b/source/blender/python/generic/idprop_py_ui_api.c index ad26fe273ed..b87d40db2ef 100644 --- a/source/blender/python/generic/idprop_py_ui_api.c +++ b/source/blender/python/generic/idprop_py_ui_api.c @@ -58,7 +58,8 @@ static bool idprop_ui_data_update_base(IDPropertyUIData *ui_data, if (pyrna_enum_value_from_id(rna_enum_property_subtype_items, rna_subtype, &ui_data->rna_subtype, - "IDPropertyUIManager.update") == -1) { + "IDPropertyUIManager.update") == -1) + { return false; } } @@ -88,7 +89,8 @@ static bool idprop_ui_data_update_int_default(IDProperty *idprop, int *new_default_array = (int *)MEM_malloc_arrayN(len, sizeof(int), __func__); if (PyC_AsArray( new_default_array, sizeof(int), default_value, len, &PyLong_Type, "ui_data_update") == - -1) { + -1) + { MEM_freeN(new_default_array); return false; } @@ -130,7 +132,8 @@ static bool idprop_ui_data_update_int(IDProperty *idprop, PyObject *args, PyObje &step, &default_value, &rna_subtype, - &description)) { + &description)) + { return false; } @@ -202,7 +205,8 @@ static bool idprop_ui_data_update_bool_default(IDProperty *idprop, default_value, len, &PyBool_Type, - "ui_data_update") == -1) { + "ui_data_update") == -1) + { MEM_freeN(new_default_array); return false; } @@ -237,7 +241,8 @@ static bool idprop_ui_data_update_bool(IDProperty *idprop, PyObject *args, PyObj (char **)kwlist, &default_value, &rna_subtype, - &description)) { + &description)) + { return false; } @@ -285,7 +290,8 @@ static bool idprop_ui_data_update_float_default(IDProperty *idprop, default_value, len, &PyFloat_Type, - "ui_data_update") == -1) { + "ui_data_update") == -1) + { MEM_freeN(new_default_array); return false; } @@ -337,7 +343,8 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb &precision, &default_value, &rna_subtype, - &description)) { + &description)) + { return false; } @@ -406,7 +413,8 @@ static bool idprop_ui_data_update_string(IDProperty *idprop, PyObject *args, PyO (char **)kwlist, &default_value, &rna_subtype, - &description)) { + &description)) + { return false; } @@ -438,7 +446,8 @@ static bool idprop_ui_data_update_id(IDProperty *idprop, PyObject *args, PyObjec const char *description = NULL; const char *kwlist[] = {"subtype", "description", NULL}; if (!PyArg_ParseTupleAndKeywords( - args, kwargs, "|$zz:update", (char **)kwlist, &rna_subtype, &description)) { + args, kwargs, "|$zz:update", (char **)kwlist, &rna_subtype, &description)) + { return false; } diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c index 925e47afaf5..d0deae67415 100644 --- a/source/blender/python/generic/imbuf_py_api.c +++ b/source/blender/python/generic/imbuf_py_api.c @@ -101,7 +101,8 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw) 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) { + args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) + { return NULL; } if (size[0] <= 0 || size[1] <= 0) { @@ -145,7 +146,8 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw) 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax)) { + args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax)) + { return NULL; } @@ -156,7 +158,8 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw) /* X order. */ !(crop.xmin <= crop.xmax) || /* Y order. */ - !(crop.ymin <= crop.ymax)) { + !(crop.ymin <= crop.ymax)) + { PyErr_SetString(PyExc_ValueError, "ImBuf crop min/max not in range"); return NULL; } @@ -261,7 +264,7 @@ static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure)) { PY_IMBUF_CHECK_OBJ(self); ImBuf *ibuf = self->ibuf; - return PyC_UnicodeFromBytes(ibuf->name); + return PyC_UnicodeFromBytes(ibuf->filepath); } static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure)) @@ -274,14 +277,14 @@ static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(c } ImBuf *ibuf = self->ibuf; - const Py_ssize_t value_str_len_max = sizeof(ibuf->name); + const Py_ssize_t value_str_len_max = sizeof(ibuf->filepath); Py_ssize_t value_str_len; const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len); if (value_str_len >= value_str_len_max) { PyErr_Format(PyExc_TypeError, "filepath length over %zd", value_str_len_max - 1); return -1; } - memcpy(ibuf->name, value_str, value_str_len + 1); + memcpy(ibuf->filepath, value_str, value_str_len + 1); return 0; } @@ -334,8 +337,11 @@ static PyObject *py_imbuf_repr(Py_ImBuf *self) { const ImBuf *ibuf = self->ibuf; if (ibuf != NULL) { - return PyUnicode_FromFormat( - "", ibuf, ibuf->name, ibuf->x, ibuf->y); + return PyUnicode_FromFormat("", + ibuf, + ibuf->filepath, + ibuf->x, + ibuf->y); } return PyUnicode_FromString(""); @@ -490,7 +496,7 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject * return NULL; } - BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); return Py_ImBuf_CreatePyObject(ibuf); } @@ -524,7 +530,7 @@ static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject } if (filepath == NULL) { - filepath = py_imb->ibuf->name; + filepath = py_imb->ibuf->filepath; } const bool ok = IMB_saveiff(py_imb->ibuf, filepath, IB_rect); diff --git a/source/blender/python/generic/py_capi_rna.c b/source/blender/python/generic/py_capi_rna.c index 8bb91d311cd..86a00133be8 100644 --- a/source/blender/python/generic/py_capi_rna.c +++ b/source/blender/python/generic/py_capi_rna.c @@ -200,7 +200,8 @@ int pyrna_enum_value_parse_string(PyObject *o, void *p) } struct BPy_EnumProperty_Parse *parse_data = p; if (pyrna_enum_value_from_id( - parse_data->items, identifier, &parse_data->value, "enum identifier") == -1) { + parse_data->items, identifier, &parse_data->value, "enum identifier") == -1) + { return 0; } @@ -218,7 +219,8 @@ int pyrna_enum_bitfield_parse_set(PyObject *o, void *p) struct BPy_EnumProperty_Parse *parse_data = p; if (pyrna_enum_bitfield_from_set( - parse_data->items, o, &parse_data->value, "enum identifier set") == -1) { + parse_data->items, o, &parse_data->value, "enum identifier set") == -1) + { return 0; } parse_data->value_orig = o; diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index b7b18aa79a1..f4bb31c7522 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -214,8 +214,8 @@ static int PyC_AsArray_Multi_FAST_impl(void **array_p, const int length = dims[0]; if (dims_len == 1) { - if (PyC_AsArray_FAST(*array_p, array_item_size, value_fast, length, type, error_prefix) == - -1) { + if (PyC_AsArray_FAST(*array_p, array_item_size, value_fast, length, type, error_prefix) == -1) + { return -1; } *array_p = POINTER_OFFSET(*array_p, array_item_size * length); @@ -241,7 +241,8 @@ static int PyC_AsArray_Multi_FAST_impl(void **array_p, dims_next, dims_next_len, type, - error_prefix) == -1) { + error_prefix) == -1) + { return -1; } } @@ -1309,7 +1310,8 @@ void *PyC_RNA_AsPointer(PyObject *value, const char *type_name) if (STREQ(Py_TYPE(value)->tp_name, type_name) && (as_pointer = PyObject_GetAttrString(value, "as_pointer")) != NULL && - PyCallable_Check(as_pointer)) { + PyCallable_Check(as_pointer)) + { void *result = NULL; /* must be a 'type_name' object */ diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index 9df37a41892..9c3d4ad6bab 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -71,7 +71,8 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args, &BPyGPUVertBuf_Type, &py_vertbuf, &BPyGPUIndexBuf_Type, - &py_indexbuf)) { + &py_indexbuf)) + { return NULL; } @@ -136,8 +137,8 @@ static PyObject *pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_bu return NULL; } - if (GPU_vertbuf_get_vertex_len(self->batch->verts[0]) != - GPU_vertbuf_get_vertex_len(py_buf->buf)) { + if (GPU_vertbuf_get_vertex_len(self->batch->verts[0]) != GPU_vertbuf_get_vertex_len(py_buf->buf)) + { PyErr_Format(PyExc_TypeError, "Expected %d length, got %d", GPU_vertbuf_get_vertex_len(self->batch->verts[0]), @@ -264,7 +265,8 @@ static PyObject *pygpu_batch_draw_instanced(BPyGPUBatch *self, PyObject *args, P 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &BPyGPUShader_Type, &py_program, &instance_start, &instance_count)) { + args, kw, &_parser, &BPyGPUShader_Type, &py_program, &instance_start, &instance_count)) + { return NULL; } @@ -305,7 +307,8 @@ static PyObject *pygpu_batch_draw_range(BPyGPUBatch *self, PyObject *args, PyObj 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &BPyGPUShader_Type, &py_program, &elem_start, &elem_count)) { + args, kw, &_parser, &BPyGPUShader_Type, &py_program, &elem_start, &elem_count)) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_buffer.c b/source/blender/python/gpu/gpu_py_buffer.c index 0d64498dbbf..b20052b347b 100644 --- a/source/blender/python/gpu/gpu_py_buffer.c +++ b/source/blender/python/gpu/gpu_py_buffer.c @@ -46,7 +46,8 @@ static bool pygpu_buffer_dimensions_tot_len_compare(const Py_ssize_t *shape_a, const Py_ssize_t shape_b_len) { if (pygpu_buffer_dimensions_tot_elem(shape_a, shape_a_len) != - pygpu_buffer_dimensions_tot_elem(shape_b, shape_b_len)) { + pygpu_buffer_dimensions_tot_elem(shape_b, shape_b_len)) + { PyErr_Format(PyExc_BufferError, "array size does not match"); return false; } @@ -382,7 +383,8 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject *UNUSED(type), PyObject *args const struct PyC_StringEnum pygpu_dataformat = {bpygpu_dataformat_items, GPU_DATA_FLOAT}; if (!PyArg_ParseTuple( - args, "O&O|O: Buffer", PyC_ParseStringEnum, &pygpu_dataformat, &length_ob, &init)) { + args, "O&O|O: Buffer", PyC_ParseStringEnum, &pygpu_dataformat, &length_ob, &init)) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c index d150a51ba04..e559e6c70e5 100644 --- a/source/blender/python/gpu/gpu_py_element.c +++ b/source/blender/python/gpu/gpu_py_element.c @@ -72,7 +72,8 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar } if (pybuffer.itemsize != 4 || - PyC_StructFmt_type_is_float_any(PyC_StructFmt_type_from_str(pybuffer.format))) { + PyC_StructFmt_type_is_float_any(PyC_StructFmt_type_from_str(pybuffer.format))) + { PyErr_Format(PyExc_ValueError, "Each index must be an 4-bytes integer value"); PyBuffer_Release(&pybuffer); return NULL; diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c index a451019a06b..b89ca246467 100644 --- a/source/blender/python/gpu/gpu_py_framebuffer.c +++ b/source/blender/python/gpu/gpu_py_framebuffer.c @@ -284,7 +284,8 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self), 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, &depth_attachment, &color_attachements)) { + args, kwds, &_parser, &depth_attachment, &color_attachements)) + { return NULL; } @@ -514,7 +515,8 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self, PyC_ParseStringEnum, &pygpu_dataformat, &BPyGPU_BufferType, - &py_buffer)) { + &py_buffer)) + { return NULL; } @@ -598,7 +600,8 @@ static PyObject *pygpu_framebuffer_read_depth(BPyGPUFrameBuffer *self, 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, &x, &y, &w, &h, &BPyGPU_BufferType, &py_buffer)) { + args, kwds, &_parser, &x, &y, &w, &h, &BPyGPU_BufferType, &py_buffer)) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_matrix.c b/source/blender/python/gpu/gpu_py_matrix.c index 414c7751926..4c9ff0bdf0f 100644 --- a/source/blender/python/gpu/gpu_py_matrix.c +++ b/source/blender/python/gpu/gpu_py_matrix.c @@ -291,7 +291,8 @@ static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value) float scale[3]; int len; if ((len = mathutils_array_parse( - scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1) { + scale, 2, 3, value, "gpu.matrix.scale(): invalid vector arg")) == -1) + { return NULL; } if (len == 2) { @@ -331,7 +332,8 @@ static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value) float offset[3]; int len; if ((len = mathutils_array_parse( - offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1) { + offset, 2, 3, value, "gpu.matrix.translate(): invalid vector arg")) == -1) + { return NULL; } if (len == 2) { diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 1a425024315..dfbdd3f4cd1 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -227,7 +227,8 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self), 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat)) { + args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat)) + { return NULL; } @@ -369,7 +370,8 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar (!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) || !(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) || !(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) || - !(region = PyC_RNA_AsPointer(py_region, "Region")))) { + !(region = PyC_RNA_AsPointer(py_region, "Region")))) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 80c22bd7a97..1b737faaee5 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -126,7 +126,8 @@ static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args ¶ms.geocode, ¶ms.libcode, ¶ms.defines, - ¶ms.name)) { + ¶ms.name)) + { return NULL; } @@ -219,7 +220,8 @@ static bool pygpu_shader_uniform_vector_impl(PyObject *args, *r_count = 1; if (!PyArg_ParseTuple( - args, "iOi|i:GPUShader.uniform_vector_*", r_location, &buffer, r_length, r_count)) { + args, "iOi|i:GPUShader.uniform_vector_*", r_location, &buffer, r_length, r_count)) + { return false; } @@ -286,8 +288,8 @@ static PyObject *pygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *a Py_buffer pybuffer; - if (!pygpu_shader_uniform_vector_impl( - args, sizeof(int), &location, &length, &count, &pybuffer)) { + if (!pygpu_shader_uniform_vector_impl(args, sizeof(int), &location, &length, &count, &pybuffer)) + { return NULL; } @@ -528,7 +530,8 @@ static PyObject *pygpu_shader_uniform_sampler(BPyGPUShader *self, PyObject *args const char *name; BPyGPUTexture *py_texture; if (!PyArg_ParseTuple( - args, "sO!:GPUShader.uniform_sampler", &name, &BPyGPUTexture_Type, &py_texture)) { + args, "sO!:GPUShader.uniform_sampler", &name, &BPyGPUTexture_Type, &py_texture)) + { return NULL; } @@ -851,7 +854,8 @@ static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg pyc_parse_buitinshader_w_backward_compatibility, &pygpu_bultinshader, PyC_ParseStringEnum, - &pygpu_config)) { + &pygpu_config)) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_shader_create_info.cc b/source/blender/python/gpu/gpu_py_shader_create_info.cc index deb8653eb18..b60cbbf918a 100644 --- a/source/blender/python/gpu/gpu_py_shader_create_info.cc +++ b/source/blender/python/gpu/gpu_py_shader_create_info.cc @@ -499,7 +499,8 @@ static PyObject *pygpu_shader_info_fragment_out(BPyGPUShaderCreateInfo *self, &pygpu_type, &name, PyC_ParseStringEnum, - &blend_type)) { + &blend_type)) + { return nullptr; } @@ -604,13 +605,15 @@ static PyObject *pygpu_shader_info_image(BPyGPUShaderCreateInfo *self, PyC_ParseStringEnum, &pygpu_imagetype, &name, - &py_qualifiers)) { + &py_qualifiers)) + { return nullptr; } if (py_qualifiers && PyC_FlagSet_ToBitfield( - pygpu_qualifiers, py_qualifiers, (int *)&qualifier, "shader_info.image") == -1) { + pygpu_qualifiers, py_qualifiers, (int *)&qualifier, "shader_info.image") == -1) + { return nullptr; } @@ -775,7 +778,8 @@ static PyObject *pygpu_shader_info_push_constant(BPyGPUShaderCreateInfo *self, nullptr, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_type, &name, &array_size)) { + args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_type, &name, &array_size)) + { return nullptr; } diff --git a/source/blender/python/gpu/gpu_py_texture.c b/source/blender/python/gpu/gpu_py_texture.c index a49866a6560..be2e19f4ff9 100644 --- a/source/blender/python/gpu/gpu_py_texture.c +++ b/source/blender/python/gpu/gpu_py_texture.c @@ -140,7 +140,8 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg PyC_ParseStringEnum, &pygpu_textureformat, &BPyGPU_BufferType, - &pybuffer_obj)) { + &pybuffer_obj)) + { return NULL; } @@ -301,7 +302,8 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_dataformat, &py_values)) { + args, kwds, &_parser, PyC_ParseStringEnum, &pygpu_dataformat, &py_values)) + { return NULL; } @@ -315,8 +317,8 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje return NULL; } - if (shape != 1 && - ELEM(pygpu_dataformat.value_found, GPU_DATA_UINT_24_8, GPU_DATA_10_11_11_REV)) { + if (shape != 1 && ELEM(pygpu_dataformat.value_found, GPU_DATA_UINT_24_8, GPU_DATA_10_11_11_REV)) + { PyErr_SetString(PyExc_AttributeError, "`UINT_24_8` and `10_11_11_REV` only support single values"); return NULL; @@ -329,7 +331,8 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje py_values, shape, (pygpu_dataformat.value_found == GPU_DATA_FLOAT) ? &PyFloat_Type : &PyLong_Type, - "clear") == -1) { + "clear") == -1) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_vertex_buffer.c b/source/blender/python/gpu/gpu_py_vertex_buffer.c index fd36c0a2d71..827feb7dda0 100644 --- a/source/blender/python/gpu/gpu_py_vertex_buffer.c +++ b/source/blender/python/gpu/gpu_py_vertex_buffer.c @@ -244,7 +244,8 @@ static PyObject *pygpu_vertbuf__tp_new(PyTypeObject *UNUSED(type), PyObject *arg 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, &BPyGPUVertFormat_Type, ¶ms.py_fmt, ¶ms.len)) { + args, kwds, &_parser, &BPyGPUVertFormat_Type, ¶ms.py_fmt, ¶ms.len)) + { return NULL; } diff --git a/source/blender/python/gpu/gpu_py_vertex_format.c b/source/blender/python/gpu/gpu_py_vertex_format.c index ac0ec6bdc01..128ef08f0a7 100644 --- a/source/blender/python/gpu/gpu_py_vertex_format.c +++ b/source/blender/python/gpu/gpu_py_vertex_format.c @@ -108,7 +108,8 @@ static PyObject *pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *arg &comp_type, &len, PyC_ParseStringEnum, - &fetch_mode)) { + &fetch_mode)) + { return NULL; } diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 78729ff54d3..2e7653fec92 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -134,7 +134,8 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec PyC_ParseBool, &packed, PyC_ParseBool, - &local)) { + &local)) + { return NULL; } @@ -188,7 +189,8 @@ static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &name_src, &name_src_len, PyC_ParseBool, &strip_digits)) { + args, kw, &_parser, &name_src, &name_src_len, PyC_ParseBool, &strip_digits)) + { return NULL; } @@ -320,7 +322,8 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor)) { + args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor)) + { return NULL; } @@ -366,7 +369,8 @@ static PyObject *bpy_driver_secure_code_test(PyObject *UNUSED(self), PyObject *a &PyDict_Type, &py_namespace, PyC_ParseBool, - &verbose)) { + &verbose)) + { return NULL; } return PyBool_FromLong(BPY_driver_secure_bytecode_test(py_code, py_namespace, verbose)); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 434151e4bf2..e93d975b780 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -508,7 +508,8 @@ static PyObject *bpy_app_is_job_running(PyObject *UNUSED(self), PyObject *args, 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, pyrna_enum_value_parse_string, &job_type_enum)) { + args, kwds, &_parser, pyrna_enum_value_parse_string, &job_type_enum)) + { return NULL; } wmWindowManager *wm = G_MAIN->wm.first; diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 387f1c73b83..17ee3a762e5 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -310,7 +310,8 @@ void BPY_app_handlers_reset(const bool do_all) PyObject **dict_ptr; if (PyFunction_Check(item) && (dict_ptr = _PyObject_GetDictPtr(item)) && (*dict_ptr) && - (PyDict_GetItem(*dict_ptr, perm_id_str) != NULL)) { + (PyDict_GetItem(*dict_ptr, perm_id_str) != NULL)) + { /* keep */ } else { diff --git a/source/blender/python/intern/bpy_app_icons.c b/source/blender/python/intern/bpy_app_icons.c index 65edbb597ca..fc34b181ab8 100644 --- a/source/blender/python/intern/bpy_app_icons.c +++ b/source/blender/python/intern/bpy_app_icons.c @@ -49,7 +49,8 @@ static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *a 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) { + args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index b9b1b629eca..99beeb5ac63 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -320,7 +320,8 @@ static PyObject *app_translations_py_messages_register(BlenderAppTranslations *s &PyUnicode_Type, &module_name, &PyDict_Type, - &uuid_dict)) { + &uuid_dict)) + { return NULL; } @@ -371,7 +372,8 @@ static PyObject *app_translations_py_messages_unregister(BlenderAppTranslations "O!:bpy.app.translations.unregister", (char **)kwlist, &PyUnicode_Type, - &module_name)) { + &module_name)) + { return NULL; } @@ -534,7 +536,8 @@ static PyObject *_py_pgettext(PyObject *args, char *msgid, *msgctxt = NULL; if (!PyArg_ParseTupleAndKeywords( - args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { + args, kw, "s|z:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) + { return NULL; } @@ -544,7 +547,8 @@ static PyObject *_py_pgettext(PyObject *args, (void)_pgettext; if (!PyArg_ParseTupleAndKeywords( - args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) { + args, kw, "O|O:bpy.app.translations.pgettext", (char **)kwlist, &msgid, &msgctxt)) + { return NULL; } @@ -678,7 +682,8 @@ static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED( char *language, *country, *variant, *language_country, *language_variant; if (!PyArg_ParseTupleAndKeywords( - args, kw, "s:bpy.app.translations.locale_explode", (char **)kwlist, &locale)) { + args, kw, "s:bpy.app.translations.locale_explode", (char **)kwlist, &locale)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 7f8376798fe..402bc6408f8 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -184,7 +184,8 @@ static void bpy_pydriver_namespace_update_frame(const float evaltime) static void bpy_pydriver_namespace_update_self(struct PathResolvedRNA *anim_rna) { if ((g_pydriver_state_prev.self == NULL) || - (pyrna_driver_is_equal_anim_rna(anim_rna, g_pydriver_state_prev.self) == false)) { + (pyrna_driver_is_equal_anim_rna(anim_rna, g_pydriver_state_prev.self) == false)) + { PyObject *item = pyrna_driver_self_from_anim_rna(anim_rna); PyDict_SetItem(bpy_pydriver_Dict, bpy_intern_str_self, item); Py_DECREF(item); @@ -225,7 +226,8 @@ static void bpy_pydriver_namespace_update_depsgraph(struct Depsgraph *depsgraph) } if ((g_pydriver_state_prev.depsgraph == NULL) || - (depsgraph != g_pydriver_state_prev.depsgraph->ptr.data)) { + (depsgraph != g_pydriver_state_prev.depsgraph->ptr.data)) + { PyObject *item = bpy_pydriver_depsgraph_as_pyobject(depsgraph); PyDict_SetItem(bpy_pydriver_Dict, bpy_intern_str_depsgraph, item); Py_DECREF(item); @@ -753,7 +755,8 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, }, /* Always be verbose since this can give hints to why evaluation fails. */ true, - __func__)) { + __func__)) + { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) { G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL; BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr); diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index 99720e7a1ba..84f90d2f3df 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -66,7 +66,8 @@ static bool bpy_gizmotype_target_property_def(wmGizmoType *gzt, PyObject *item) ¶ms.id, pyrna_enum_value_parse_string, ¶ms.type_enum, - ¶ms.array_length)) { + ¶ms.array_length)) + { goto fail; } @@ -117,7 +118,8 @@ static void gizmo_properties_init(wmGizmoType *gzt) if (bl_target_properties != NULL) { PyObject *bl_target_properties_fast; if (!(bl_target_properties_fast = PySequence_Fast(bl_target_properties, - "bl_target_properties sequence"))) { + "bl_target_properties sequence"))) + { /* PySequence_Fast sets the error */ PyErr_Print(); PyErr_Clear(); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 4fe39e1c5b0..8ec4a91b822 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -401,7 +401,8 @@ void BPY_python_start(bContext *C, int argc, const char **argv) { char program_path[FILE_MAX]; if (BKE_appdir_program_python_search( - program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) { + program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) + { status = PyConfig_SetBytesString(&config, &config.executable, program_path); pystatus_exit_on_error(status); has_python_executable = true; @@ -848,7 +849,8 @@ static bool bpy_module_ensure_compatible_version(void) uint version_runtime_major = version_runtime >> 24; uint version_runtime_minor = ((version_runtime & 0x00ff0000) >> 16); if ((version_compile_major != version_runtime_major) || - (version_compile_minor != version_runtime_minor)) { + (version_compile_minor != version_runtime_minor)) + { PyErr_Format(PyExc_ImportError, "The version of \"bpy\" was compiled with: " "(%u.%u) is incompatible with: (%u.%u) used by the interpreter!", diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c index 7675aab2945..0f554fc1536 100644 --- a/source/blender/python/intern/bpy_library_load.c +++ b/source/blender/python/intern/bpy_library_load.c @@ -219,7 +219,8 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k PyC_ParseBool, &reuse_liboverrides, PyC_ParseBool, - &create_liboverrides_runtime)) { + &create_liboverrides_runtime)) + { return NULL; } @@ -353,7 +354,8 @@ static void bpy_lib_exit_warn_idname(BPy_Library *self, "load: '%s' does not contain %s[\"%s\"]", self->abspath, name_plural, - idname)) { + idname)) + { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { PyErr_WriteUnraisable((PyObject *)self); @@ -370,7 +372,8 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item) 1, "load: '%s' expected a string type, not a %.200s", self->abspath, - Py_TYPE(item)->tp_name)) { + Py_TYPE(item)->tp_name)) + { /* Spurious errors can appear at shutdown */ if (PyErr_ExceptionMatches(PyExc_Warning)) { PyErr_WriteUnraisable((PyObject *)self); diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c index 79a3680b78d..6b5cae45222 100644 --- a/source/blender/python/intern/bpy_library_write.c +++ b/source/blender/python/intern/bpy_library_write.c @@ -105,7 +105,8 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * PyC_ParseBool, &use_fake_user, PyC_ParseBool, - &use_compress)) { + &use_compress)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_msgbus.c b/source/blender/python/intern/bpy_msgbus.c index 835ef8f7f1f..2d7a293ea9a 100644 --- a/source/blender/python/intern/bpy_msgbus.c +++ b/source/blender/python/intern/bpy_msgbus.c @@ -260,12 +260,14 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject *UNUSED(self), PyObject *args &callback_args, &callback_notify, &PySet_Type, - &py_options)) { + &py_options)) + { return NULL; } if (py_options && - (pyrna_enum_bitfield_from_set(py_options_enum, py_options, &options, error_prefix) == -1)) { + (pyrna_enum_bitfield_from_set(py_options_enum, py_options, &options, error_prefix) == -1)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index f97e7a3f38d..585e8902a67 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -70,7 +70,8 @@ static void op_context_override_deprecated_warning(const char *action, const cha "Passing in context overrides is deprecated in favor of " "Context.temp_override(..), %s \"%s\"", action, - opname) < 0) { + opname) < 0) + { /* The function has no return value, the exception cannot * be reported to the caller, so just log it. */ PyErr_WriteUnraisable(NULL); @@ -196,7 +197,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) &PyDict_Type, &kw, &context_str, - &is_undo)) { + &is_undo)) + { return NULL; } @@ -397,7 +399,8 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) PyC_ParseBool, &all_args, PyC_ParseBool, - ¯o_args)) { + ¯o_args)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 8777a0393da..98449e9d810 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -743,7 +743,8 @@ static void bpy_prop_boolean_array_get_fn(struct PointerRNA *ptr, ret, &array_len_info, &PyBool_Type, - "BoolVectorProperty get callback") == -1) { + "BoolVectorProperty get callback") == -1) + { PyC_Err_PrintWithFunc(py_func); } else { @@ -1004,7 +1005,8 @@ static void bpy_prop_int_array_get_fn(struct PointerRNA *ptr, ret, &array_len_info, &PyLong_Type, - "IntVectorProperty get callback") == -1) { + "IntVectorProperty get callback") == -1) + { PyC_Err_PrintWithFunc(py_func); } else { @@ -1266,7 +1268,8 @@ static void bpy_prop_float_array_get_fn(struct PointerRNA *ptr, ret, &array_len_info, &PyFloat_Type, - "FloatVectorProperty get callback") == -1) { + "FloatVectorProperty get callback") == -1) + { PyC_Err_PrintWithFunc(py_func); } else { @@ -2009,7 +2012,8 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, (item_size != 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value)) && (item_size != 5 || ((py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.icon) || (tmp_icon = PyUnicode_AsUTF8(PyTuple_GET_ITEM(item, 3)))) && - py_long_as_int(PyTuple_GET_ITEM(item, 4), &tmp.value)))) { + py_long_as_int(PyTuple_GET_ITEM(item, 4), &tmp.value)))) + { if (is_enum_flag) { if (item_size < 4) { tmp.value = 1 << i; @@ -2027,7 +2031,8 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, if (default_py && default_used == 0) { if ((default_str_cmp != NULL && STREQ(default_str_cmp, tmp.identifier)) || - (default_str_cmp == NULL && default_int_cmp == tmp.value)) { + (default_str_cmp == NULL && default_int_cmp == tmp.value)) + { *r_default_value = tmp.value; default_used++; /* only ever 1 */ } @@ -2161,7 +2166,8 @@ static const EnumPropertyItem *bpy_prop_enum_itemf_fn(struct bContext *C, if (!(items_fast = PySequence_Fast(items, "EnumProperty(...): " - "return value from the callback was not a sequence"))) { + "return value from the callback was not a sequence"))) + { err = -1; } else { @@ -2571,7 +2577,8 @@ static int bpy_prop_arg_parse_id(PyObject *o, void *p) parse_data->prop_free_handle = NULL; if (UNLIKELY(RNA_def_property_free_identifier_deferred_prepare( - srna, id, &parse_data->prop_free_handle) == -1)) { + srna, id, &parse_data->prop_free_handle) == -1)) + { PyErr_Format(PyExc_TypeError, "'%s' is defined as a non-dynamic type for '%s'", id, @@ -2840,7 +2847,8 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) &subtype_enum, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -2990,7 +2998,8 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject &array_len_info, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -3000,7 +3009,8 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject default_py, &array_len_info, &PyBool_Type, - "BoolVectorProperty(default=sequence)") == -1) { + "BoolVectorProperty(default=sequence)") == -1) + { return NULL; } } @@ -3177,7 +3187,8 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) &subtype_enum, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -3354,7 +3365,8 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject &array_len_info, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -3364,7 +3376,8 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject default_py, &array_len_info, &PyLong_Type, - "IntVectorProperty(default=sequence)") == -1) { + "IntVectorProperty(default=sequence)") == -1) + { return NULL; } } @@ -3543,7 +3556,8 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) &unit_enum, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -3719,7 +3733,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec &array_len_info, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -3729,7 +3744,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec default_py, &array_len_info, &PyFloat_Type, - "FloatVectorProperty(default=sequence)") == -1) { + "FloatVectorProperty(default=sequence)") == -1) + { return NULL; } if (bpy_prop_array_is_matrix_compatible_ex(subtype_enum.value, &array_len_info)) { @@ -3909,7 +3925,8 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw &set_fn, &search_fn, pyrna_enum_bitfield_parse_set, - &search_options_enum)) { + &search_options_enum)) + { return NULL; } @@ -4096,7 +4113,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) &tags_enum, &update_fn, &get_fn, - &set_fn)) { + &set_fn)) + { return NULL; } @@ -4116,9 +4134,9 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) default_py = NULL; } - /* items can be a list or a callable */ - if (PyFunction_Check( - items)) { /* don't use PyCallable_Check because we need the function code for errors */ + /* Items can be a list or a callable. + * NOTE: Don't use #PyCallable_Check because we need the function code for errors. */ + if (PyFunction_Check(items)) { PyCodeObject *f_code = (PyCodeObject *)PyFunction_GET_CODE(items); if (f_code->co_argcount != 2) { PyErr_Format(PyExc_ValueError, @@ -4145,7 +4163,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) if (!(items_fast = PySequence_Fast( items, "EnumProperty(...): " - "expected a sequence of tuples for the enum items or a function"))) { + "expected a sequence of tuples for the enum items or a function"))) + { return NULL; } @@ -4310,7 +4329,8 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw) bpy_prop_arg_parse_tag_defines, &tags_enum, &poll_fn, - &update_fn)) { + &update_fn)) + { return NULL; } @@ -4440,7 +4460,8 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw) pyrna_enum_bitfield_parse_set, &override_enum, bpy_prop_arg_parse_tag_defines, - &tags_enum)) { + &tags_enum)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 26d3b13d68d..8b251973d14 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -147,7 +147,8 @@ static void id_release_gc(struct ID *id) while ((g = g->gc.gc_next) != gen) { PyObject *ob = FROM_GC(g); if (PyType_IsSubtype(Py_TYPE(ob), &pyrna_struct_Type) || - PyType_IsSubtype(Py_TYPE(ob), &pyrna_prop_Type)) { + PyType_IsSubtype(Py_TYPE(ob), &pyrna_prop_Type)) + { BPy_DummyPointerRNA *ob_ptr = (BPy_DummyPointerRNA *)ob; if (ob_ptr->ptr.owner_id == id) { pyrna_invalidate(ob_ptr); @@ -2051,7 +2052,8 @@ static int pyrna_py_to_prop( } if (pyrna_pydict_to_props( - &itemptr, item, true, "Converting a Python list to an RNA collection") == -1) { + &itemptr, item, true, "Converting a Python list to an RNA collection") == -1) + { PyObject *msg = PyC_ExceptionBuffer(); const char *msg_char = PyUnicode_AsUTF8(msg); PyErr_Clear(); @@ -2108,7 +2110,8 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P if (totdim > 1) { // char error_str[512]; if (pyrna_py_to_array_index( - &self->ptr, self->prop, self->arraydim, self->arrayoffset, index, value, "") == -1) { + &self->ptr, self->prop, self->arraydim, self->arrayoffset, index, value, "") == -1) + { /* Error is set. */ ret = -1; } @@ -2943,7 +2946,8 @@ static PyObject *prop_subscript_ass_array_slice__as_seq_fast(PyObject *value, in PyObject *value_fast; if (!(value_fast = PySequence_Fast(value, "bpy_prop_array[slice] = value: " - "element in assignment is not a sequence type"))) { + "element in assignment is not a sequence type"))) + { return NULL; } if (PySequence_Fast_GET_SIZE(value_fast) != length) { @@ -3077,7 +3081,8 @@ static int prop_subscript_ass_array_slice(PointerRNA *ptr, } if (!(value = PySequence_Fast( - value_orig, "bpy_prop_array[slice] = value: assignment is not a sequence type"))) { + value_orig, "bpy_prop_array[slice] = value: assignment is not a sequence type"))) + { return -1; } @@ -3371,7 +3376,8 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key) return 1; } if (pyrna_prop_collection_string_subscript_supported_or_error( - self, "bpy_prop_collection.__contains__") == -1) { + self, "bpy_prop_collection.__contains__") == -1) + { return -1; } @@ -3503,7 +3509,8 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje BPy_StructRNA *val = (BPy_StructRNA *)value; if (val && self->ptr.type && val->ptr.type) { if (!RNA_struct_idprops_datablock_allowed(self->ptr.type) && - RNA_struct_idprops_contains_datablock(val->ptr.type)) { + RNA_struct_idprops_contains_datablock(val->ptr.type)) + { PyErr_SetString( PyExc_TypeError, "bpy_struct[key] = val: datablock id properties not supported for this type"); @@ -4338,10 +4345,11 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) } else if ( /* RNA can't start with a "_", so for __dict__ and similar we can skip using RNA lookups. */ - name[0] == '_') { + name[0] == '_') + { /* Annoying exception, maybe we need to have different types for this... */ - if (STR_ELEM(name, "__getitem__", "__setitem__") && - !RNA_struct_idprops_check(self->ptr.type)) { + if (STR_ELEM(name, "__getitem__", "__setitem__") && !RNA_struct_idprops_check(self->ptr.type)) + { PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type"); ret = NULL; } @@ -4498,7 +4506,8 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb const char *attr_str = PyUnicode_AsUTF8(attr); if (srna && !pyrna_write_check() && - (is_deferred_prop || RNA_struct_type_find_property_no_base(srna, attr_str))) { + (is_deferred_prop || RNA_struct_type_find_property_no_base(srna, attr_str))) + { PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() " "can't set in readonly state '%.200s.%S'", @@ -5134,8 +5143,9 @@ static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args if (RNA_property_collection_lookup_string(&self->ptr, self->prop, key, &newptr)) { return pyrna_struct_CreatePyObject(&newptr); } - if (pyrna_prop_collection_string_subscript_supported_or_error( - self, "bpy_prop_collection.get") == -1) { + if (pyrna_prop_collection_string_subscript_supported_or_error(self, + "bpy_prop_collection.get") == -1) + { return NULL; } } @@ -5368,7 +5378,8 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) RawPropertyType raw_type; if (foreach_parse_args( - self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1) { + self, args, &attr, &seq, &tot, &size, &raw_type, &attr_tot, &attr_signed) == -1) + { return NULL; } @@ -5654,7 +5665,8 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, else { const char f = buf.format ? buf.format[0] : 0; if ((prop_type == PROP_INT && (buf.itemsize != sizeof(int) || !ELEM(f, 'l', 'i'))) || - (prop_type == PROP_FLOAT && (buf.itemsize != sizeof(float) || f != 'f'))) { + (prop_type == PROP_FLOAT && (buf.itemsize != sizeof(float) || f != 'f'))) + { PyBuffer_Release(&buf); PyErr_Format(PyExc_TypeError, "incorrect sequence item type: %s", buf.format); return NULL; @@ -7279,7 +7291,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) #endif if (RNA_struct_idprops_check(srna) && - !PyObject_IsSubclass(py_base, (PyObject *)&pyrna_struct_meta_idprop_Type)) { + !PyObject_IsSubclass(py_base, (PyObject *)&pyrna_struct_meta_idprop_Type)) + { metaclass = (PyObject *)&pyrna_struct_meta_idprop_Type; } else { @@ -7958,7 +7971,8 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item if (!RNA_struct_idprops_datablock_allowed(srna) && (*(PyCFunctionWithKeywords)PyCFunction_GET_FUNCTION(py_func) == BPy_PointerProperty || *(PyCFunctionWithKeywords)PyCFunction_GET_FUNCTION(py_func) == BPy_CollectionProperty) && - RNA_struct_idprops_contains_datablock(type_srna)) { + RNA_struct_idprops_contains_datablock(type_srna)) + { PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: " "'%.200s' %.200s could not register because " @@ -8064,7 +8078,8 @@ static int pyrna_deferred_register_props(StructRNA *srna, PyObject *class_dict) /* in both cases PyDict_CheckExact(class_dict) will be true even * though Operators have a metaclass dict namespace */ if ((annotations_dict = PyDict_GetItem(class_dict, bpy_intern_str___annotations__)) && - PyDict_CheckExact(annotations_dict)) { + PyDict_CheckExact(annotations_dict)) + { while (PyDict_Next(annotations_dict, &pos, &key, &item)) { ret = deferred_register_prop(srna, key, item); @@ -8096,7 +8111,8 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject * This best fits having 'mix-in' classes for operators and render engines. */ if (py_superclass != &PyBaseObject_Type && - !PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&pyrna_struct_Type)) { + !PyObject_IsSubclass((PyObject *)py_superclass, (PyObject *)&pyrna_struct_Type)) + { ret = pyrna_deferred_register_class_recursive(srna, py_superclass); if (ret != 0) { @@ -8321,8 +8337,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, /* Sneaky workaround to use the class name as the bl_idname. */ #define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \ - else if (STREQ(identifier, rna_attr)) \ - { \ + else if (STREQ(identifier, rna_attr)) { \ if ((item = PyObject_GetAttr(py_class, py_attr))) { \ if (item != Py_None) { \ if (pyrna_py_to_prop(dummy_ptr, prop, NULL, item, "validating class:") != 0) { \ @@ -8678,8 +8693,8 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param ReportList *reports; /* Alert the user, else they won't know unless they see the console. */ if ((!is_staticmethod) && (!is_classmethod) && (ptr->data) && - RNA_struct_is_a(ptr->type, &RNA_Operator) && - (is_valid_wm == (CTX_wm_manager(C) != NULL))) { + RNA_struct_is_a(ptr->type, &RNA_Operator) && (is_valid_wm == (CTX_wm_manager(C) != NULL))) + { wmOperator *op = ptr->data; reports = op->reports; } diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index d4a164d9482..99a96133bac 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -199,7 +199,8 @@ static int pyrna_struct_anim_args_parse_no_resolve_fallback(PointerRNA *ptr, { bool path_unresolved = false; if (pyrna_struct_anim_args_parse_ex( - ptr, error_prefix, path, r_path_full, r_index, &path_unresolved) == -1) { + ptr, error_prefix, path, r_path_full, r_index, &path_unresolved) == -1) + { if (path_unresolved == true) { if (pyrna_struct_anim_args_parse_no_resolve(ptr, error_prefix, path, r_path_full) == -1) { return -1; @@ -239,7 +240,8 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, r_cfra, r_group_name, &PySet_Type, - &pyoptions)) { + &pyoptions)) + { return -1; } @@ -255,7 +257,8 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, if (r_options) { if (pyoptions && (pyrna_enum_bitfield_from_set( - rna_enum_keying_flag_items_api, pyoptions, r_options, error_prefix) == -1)) { + rna_enum_keying_flag_items_api, pyoptions, r_options, error_prefix) == -1)) + { return -1; } @@ -319,7 +322,8 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb &index, &cfra, &group_name, - &options) == -1) { + &options) == -1) + { return NULL; } @@ -434,7 +438,8 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb &index, &cfra, &group_name, - NULL) == -1) { + NULL) == -1) + { return NULL; } @@ -536,7 +541,8 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) } if (pyrna_struct_anim_args_parse( - &self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) { + &self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) + { return NULL; } @@ -618,7 +624,8 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) } if (pyrna_struct_anim_args_parse_no_resolve_fallback( - &self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) { + &self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) + { return NULL; } diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index d1a351e8509..fbc981689d5 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -144,7 +144,8 @@ static int validate_array_type(PyObject *seq, is_dynamic, check_item_type, item_type_str, - error_prefix) == -1) { + error_prefix) == -1) + { ok = 0; } @@ -402,7 +403,8 @@ static int validate_array(PyObject *rvalue, (prop_flag & PROP_DYNAMIC) != 0, check_item_type, item_type_str, - error_prefix) == -1) { + error_prefix) == -1) + { return -1; } @@ -537,7 +539,8 @@ static int py_to_array(PyObject *seq, check_item_type, item_type_str, &totitem, - error_prefix) == -1) { + error_prefix) == -1) + { return -1; } @@ -643,7 +646,8 @@ static int py_to_array_index(PyObject *py, check_item_type, item_type_str, &totitem, - error_prefix) == -1) { + error_prefix) == -1) + { return -1; } diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 4409e3ae828..39ebf8a70b4 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -296,7 +296,8 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) pyrna_enum_value_parse_string, ¶ms.space_type_enum, pyrna_enum_value_parse_string, - ¶ms.region_type_enum)) { + ¶ms.region_type_enum)) + { return NULL; } @@ -324,7 +325,8 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) pyrna_enum_value_parse_string, ¶ms.region_type_enum, pyrna_enum_value_parse_string, - ¶ms.event_enum)) { + ¶ms.event_enum)) + { return NULL; } @@ -391,7 +393,8 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar if (srna == &RNA_WindowManager) { if (!PyArg_ParseTuple( - args, "OO!:WindowManager.draw_cursor_remove", &cls, &PyCapsule_Type, &py_handle)) { + args, "OO!:WindowManager.draw_cursor_remove", &cls, &PyCapsule_Type, &py_handle)) + { return NULL; } handle_removed = WM_paint_cursor_end(handle); @@ -411,7 +414,8 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar &PyCapsule_Type, &py_handle, /* already assigned, no matter */ pyrna_enum_value_parse_string, - ¶ms.region_type_enum)) { + ¶ms.region_type_enum)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_rna_context.c b/source/blender/python/intern/bpy_rna_context.c index df0a10050a1..b3a60e13e23 100644 --- a/source/blender/python/intern/bpy_rna_context.c +++ b/source/blender/python/intern/bpy_rna_context.c @@ -85,7 +85,8 @@ static PyObject *bpy_rna_context_temp_override_enter(BPyContextTempOverride *sel return NULL; } if ((screen && BLI_findindex(&screen->regionbase, region) == -1) && - (BLI_findindex(&area->regionbase, region) == -1)) { + (BLI_findindex(&area->regionbase, region) == -1)) + { PyErr_SetString(PyExc_TypeError, "Region not found in area"); return NULL; } diff --git a/source/blender/python/intern/bpy_rna_driver.c b/source/blender/python/intern/bpy_rna_driver.c index f15daba3890..01ef3aed3fa 100644 --- a/source/blender/python/intern/bpy_rna_driver.c +++ b/source/blender/python/intern/bpy_rna_driver.c @@ -78,7 +78,8 @@ bool pyrna_driver_is_equal_anim_rna(const PathResolvedRNA *anim_rna, const PyObj const PointerRNA *ptr_b = &(((const BPy_StructRNA *)py_anim_rna)->ptr); if ((ptr_a->owner_id == ptr_b->owner_id) && (ptr_a->type == ptr_b->type) && - (ptr_a->data == ptr_b->data)) { + (ptr_a->data == ptr_b->data)) + { return true; } } diff --git a/source/blender/python/intern/bpy_rna_gizmo.c b/source/blender/python/intern/bpy_rna_gizmo.c index 32ef7865e84..8ba8b4d66f6 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.c +++ b/source/blender/python/intern/bpy_rna_gizmo.c @@ -169,7 +169,8 @@ static void py_rna_gizmo_handler_get_cb(const wmGizmo *UNUSED(gz), ret, gz_prop->type->array_length, &PyFloat_Type, - "Gizmo get callback: ") == -1) { + "Gizmo get callback: ") == -1) + { goto fail; } } @@ -361,7 +362,8 @@ static PyObject *bpy_gizmo_target_set_handler(PyObject *UNUSED(self), PyObject * /* `get/set/range` */ ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_GET], ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_SET], - ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET])) { + ¶ms.py_fn_slots[BPY_GIZMO_FN_SLOT_RANGE_GET])) + { goto fail; } @@ -450,7 +452,8 @@ static PyObject *bpy_gizmo_target_get_value(PyObject *UNUSED(self), PyObject *ar ¶ms.gz_with_target.gz, /* `target` */ py_rna_gizmo_target_id_parse_and_ensure_is_valid, - ¶ms.gz_with_target)) { + ¶ms.gz_with_target)) + { goto fail; } @@ -517,7 +520,8 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar py_rna_gizmo_target_id_parse_and_ensure_is_valid, ¶ms.gz_with_target, /* `value` */ - ¶ms.value)) { + ¶ms.value)) + { goto fail; } @@ -534,7 +538,8 @@ static PyObject *bpy_gizmo_target_set_value(PyObject *UNUSED(self), PyObject *ar params.value, gz_prop->type->array_length, &PyFloat_Type, - "Gizmo target property array: ") == -1) { + "Gizmo target property array: ") == -1) + { goto fail; } WM_gizmo_target_property_float_set_array(BPY_context_get(), gz, gz_prop, value); @@ -590,7 +595,8 @@ static PyObject *bpy_gizmo_target_get_range(PyObject *UNUSED(self), PyObject *ar ¶ms.gz_with_target.gz, /* `target` */ py_rna_gizmo_target_id_parse_and_ensure_is_valid, - ¶ms.gz_with_target)) { + ¶ms.gz_with_target)) + { goto fail; } diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c index df3c687307b..1b18877dbe9 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.c +++ b/source/blender/python/intern/bpy_rna_id_collection.c @@ -168,7 +168,8 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, &subset, &PySet_Type, &key_types, &PySet_Type, &val_types)) { + args, kwds, &_parser, &subset, &PySet_Type, &key_types, &PySet_Type, &val_types)) + { return NULL; } @@ -226,7 +227,8 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject * (key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) && /* We do not want to pre-add keys when we have filter on value types, * but not on key types. */ - (val_types_bitmap == NULL || key_types_bitmap != NULL)) { + (val_types_bitmap == NULL || key_types_bitmap != NULL)) + { PyObject *key = pyrna_id_CreatePyObject(id); PyObject *set; @@ -394,7 +396,8 @@ static PyObject *bpy_orphans_purge(PyObject *UNUSED(self), PyObject *args, PyObj PyC_ParseBool, &do_linked_ids, PyC_ParseBool, - &do_recursive_cleanup)) { + &do_recursive_cleanup)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_rna_text.c b/source/blender/python/intern/bpy_rna_text.c index 9653ecbe1e3..8f1049614c7 100644 --- a/source/blender/python/intern/bpy_rna_text.c +++ b/source/blender/python/intern/bpy_rna_text.c @@ -71,7 +71,8 @@ static PyObject *bpy_rna_region_as_string(PyObject *self, PyObject *args, PyObje 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, ®ion.curl, ®ion.curc, ®ion.sell, ®ion.selc)) { + args, kwds, &_parser, ®ion.curl, ®ion.curc, ®ion.sell, ®ion.selc)) + { return NULL; } @@ -136,7 +137,8 @@ static PyObject *bpy_rna_region_from_string(PyObject *self, PyObject *args, PyOb ®ion.curl, ®ion.curc, ®ion.sell, - ®ion.selc)) { + ®ion.selc)) + { return NULL; } diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index 63da19b8c9e..1466d674384 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -201,11 +201,13 @@ bool python_script_error_jump( r_offset, r_lineno_end, r_offset_end, - &text_py)) { + &text_py)) + { const char *filepath_exc = PyUnicode_AsUTF8(filepath_exc_py); /* python adds a '/', prefix, so check for both */ if ((BLI_path_cmp(filepath_exc, filepath) == 0) || - (ELEM(filepath_exc[0], '\\', '/') && BLI_path_cmp(filepath_exc + 1, filepath) == 0)) { + (ELEM(filepath_exc[0], '\\', '/') && BLI_path_cmp(filepath_exc + 1, filepath) == 0)) + { success = true; } } @@ -216,7 +218,8 @@ bool python_script_error_jump( for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback"); tb && (PyObject *)tb != Py_None; - tb = tb->tb_next) { + tb = tb->tb_next) + { PyObject *coerce; const char *tb_filepath = traceback_filepath(tb, &coerce); const int match = ((BLI_path_cmp(tb_filepath, filepath) == 0) || diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c index 95d7f4f2eb7..49ed09a1806 100644 --- a/source/blender/python/intern/bpy_utils_units.c +++ b/source/blender/python/intern/bpy_utils_units.c @@ -186,7 +186,8 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj 0, }; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kw, &_parser, &usys_str, &ucat_str, &inpt, &str_len, &uref)) { + args, kw, &_parser, &usys_str, &ucat_str, &inpt, &str_len, &uref)) + { return NULL; } @@ -283,7 +284,8 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb PyC_ParseBool, &split_unit, PyC_ParseBool, - &compatible_unit)) { + &compatible_unit)) + { return NULL; } diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index fe9c05b4e4f..4af6357ad73 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -102,7 +102,8 @@ int mathutils_array_parse( if ((num = VectorObject_Check(value) ? ((VectorObject *)value)->vec_num : 0) || (num = EulerObject_Check(value) ? 3 : 0) || (num = QuaternionObject_Check(value) ? 4 : 0) || - (num = ColorObject_Check(value) ? 3 : 0)) { + (num = ColorObject_Check(value) ? 3 : 0)) + { if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) { return -1; } @@ -196,7 +197,8 @@ int mathutils_array_parse_alloc(float **array, if ((num = VectorObject_Check(value) ? ((VectorObject *)value)->vec_num : 0) || (num = EulerObject_Check(value) ? 3 : 0) || (num = QuaternionObject_Check(value) ? 4 : 0) || - (num = ColorObject_Check(value) ? 3 : 0)) { + (num = ColorObject_Check(value) ? 3 : 0)) + { if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) { return -1; } diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 017e733de8e..65edb95d18d 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -74,7 +74,8 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) break; case 1: if (mathutils_array_parse( - col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()") == -1) { + col, COLOR_SIZE, COLOR_SIZE, PyTuple_GET_ITEM(args, 0), "mathutils.Color()") == -1) + { return NULL; } break; @@ -457,7 +458,8 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) begin = MIN2(begin, end); if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == - -1) { + -1) + { return -1; } diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index c34f97f201d..74e836f2820 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -280,7 +280,8 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value) EULER_SIZE, EULER_SIZE, value, - "euler.make_compatible(other), invalid 'other' arg") == -1) { + "euler.make_compatible(other), invalid 'other' arg") == -1) + { return NULL; } @@ -540,7 +541,8 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) begin = MIN2(begin, end); if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == - -1) { + -1) + { return -1; } @@ -698,7 +700,8 @@ static int Euler_order_set(EulerObject *self, PyObject *value, void *UNUSED(clos } if (((order_str = PyUnicode_AsUTF8(value)) == NULL) || - ((order = euler_order_from_string(order_str, "euler.order")) == -1)) { + ((order = euler_order_from_string(order_str, "euler.order")) == -1)) + { return -1; } diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 1c02ecb0bd3..84ee3a9db57 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -737,7 +737,8 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) float tvec[3]; if (mathutils_array_parse( - tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1) { + tvec, 3, 3, vec, "Matrix.Rotation(angle, size, axis), invalid 'axis' arg") == -1) + { return NULL; } @@ -775,7 +776,8 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) unit_m4(mat); if (mathutils_array_parse( - mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) { + mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) + { return NULL; } @@ -847,7 +849,8 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) vec_num = (matSize == 2 ? 2 : 3); if (mathutils_array_parse( tvec, vec_num, vec_num, vec, "Matrix.Scale(factor, size, axis), invalid 'axis' arg") == - -1) { + -1) + { return NULL; } } @@ -980,7 +983,8 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) vec_num, vec_num, axis, - "Matrix.OrthoProjection(axis, size), invalid 'axis' arg") == -1) { + "Matrix.OrthoProjection(axis, size), invalid 'axis' arg") == -1) + { return NULL; } @@ -1148,7 +1152,8 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) zero_v3(loc); } else if (mathutils_array_parse( - loc, 3, 3, loc_obj, "Matrix.LocRotScale(), invalid location argument") == -1) { + loc, 3, 3, loc_obj, "Matrix.LocRotScale(), invalid location argument") == -1) + { return NULL; } @@ -1203,7 +1208,8 @@ static PyObject *C_Matrix_LocRotScale(PyObject *cls, PyObject *args) float scale[3]; if (mathutils_array_parse( - scale, 3, 3, scale_obj, "Matrix.LocRotScale(), invalid scale argument") == -1) { + scale, 3, 3, scale_obj, "Matrix.LocRotScale(), invalid scale argument") == -1) + { return NULL; } @@ -2438,7 +2444,8 @@ static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value) } if (mathutils_array_parse( - vec, self->col_num, self->col_num, value, "matrix[i] = value assignment") == -1) { + vec, self->col_num, self->col_num, value, "matrix[i] = value assignment") == -1) + { return -1; } @@ -2466,7 +2473,8 @@ static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value) } if (mathutils_array_parse( - vec, self->row_num, self->row_num, value, "matrix[i] = value assignment") == -1) { + vec, self->row_num, self->row_num, value, "matrix[i] = value assignment") == -1) + { return -1; } @@ -2546,8 +2554,8 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va PyObject *item = value_fast_items[row - begin]; if (mathutils_array_parse( - vec, self->col_num, self->col_num, item, "matrix[begin:end] = value assignment") == - -1) { + vec, self->col_num, self->col_num, item, "matrix[begin:end] = value assignment") == -1) + { Py_DECREF(value_fast); return -1; } @@ -3692,8 +3700,8 @@ static PyObject *MatrixAccess_subscript(MatrixAccessObject *self, PyObject *item if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < - 0) { + if (PySlice_GetIndicesEx(item, MatrixAccess_len(self), &start, &stop, &step, &slicelength) < 0) + { return NULL; } diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index b56a1b78f0a..91a994749d2 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -54,7 +54,8 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) axis[2] = 0.0f; } else if (EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && EXPP_FloatsAreEqual(axis[1], 0.0f, 10) && - EXPP_FloatsAreEqual(axis[2], 0.0f, 10)) { + EXPP_FloatsAreEqual(axis[2], 0.0f, 10)) + { axis[0] = 1.0f; } } @@ -120,8 +121,8 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 1: { int size; - if ((size = mathutils_array_parse(quat, 3, QUAT_SIZE, seq, "mathutils.Quaternion()")) == - -1) { + if ((size = mathutils_array_parse(quat, 3, QUAT_SIZE, seq, "mathutils.Quaternion()")) == -1) + { return NULL; } @@ -387,7 +388,8 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value) if (mathutils_array_parse( tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == - -1) { + -1) + { return NULL; } @@ -419,8 +421,8 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value) } if (mathutils_array_parse( - tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == - -1) { + tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1) + { return NULL; } @@ -454,7 +456,8 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject QUAT_SIZE, QUAT_SIZE, value, - "Quaternion.rotation_difference(other), invalid 'other' arg") == -1) { + "Quaternion.rotation_difference(other), invalid 'other' arg") == -1) + { return NULL; } @@ -498,7 +501,8 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args) if (mathutils_array_parse( tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == - -1) { + -1) + { return NULL; } @@ -568,7 +572,8 @@ static PyObject *Quaternion_make_compatible(QuaternionObject *self, PyObject *va QUAT_SIZE, QUAT_SIZE, value, - "Quaternion.make_compatible(other), invalid 'other' arg") == -1) { + "Quaternion.make_compatible(other), invalid 'other' arg") == -1) + { return NULL; } @@ -987,7 +992,8 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb begin = MIN2(begin, end); if ((size = mathutils_array_parse( - quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) { + quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) + { return -1; } diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 72084a624d3..ceb8bc78804 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -158,7 +158,8 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) break; case 1: if ((vec_num = mathutils_array_parse_alloc( - &vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { + &vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) + { return NULL; } break; @@ -360,7 +361,8 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) } if ((value_num = mathutils_array_parse_alloc( - &iter_vec, 2, value, "Vector.Repeat(vector, vec_num), invalid 'vector' arg")) == -1) { + &iter_vec, 2, value, "Vector.Repeat(vector, vec_num), invalid 'vector' arg")) == -1) + { return NULL; } @@ -947,7 +949,8 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) } if ((value_num = mathutils_array_parse( - tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) { + tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) + { return NULL; } @@ -1003,7 +1006,8 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) if (mathutils_array_parse( tvec, self->vec_num, self->vec_num, value, "Vector.cross(other), invalid 'other' arg") == - -1) { + -1) + { return NULL; } @@ -1043,7 +1047,8 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) } if (mathutils_array_parse_alloc( - &tvec, self->vec_num, value, "Vector.dot(other), invalid 'other' arg") == -1) { + &tvec, self->vec_num, value, "Vector.dot(other), invalid 'other' arg") == -1) + { return NULL; } @@ -1092,7 +1097,8 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) * even though n this case 'w' is ignored */ if (mathutils_array_parse( tvec, self->vec_num, self->vec_num, value, "Vector.angle(other), invalid 'other' arg") == - -1) { + -1) + { return NULL; } @@ -1158,7 +1164,8 @@ static PyObject *Vector_angle_signed(VectorObject *self, PyObject *args) } if (mathutils_array_parse( - tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1) { + tvec, 2, 2, value, "Vector.angle_signed(other), invalid 'other' arg") == -1) + { return NULL; } @@ -1217,8 +1224,8 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) } if (mathutils_array_parse( - vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == - -1) { + vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) + { return NULL; } @@ -1257,7 +1264,8 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) } if (mathutils_array_parse_alloc( - &tvec, vec_num, value, "Vector.project(other), invalid 'other' arg") == -1) { + &tvec, vec_num, value, "Vector.project(other), invalid 'other' arg") == -1) + { return NULL; } @@ -1307,7 +1315,8 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) } if (mathutils_array_parse_alloc( - &tvec, vec_num, value, "Vector.lerp(other), invalid 'other' arg") == -1) { + &tvec, vec_num, value, "Vector.lerp(other), invalid 'other' arg") == -1) + { return NULL; } @@ -1361,7 +1370,8 @@ static PyObject *Vector_slerp(VectorObject *self, PyObject *args) } if (mathutils_array_parse( - other_vec, vec_num, vec_num, value, "Vector.slerp(other), invalid 'other' arg") == -1) { + other_vec, vec_num, vec_num, value, "Vector.slerp(other), invalid 'other' arg") == -1) + { return NULL; } @@ -2193,8 +2203,8 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) /* Element-wise product in-place. */ mul_vn_vn(vec1->vec, vec2->vec, vec1->vec_num); } - else if (vec1 && (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == - 0)) { /* VEC *= FLOAT */ + else if (vec1 && (((scalar = PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) == 0)) { + /* VEC *= FLOAT */ mul_vn_fl(vec1->vec, vec1->vec_num, scalar); } else { @@ -2682,7 +2692,8 @@ static int Vector_swizzle_set(VectorObject *self, PyObject *value, void *closure } else if ((void)PyErr_Clear(), /* run but ignore the result */ (size_from = (size_t)mathutils_array_parse( - vec_assign, 2, 4, value, "Vector.**** = swizzle assignment")) == (size_t)-1) { + vec_assign, 2, 4, value, "Vector.**** = swizzle assignment")) == (size_t)-1) + { return -1; } diff --git a/source/blender/python/mathutils/mathutils_bvhtree.cc b/source/blender/python/mathutils/mathutils_bvhtree.cc index 52b4bb72983..ee8cda2c931 100644 --- a/source/blender/python/mathutils/mathutils_bvhtree.cc +++ b/source/blender/python/mathutils/mathutils_bvhtree.cc @@ -341,8 +341,8 @@ static PyObject *py_bvhtree_ray_cast(PyBVHTree *self, PyObject *args) } if ((mathutils_array_parse(co, 2, 3 | MU_ARRAY_ZERO, py_co, error_prefix) == -1) || - (mathutils_array_parse(direction, 2, 3 | MU_ARRAY_ZERO, py_direction, error_prefix) == - -1)) { + (mathutils_array_parse(direction, 2, 3 | MU_ARRAY_ZERO, py_direction, error_prefix) == -1)) + { return nullptr; } @@ -668,12 +668,14 @@ static PyObject *C_BVHTree_FromPolygons(PyObject * /*cls*/, PyObject *args, PyOb &py_tris, PyC_ParseBool, &all_triangles, - &epsilon)) { + &epsilon)) + { return nullptr; } if (!(py_coords_fast = PySequence_Fast(py_coords, error_prefix)) || - !(py_tris_fast = PySequence_Fast(py_tris, error_prefix))) { + !(py_tris_fast = PySequence_Fast(py_tris, error_prefix))) + { Py_XDECREF(py_coords_fast); return nullptr; } @@ -940,7 +942,8 @@ static PyObject *C_BVHTree_FromBMesh(PyObject * /*cls*/, PyObject *args, PyObjec (char **)keywords, &BPy_BMesh_Type, &py_bm, - &epsilon)) { + &epsilon)) + { return nullptr; } @@ -1125,7 +1128,8 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje &epsilon) || ((ob = static_cast(PyC_RNA_AsPointer(py_ob, "Object"))) == nullptr) || ((depsgraph = static_cast(PyC_RNA_AsPointer(py_depsgraph, "Depsgraph"))) == - nullptr)) { + nullptr)) + { return nullptr; } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 751883e6f1f..2c136e63b7c 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -67,20 +67,23 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject * &py_ray, &py_ray_off, PyC_ParseBool, - &clip)) { + &clip)) + { return NULL; } if (((mathutils_array_parse(dir, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_ray, error_prefix) != -1) && (mathutils_array_parse( - orig, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_ray_off, error_prefix) != -1)) == 0) { + orig, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_ray_off, error_prefix) != -1)) == 0) + { return NULL; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( - tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { + tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) + { return NULL; } } @@ -181,7 +184,8 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject ix_vec_num, ix_vec_num | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_lines[3], - error_prefix) != -1)) == 0) { + error_prefix) != -1)) == 0) + { return NULL; } @@ -238,13 +242,14 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P float v_ab[2]; float dist; - if (!PyArg_ParseTuple( - args, "OfOf:intersect_sphere_sphere_2d", &py_v_a, &rad_a, &py_v_b, &rad_b)) { + if (!PyArg_ParseTuple(args, "OfOf:intersect_sphere_sphere_2d", &py_v_a, &rad_a, &py_v_b, &rad_b)) + { return NULL; } if (((mathutils_array_parse(v_a, 2, 2, py_v_a, error_prefix) != -1) && - (mathutils_array_parse(v_b, 2, 2, py_v_b, error_prefix) != -1)) == 0) { + (mathutils_array_parse(v_b, 2, 2, py_v_b, error_prefix) != -1)) == 0) + { return NULL; } @@ -258,7 +263,8 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P /* fully-contained in the other */ (dist < fabsf(rad_a - rad_b)) || /* co-incident */ - (dist < FLT_EPSILON)) { + (dist < FLT_EPSILON)) + { /* out of range */ PyTuple_SET_ITEMS(ret, Py_INCREF_RET(Py_None), Py_INCREF_RET(Py_None)); } @@ -302,14 +308,16 @@ static PyObject *M_Geometry_intersect_tri_tri_2d(PyObject *UNUSED(self), PyObjec &tri_pair_py[0][2], &tri_pair_py[1][0], &tri_pair_py[1][1], - &tri_pair_py[1][2])) { + &tri_pair_py[1][2])) + { return NULL; } for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { if (mathutils_array_parse( - tri_pair[i][j], 2, 2 | MU_ARRAY_SPILL, tri_pair_py[i][j], error_prefix) == -1) { + tri_pair[i][j], 2, 2 | MU_ARRAY_SPILL, tri_pair_py[i][j], error_prefix) == -1) + { return NULL; } } @@ -340,7 +348,8 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) } if ((coords_len = mathutils_array_parse_alloc_v( - (float **)&coords, 3 | MU_ARRAY_SPILL, args, "normal")) == -1) { + (float **)&coords, 3 | MU_ARRAY_SPILL, args, "normal")) == -1) + { return NULL; } @@ -384,7 +393,8 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject *args) if ((((len = mathutils_array_parse(tri[0], 2, 3, py_tri[0], error_prefix)) != -1) && (mathutils_array_parse(tri[1], len, len, py_tri[1], error_prefix) != -1) && - (mathutils_array_parse(tri[2], len, len, py_tri[2], error_prefix) != -1)) == 0) { + (mathutils_array_parse(tri[2], len, len, py_tri[2], error_prefix) != -1)) == 0) + { return NULL; } @@ -501,7 +511,8 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec &py_plane_co, &py_plane_no, PyC_ParseBool, - &no_flip)) { + &no_flip)) + { return NULL; } @@ -509,7 +520,8 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec (mathutils_array_parse(line_b, 3, 3 | MU_ARRAY_SPILL, py_line_b, error_prefix) != -1) && (mathutils_array_parse(plane_co, 3, 3 | MU_ARRAY_SPILL, py_plane_co, error_prefix) != -1) && (mathutils_array_parse(plane_no, 3, 3 | MU_ARRAY_SPILL, py_plane_no, error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } @@ -554,7 +566,8 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje &py_plane_a_co, &py_plane_a_no, &py_plane_b_co, - &py_plane_b_no)) { + &py_plane_b_no)) + { return NULL; } @@ -565,7 +578,8 @@ static PyObject *M_Geometry_intersect_plane_plane(PyObject *UNUSED(self), PyObje (mathutils_array_parse(plane_b_co, 3, 3 | MU_ARRAY_SPILL, py_plane_b_co, error_prefix) != -1) && (mathutils_array_parse(plane_b_no, 3, 3 | MU_ARRAY_SPILL, py_plane_b_no, error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } @@ -624,14 +638,16 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje &py_sphere_co, &sphere_radius, PyC_ParseBool, - &clip)) { + &clip)) + { return NULL; } if (((mathutils_array_parse(line_a, 3, 3 | MU_ARRAY_SPILL, py_line_a, error_prefix) != -1) && (mathutils_array_parse(line_b, 3, 3 | MU_ARRAY_SPILL, py_line_b, error_prefix) != -1) && (mathutils_array_parse(sphere_co, 3, 3 | MU_ARRAY_SPILL, py_sphere_co, error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } @@ -644,18 +660,21 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje switch (isect_line_sphere_v3(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) { case 1: if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_a = false; } use_b = false; break; case 2: if (!(!clip || (((lambda = line_point_factor_v3(isect_a, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_a = false; } if (!(!clip || (((lambda = line_point_factor_v3(isect_b, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_b = false; } break; @@ -709,14 +728,16 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO &py_sphere_co, &sphere_radius, PyC_ParseBool, - &clip)) { + &clip)) + { return NULL; } if (((mathutils_array_parse(line_a, 2, 2 | MU_ARRAY_SPILL, py_line_a, error_prefix) != -1) && (mathutils_array_parse(line_b, 2, 2 | MU_ARRAY_SPILL, py_line_b, error_prefix) != -1) && (mathutils_array_parse(sphere_co, 2, 2 | MU_ARRAY_SPILL, py_sphere_co, error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } @@ -729,18 +750,21 @@ static PyObject *M_Geometry_intersect_line_sphere_2d(PyObject *UNUSED(self), PyO switch (isect_line_sphere_v2(line_a, line_b, sphere_co, sphere_radius, isect_a, isect_b)) { case 1: if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_a = false; } use_b = false; break; case 2: if (!(!clip || (((lambda = line_point_factor_v2(isect_a, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_a = false; } if (!(!clip || (((lambda = line_point_factor_v2(isect_b, line_a, line_b)) >= 0.0f) && - (lambda <= 1.0f)))) { + (lambda <= 1.0f)))) + { use_b = false; } break; @@ -790,7 +814,8 @@ static PyObject *M_Geometry_intersect_point_line(PyObject *UNUSED(self), PyObjec (mathutils_array_parse( line_a, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_line_a, error_prefix) != -1) && (mathutils_array_parse( - line_b, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_line_b, error_prefix) != -1)) == 0) { + line_b, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_line_b, error_prefix) != -1)) == 0) + { return NULL; } @@ -830,13 +855,14 @@ static PyObject *M_Geometry_intersect_point_tri(PyObject *UNUSED(self), PyObject return NULL; } - if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == - -1) { + if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == -1) + { return NULL; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( - tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { + tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) + { return NULL; } } @@ -875,13 +901,14 @@ static PyObject *M_Geometry_closest_point_on_tri(PyObject *UNUSED(self), PyObjec return NULL; } - if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == - -1) { + if (mathutils_array_parse(pt, 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_pt, error_prefix) == -1) + { return NULL; } for (i = 0; i < ARRAY_SIZE(tri); i++) { if (mathutils_array_parse( - tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) { + tri[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_tri[i], error_prefix) == -1) + { return NULL; } } @@ -1000,7 +1027,8 @@ static PyObject *M_Geometry_distance_point_to_plane(PyObject *UNUSED(self), PyOb if (((mathutils_array_parse(pt, 3, 3 | MU_ARRAY_SPILL, py_pt, error_prefix) != -1) && (mathutils_array_parse(plane_co, 3, 3 | MU_ARRAY_SPILL, py_plane_co, error_prefix) != -1) && (mathutils_array_parse(plane_no, 3, 3 | MU_ARRAY_SPILL, py_plane_no, error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } @@ -1041,7 +1069,8 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje "OOOOOOO:barycentric_transform", &py_pt_src, UNPACK3_EX(&, py_tri_src, ), - UNPACK3_EX(&, py_tri_dst, ))) { + UNPACK3_EX(&, py_tri_dst, ))) + { return NULL; } @@ -1052,7 +1081,8 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje if (((mathutils_array_parse(tri_src[i], 3, 3 | MU_ARRAY_SPILL, py_tri_src[i], error_prefix) != -1) && (mathutils_array_parse(tri_dst[i], 3, 3 | MU_ARRAY_SPILL, py_tri_dst[i], error_prefix) != - -1)) == 0) { + -1)) == 0) + { return NULL; } } @@ -1098,7 +1128,8 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a } if ((planes_len = mathutils_array_parse_alloc_v( - (float **)&planes, 4, py_planes, "points_in_planes")) == -1) { + (float **)&planes, 4, py_planes, "points_in_planes")) == -1) + { return NULL; } @@ -1175,7 +1206,8 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject for (i = 0; i < 4; i++) { int dims_tmp; if ((dims_tmp = mathutils_array_parse( - data[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_data[i], error_prefix)) == -1) { + data[i], 2, 3 | MU_ARRAY_SPILL | MU_ARRAY_ZERO, py_data[i], error_prefix)) == -1) + { return NULL; } dims = max_ii(dims, dims_tmp); @@ -1597,7 +1629,8 @@ static PyObject *M_Geometry_delaunay_2d_cdt(PyObject *UNUSED(self), PyObject *ar &faces, &output_type, &epsilon, - &need_ids)) { + &need_ids)) + { return NULL; } diff --git a/source/blender/python/mathutils/mathutils_interpolate.c b/source/blender/python/mathutils/mathutils_interpolate.c index 4b90a8233a4..62ba1214a78 100644 --- a/source/blender/python/mathutils/mathutils_interpolate.c +++ b/source/blender/python/mathutils/mathutils_interpolate.c @@ -45,7 +45,8 @@ static PyObject *M_Interpolate_poly_3d_calc(PyObject *UNUSED(self), PyObject *ar } if (mathutils_array_parse( - fp, 2, 3 | MU_ARRAY_ZERO, point, "pt must be a 2-3 dimensional vector") == -1) { + fp, 2, 3 | MU_ARRAY_ZERO, point, "pt must be a 2-3 dimensional vector") == -1) + { return NULL; } diff --git a/source/blender/python/mathutils/mathutils_kdtree.c b/source/blender/python/mathutils/mathutils_kdtree.c index 190a3768286..fc7edcf5f71 100644 --- a/source/blender/python/mathutils/mathutils_kdtree.c +++ b/source/blender/python/mathutils/mathutils_kdtree.c @@ -320,7 +320,8 @@ static PyObject *py_kdtree_find_range(PyKDTree *self, PyObject *args, PyObject * const char *keywords[] = {"co", "radius", NULL}; if (!PyArg_ParseTupleAndKeywords( - args, kwargs, "Of:find_range", (char **)keywords, &py_co, &radius)) { + args, kwargs, "Of:find_range", (char **)keywords, &py_co, &radius)) + { return NULL; } diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c index 79bb0a58df4..004d7255582 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.c @@ -307,8 +307,8 @@ static PyObject *M_Noise_random_unit_vector(PyObject *UNUSED(self), PyObject *ar float norm = 2.0f; int vec_num = 3; - if (!PyArg_ParseTupleAndKeywords( - args, kw, "|$i:random_unit_vector", (char **)kwlist, &vec_num)) { + if (!PyArg_ParseTupleAndKeywords(args, kw, "|$i:random_unit_vector", (char **)kwlist, &vec_num)) + { return NULL; } @@ -392,7 +392,8 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject int noise_basis_enum = DEFAULT_NOISE_TYPE; if (!PyArg_ParseTupleAndKeywords( - args, kw, "O|$s:noise", (char **)kwlist, &value, &noise_basis_str)) { + args, kw, "O|$s:noise", (char **)kwlist, &value, &noise_basis_str)) + { return NULL; } @@ -400,7 +401,8 @@ static PyObject *M_Noise_noise(PyObject *UNUSED(self), PyObject *args, PyObject /* pass through */ } else if (PyC_FlagSet_ValueFromID(bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise") == - -1) { + -1) + { return NULL; } @@ -431,7 +433,8 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, Py int noise_basis_enum = DEFAULT_NOISE_TYPE; if (!PyArg_ParseTupleAndKeywords( - args, kw, "O|$s:noise_vector", (char **)kwlist, &value, &noise_basis_str)) { + args, kw, "O|$s:noise_vector", (char **)kwlist, &value, &noise_basis_str)) + { return NULL; } @@ -439,7 +442,8 @@ static PyObject *M_Noise_noise_vector(PyObject *UNUSED(self), PyObject *args, Py /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise_vector") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "noise_vector") == -1) + { return NULL; } @@ -490,7 +494,8 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyOb &hd, &noise_basis_str, &as, - &fs)) { + &fs)) + { return NULL; } @@ -498,7 +503,8 @@ static PyObject *M_Noise_turbulence(PyObject *UNUSED(self), PyObject *args, PyOb /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence") == -1) + { return NULL; } @@ -547,7 +553,8 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg &hd, &noise_basis_str, &as, - &fs)) { + &fs)) + { return NULL; } @@ -555,7 +562,8 @@ static PyObject *M_Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *arg /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence_vector") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "turbulence_vector") == -1) + { return NULL; } @@ -595,15 +603,9 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObjec float H, lac, oct; int noise_basis_enum = DEFAULT_NOISE_TYPE; - if (!PyArg_ParseTupleAndKeywords(args, - kw, - "Offf|$s:fractal", - (char **)kwlist, - &value, - &H, - &lac, - &oct, - &noise_basis_str)) { + if (!PyArg_ParseTupleAndKeywords( + args, kw, "Offf|$s:fractal", (char **)kwlist, &value, &H, &lac, &oct, &noise_basis_str)) + { return NULL; } @@ -611,7 +613,8 @@ static PyObject *M_Noise_fractal(PyObject *UNUSED(self), PyObject *args, PyObjec /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "fractal") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "fractal") == -1) + { return NULL; } @@ -657,7 +660,8 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P &H, &lac, &oct, - &noise_basis_str)) { + &noise_basis_str)) + { return NULL; } @@ -665,7 +669,8 @@ static PyObject *M_Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args, P /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "multi_fractal") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "multi_fractal") == -1) + { return NULL; } @@ -716,7 +721,8 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a &value, &d, &noise_type1_str, - &noise_type2_str)) { + &noise_type2_str)) + { return NULL; } @@ -724,7 +730,8 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_type1_str, &noise_type1_enum, "variable_lacunarity") == -1) { + bpy_noise_types, noise_type1_str, &noise_type1_enum, "variable_lacunarity") == -1) + { return NULL; } @@ -732,12 +739,13 @@ static PyObject *M_Noise_variable_lacunarity(PyObject *UNUSED(self), PyObject *a /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_type2_str, &noise_type2_enum, "variable_lacunarity") == -1) { + bpy_noise_types, noise_type2_str, &noise_type2_enum, "variable_lacunarity") == -1) + { return NULL; } - if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == - -1) { + if (mathutils_array_parse(vec, 3, 3, value, "variable_lacunarity: invalid 'position' arg") == -1) + { return NULL; } @@ -782,7 +790,8 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, &lac, &oct, &ofs, - &noise_basis_str)) { + &noise_basis_str)) + { return NULL; } @@ -790,7 +799,8 @@ static PyObject *M_Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args, /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "hetero_terrain") == -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "hetero_terrain") == -1) + { return NULL; } @@ -842,7 +852,8 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * &oct, &ofs, &gn, - &noise_basis_str)) { + &noise_basis_str)) + { return NULL; } @@ -850,8 +861,8 @@ static PyObject *M_Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject * /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "hybrid_multi_fractal") == - -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "hybrid_multi_fractal") == -1) + { return NULL; } @@ -904,7 +915,8 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * &oct, &ofs, &gn, - &noise_basis_str)) { + &noise_basis_str)) + { return NULL; } @@ -912,8 +924,8 @@ static PyObject *M_Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject * /* pass through */ } else if (PyC_FlagSet_ValueFromID( - bpy_noise_types, noise_basis_str, &noise_basis_enum, "ridged_multi_fractal") == - -1) { + bpy_noise_types, noise_basis_str, &noise_basis_enum, "ridged_multi_fractal") == -1) + { return NULL; } @@ -952,7 +964,8 @@ static PyObject *M_Noise_voronoi(PyObject *UNUSED(self), PyObject *args, PyObjec int i; if (!PyArg_ParseTupleAndKeywords( - args, kw, "O|$sf:voronoi", (char **)kwlist, &value, &metric_str, &me)) { + args, kw, "O|$sf:voronoi", (char **)kwlist, &value, &metric_str, &me)) + { return NULL; } diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index e6ff43d215f..9c417bb812c 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -47,7 +47,7 @@ set(SRC RE_texture.h RE_texture_margin.h - intern/pipeline.h + intern/pipeline.hh intern/render_result.h intern/render_types.h intern/texture_common.h diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 3cffb99078b..8022d875e65 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -654,7 +654,8 @@ bool RE_bake_pixels_populate_from_objects(Mesh *me_low, dir, i, tot_highpoly, - max_ray_distance)) { + max_ray_distance)) + { /* if it fails mask out the original pixel array */ pixel_array_from[i].primitive_id = -1; } diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index 04b0da6acad..f70558bf3bd 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -50,7 +50,7 @@ #include "WM_api.h" -#include "pipeline.h" +#include "pipeline.hh" #include "render_result.h" #include "render_types.h" diff --git a/source/blender/render/intern/initrender.cc b/source/blender/render/intern/initrender.cc index 591791587fe..05bf9f220f9 100644 --- a/source/blender/render/intern/initrender.cc +++ b/source/blender/render/intern/initrender.cc @@ -24,7 +24,7 @@ #include "BKE_camera.h" /* this module */ -#include "pipeline.h" +#include "pipeline.hh" #include "render_types.h" /* ****************** MASKS and LUTS **************** */ diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index c74b7df6a65..2a8a06b59d3 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -90,7 +90,7 @@ #endif /* internal */ -#include "pipeline.h" +#include "pipeline.hh" #include "render_result.h" #include "render_types.h" @@ -160,7 +160,7 @@ static bool do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const int totvideos, - const char *name_override); + const char *filepath_override); /* default callbacks, set in each new render */ static void result_nothing(void * /*arg*/, RenderResult * /*rr*/) {} @@ -732,12 +732,14 @@ void RE_InitState(Render *re, /* disable border if it's a full render anyway */ if (re->r.border.xmin == 0.0f && re->r.border.xmax == 1.0f && re->r.border.ymin == 0.0f && - re->r.border.ymax == 1.0f) { + re->r.border.ymax == 1.0f) + { re->r.mode &= ~R_BORDER; } if (re->rectx < 1 || re->recty < 1 || - (BKE_imtype_is_movie(rd->im_format.imtype) && (re->rectx < 16 || re->recty < 16))) { + (BKE_imtype_is_movie(rd->im_format.imtype) && (re->rectx < 16 || re->recty < 16))) + { BKE_report(re->reports, RPT_ERROR, "Image too small"); re->ok = false; return; @@ -1473,11 +1475,12 @@ static int check_valid_camera(Scene *scene, Object *camera_override, ReportList if (scene->ed) { LISTBASE_FOREACH (Sequence *, seq, &scene->ed->seqbase) { if ((seq->type == SEQ_TYPE_SCENE) && ((seq->flag & SEQ_SCENE_STRIPS) == 0) && - (seq->scene != nullptr)) { + (seq->scene != nullptr)) + { if (!seq->scene_camera) { if (!seq->scene->camera && - !BKE_view_layer_camera_find(seq->scene, - BKE_view_layer_default_render(seq->scene))) { + !BKE_view_layer_camera_find(seq->scene, BKE_view_layer_default_render(seq->scene))) + { /* camera could be unneeded due to composite nodes */ Object *override = (seq->scene == scene) ? camera_override : nullptr; @@ -1758,7 +1761,8 @@ void RE_RenderFrame(Render *re, scene->r.subframe = subframe; if (render_init_from_main( - re, &scene->r, bmain, scene, single_layer, camera_override, false, false)) { + re, &scene->r, bmain, scene, single_layer, camera_override, false, false)) + { RenderData rd; memcpy(&rd, &scene->r, sizeof(rd)); MEM_reset_peak_memory(); @@ -1775,8 +1779,8 @@ void RE_RenderFrame(Render *re, printf("Error: can't write single images with a movie format!\n"); } else { - char name[FILE_MAX]; - BKE_image_path_from_imformat(name, + char filepath_override[FILE_MAX]; + BKE_image_path_from_imformat(filepath_override, rd.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -1786,7 +1790,7 @@ void RE_RenderFrame(Render *re, nullptr); /* reports only used for Movie */ - do_write_image_or_movie(re, bmain, scene, nullptr, 0, name); + do_write_image_or_movie(re, bmain, scene, nullptr, 0, filepath_override); } } @@ -1918,7 +1922,8 @@ bool RE_WriteRenderViewsMovie(ReportList *reports, ibuf->x, ibuf->y, suffix, - reports)) { + reports)) + { ok = false; } @@ -1951,7 +1956,8 @@ bool RE_WriteRenderViewsMovie(ReportList *reports, ibuf_arr[2]->x, ibuf_arr[2]->y, "", - reports)) { + reports)) + { ok = false; } @@ -1971,9 +1977,9 @@ static bool do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const int totvideos, - const char *name_override) + const char *filepath_override) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; RenderResult rres; double render_time; bool ok = true; @@ -1992,11 +1998,11 @@ static bool do_write_image_or_movie(Render *re, re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, false); } else { - if (name_override) { - BLI_strncpy(name, name_override, sizeof(name)); + if (filepath_override) { + BLI_strncpy(filepath, filepath_override, sizeof(filepath)); } else { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, scene->r.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -2007,7 +2013,7 @@ static bool do_write_image_or_movie(Render *re, } /* write images as individual images or stereo */ - ok = BKE_image_render_write(re->reports, &rres, scene, true, name); + ok = BKE_image_render_write(re->reports, &rres, scene, true, filepath); } RE_ReleaseResultImageViews(re, &rres); @@ -2016,8 +2022,8 @@ static bool do_write_image_or_movie(Render *re, render_time = re->i.lastframetime; re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; - BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime); - printf(" Time: %s", name); + BLI_timecode_string_from_time_simple(filepath, sizeof(filepath), re->i.lastframetime); + printf(" Time: %s", filepath); /* Flush stdout to be sure python callbacks are printing stuff after blender. */ fflush(stdout); @@ -2027,8 +2033,9 @@ static bool do_write_image_or_movie(Render *re, render_callback_exec_null(re, G_MAIN, BKE_CB_EVT_RENDER_STATS); if (do_write_file) { - BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time); - printf(" (Saving: %s)\n", name); + BLI_timecode_string_from_time_simple( + filepath, sizeof(filepath), re->i.lastframetime - render_time); + printf(" (Saving: %s)\n", filepath); } fputc('\n', stdout); @@ -2138,7 +2145,8 @@ void RE_RenderAnim(Render *re, height, re->reports, false, - suffix)) { + suffix)) + { is_error = true; break; } @@ -2161,7 +2169,7 @@ void RE_RenderAnim(Render *re, { scene->r.subframe = 0.0f; for (nfra = sfra, scene->r.cfra = sfra; scene->r.cfra <= efra; scene->r.cfra++) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; /* A feedback loop exists here -- render initialization requires updated * render layers settings which could be animated, but scene evaluation for @@ -2197,7 +2205,7 @@ void RE_RenderAnim(Render *re, /* Touch/NoOverwrite options are only valid for image's */ if (is_movie == false && do_write_file) { if (rd.mode & (R_NO_OVERWRITE | R_TOUCH)) { - BKE_image_path_from_imformat(name, + BKE_image_path_from_imformat(filepath, rd.pic, BKE_main_blendfile_path(bmain), scene->r.cfra, @@ -2209,8 +2217,8 @@ void RE_RenderAnim(Render *re, if (rd.mode & R_NO_OVERWRITE) { if (!is_multiview_name) { - if (BLI_exists(name)) { - printf("skipping existing frame \"%s\"\n", name); + if (BLI_exists(filepath)) { + printf("skipping existing frame \"%s\"\n", filepath); totskipped++; continue; } @@ -2224,7 +2232,7 @@ void RE_RenderAnim(Render *re, continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath); if (BLI_exists(filepath)) { is_skip = true; @@ -2241,24 +2249,24 @@ void RE_RenderAnim(Render *re, if (rd.mode & R_TOUCH) { if (!is_multiview_name) { - if (!BLI_exists(name)) { - BLI_make_existing_file(name); /* makes the dir if its not there */ - BLI_file_touch(name); + if (!BLI_exists(filepath)) { + BLI_file_ensure_parent_dir_exists(filepath); + BLI_file_touch(filepath); } } else { - char filepath[FILE_MAX]; + char filepath_view[FILE_MAX]; LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) { if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath_view); - if (!BLI_exists(filepath)) { - BLI_make_existing_file(filepath); /* makes the dir if its not there */ - BLI_file_touch(filepath); + if (!BLI_exists(filepath_view)) { + BLI_file_ensure_parent_dir_exists(filepath_view); + BLI_file_touch(filepath_view); } } } @@ -2290,24 +2298,24 @@ void RE_RenderAnim(Render *re, if (is_movie == false && do_write_file) { if (rd.mode & R_TOUCH) { if (!is_multiview_name) { - if (BLI_file_size(name) == 0) { - /* BLI_exists(name) is implicit */ - BLI_delete(name, false, false); + if (BLI_file_size(filepath) == 0) { + /* BLI_exists(filepath) is implicit */ + BLI_delete(filepath, false, false); } } else { - char filepath[FILE_MAX]; + char filepath_view[FILE_MAX]; LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) { if (!BKE_scene_multiview_is_render_view_active(&scene->r, srv)) { continue; } - BKE_scene_multiview_filepath_get(srv, name, filepath); + BKE_scene_multiview_filepath_get(srv, filepath, filepath_view); - if (BLI_file_size(filepath) == 0) { - /* BLI_exists(filepath) is implicit */ - BLI_delete(filepath, false, false); + if (BLI_file_size(filepath_view) == 0) { + /* BLI_exists(filepath_view) is implicit */ + BLI_delete(filepath_view, false, false); } } } diff --git a/source/blender/render/intern/pipeline.h b/source/blender/render/intern/pipeline.h deleted file mode 100644 index aa56647d029..00000000000 --- a/source/blender/render/intern/pipeline.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2006 Blender Foundation */ - -/** \file - * \ingroup render - */ - -#pragma once - -struct Render; -struct RenderData; -struct RenderLayer; -struct RenderResult; - -#ifdef __cplusplus -extern "C" { -#endif - -struct RenderLayer *render_get_single_layer(struct Render *re, struct RenderResult *rr); -void render_copy_renderdata(struct RenderData *to, struct RenderData *from); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/render/intern/pipeline.hh b/source/blender/render/intern/pipeline.hh new file mode 100644 index 00000000000..f74c73373ba --- /dev/null +++ b/source/blender/render/intern/pipeline.hh @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2006 Blender Foundation */ + +/** \file + * \ingroup render + */ + +#pragma once + +struct Render; +struct RenderData; +struct RenderLayer; +struct RenderResult; + +RenderLayer *render_get_single_layer(Render *re, RenderResult *rr); +void render_copy_renderdata(RenderData *to, RenderData *from); diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index 4383f30c5aa..010ef2c0cc1 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -715,7 +715,8 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart) for (RenderPass *rpass = static_cast(rl->passes.first), *rpassp = static_cast(rlp->passes.first); rpass && rpassp; - rpass = rpass->next) { + rpass = rpass->next) + { /* For save buffers, skip any passes that are only saved to disk. */ if (rpass->rect == nullptr || rpassp->rect == nullptr) { continue; @@ -758,8 +759,8 @@ void render_result_single_layer_end(Render *re) return; } - if (re->pushedresult->rectx == re->result->rectx && - re->pushedresult->recty == re->result->recty) { + if (re->pushedresult->rectx == re->result->rectx && re->pushedresult->recty == re->result->recty) + { /* find which layer in re->pushedresult should be replaced */ RenderLayer *rl = static_cast(re->result->layers.first); @@ -851,7 +852,7 @@ static void render_result_exr_file_cache_path(Scene *sce, /* If root is relative, use either current .blend file dir, or temp one if not saved. */ const char *blendfile_path = BKE_main_blendfile_path_from_global(); if (blendfile_path[0] != '\0') { - BLI_split_dirfile(blendfile_path, dirname, filename, sizeof(dirname), sizeof(filename)); + BLI_path_split_dir_file(blendfile_path, dirname, sizeof(dirname), filename, sizeof(filename)); BLI_path_extension_strip(filename); /* Strip `.blend`. */ BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest); } @@ -947,7 +948,8 @@ ImBuf *RE_render_result_rect_to_ibuf(RenderResult *rr, */ if (ibuf->rect) { if (BKE_imtype_valid_depths(imf->imtype) & - (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) { + (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) + { if (imf->depth == R_IMF_CHAN_DEPTH_8) { /* Higher depth bits are supported but not needed for current file output. */ ibuf->rect_float = nullptr; diff --git a/source/blender/render/intern/render_result.h b/source/blender/render/intern/render_result.h index 2f98f13f9c4..fa8e28e3b9f 100644 --- a/source/blender/render/intern/render_result.h +++ b/source/blender/render/intern/render_result.h @@ -136,7 +136,8 @@ void render_result_views_shallowdelete(struct RenderResult *rr); ViewLayer *iter_; \ for (nr_ = 0, iter_ = static_cast((re_)->scene->view_layers.first); \ iter_ != NULL; \ - iter_ = iter_->next, nr_++) { \ + iter_ = iter_->next, nr_++) \ + { \ if (!G.background && (re_)->r.scemode & R_SINGLE_LAYER) { \ if (!STREQ(iter_->name, re->single_view_layer)) { \ continue; \ diff --git a/source/blender/render/intern/texture_image.c b/source/blender/render/intern/texture_image.c index 8c7d842ee47..ec79b8e5193 100644 --- a/source/blender/render/intern/texture_image.c +++ b/source/blender/render/intern/texture_image.c @@ -1137,7 +1137,8 @@ static int imagewraposa_aniso(Tex *tex, if (tex->extend == TEX_CLIPCUBE) { if ((fx + minx) < 0.0f || (fy + miny) < 0.0f || (fx - minx) > 1.0f || (fy - miny) > 1.0f || - texvec[2] < -1.0f || texvec[2] > 1.0f) { + texvec[2] < -1.0f || texvec[2] > 1.0f) + { if (ima) { BKE_image_pool_release_ibuf(ima, ibuf, pool); } @@ -1565,7 +1566,8 @@ int imagewraposa(Tex *tex, if (tex->extend == TEX_CLIPCUBE) { if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f || - texvec[2] < -1.0f || texvec[2] > 1.0f) { + texvec[2] < -1.0f || texvec[2] > 1.0f) + { if (ima) { BKE_image_pool_release_ibuf(ima, ibuf, pool); } diff --git a/source/blender/render/intern/texture_pointdensity.c b/source/blender/render/intern/texture_pointdensity.c index 816bfbdf09e..dabf9c2f401 100644 --- a/source/blender/render/intern/texture_pointdensity.c +++ b/source/blender/render/intern/texture_pointdensity.c @@ -52,12 +52,13 @@ static int point_data_used(PointDensity *pd) if (pd->source == TEX_PD_PSYS) { if ((pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) || - (pd->color_source == TEX_PD_COLOR_PARTVEL) || - (pd->color_source == TEX_PD_COLOR_PARTSPEED)) { + (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED)) + { pd_bitflag |= POINT_DATA_VEL; } if ((pd->color_source == TEX_PD_COLOR_PARTAGE) || - (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE)) { + (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE)) + { pd_bitflag |= POINT_DATA_LIFE; } } diff --git a/source/blender/sequencer/intern/disk_cache.c b/source/blender/sequencer/intern/disk_cache.c index c059004359a..d20aacf1d46 100644 --- a/source/blender/sequencer/intern/disk_cache.c +++ b/source/blender/sequencer/intern/disk_cache.c @@ -141,7 +141,7 @@ static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, DiskCacheFile *cache_file = MEM_callocN(sizeof(DiskCacheFile), "SeqDiskCacheFile"); char dir[FILE_MAXDIR], file[FILE_MAX]; - BLI_split_dirfile(path, dir, file, sizeof(dir), sizeof(file)); + BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); BLI_strncpy(cache_file->path, path, sizeof(cache_file->path)); BLI_strncpy(cache_file->dir, dir, sizeof(cache_file->dir)); BLI_strncpy(cache_file->file, file, sizeof(cache_file->file)); @@ -176,7 +176,7 @@ static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path) } char file[FILE_MAX]; - BLI_split_dirfile(fl->path, NULL, file, 0, sizeof(file)); + BLI_path_split_file_part(fl->path, file, sizeof(file)); bool is_dir = BLI_is_dir(fl->path); if (is_dir && !FILENAME_IS_CURRPAR(file)) { @@ -287,7 +287,8 @@ static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *path) static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path, size_t path_len) { char cache_dir[FILE_MAX]; - BLI_split_file_part(BKE_main_blendfile_path(disk_cache->bmain), cache_dir, sizeof(cache_dir)); + BLI_path_split_file_part( + BKE_main_blendfile_path(disk_cache->bmain), cache_dir, sizeof(cache_dir)); /* Use suffix, so that the cache directory name does not conflict with the bmain's blend file. */ const char *suffix = "_seq_cache"; strncat(cache_dir, suffix, sizeof(cache_dir) - strlen(cache_dir) - 1); @@ -306,8 +307,8 @@ static void seq_disk_cache_get_dir( BLI_snprintf( scene_name, sizeof(scene_name), "%s-%" PRId64, scene->id.name, disk_cache->timestamp); BLI_strncpy(seq_name, seq->name, sizeof(seq_name)); - BLI_filename_make_safe(scene_name); - BLI_filename_make_safe(seq_name); + BLI_path_make_safe_filename(scene_name); + BLI_path_make_safe_filename(seq_name); BLI_path_join(path, path_len, project_dir, scene_name, seq_name); } @@ -333,11 +334,11 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, BLI_path_append(path, path_len, cache_filename); } -static void seq_disk_cache_create_version_file(char *path) +static void seq_disk_cache_create_version_file(char *filepath) { - BLI_make_existing_file(path); + BLI_file_ensure_parent_dir_exists(filepath); - FILE *file = BLI_fopen(path, "w"); + FILE *file = BLI_fopen(filepath, "w"); if (file) { fprintf(file, "%d", DCACHE_CURRENT_VERSION); fclose(file); @@ -552,8 +553,9 @@ bool seq_disk_cache_write_file(SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf char filepath[FILE_MAX]; seq_disk_cache_get_file_path(disk_cache, key, filepath, sizeof(filepath)); - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); + /* Touch the file. */ FILE *file = BLI_fopen(filepath, "rb+"); if (!file) { file = BLI_fopen(filepath, "wb+"); @@ -567,8 +569,8 @@ bool seq_disk_cache_write_file(SeqDiskCache *disk_cache, SeqCacheKey *key, ImBuf DiskCacheFile *cache_file = seq_disk_cache_get_file_entry_by_path(disk_cache, filepath); DiskCacheHeader header; memset(&header, 0, sizeof(header)); - /* #BLI_make_existing_file() above may create an empty file. This is fine, don't attempt reading - * the header in that case. */ + /* The file may be empty when touched (above). + * This is fine, don't attempt reading the header in that case. */ if (cache_file->fstat.st_size != 0 && !seq_disk_cache_read_header(file, &header)) { fclose(file); seq_disk_cache_delete_file(disk_cache, cache_file); @@ -605,7 +607,7 @@ ImBuf *seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key) DiskCacheHeader header; seq_disk_cache_get_file_path(disk_cache, key, filepath, sizeof(filepath)); - BLI_make_existing_file(filepath); + BLI_file_ensure_parent_dir_exists(filepath); FILE *file = BLI_fopen(filepath, "rb"); if (!file) { diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 607bde4b61b..624eb3a27e4 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -143,7 +143,8 @@ static ImBuf *prepare_effect_imbufs(const SeqRenderData *context, out = IMB_allocImBuf(x, y, 32, IB_rect); } else if ((ibuf1 && ibuf1->rect_float) || (ibuf2 && ibuf2->rect_float) || - (ibuf3 && ibuf3->rect_float)) { + (ibuf3 && ibuf3->rect_float)) + { /* if any inputs are rectfloat, output is float too */ out = IMB_allocImBuf(x, y, 32, IB_rectfloat); @@ -3283,7 +3284,8 @@ static int early_out_text(Sequence *seq, float UNUSED(fac)) TextVars *data = seq->effectdata; if (data->text[0] == 0 || data->text_size < 1.0f || ((data->color[3] == 0.0f) && - (data->shadow_color[3] == 0.0f || (data->flag & SEQ_TEXT_SHADOW) == 0))) { + (data->shadow_color[3] == 0.0f || (data->flag & SEQ_TEXT_SHADOW) == 0))) + { return EARLY_USE_INPUT_1; } return EARLY_NO_INPUT; diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index f8c43a7d293..a5bfca6a85c 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -566,7 +566,8 @@ void seq_cache_free_temp_cache(Scene *scene, short id, int timeline_frame) scene, key->seq, timeline_frame, key->type); if (frame_index != key->frame_index || timeline_frame > SEQ_time_right_handle_frame_get(scene, key->seq) || - timeline_frame < SEQ_time_left_handle_frame_get(scene, key->seq)) { + timeline_frame < SEQ_time_left_handle_frame_get(scene, key->seq)) + { BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree); } } @@ -661,7 +662,8 @@ void seq_cache_cleanup_sequence(Scene *scene, /* Clean all final and composite in intersection of seq and seq_changed. */ if (key->type & invalidate_composite && key->timeline_frame >= range_start && - key->timeline_frame <= range_end) { + key->timeline_frame <= range_end) + { if (key->link_next || key->link_prev) { seq_cache_relink_keys(key->link_next, key->link_prev); } @@ -671,7 +673,8 @@ void seq_cache_cleanup_sequence(Scene *scene, if (key->type & invalidate_source && key->seq == seq && key->timeline_frame >= SEQ_time_left_handle_frame_get(scene, seq_changed) && - key->timeline_frame <= SEQ_time_right_handle_frame_get(scene, seq_changed)) { + key->timeline_frame <= SEQ_time_right_handle_frame_get(scene, seq_changed)) + { if (key->link_next || key->link_prev) { seq_cache_relink_keys(key->link_next, key->link_prev); } @@ -715,7 +718,8 @@ void seq_cache_thumbnail_cleanup(Scene *scene, rctf *view_area_safe) if ((key->type & SEQ_CACHE_STORE_THUMBNAIL) && (key->timeline_frame > view_area_safe->xmax || key->timeline_frame < view_area_safe->xmin || key->seq->machine > view_area_safe->ymax || - key->seq->machine < view_area_safe->ymin)) { + key->seq->machine < view_area_safe->ymin)) + { BLI_ghash_remove(cache->hash, key, seq_cache_keyfree, seq_cache_valfree); cache->thumbnail_count--; } diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c index acf6776c4ed..b303c035574 100644 --- a/source/blender/sequencer/intern/iterator.c +++ b/source/blender/sequencer/intern/iterator.c @@ -261,8 +261,8 @@ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_at_time return false; } - if ((seq_iter->type & SEQ_TYPE_EFFECT) != 0 && - SEQ_relation_is_effect_of_strip(seq_iter, seq)) { + if ((seq_iter->type & SEQ_TYPE_EFFECT) != 0 && SEQ_relation_is_effect_of_strip(seq_iter, seq)) + { /* Strips in same channel or higher than its effect are rendered. */ if (seq->machine >= seq_iter->machine) { return true; @@ -357,7 +357,8 @@ void SEQ_query_strip_effect_chain(const Scene *scene, /* Find all strips connected to seq_reference. */ LISTBASE_FOREACH (Sequence *, seq_test, seqbase) { if (seq_test->seq1 == seq_reference || seq_test->seq2 == seq_reference || - seq_test->seq3 == seq_reference) { + seq_test->seq3 == seq_reference) + { SEQ_query_strip_effect_chain(scene, seq_test, seqbase, collection); } } diff --git a/source/blender/sequencer/intern/prefetch.c b/source/blender/sequencer/intern/prefetch.c index 2a9f7f52779..4b749d233ad 100644 --- a/source/blender/sequencer/intern/prefetch.c +++ b/source/blender/sequencer/intern/prefetch.c @@ -401,13 +401,15 @@ static bool seq_prefetch_scene_strip_is_rendered(PrefetchJob *pfjob, for (int i = 0; i < count; i++) { Sequence *seq = seq_arr[i]; if (seq->type == SEQ_TYPE_META && - seq_prefetch_scene_strip_is_rendered(pfjob, channels, &seq->seqbase, scene_strips, true)) { + seq_prefetch_scene_strip_is_rendered(pfjob, channels, &seq->seqbase, scene_strips, true)) + { return true; } /* Disable prefetching 3D scene strips, but check for disk cache. */ if (seq->type == SEQ_TYPE_SCENE && (seq->flag & SEQ_SCENE_STRIPS) == 0 && - !seq_prefetch_seq_has_disk_cache(pfjob, seq, !is_recursive_check)) { + !seq_prefetch_seq_has_disk_cache(pfjob, seq, !is_recursive_check)) + { return true; } @@ -456,7 +458,8 @@ static void seq_prefetch_do_suspend(PrefetchJob *pfjob) { BLI_mutex_lock(&pfjob->prefetch_suspend_mutex); while (seq_prefetch_need_suspend(pfjob) && - (pfjob->scene->ed->cache_flag & SEQ_CACHE_PREFETCH_ENABLE) && !pfjob->stop) { + (pfjob->scene->ed->cache_flag & SEQ_CACHE_PREFETCH_ENABLE) && !pfjob->stop) + { pfjob->waiting = true; BLI_condition_wait(&pfjob->prefetch_suspend_cond, &pfjob->prefetch_suspend_mutex); seq_prefetch_update_area(pfjob); @@ -501,8 +504,8 @@ static void *seq_prefetch_frames(void *job) seq_prefetch_do_suspend(pfjob); /* Avoid "collision" with main thread, but make sure to fetch at least few frames */ - if (pfjob->num_frames_prefetched > 5 && - (seq_prefetch_cfra(pfjob) - pfjob->scene->r.cfra) < 2) { + if (pfjob->num_frames_prefetched > 5 && (seq_prefetch_cfra(pfjob) - pfjob->scene->r.cfra) < 2) + { break; } @@ -575,7 +578,8 @@ void seq_prefetch_start(const SeqRenderData *context, float timeline_frame) * important, see D7820. */ if ((ed->cache_flag & SEQ_CACHE_PREFETCH_ENABLE) && !running && !scrubbing && !playing && - ed->cache_flag & SEQ_CACHE_ALL_TYPES && has_strips && !G.is_rendering && !G.moving) { + ed->cache_flag & SEQ_CACHE_ALL_TYPES && has_strips && !G.is_rendering && !G.moving) + { seq_prefetch_start_ex(context, timeline_frame); } diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index cff8c5ad082..de4eb123b01 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -96,9 +96,9 @@ double SEQ_rendersize_to_scale_factor(int render_size) return 1.0; } -bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_id) +bool seq_proxy_get_custom_file_fname(Sequence *seq, char *filepath, const int view_id) { - char fname[FILE_MAXFILE]; + char filepath_temp[FILE_MAXFILE]; char suffix[24]; StripProxy *proxy = seq->strip->proxy; @@ -106,18 +106,18 @@ bool seq_proxy_get_custom_file_fname(Sequence *seq, char *name, const int view_i return false; } - BLI_path_join(fname, PROXY_MAXFILE, proxy->dir, proxy->file); - BLI_path_abs(fname, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath_temp, PROXY_MAXFILE, proxy->dir, proxy->file); + BLI_path_abs(filepath_temp, BKE_main_blendfile_path_from_global()); if (view_id > 0) { BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id); /* TODO(sergey): This will actually append suffix after extension * which is weird but how was originally coded in multi-view branch. */ - BLI_snprintf(name, PROXY_MAXFILE, "%s_%s", fname, suffix); + BLI_snprintf(filepath, PROXY_MAXFILE, "%s_%s", filepath_temp, suffix); } else { - BLI_strncpy(name, fname, PROXY_MAXFILE); + BLI_strncpy(filepath, filepath_temp, PROXY_MAXFILE); } return true; @@ -127,7 +127,7 @@ static bool seq_proxy_get_fname(Scene *scene, Sequence *seq, int timeline_frame, eSpaceSeq_Proxy_RenderSize render_size, - char *name, + char *filepath, const int view_id) { char dir[PROXY_MAXFILE]; @@ -146,8 +146,9 @@ static bool seq_proxy_get_fname(Scene *scene, /* Per strip with Custom file situation is handled separately. */ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE && - ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) { - if (seq_proxy_get_custom_file_fname(seq, name, view_id)) { + ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE) + { + if (seq_proxy_get_custom_file_fname(seq, filepath, view_id)) { return true; } } @@ -160,7 +161,7 @@ static bool seq_proxy_get_fname(Scene *scene, else { /* Per project with custom dir. */ BLI_strncpy(dir, ed->proxy_dir, sizeof(dir)); } - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); } else { /* Pre strip with custom dir. */ @@ -175,14 +176,14 @@ static bool seq_proxy_get_fname(Scene *scene, /* Proxy size number to be used in path. */ int proxy_size_number = SEQ_rendersize_to_scale_factor(render_size) * 100; - BLI_snprintf(name, + BLI_snprintf(filepath, PROXY_MAXFILE, "%s/images/%d/%s_proxy%s.jpg", dir, proxy_size_number, SEQ_render_give_stripelem(scene, seq, timeline_frame)->name, suffix); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); return true; } @@ -198,7 +199,7 @@ bool SEQ_can_use_proxy(const struct SeqRenderData *context, Sequence *seq, int p ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; StripProxy *proxy = seq->strip->proxy; const eSpaceSeq_Proxy_RenderSize psize = context->preview_render_size; StripAnim *sanim; @@ -213,11 +214,12 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline seq->anim_startofs; if (proxy->anim == NULL) { if (seq_proxy_get_fname( - context->scene, seq, timeline_frame, psize, name, context->view_id) == 0) { + context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) + { return NULL; } - proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); + proxy->anim = openanim(filepath, IB_rect, 0, seq->strip->colorspace_settings.name); } if (proxy->anim == NULL) { return NULL; @@ -232,13 +234,14 @@ ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); } - if (seq_proxy_get_fname(context->scene, seq, timeline_frame, psize, name, context->view_id) == - 0) { + if (seq_proxy_get_fname( + context->scene, seq, timeline_frame, psize, filepath, context->view_id) == 0) + { return NULL; } - if (BLI_exists(name)) { - ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL); + if (BLI_exists(filepath)) { + ImBuf *ibuf = IMB_loadiffname(filepath, IB_rect, NULL); if (ibuf) { seq_imbuf_assign_spaces(context->scene, ibuf); @@ -257,18 +260,19 @@ static void seq_proxy_build_frame(const SeqRenderData *context, int proxy_render_size, const bool overwrite) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; int quality; int rectx, recty; ImBuf *ibuf_tmp, *ibuf; Scene *scene = context->scene; if (!seq_proxy_get_fname( - scene, seq, timeline_frame, proxy_render_size, name, context->view_id)) { + scene, seq, timeline_frame, proxy_render_size, filepath, context->view_id)) + { return; } - if (!overwrite && BLI_exists(name)) { + if (!overwrite && BLI_exists(filepath)) { return; } @@ -298,11 +302,11 @@ static void seq_proxy_build_frame(const SeqRenderData *context, ibuf->planes = 24; } - BLI_make_existing_file(name); + BLI_file_ensure_parent_dir_exists(filepath); - const bool ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); + const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == false) { - perror(name); + perror(filepath); } IMB_freeImBuf(ibuf); @@ -392,7 +396,7 @@ static bool seq_proxy_need_rebuild(Sequence *seq, struct anim *anim) } IMB_Proxy_Size required_proxies = seq->strip->proxy->build_size_flags; - IMB_Proxy_Size built_proxies = IMB_anim_proxy_get_existing(anim); + int built_proxies = IMB_anim_proxy_get_existing(anim); return (required_proxies & built_proxies) != required_proxies; } @@ -521,7 +525,8 @@ void SEQ_proxy_rebuild(SeqIndexBuildContext *context, bool *stop, bool *do_updat for (timeline_frame = SEQ_time_left_handle_frame_get(scene, seq); timeline_frame < SEQ_time_right_handle_frame_get(scene, seq); - timeline_frame++) { + timeline_frame++) + { if (context->size_flags & IMB_PROXY_25) { seq_proxy_build_frame(&render_context, &state, seq, timeline_frame, 25, overwrite); } @@ -578,12 +583,12 @@ void SEQ_proxy_set(struct Sequence *seq, bool value) void seq_proxy_index_dir_set(struct anim *anim, const char *base_dir) { - char dir[FILE_MAX]; - char fname[FILE_MAXFILE]; + char dirname[FILE_MAX]; + char filename[FILE_MAXFILE]; - IMB_anim_get_fname(anim, fname, FILE_MAXFILE); - BLI_path_join(dir, sizeof(dir), base_dir, fname); - IMB_anim_set_index_dir(anim, dir); + IMB_anim_get_filename(anim, filename, FILE_MAXFILE); + BLI_path_join(dirname, sizeof(dirname), base_dir, filename); + IMB_anim_set_index_dir(anim, dirname); } void free_proxy_seq(Sequence *seq) diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index fe40c3b3d09..ad23c9c5d27 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -313,7 +313,8 @@ static bool sequencer_use_transform(const Sequence *seq) const StripTransform *transform = seq->strip->transform; if (transform->xofs != 0 || transform->yofs != 0 || transform->scale_x != 1 || - transform->scale_y != 1 || transform->rotation != 0) { + transform->scale_y != 1 || transform->rotation != 0) + { return true; } @@ -341,7 +342,8 @@ static bool seq_input_have_to_preprocess(const SeqRenderData *context, } if ((seq->flag & (SEQ_FILTERY | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_FLOAT)) || - sequencer_use_crop(seq) || sequencer_use_transform(seq)) { + sequencer_use_crop(seq) || sequencer_use_transform(seq)) + { return true; } @@ -379,7 +381,8 @@ static bool seq_need_scale_to_render_size(const Sequence *seq, bool is_proxy_ima } if ((seq->type & SEQ_TYPE_EFFECT) != 0 || seq->type == SEQ_TYPE_MASK || seq->type == SEQ_TYPE_META || - (seq->type == SEQ_TYPE_SCENE && ((seq->flag & SEQ_SCENE_STRIPS) != 0))) { + (seq->type == SEQ_TYPE_SCENE && ((seq->flag & SEQ_SCENE_STRIPS) != 0))) + { return true; } return false; @@ -607,7 +610,8 @@ static ImBuf *input_preprocess(const SeqRenderData *context, } if (sequencer_use_crop(seq) || sequencer_use_transform(seq) || context->rectx != ibuf->x || - context->recty != ibuf->y) { + context->recty != ibuf->y) + { const int x = context->rectx; const int y = context->recty; preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); @@ -889,7 +893,7 @@ static ImBuf *seq_render_effect_strip_impl(const SeqRenderData *context, */ static ImBuf *seq_render_image_strip_view(const SeqRenderData *context, Sequence *seq, - char *name, + char *filepath, char *prefix, const char *ext, int view_id) @@ -903,13 +907,13 @@ static ImBuf *seq_render_image_strip_view(const SeqRenderData *context, } if (prefix[0] == '\0') { - ibuf = IMB_loadiffname(name, flag, seq->strip->colorspace_settings.name); + ibuf = IMB_loadiffname(filepath, flag, seq->strip->colorspace_settings.name); } else { - char str[FILE_MAX]; - BKE_scene_multiview_view_prefix_get(context->scene, name, prefix, &ext); - seq_multiview_name(context->scene, view_id, prefix, ext, str, FILE_MAX); - ibuf = IMB_loadiffname(str, flag, seq->strip->colorspace_settings.name); + char filepath_view[FILE_MAX]; + BKE_scene_multiview_view_prefix_get(context->scene, filepath, prefix, &ext); + seq_multiview_name(context->scene, view_id, prefix, ext, filepath_view, FILE_MAX); + ibuf = IMB_loadiffname(filepath_view, flag, seq->strip->colorspace_settings.name); } if (ibuf == NULL) { @@ -949,7 +953,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, float timeline_frame, bool *r_is_proxy_image) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; const char *ext = NULL; char prefix[FILE_MAX]; ImBuf *ibuf = NULL; @@ -959,8 +963,8 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, return NULL; } - BLI_path_join(name, sizeof(name), seq->strip->dir, s_elem->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, s_elem->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); /* Try to get a proxy image. */ ibuf = seq_proxy_fetch(context, seq, timeline_frame); @@ -972,14 +976,15 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, /* Proxy not found, render original. */ const int totfiles = seq_num_files(context->scene, seq->views_format, true); bool is_multiview_render = seq_image_strip_is_multiview_render( - context->scene, seq, totfiles, name, prefix, ext); + context->scene, seq, totfiles, filepath, prefix, ext); if (is_multiview_render) { int totviews = BKE_scene_multiview_num_views_get(&context->scene->r); ImBuf **ibufs_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs"); for (int view_id = 0; view_id < totfiles; view_id++) { - ibufs_arr[view_id] = seq_render_image_strip_view(context, seq, name, prefix, ext, view_id); + ibufs_arr[view_id] = seq_render_image_strip_view( + context, seq, filepath, prefix, ext, view_id); } if (ibufs_arr[0] == NULL) { @@ -1013,7 +1018,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, MEM_freeN(ibufs_arr); } else { - ibuf = seq_render_image_strip_view(context, seq, name, prefix, ext, context->view_id); + ibuf = seq_render_image_strip_view(context, seq, filepath, prefix, ext, context->view_id); } if (ibuf == NULL) { @@ -1030,12 +1035,12 @@ static ImBuf *seq_render_movie_strip_custom_file_proxy(const SeqRenderData *cont Sequence *seq, int timeline_frame) { - char name[PROXY_MAXFILE]; + char filepath[PROXY_MAXFILE]; StripProxy *proxy = seq->strip->proxy; if (proxy->anim == NULL) { - if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) { - proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); + if (seq_proxy_get_custom_file_fname(seq, filepath, context->view_id)) { + proxy->anim = openanim(filepath, IB_rect, 0, seq->strip->colorspace_settings.name); } if (proxy->anim == NULL) { return NULL; @@ -1073,7 +1078,8 @@ static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, /* Try to get a proxy image. * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */ if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE && - seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) { + seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) + { ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, timeline_frame); } else { @@ -1761,8 +1767,8 @@ ImBuf *seq_render_strip(const SeqRenderData *context, } /* Proxies are not stored in cache. */ - if (!SEQ_can_use_proxy( - context, seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) { + if (!SEQ_can_use_proxy(context, seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) + { ibuf = seq_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW); } diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c index a47aa2c9f15..82032fbb372 100644 --- a/source/blender/sequencer/intern/sequencer.c +++ b/source/blender/sequencer/intern/sequencer.c @@ -979,7 +979,8 @@ static bool seq_update_seq_cb(Sequence *seq, void *user_data) if (seq->type == SEQ_TYPE_SCENE && seq->scene != NULL) { BKE_sound_set_scene_volume(seq->scene, seq->scene->audio.volume); if ((seq->flag & SEQ_SCENE_STRIPS) == 0 && seq->scene->sound_scene != NULL && - seq->scene->ed != NULL) { + seq->scene->ed != NULL) + { SEQ_for_each_callback(&seq->scene->ed->seqbase, seq_disable_sound_strips_cb, seq->scene); } } diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index 621d342810b..a790794b360 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -202,16 +202,16 @@ void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, ch void SEQ_add_image_init_alpha_mode(Sequence *seq) { if (seq->strip && seq->strip->stripdata) { - char name[FILE_MAX]; + char filepath[FILE_MAX]; ImBuf *ibuf; - BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); /* Initialize input color space. */ if (seq->type == SEQ_TYPE_IMAGE) { ibuf = IMB_loadiffname( - name, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name); + filepath, IB_test | IB_alphamode_detect, seq->strip->colorspace_settings.name); /* Byte images are default to straight alpha, however sequencer * works in premul space, so mark strip to be premultiplied first. @@ -325,7 +325,8 @@ Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL Strip *strip = seq->strip; /* We only need 1 element to store the filename. */ StripElem *se = strip->stripdata = MEM_callocN(sizeof(StripElem), "stripelem"); - BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + BLI_path_split_dir_file( + load_data->path, strip->dir, sizeof(strip->dir), se->name, sizeof(se->name)); if (seq != NULL && seq->sound != NULL) { if (load_data->flags & SEQ_LOAD_SOUND_MONO) { @@ -501,7 +502,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL strip->stripdata->orig_width = orig_width; strip->stripdata->orig_height = orig_height; strip->stripdata->orig_fps = video_fps; - BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + BLI_path_split_dir_file( + load_data->path, strip->dir, sizeof(strip->dir), se->name, sizeof(se->name)); seq_add_set_view_transform(scene, seq, load_data); seq_add_set_name(scene, seq, load_data); @@ -524,7 +526,8 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo SEQ_TYPE_SCENE, SEQ_TYPE_META, SEQ_TYPE_MOVIECLIP, - SEQ_TYPE_MASK) == 0) { + SEQ_TYPE_MASK) == 0) + { return; } diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c index f89974b8fef..7f88fb178a2 100644 --- a/source/blender/sequencer/intern/strip_relations.c +++ b/source/blender/sequencer/intern/strip_relations.c @@ -49,7 +49,8 @@ static bool seq_relations_check_depend(const Scene *scene, Sequence *seq, Sequen /* sequences are not intersecting in time, assume no dependency exists between them */ if (SEQ_time_right_handle_frame_get(scene, cur) < SEQ_time_left_handle_frame_get(scene, seq) || - SEQ_time_left_handle_frame_get(scene, cur) > SEQ_time_right_handle_frame_get(scene, seq)) { + SEQ_time_left_handle_frame_get(scene, cur) > SEQ_time_right_handle_frame_get(scene, seq)) + { return false; } @@ -63,7 +64,8 @@ static bool seq_relations_check_depend(const Scene *scene, Sequence *seq, Sequen */ if ((cur->type & SEQ_TYPE_EFFECT) == 0 && ((cur->blend_mode == SEQ_BLEND_REPLACE) || - (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) { + (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) + { return false; } @@ -280,7 +282,8 @@ static void sequencer_all_free_anim_ibufs(const Scene *scene, Editing *ed = SEQ_editing_get(scene); for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) { if (!SEQ_time_strip_intersects_frame(scene, seq, timeline_frame) || - !((frame_range[0] <= timeline_frame) && (frame_range[1] > timeline_frame))) { + !((frame_range[0] <= timeline_frame) && (frame_range[1] > timeline_frame))) + { SEQ_relations_sequence_free_anim(seq); } if (seq->type == SEQ_TYPE_META) { @@ -375,7 +378,8 @@ bool SEQ_relations_render_loop_check(Sequence *seq_main, Sequence *seq) if ((seq_main->seq1 && SEQ_relations_render_loop_check(seq_main->seq1, seq)) || (seq_main->seq2 && SEQ_relations_render_loop_check(seq_main->seq2, seq)) || - (seq_main->seq3 && SEQ_relations_render_loop_check(seq_main->seq3, seq))) { + (seq_main->seq3 && SEQ_relations_render_loop_check(seq_main->seq3, seq))) + { return true; } @@ -451,8 +455,8 @@ struct Sequence *SEQ_find_metastrip_by_sequence(ListBase *seqbase, Sequence *met if (seq == iseq) { return meta; } - if (iseq->seqbase.first && - (rval = SEQ_find_metastrip_by_sequence(&iseq->seqbase, iseq, seq))) { + if (iseq->seqbase.first && (rval = SEQ_find_metastrip_by_sequence(&iseq->seqbase, iseq, seq))) + { return rval; } } diff --git a/source/blender/sequencer/intern/strip_retiming.cc b/source/blender/sequencer/intern/strip_retiming.cc index 0c9c859f6ad..8427cb35629 100644 --- a/source/blender/sequencer/intern/strip_retiming.cc +++ b/source/blender/sequencer/intern/strip_retiming.cc @@ -143,7 +143,7 @@ float seq_retiming_evaluate(const Sequence *seq, const float frame_index) const int segment_length = next_handle->strip_frame_index - previous_handle->strip_frame_index; const float segment_frame_index = frame_index - previous_handle->strip_frame_index; - const float segment_fac = segment_frame_index / (float)segment_length; + const float segment_fac = segment_frame_index / float(segment_length); const float target_diff = next_handle->retiming_factor - previous_handle->retiming_factor; return previous_handle->retiming_factor + (target_diff * segment_fac); } diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index c8ee4e58b4a..09c0736612c 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -65,13 +65,15 @@ bool SEQ_transform_seqbase_isolated_sel_check(ListBase *seqbase) if (seq->flag & SELECT) { if ((seq->seq1 && (seq->seq1->flag & SELECT) == 0) || (seq->seq2 && (seq->seq2->flag & SELECT) == 0) || - (seq->seq3 && (seq->seq3->flag & SELECT) == 0)) { + (seq->seq3 && (seq->seq3->flag & SELECT) == 0)) + { return false; } } else { if ((seq->seq1 && (seq->seq1->flag & SELECT)) || (seq->seq2 && (seq->seq2->flag & SELECT)) || - (seq->seq3 && (seq->seq3->flag & SELECT))) { + (seq->seq3 && (seq->seq3->flag & SELECT))) + { return false; } } @@ -405,25 +407,29 @@ static eOvelapDescrition overlap_description_get(const Scene *scene, if (SEQ_time_left_handle_frame_get(scene, transformed) <= SEQ_time_left_handle_frame_get(scene, target) && SEQ_time_right_handle_frame_get(scene, transformed) >= - SEQ_time_right_handle_frame_get(scene, target)) { + SEQ_time_right_handle_frame_get(scene, target)) + { return STRIP_OVERLAP_IS_FULL; } if (SEQ_time_left_handle_frame_get(scene, transformed) > SEQ_time_left_handle_frame_get(scene, target) && SEQ_time_right_handle_frame_get(scene, transformed) < - SEQ_time_right_handle_frame_get(scene, target)) { + SEQ_time_right_handle_frame_get(scene, target)) + { return STRIP_OVERLAP_IS_INSIDE; } if (SEQ_time_left_handle_frame_get(scene, transformed) <= SEQ_time_left_handle_frame_get(scene, target) && SEQ_time_left_handle_frame_get(scene, target) <= - SEQ_time_right_handle_frame_get(scene, transformed)) { + SEQ_time_right_handle_frame_get(scene, transformed)) + { return STRIP_OVERLAP_LEFT_SIDE; } if (SEQ_time_left_handle_frame_get(scene, transformed) <= SEQ_time_right_handle_frame_get(scene, target) && SEQ_time_right_handle_frame_get(scene, target) <= - SEQ_time_right_handle_frame_get(scene, transformed)) { + SEQ_time_right_handle_frame_get(scene, transformed)) + { return STRIP_OVERLAP_RIGHT_SIDE; } return STRIP_OVERLAP_NONE; diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 5b70bc33e88..10e9ccd4d7f 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -209,7 +209,7 @@ ListBase *SEQ_get_seqbase_from_sequence(Sequence *seq, ListBase **r_channels, in void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) { char dir[FILE_MAX]; - char name[FILE_MAX]; + char filepath[FILE_MAX]; StripProxy *proxy; bool use_proxy; bool is_multiview_loaded = false; @@ -224,8 +224,8 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) /* reset all the previously created anims */ SEQ_relations_sequence_free_anim(seq); - BLI_path_join(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, BKE_main_blendfile_path_from_global()); + BLI_path_join(filepath, sizeof(filepath), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); proxy = seq->strip->proxy; @@ -253,7 +253,7 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) const char *ext = NULL; int i; - BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext); + BKE_scene_multiview_view_prefix_get(scene, filepath, prefix, &ext); if (prefix[0] != '\0') { for (i = 0; i < totfiles; i++) { @@ -285,13 +285,13 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) } else { if (openfile) { - sanim->anim = openanim(name, + sanim->anim = openanim(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); } else { - sanim->anim = openanim_noload(name, + sanim->anim = openanim_noload(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, @@ -317,13 +317,13 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) BLI_addtail(&seq->anims, sanim); if (openfile) { - sanim->anim = openanim(name, + sanim->anim = openanim(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); } else { - sanim->anim = openanim_noload(name, + sanim->anim = openanim_noload(filepath, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, seq->strip->colorspace_settings.name); @@ -348,8 +348,8 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame) int best_machine = -1; for (seq = ed->seqbasep->first; seq; seq = seq->next) { - if (SEQ_render_is_muted(channels, seq) || - !SEQ_time_strip_intersects_frame(scene, seq, frame)) { + if (SEQ_render_is_muted(channels, seq) || !SEQ_time_strip_intersects_frame(scene, seq, frame)) + { continue; } /* Only use strips that generate an image, not ones that combine @@ -360,7 +360,8 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame) SEQ_TYPE_SCENE, SEQ_TYPE_MOVIE, SEQ_TYPE_COLOR, - SEQ_TYPE_TEXT)) { + SEQ_TYPE_TEXT)) + { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; @@ -407,7 +408,8 @@ Sequence *SEQ_sequence_from_strip_elem(ListBase *seqbase, StripElem *se) for (iseq = seqbase->first; iseq; iseq = iseq->next) { Sequence *seq_found; if ((iseq->strip && iseq->strip->stripdata) && - ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len)) { + ARRAY_HAS_ITEM(se, iseq->strip->stripdata, iseq->len)) + { break; } if ((seq_found = SEQ_sequence_from_strip_elem(&iseq->seqbase, se))) { @@ -429,7 +431,8 @@ Sequence *SEQ_get_sequence_by_name(ListBase *seqbase, const char *name, bool rec return iseq; } if (recursive && (iseq->seqbase.first) && - (rseq = SEQ_get_sequence_by_name(&iseq->seqbase, name, 1))) { + (rseq = SEQ_get_sequence_by_name(&iseq->seqbase, name, 1))) + { return rseq; } } diff --git a/source/blender/simulation/intern/ConstrainedConjugateGradient.h b/source/blender/simulation/intern/ConstrainedConjugateGradient.h index dda84095b2a..9b4ccbc3c71 100644 --- a/source/blender/simulation/intern/ConstrainedConjugateGradient.h +++ b/source/blender/simulation/intern/ConstrainedConjugateGradient.h @@ -89,9 +89,10 @@ EIGEN_DONT_INLINE void constrained_conjugate_gradient(const MatrixType &mat, RealScalar absOld = absNew; absNew = numext::real(residual.dot(z)); /* update the absolute value of r */ - RealScalar beta = - absNew / - absOld; /* calculate the Gram-Schmidt value used to create the new search direction */ + + /* Calculate the Gram-Schmidt value used to create the new search direction. */ + RealScalar beta = absNew / absOld; + p = filter * (z + beta * p); /* update search direction */ i++; } diff --git a/source/blender/simulation/intern/SIM_mass_spring.cpp b/source/blender/simulation/intern/SIM_mass_spring.cpp index f703c9a3f78..301e6bc898f 100644 --- a/source/blender/simulation/intern/SIM_mass_spring.cpp +++ b/source/blender/simulation/intern/SIM_mass_spring.cpp @@ -371,8 +371,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) s->flags |= CLOTH_SPRING_FLAG_NEEDED; scaling = parms->bending + s->ang_stiffness * fabsf(parms->max_bend - parms->bending); - k = scaling * s->restlen * - 0.1f; /* Multiplying by 0.1, just to scale the forces to more reasonable values. */ + /* Multiplying by 0.1, just to scale the forces to more reasonable values. */ + k = scaling * s->restlen * 0.1f; SIM_mass_spring_force_spring_angular( data, s->ij, s->kl, s->pa, s->pb, s->la, s->lb, s->restang, k, parms->bending_damping); @@ -381,7 +381,8 @@ BLI_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s) /* Calculate force of structural + shear springs. */ if (s->type & - (CLOTH_SPRING_TYPE_STRUCTURAL | CLOTH_SPRING_TYPE_SEWING | CLOTH_SPRING_TYPE_INTERNAL)) { + (CLOTH_SPRING_TYPE_STRUCTURAL | CLOTH_SPRING_TYPE_SEWING | CLOTH_SPRING_TYPE_INTERNAL)) + { #ifdef CLOTH_FORCE_SPRING_STRUCTURAL float k_tension, scaling_tension; @@ -1193,11 +1194,9 @@ static void cloth_solve_collisions( zero_v3(verts[i].dcvel); } - if (cloth_bvh_collision(depsgraph, - ob, - clmd, - step / clmd->sim_parms->timescale, - dt / clmd->sim_parms->timescale)) { + if (cloth_bvh_collision( + depsgraph, ob, clmd, step / clmd->sim_parms->timescale, dt / clmd->sim_parms->timescale)) + { for (i = 0; i < mvert_num; i++) { if ((clmd->sim_parms->vgroup_mass > 0) && (verts[i].flags & CLOTH_VERT_FLAG_PINNED)) { continue; diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c index 93a31189f16..89bef63c641 100644 --- a/source/blender/simulation/intern/implicit_blender.c +++ b/source/blender/simulation/intern/implicit_blender.c @@ -815,8 +815,8 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z, del_lfvector(r); // printf("W/O conjgrad_loopcount: %d\n", conjgrad_loopcount); - return conjgrad_loopcount < - conjgrad_looplimit; /* true means we reached desired accuracy in given time - ie stable */ + /* True means we reached desired accuracy in given time - ie stable. */ + return conjgrad_loopcount < conjgrad_looplimit; } # endif @@ -911,8 +911,8 @@ static int cg_filtered(lfVector *ldV, result->iterations = conjgrad_loopcount; result->error = bnorm2 > 0.0f ? sqrtf(delta_new / bnorm2) : 0.0f; - return conjgrad_loopcount < - conjgrad_looplimit; /* true means we reached desired accuracy in given time - ie stable */ + /* True means we reached desired accuracy in given time - ie stable. */ + return conjgrad_loopcount < conjgrad_looplimit; } # if 0 diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c index aa9518186c8..6da422e4014 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.c @@ -505,7 +505,8 @@ int wm_gizmo_is_visible(wmGizmo *gz) return 0; } if ((gz->state & WM_GIZMO_STATE_MODAL) && - !(gz->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) { + !(gz->flag & (WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_VALUE))) + { /* don't draw while modal (dragging) */ return 0; } diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index ca02e3c17c0..5d8e6cdb211 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -73,8 +73,8 @@ void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup) /* Similar to WM_gizmo_unlink, but only to keep gzmap state correct, * we don't want to run callbacks. */ - if (gzmap->gzmap_context.highlight && - gzmap->gzmap_context.highlight->parent_gzgroup == gzgroup) { + if (gzmap->gzmap_context.highlight && gzmap->gzmap_context.highlight->parent_gzgroup == gzgroup) + { wm_gizmomap_highlight_set(gzmap, C, NULL, 0); } if (gzmap->gzmap_context.modal && gzmap->gzmap_context.modal->parent_gzgroup == gzgroup) { @@ -199,7 +199,8 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm, if (gz->type->test_select && (gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) { if (!wm_gizmo_keymap_uses_event_modifier( - wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) { + wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) + { continue; } @@ -222,10 +223,12 @@ void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm, if ((gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) { if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && (gz->type->draw_select || gz->type->test_select)) || - ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select)) { + ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select)) + { if (!wm_gizmo_keymap_uses_event_modifier( - wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) { + wm, gzgroup, gz, event_modifier, &gzgroup_keymap_uses_modifier)) + { continue; } @@ -458,7 +461,8 @@ static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, b if (clear_modal) { /* The gizmo may have been removed. */ if ((BLI_findindex(&mtweak->gzmap->groups, mtweak->gzgroup) != -1) && - (BLI_findindex(&mtweak->gzgroup->gizmos, mtweak->gz_modal) != -1)) { + (BLI_findindex(&mtweak->gzgroup->gizmos, mtweak->gz_modal) != -1)) + { wm_gizmomap_modal_set(mtweak->gzmap, C, mtweak->gz_modal, NULL, false); } } @@ -1244,7 +1248,8 @@ void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup) BLI_assert(region->gizmo_map == gzmap); /* Check if the tweak event originated from this region. */ if ((win->eventstate != NULL) && (win->event_queue_check_drag) && - BLI_rcti_isect_pt_v(®ion->winrct, win->eventstate->prev_press_xy)) { + BLI_rcti_isect_pt_v(®ion->winrct, win->eventstate->prev_press_xy)) + { /* We need to run refresh again. */ gzgroup->init_flag &= ~WM_GIZMOGROUP_INIT_REFRESH; WM_gizmomap_tag_refresh_drawstep(gzmap, WM_gizmomap_drawstep_from_gizmo_group(gzgroup)); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 0dde58ebfcd..079b9f3431d 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -176,8 +176,8 @@ static void wm_gizmomap_free_data(wmGizmoMap *gzmap) /* Clear first so further calls don't waste time trying to maintain correct array state. */ wm_gizmomap_select_array_clear(gzmap); - for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup; - gzgroup = gzgroup_next) { + for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup; gzgroup = gzgroup_next) + { gzgroup_next = gzgroup->next; BLI_assert(gzgroup->parent_gzmap == gzmap); wm_gizmogroup_free(NULL, gzgroup); @@ -274,8 +274,8 @@ static GHash *WM_gizmomap_gizmo_hash_new(const bContext *C, LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (WM_gizmo_group_type_poll(C, gzgroup->type)) { LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { - if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) && - (!poll || poll(gz, data))) { + if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) && (!poll || poll(gz, data))) + { BLI_ghash_insert(hash, gz, gz); } } @@ -1135,7 +1135,8 @@ void wm_gizmomap_modal_set( } LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL) == 0) && - wm_gizmogroup_is_visible_in_drawstep(gzgroup, step_iter)) { + wm_gizmogroup_is_visible_in_drawstep(gzgroup, step_iter)) + { gzmap->update_flag[i] |= update_flag; break; } @@ -1167,7 +1168,8 @@ void WM_gizmomap_message_subscribe(const bContext *C, { LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) { if ((gzgroup->hide.any != 0) || (gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0 || - !WM_gizmo_group_type_poll(C, gzgroup->type)) { + !WM_gizmo_group_type_poll(C, gzgroup->type)) + { continue; } LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { @@ -1247,10 +1249,12 @@ wmGizmoMapType *WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap void wm_gizmomaptypes_free(void) { for (wmGizmoMapType *gzmap_type = gizmomaptypes.first, *gzmap_type_next; gzmap_type; - gzmap_type = gzmap_type_next) { + gzmap_type = gzmap_type_next) + { gzmap_type_next = gzmap_type->next; for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_next; gzgt_ref; - gzgt_ref = gzgt_next) { + gzgt_ref = gzgt_next) + { gzgt_next = gzgt_ref->next; WM_gizmomaptype_group_free(gzgt_ref); } @@ -1317,7 +1321,8 @@ void WM_gizmoconfig_update(struct Main *bmain) gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next; gzgt_ref; - gzgt_ref = gzgt_ref_next) { + gzgt_ref = gzgt_ref_next) + { gzgt_ref_next = gzgt_ref->next; if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) { gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE; diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 75b4073660c..ca1a88c650e 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -154,7 +154,8 @@ void WM_cursor_set(wmWindow *win, int curs) GHOST_TStandardCursor ghost_cursor = convert_to_ghost_standard_cursor(curs); if (ghost_cursor != GHOST_kStandardCursorCustom && - GHOST_HasCursorShape(win->ghostwin, ghost_cursor)) { + GHOST_HasCursorShape(win->ghostwin, ghost_cursor)) + { /* Use native GHOST cursor when available. */ GHOST_SetCursorShape(win->ghostwin, ghost_cursor); } diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 5b74ee2984f..c0f03791a90 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -431,8 +431,8 @@ static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *even const int winsize_y = WM_window_pixels_y(win); /* for multiwin drags, we only do this if mouse inside */ - if (event->xy[0] < 0 || event->xy[1] < 0 || event->xy[0] > winsize_x || - event->xy[1] > winsize_y) { + if (event->xy[0] < 0 || event->xy[1] < 0 || event->xy[0] > winsize_x || event->xy[1] > winsize_y) + { return; } diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 6936f741f05..ce20e8b6d8a 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -666,7 +666,8 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_ /* Free offscreen buffer on size changes. Viewport auto resizes. */ GPUOffScreen *offscreen = region->draw_buffer->offscreen; if (offscreen && (GPU_offscreen_width(offscreen) != region->winx || - GPU_offscreen_height(offscreen) != region->winy)) { + GPU_offscreen_height(offscreen) != region->winy)) + { wm_draw_region_buffer_free(region); } } @@ -906,7 +907,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) !(region->flag & RGN_FLAG_HIDDEN); if ((region->visible || ignore_visibility) && region->do_draw && region->type && - region->type->layout) { + region->type->layout) + { CTX_wm_region_set(C, region); ED_region_do_layout(C, region); CTX_wm_region_set(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c index 3e33f88126e..1ae7e157c1a 100644 --- a/source/blender/windowmanager/intern/wm_event_query.c +++ b/source/blender/windowmanager/intern/wm_event_query.c @@ -353,7 +353,8 @@ bool WM_event_consecutive_gesture_test_break(const wmWindow *win, const wmEvent /* Mouse motion is checked because the user may navigate to a new area * and perform the same gesture - logically it's best to view this as two separate gestures. */ if (len_manhattan_v2v2_int(event->xy, win->event_queue_consecutive_gesture_xy) > - WM_EVENT_CURSOR_MOTION_THRESHOLD) { + WM_EVENT_CURSOR_MOTION_THRESHOLD) + { return true; } } diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 53f3541c611..6bf4e127fee 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -642,7 +642,8 @@ void wm_event_do_notifiers(bContext *C) /* Filter out notifiers. */ if (note->category == NC_SCREEN && note->reference && note->reference != screen && - note->reference != workspace && note->reference != WM_window_get_active_layout(win)) { + note->reference != workspace && note->reference != WM_window_get_active_layout(win)) + { /* Pass. */ } else if (note->category == NC_SCENE && note->reference && note->reference != scene) { @@ -779,7 +780,8 @@ static eHandlerActionFlag wm_handler_ui_call(bContext *C, /* UI code doesn't handle return values - it just always returns break. * to make the #DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks. */ if (((handler->head.flag & WM_HANDLER_ACCEPT_DBL_CLICK) == 0) && !ISMOUSE_BUTTON(event->type) && - (event->val == KM_DBL_CLICK)) { + (event->val == KM_DBL_CLICK)) + { return WM_HANDLER_CONTINUE; } @@ -1577,8 +1579,8 @@ static int wm_operator_invoke(bContext *C, if (event && (U.uiflag & USER_CONTINUOUS_MOUSE)) { const wmOperator *op_test = op->opm ? op->opm : op; const wmOperatorType *ot_test = op_test->type; - if ((ot_test->flag & OPTYPE_GRAB_CURSOR_XY) || - (op_test->flag & OP_IS_MODAL_GRAB_CURSOR)) { + if ((ot_test->flag & OPTYPE_GRAB_CURSOR_XY) || (op_test->flag & OP_IS_MODAL_GRAB_CURSOR)) + { wrap = WM_CURSOR_WRAP_XY; } else if (ot_test->flag & OPTYPE_GRAB_CURSOR_X) { @@ -1599,7 +1601,8 @@ static int wm_operator_invoke(bContext *C, } if (region && region->regiontype == RGN_TYPE_WINDOW && - BLI_rcti_isect_pt_v(®ion->winrct, event->xy)) { + BLI_rcti_isect_pt_v(®ion->winrct, event->xy)) + { wrap_region = ®ion->winrct; } else if (area && BLI_rcti_isect_pt_v(&area->totrct, event->xy)) { @@ -2264,8 +2267,8 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) /* Account for rare case of when these keys are used as the 'type' not as modifiers. */ if (kmi->shift != KM_ANY) { const bool shift = (winevent->modifier & KM_SHIFT) != 0; - if ((shift != bool(kmi->shift)) && - !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) { + if ((shift != bool(kmi->shift)) && !ELEM(winevent->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) + { return false; } } @@ -2429,7 +2432,8 @@ static eHandlerActionFlag wm_handler_operator_call(bContext *C, /* Derived, modal or blocking operator. */ if ((handler_base->type == WM_HANDLER_TYPE_OP) && - (((wmEventHandler_Op *)handler_base)->op != nullptr)) { + (((wmEventHandler_Op *)handler_base)->op != nullptr)) + { wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; wmOperator *op = handler->op; wmOperatorType *ot = op->type; @@ -2650,7 +2654,8 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C, U.file_space_data.temp_win_sizey * UI_SCALE_FAC, SPACE_FILE, U.filebrowser_display_type, - true))) { + true))) + { ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); BLI_assert(area->spacetype == SPACE_FILE); @@ -3103,7 +3108,8 @@ static eHandlerActionFlag wm_handlers_do_gizmo_handler(bContext *C, /* Handle gizmo highlighting. */ if ((prev.gz_modal == nullptr) && - ((event->type == MOUSEMOVE) || is_event_modifier || is_event_drag)) { + ((event->type == MOUSEMOVE) || is_event_modifier || is_event_drag)) + { handle_highlight = true; if (is_event_modifier || is_event_drag) { handle_keymap = true; @@ -3257,7 +3263,8 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, for (wmEventHandler *handler_base = static_cast(handlers->first), *handler_base_next; handler_base && handlers->first; - handler_base = handler_base_next) { + handler_base = handler_base_next) + { handler_base_next = handler_base->next; /* During this loop, UI handlers for nested menus can tag multiple handlers free. */ @@ -3438,7 +3445,8 @@ static eHandlerActionFlag wm_handlers_do(bContext *C, wmEvent *event, ListBase * if ((action & WM_HANDLER_BREAK) == 0 || wm_action_not_handled(action)) { if (win->event_queue_check_drag) { if ((event->flag & WM_EVENT_FORCE_DRAG_THRESHOLD) || - WM_event_drag_test(event, event->prev_press_xy)) { + WM_event_drag_test(event, event->prev_press_xy)) + { win->event_queue_check_drag_handled = true; const int direction = WM_event_drag_direction(event); @@ -3502,7 +3510,8 @@ static eHandlerActionFlag wm_handlers_do(bContext *C, wmEvent *event, ListBase * else if (event->val == KM_RELEASE) { if (win->event_queue_check_drag) { if ((event->prev_press_type != event->type) && - (ISKEYMODIFIER(event->type) || (event->type == event->prev_press_keymodifier))) { + (ISKEYMODIFIER(event->type) || (event->type == event->prev_press_keymodifier))) + { /* Support releasing modifier keys without canceling the drag event, see #89989. */ } else { @@ -3920,7 +3929,8 @@ void wm_event_do_handlers(bContext *C) is_playing_screen = (ED_screen_animation_playing(wm) != nullptr); if (((is_playing_sound == 1) && (is_playing_screen == 0)) || - ((is_playing_sound == 0) && (is_playing_screen == 1))) { + ((is_playing_sound == 0) && (is_playing_screen == 1))) + { wmWindow *win_ctx = CTX_wm_window(C); bScreen *screen_stx = CTX_wm_screen(C); Scene *scene_ctx = CTX_data_scene(C); @@ -3962,7 +3972,8 @@ void wm_event_do_handlers(bContext *C) * Otherwise pressing two keys on the keyboard will interpret this as a drag action. */ if (win->event_queue_check_drag) { if ((event->val == KM_PRESS) && ((event->flag & WM_EVENT_IS_REPEAT) == 0) && - ISKEYBOARD_OR_BUTTON(event->type) && ISMOUSE_BUTTON(event->prev_press_type)) { + ISKEYBOARD_OR_BUTTON(event->type) && ISMOUSE_BUTTON(event->prev_press_type)) + { event = wm_event_add_mousemove_to_head(win); event->flag |= WM_EVENT_FORCE_DRAG_THRESHOLD; } @@ -4024,7 +4035,8 @@ void wm_event_do_handlers(bContext *C) if (screen->tool_tip && screen->tool_tip->exit_on_event) { if (ISMOUSE_MOTION(event->type)) { if (len_manhattan_v2v2_int(screen->tool_tip->event_xy, event->xy) > - WM_EVENT_CURSOR_MOTION_THRESHOLD) { + WM_EVENT_CURSOR_MOTION_THRESHOLD) + { WM_tooltip_clear(C, win); } } @@ -4138,8 +4150,8 @@ void wm_event_do_handlers(bContext *C) /* If press was handled, we don't want to do click. This way * press in tool key-map can override click in editor key-map. */ - if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS && - !wm_action_not_handled(action)) { + if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS && !wm_action_not_handled(action)) + { win->event_queue_check_click = false; } @@ -4230,7 +4242,8 @@ static wmWindow *wm_event_find_fileselect_root_window_from_context(const bContex wmWindow *ctx_win = CTX_wm_window(C); for (wmWindow *ctx_win_or_parent = ctx_win; ctx_win_or_parent; - ctx_win_or_parent = ctx_win_or_parent->parent) { + ctx_win_or_parent = ctx_win_or_parent->parent) + { ScrArea *file_area = ED_fileselect_handler_area_find_any_with_op(ctx_win_or_parent); if (!file_area) { @@ -4525,7 +4538,8 @@ static void wm_event_get_keymap_from_toolsystem_ex(wmWindowManager *wm, bool is_gizmo_highlight = false; if ((tref_rt && tref_rt->keymap_fallback[0]) && - (scene && (scene->toolsettings->workspace_tool_type == SCE_WORKSPACE_TOOL_FALLBACK))) { + (scene && (scene->toolsettings->workspace_tool_type == SCE_WORKSPACE_TOOL_FALLBACK))) + { bool add_keymap = false; /* Support for the gizmo owning the tool key-map. */ @@ -4746,7 +4760,8 @@ void WM_event_remove_ui_handler(ListBase *handlers, if (handler_base->type == WM_HANDLER_TYPE_UI) { wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base; if ((handler->handle_fn == handle_fn) && (handler->remove_fn == remove_fn) && - (handler->user_data == user_data)) { + (handler->user_data == user_data)) + { /* Handlers will be freed in #wm_handlers_do(). */ if (postpone) { handler->head.flag |= WM_HANDLER_DO_FREE; @@ -5181,7 +5196,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi /* Check if outside, include top window bar. */ int event_xy[2] = {UNPACK2(event->xy)}; if (event_xy[0] < 0 || event_xy[1] < 0 || event_xy[0] > WM_window_pixels_x(win) || - event_xy[1] > WM_window_pixels_y(win) + 30) { + event_xy[1] > WM_window_pixels_y(win) + 30) + { /* Let's skip windows having modal handlers now. */ /* Potential XXX ugly... I wouldn't have added a `modalhandlers` list * (introduced in rev 23331, ton). */ @@ -5203,7 +5219,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi static bool wm_event_is_double_click(const wmEvent *event) { if ((event->type == event->prev_type) && (event->prev_val == KM_RELEASE) && - (event->val == KM_PRESS)) { + (event->val == KM_PRESS)) + { if (ISMOUSE_BUTTON(event->type) && WM_event_drag_test(event, event->prev_press_xy)) { /* Pass. */ } @@ -5457,13 +5474,15 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, const int type, * while not common, avoid a false alarm. */ #ifndef NDEBUG if ((event_state->type || event_state->val) && /* Ignore cleared event state. */ - !(ISKEYBOARD_OR_BUTTON(event_state->type) || (event_state->type == EVENT_NONE))) { + !(ISKEYBOARD_OR_BUTTON(event_state->type) || (event_state->type == EVENT_NONE))) + { CLOG_WARN(WM_LOG_HANDLERS, "Non-keyboard/mouse button found in 'win->eventstate->type = %d'", event_state->type); } if ((event_state->prev_type || event_state->prev_val) && /* Ignore cleared event state. */ - !(ISKEYBOARD_OR_BUTTON(event_state->prev_type) || (event_state->type == EVENT_NONE))) { + !(ISKEYBOARD_OR_BUTTON(event_state->prev_type) || (event_state->type == EVENT_NONE))) + { CLOG_WARN(WM_LOG_HANDLERS, "Non-keyboard/mouse button found in 'win->eventstate->prev_type = %d'", event_state->prev_type); @@ -6121,7 +6140,8 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) RGN_TYPE_TOOL_HEADER, RGN_TYPE_FOOTER, RGN_TYPE_TEMPORARY, - RGN_TYPE_HUD)) { + RGN_TYPE_HUD)) + { return; } /* Fallback to window. */ diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 0ca6d2372a9..f8eb81b0b34 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -286,7 +286,7 @@ static void wm_window_match_keep_current_wm(const bContext *C, LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace; - BKE_workspace_layout_find_global(bmain, screen, &workspace); + WorkSpaceLayout *layout_old = BKE_workspace_layout_find_global(bmain, screen, &workspace); BKE_workspace_active_set(win->workspace_hook, workspace); win->scene = CTX_data_scene(C); @@ -295,7 +295,9 @@ static void wm_window_match_keep_current_wm(const bContext *C, WM_window_set_active_screen(win, workspace, screen); } else { +#if 0 /* NOTE(@ideasman42): The screen referenced from the window has been freed, see: 107525. */ WorkSpaceLayout *layout_old = WM_window_get_active_layout(win); +#endif WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( bmain, workspace, layout_old, win); @@ -590,7 +592,7 @@ void WM_file_autoexec_init(const char *filepath) if (G.f & G_FLAG_SCRIPT_AUTOEXEC) { char dirpath[FILE_MAX]; - BLI_split_dir_part(filepath, dirpath, sizeof(dirpath)); + BLI_path_split_dir_part(filepath, dirpath, sizeof(dirpath)); if (BKE_autoexec_match(dirpath)) { G.f &= ~G_FLAG_SCRIPT_AUTOEXEC; } @@ -602,8 +604,8 @@ void wm_file_read_report(bContext *C, Main *bmain) ReportList *reports = nullptr; LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { if (scene->r.engine[0] && - BLI_findstring(&R_engines, scene->r.engine, offsetof(RenderEngineType, idname)) == - nullptr) { + BLI_findstring(&R_engines, scene->r.engine, offsetof(RenderEngineType, idname)) == nullptr) + { if (reports == nullptr) { reports = CTX_wm_reports(C); } @@ -874,7 +876,8 @@ static void file_read_reports_finalize(BlendFileReadReport *bf_reports) if (bf_reports->resynced_lib_overrides_libraries_count != 0) { for (LinkNode *node_lib = bf_reports->resynced_lib_overrides_libraries; node_lib != nullptr; - node_lib = node_lib->next) { + node_lib = node_lib->next) + { Library *library = static_cast(node_lib->link); BKE_reportf(bf_reports->reports, RPT_INFO, @@ -914,7 +917,8 @@ static void file_read_reports_finalize(BlendFileReadReport *bf_reports) } if (bf_reports->count.proxies_to_lib_overrides_success != 0 || - bf_reports->count.proxies_to_lib_overrides_failures != 0) { + bf_reports->count.proxies_to_lib_overrides_failures != 0) + { BKE_reportf(bf_reports->reports, RPT_WARNING, "Proxies have been removed from Blender (%d proxies were automatically converted " @@ -1250,7 +1254,8 @@ void wm_homefile_read_ex(bContext *C, if ((app_template != nullptr) && (app_template[0] != '\0')) { if (!BKE_appdir_app_template_id_search( - app_template, app_template_system, sizeof(app_template_system))) { + app_template, app_template_system, sizeof(app_template_system))) + { /* Can safely continue with code below, just warn it's not found. */ BKE_reportf(reports, RPT_WARNING, "Application Template \"%s\" not found", app_template); } @@ -1465,13 +1470,13 @@ void wm_history_file_read(void) return; } - char name[FILE_MAX]; + char filepath[FILE_MAX]; LinkNode *l; int num; - BLI_path_join(name, sizeof(name), cfgdir, BLENDER_HISTORY_FILE); + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_HISTORY_FILE); - LinkNode *lines = BLI_file_read_as_lines(name); + LinkNode *lines = BLI_file_read_as_lines(filepath); wm_history_files_free(); @@ -1524,7 +1529,7 @@ static RecentFile *wm_file_history_find(const char *filepath) static void wm_history_file_write(void) { const char *user_config_dir; - char name[FILE_MAX]; + char filepath[FILE_MAX]; FILE *fp; /* will be nullptr in background mode */ @@ -1533,9 +1538,9 @@ static void wm_history_file_write(void) return; } - BLI_path_join(name, sizeof(name), user_config_dir, BLENDER_HISTORY_FILE); + BLI_path_join(filepath, sizeof(filepath), user_config_dir, BLENDER_HISTORY_FILE); - fp = BLI_fopen(name, "w"); + fp = BLI_fopen(filepath, "w"); if (fp) { LISTBASE_FOREACH (RecentFile *, recent, &G.recent_files) { fprintf(fp, "%s\n", recent->filepath); @@ -1569,7 +1574,8 @@ static void wm_history_file_update(void) RecentFile *recent_next; for (recent = static_cast(BLI_findlink(&G.recent_files, U.recent_files - 1)); recent; - recent = recent_next) { + recent = recent_next) + { recent_next = recent->next; wm_history_file_free(recent); } @@ -3683,7 +3689,8 @@ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_dat if (file_has_been_saved_before) { if (WM_operator_name_call(C, "WM_OT_save_mainfile", WM_OP_EXEC_DEFAULT, nullptr, nullptr) & - OPERATOR_CANCELLED) { + OPERATOR_CANCELLED) + { execute_callback = false; } } @@ -3752,7 +3759,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, const char *blendfile_path = BKE_main_blendfile_path(CTX_data_main(C)); char filename[FILE_MAX]; if (blendfile_path[0] != '\0') { - BLI_split_file_part(blendfile_path, filename, sizeof(filename)); + BLI_path_split_file_part(blendfile_path, filename, sizeof(filename)); } else { SNPRINTF(filename, "%s.blend", DATA_("untitled")); @@ -3926,7 +3933,8 @@ bool wm_operator_close_file_dialog_if_needed(bContext *C, wmGenericCallbackFn post_action_fn) { if (U.uiflag & USER_SAVE_PROMPT && - wm_file_or_session_data_has_unsaved_changes(CTX_data_main(C), CTX_wm_manager(C))) { + wm_file_or_session_data_has_unsaved_changes(CTX_data_main(C), CTX_wm_manager(C))) + { wmGenericCallback *callback = MEM_cnew(__func__); callback->exec = post_action_fn; callback->user_data = IDP_CopyProperty(op->properties); diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 8b1885c8ad0..1473d4ae7e5 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -126,7 +126,8 @@ static int wm_link_append_flag(wmOperator *op) flag |= FILE_ACTIVE_COLLECTION; } if ((prop = RNA_struct_find_property(op->ptr, "relative_path")) && - RNA_property_boolean_get(op->ptr, prop)) { + RNA_property_boolean_get(op->ptr, prop)) + { flag |= FILE_RELPATH; } if (RNA_boolean_get(op->ptr, "link")) { @@ -177,7 +178,8 @@ static bool wm_link_append_item_poll(ReportList *reports, idcode = BKE_idtype_idcode_from_name(group); if (!BKE_idtype_idcode_is_linkable(idcode) || - (!do_append && BKE_idtype_idcode_is_only_appendable(idcode))) { + (!do_append && BKE_idtype_idcode_is_only_appendable(idcode))) + { if (reports) { if (do_append) { BKE_reportf(reports, diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index 764177fcc18..4cf6e5939c0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -498,7 +498,8 @@ void WM_exit_ex(bContext *C, const bool do_python) BlendFileWriteParams blend_file_write_params{}; if ((has_edited && BLO_write_file(bmain, filepath, fileflags, &blend_file_write_params, nullptr)) || - BLO_memfile_write_file(undo_memfile, filepath)) { + BLO_memfile_write_file(undo_memfile, filepath)) + { printf("Saved session recovery to \"%s\"\n", filepath); } } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 16a93dd4ead..936eab3b21b 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -450,7 +450,8 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap) !BLI_str_endswith(keymap->idname, " (fallback)") && /* This is an exception which may be empty. * Longer term we might want a flag to indicate an empty key-map is intended. */ - !STREQ(keymap->idname, "Node Tool: Tweak")) { + !STREQ(keymap->idname, "Node Tool: Tweak")) + { CLOG_WARN(WM_LOG_KEYMAPS, "empty keymap '%s'", keymap->idname); } } @@ -1252,7 +1253,8 @@ int WM_modalkeymap_items_to_string(const wmKeyMap *km, totlen += WM_keymap_item_to_string(kmi, compact, &result[totlen], result_len - totlen); if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == NULL || - totlen >= (result_len - 2)) { + totlen >= (result_len - 2)) + { break; } diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c index 10ef02f3829..5e4ebeedd62 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.c +++ b/source/blender/windowmanager/intern/wm_keymap_utils.c @@ -202,7 +202,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } /* Screen & Render */ else if (STRPREFIX(opname, "SCREEN_OT") || STRPREFIX(opname, "RENDER_OT") || - STRPREFIX(opname, "SOUND_OT") || STRPREFIX(opname, "SCENE_OT")) { + STRPREFIX(opname, "SOUND_OT") || STRPREFIX(opname, "SCENE_OT")) + { km = WM_keymap_find_all(wm, "Screen", 0, 0); } /* Grease Pencil */ @@ -233,7 +234,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } /* Object mode related */ else if (STRPREFIX(opname, "GROUP_OT") || STRPREFIX(opname, "MATERIAL_OT") || - STRPREFIX(opname, "PTCACHE_OT") || STRPREFIX(opname, "RIGIDBODY_OT")) { + STRPREFIX(opname, "PTCACHE_OT") || STRPREFIX(opname, "RIGIDBODY_OT")) + { km = WM_keymap_find_all(wm, "Object Mode", 0, 0); } diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 304880a75d0..d71f60c8a4b 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -235,8 +235,8 @@ void WM_operatortype_last_properties_clear_all(void) { GHashIterator iter; - for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); - BLI_ghashIterator_step(&iter)) { + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) + { wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); if (ot->last_properties) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 548ee1440c9..7689364d4af 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -446,7 +446,8 @@ static const char *wm_context_member_from_ptr(const bContext *C, { \ const char *ctx_member = member; \ if (RNA_struct_is_a((rna_ptr)->type, &(rna_type)) && \ - (rna_ptr)->data == (CTX_data_pointer_get_type(C, ctx_member, &(rna_type)).data)) { \ + (rna_ptr)->data == (CTX_data_pointer_get_type(C, ctx_member, &(rna_type)).data)) \ + { \ member_id = ctx_member; \ break; \ } \ @@ -2304,7 +2305,8 @@ static void radial_control_set_tex(RadialControl *rc) if ((ibuf = BKE_brush_gen_radial_control_imbuf( rc->image_id_ptr.data, rc->use_secondary_tex, - !ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) { + !ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) + { rc->texture = GPU_texture_create_2d("radial_control", ibuf->x, @@ -2336,8 +2338,9 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph PointerRNA *fill_ptr; PropertyRNA *fill_prop; - if (rc->fill_col_override_prop && RNA_property_boolean_get(&rc->fill_col_override_test_ptr, - rc->fill_col_override_test_prop)) { + if (rc->fill_col_override_prop && + RNA_property_boolean_get(&rc->fill_col_override_test_ptr, rc->fill_col_override_test_prop)) + { fill_ptr = &rc->fill_col_override_ptr; fill_prop = rc->fill_col_override_prop; } @@ -2631,7 +2634,8 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, PropertyType prop_type = RNA_property_type(*r_prop); if (((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) || - ((flags & RC_PROP_REQUIRE_FLOAT) && (prop_type != PROP_FLOAT))) { + ((flags & RC_PROP_REQUIRE_FLOAT) && (prop_type != PROP_FLOAT))) + { MEM_freeN(str); BKE_reportf(op->reports, RPT_ERROR, "Property from path '%s' is not a float", name); return 0; @@ -2673,7 +2677,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) &use_secondary_ptr, &use_secondary_prop, 0, - (RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))) { + (RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))) + { return 0; } @@ -2695,12 +2700,14 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) } if (!radial_control_get_path( - &ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) { + &ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) + { return 0; } if (!radial_control_get_path( - &ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 4, RC_PROP_REQUIRE_FLOAT)) { + &ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 4, RC_PROP_REQUIRE_FLOAT)) + { return 0; } @@ -2710,7 +2717,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) &rc->fill_col_ptr, &rc->fill_col_prop, 3, - RC_PROP_REQUIRE_FLOAT)) { + RC_PROP_REQUIRE_FLOAT)) + { return 0; } @@ -2720,7 +2728,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) &rc->fill_col_override_ptr, &rc->fill_col_override_prop, 3, - RC_PROP_REQUIRE_FLOAT)) { + RC_PROP_REQUIRE_FLOAT)) + { return 0; } if (!radial_control_get_path(&ctx_ptr, @@ -2729,7 +2738,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) &rc->fill_col_override_test_ptr, &rc->fill_col_override_test_prop, 0, - RC_PROP_REQUIRE_BOOL)) { + RC_PROP_REQUIRE_BOOL)) + { return 0; } @@ -2742,7 +2752,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) &rc->zoom_ptr, &rc->zoom_prop, 2, - RC_PROP_REQUIRE_FLOAT | RC_PROP_ALLOW_MISSING)) { + RC_PROP_REQUIRE_FLOAT | RC_PROP_ALLOW_MISSING)) + { return 0; } @@ -2821,7 +2832,8 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve PROP_FACTOR, PROP_PERCENTAGE, PROP_ANGLE, - PROP_PIXEL)) { + PROP_PIXEL)) + { BKE_report(op->reports, RPT_ERROR, "Property must be a none, distance, factor, percentage, angle, or pixel"); @@ -3085,7 +3097,8 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even } if (!handled && (event->val == KM_RELEASE) && (rc->init_event == event->type) && - RNA_boolean_get(op->ptr, "release_confirm")) { + RNA_boolean_get(op->ptr, "release_confirm")) + { ret = OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_platform_support.c b/source/blender/windowmanager/intern/wm_platform_support.c index 60037f3ceb5..1d19c952f2e 100644 --- a/source/blender/windowmanager/intern/wm_platform_support.c +++ b/source/blender/windowmanager/intern/wm_platform_support.c @@ -109,7 +109,8 @@ bool WM_platform_support_perform_checks(void) /* Check if previous check matches the current check. Don't update the approval when running in * `background`. this could have been triggered by installing add-ons via installers. */ if (support_level != GPU_SUPPORT_LEVEL_UNSUPPORTED && !G.factory_startup && - wm_platform_support_check_approval(platform_key, !G.background)) { + wm_platform_support_check_approval(platform_key, !G.background)) + { /* If it matches the user has confirmed and wishes to use it. */ return result; } diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 6b539985235..88a4d821c83 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -242,7 +242,8 @@ typedef struct PlayAnimPict { struct PlayAnimPict *next, *prev; uchar *mem; int size; - const char *name; + /** The allocated file-path to the image. */ + const char *filepath; struct ImBuf *ibuf; struct anim *anim; int frame; @@ -352,11 +353,11 @@ static ImBuf *ibuf_from_picture(PlayAnimPict *pic) } else if (pic->mem) { /* use correct colorspace here */ - ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->name); + ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->filepath); } else { /* use correct colorspace here */ - ibuf = IMB_loadiffname(pic->name, pic->IB_flags, NULL); + ibuf = IMB_loadiffname(pic->filepath, pic->IB_flags, NULL); } return ibuf; @@ -537,7 +538,7 @@ static void playanim_toscreen( PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) { if (ibuf == NULL) { - printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : ""); + printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->filepath : ""); return; } @@ -579,7 +580,7 @@ static void playanim_toscreen( int sizex, sizey; float fsizex_inv, fsizey_inv; char str[32 + FILE_MAX]; - BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->name, fstep / swaptime); + BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->filepath, fstep / swaptime); playanim_window_get_size(&sizex, &sizey); fsizex_inv = 1.0f / sizex; @@ -622,11 +623,11 @@ static void playanim_toscreen( } static void build_pict_list_ex( - PlayState *ps, const char *first, int totframes, int fstep, int fontid) + PlayState *ps, const char *filepath_first, int totframes, int fstep, int fontid) { - if (IMB_isanim(first)) { + if (IMB_isanim(filepath_first)) { /* OCIO_TODO: support different input color space */ - struct anim *anim = IMB_open_anim(first, IB_rect, 0, NULL); + struct anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, NULL); if (anim) { int pic; struct ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -640,12 +641,12 @@ static void build_pict_list_ex( picture->anim = anim; picture->frame = pic; picture->IB_flags = IB_rect; - picture->name = BLI_sprintfN("%s : %4.d", first, pic + 1); + picture->filepath = BLI_sprintfN("%s : %4.d", filepath_first, pic + 1); BLI_addtail(&picsbase, picture); } } else { - printf("couldn't open anim %s\n", first); + printf("couldn't open anim %s\n", filepath_first); } } else { @@ -666,7 +667,7 @@ static void build_pict_list_ex( } fp_decoded; char filepath[FILE_MAX]; - BLI_strncpy(filepath, first, sizeof(filepath)); + BLI_strncpy(filepath, filepath_first, sizeof(filepath)); fp_framenr = BLI_path_sequence_decode(filepath, fp_decoded.head, sizeof(fp_decoded.head), @@ -739,7 +740,7 @@ static void build_pict_list_ex( } picture->mem = mem; - picture->name = BLI_strdup(filepath); + picture->filepath = BLI_strdup(filepath); picture->frame = count; close(file); BLI_addtail(&picsbase, picture); @@ -797,10 +798,11 @@ static void build_pict_list_ex( } } -static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid) +static void build_pict_list( + PlayState *ps, const char *filepath_first, int totframes, int fstep, int fontid) { ps->loading = true; - build_pict_list_ex(ps, first, totframes, fstep, fontid); + build_pict_list_ex(ps, filepath_first, totframes, fstep, fontid); ps->loading = false; } @@ -1078,7 +1080,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) if (g_WS.qual & WS_QUAL_SHIFT) { if (ps->picture && ps->picture->ibuf) { printf(" Name: %s | Speed: %.2f frames/s\n", - ps->picture->ibuf->name, + ps->picture->ibuf->filepath, ps->fstep / swaptime); } } @@ -1702,11 +1704,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif /* USE_FRAME_CACHE_LIMIT */ - BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name)); + BLI_strncpy(ibuf->filepath, ps.picture->filepath, sizeof(ibuf->filepath)); /* why only windows? (from 2.4x) - campbell */ #ifdef _WIN32 - GHOST_SetTitle(g_WS.ghost_window, ps.picture->name); + GHOST_SetTitle(g_WS.ghost_window, ps.picture->filepath); #endif while (pupdate_time()) { @@ -1796,7 +1798,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) MEM_freeN(ps.picture->mem); } - MEM_freeN((void *)ps.picture->name); + MEM_freeN((void *)ps.picture->filepath); MEM_freeN(ps.picture); } diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c index f1fe742fde2..42164bf0029 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.c +++ b/source/blender/windowmanager/intern/wm_splash_screen.c @@ -139,7 +139,8 @@ static ImBuf *wm_block_splash_image(int width, int *r_height) char splash_filepath[FILE_MAX]; char template_directory[FILE_MAX]; if (BKE_appdir_app_template_id_search( - U.app_template, template_directory, sizeof(template_directory))) { + U.app_template, template_directory, sizeof(template_directory))) + { BLI_path_join(splash_filepath, sizeof(splash_filepath), template_directory, "splash.png"); ibuf = IMB_loadiffname(splash_filepath, IB_rect, NULL); } diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index c46160197d1..f249cac104c 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -275,7 +275,8 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) *win_src->stereo3d_format = s3dd->stereo3d_format; if (prev_display_mode == S3D_DISPLAY_PAGEFLIP && - prev_display_mode != win_src->stereo3d_format->display_mode) { + prev_display_mode != win_src->stereo3d_format->display_mode) + { /* in case the hardware supports pageflip but not the display */ if ((win_dst = wm_window_copy_test(C, win_src, false, false))) { /* pass */ diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index b742569738f..bab9fe40d84 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -523,7 +523,8 @@ void WM_toolsystem_refresh_active(bContext *C) /* Don't change the space type of the active tool, only update its mode. */ const int space_type_mask = (1 << area->spacetype); if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) && - ((space_type_mask_handled & space_type_mask) == 0)) { + ((space_type_mask_handled & space_type_mask) == 0)) + { space_type_mask_handled |= space_type_mask; const bToolKey tkey = { .space_type = area->spacetype, diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index ae0411e38c7..017b1d86bba 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -388,7 +388,8 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) if (U.uiflag & USER_SAVE_PROMPT) { if (wm_file_or_session_data_has_unsaved_changes(CTX_data_main(C), CTX_wm_manager(C)) && - !G.background) { + !G.background) + { wm_window_raise(win); wm_confirm_quit(C); } diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c index bf2107c3db3..a170469908a 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c @@ -68,8 +68,8 @@ void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner) msg_key_next = msg_key->next; wmMsgSubscribeValueLink *msg_lnk_next; - for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; - msg_lnk = msg_lnk_next) { + for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; msg_lnk = msg_lnk_next) + { msg_lnk_next = msg_lnk->next; if (msg_lnk->params.owner == owner) { if (msg_lnk->params.tag) { @@ -154,7 +154,8 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus, LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) { if ((msg_lnk->params.notify == msg_val_params->notify) && (msg_lnk->params.owner == msg_val_params->owner) && - (msg_lnk->params.user_data == msg_val_params->user_data)) { + (msg_lnk->params.user_data == msg_val_params->user_data)) + { return key; } } diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c index e903ac11fba..661ef748a55 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c @@ -55,8 +55,8 @@ static void wm_msg_rna_gset_key_free(void *key_p) { wmMsgSubscribeKey_RNA *key = key_p; wmMsgSubscribeValueLink *msg_lnk_next; - for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first; msg_lnk; - msg_lnk = msg_lnk_next) { + for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first; msg_lnk; msg_lnk = msg_lnk_next) + { msg_lnk_next = msg_lnk->next; wm_msg_subscribe_value_free(&key->head, msg_lnk); } @@ -97,7 +97,8 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds /* Remove any non-persistent values, so a single persistent * value doesn't modify behavior for the rest. */ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk; - msg_lnk = msg_lnk_next) { + msg_lnk = msg_lnk_next) + { msg_lnk_next = msg_lnk->next; if (msg_lnk->params.is_persistent == false) { if (msg_lnk->params.tag) { @@ -125,7 +126,8 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds PointerRNA ptr; PropertyRNA *prop = NULL; if (RNA_path_resolve(&idptr, key->msg.params.data_path, &ptr, &prop) && - (prop == NULL) == (key->msg.params.prop == NULL)) { + (prop == NULL) == (key->msg.params.prop == NULL)) + { key->msg.params.ptr = ptr; key->msg.params.prop = prop; remove = false; @@ -134,7 +136,8 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds if (remove) { for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk; - msg_lnk = msg_lnk_next) { + msg_lnk = msg_lnk_next) + { msg_lnk_next = msg_lnk->next; if (msg_lnk->params.is_persistent == false) { if (msg_lnk->params.tag) { @@ -169,7 +172,8 @@ static void wm_msg_rna_remove_by_id(struct wmMsgBus *mbus, const ID *id) if (key->msg.params.ptr.owner_id == id) { /* Clear here so we can decrement 'messages_tag_count'. */ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk; - msg_lnk = msg_lnk_next) { + msg_lnk = msg_lnk_next) + { msg_lnk_next = msg_lnk->next; if (msg_lnk->params.tag) { mbus->messages_tag_count -= 1; diff --git a/source/blender/windowmanager/xr/intern/wm_xr_action.c b/source/blender/windowmanager/xr/intern/wm_xr_action.c index 68f6bfc1aff..ee2dbc9ee3b 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_action.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_action.c @@ -302,7 +302,8 @@ void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char if ((action_set->controller_grip_action && STREQ(action_set->controller_grip_action->name, action_name)) || (action_set->controller_aim_action && - STREQ(action_set->controller_aim_action->name, action_name))) { + STREQ(action_set->controller_aim_action->name, action_name))) + { if (action_set == xr->runtime->session_state.active_action_set) { wm_xr_session_controller_data_clear(&xr->runtime->session_state); } diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c index 6cc9c8962dc..77f68144caf 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_draw.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c @@ -196,7 +196,8 @@ static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_co GHOST_XrControllerModelData model_data; if (!GHOST_XrGetControllerModelData(xr_context, subaction_path, &model_data) || - model_data.count_vertices < 1) { + model_data.count_vertices < 1) + { return NULL; } @@ -259,7 +260,8 @@ static void wm_xr_controller_model_draw(const XrSessionSettings *settings, if (model && GHOST_XrGetControllerModelData(xr_context, controller->subaction_path, &model_data) && - model_data.count_components > 0) { + model_data.count_components > 0) + { GPU_batch_program_set_builtin(model, GPU_SHADER_3D_UNIFORM_COLOR); GPU_batch_uniform_4fv(model, "color", color); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.c b/source/blender/windowmanager/xr/intern/wm_xr_operators.c index 543e5782a5a..f17f6847ae4 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_operators.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_operators.c @@ -474,8 +474,8 @@ static void wm_xr_navigation_grab_apply(wmXrData *xr, /* Limit scale to reasonable values. */ nav_scale = len_v3(out[0]); - if (!(nav_scale < xr->session_settings.clip_start || - nav_scale > xr->session_settings.clip_end)) { + if (!(nav_scale < xr->session_settings.clip_start || nav_scale > xr->session_settings.clip_end)) + { WM_xr_session_state_nav_location_set(xr, out[3]); if (!data->rot_lock) { mat4_to_quat(nav_pose.orientation_quat, out); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index 64d687b956a..41342378b3b 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -215,7 +215,8 @@ wmWindow *wm_xr_session_root_window_or_fallback_get(const wmWindowManager *wm, const wmXrRuntimeData *runtime_data) { if (runtime_data->session_root_win && - BLI_findindex(&wm->windows, runtime_data->session_root_win) != -1) { + BLI_findindex(&wm->windows, runtime_data->session_root_win) != -1) + { /* Root window is still valid, use it. */ return runtime_data->session_root_win; } @@ -436,7 +437,8 @@ bool WM_xr_session_state_controller_grip_location_get(const wmXrData *xr, float r_location[3]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || - (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) { + (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) + { zero_v3(r_location); return false; } @@ -453,7 +455,8 @@ bool WM_xr_session_state_controller_grip_rotation_get(const wmXrData *xr, float r_rotation[4]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || - (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) { + (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) + { unit_qt(r_rotation); return false; } @@ -470,7 +473,8 @@ bool WM_xr_session_state_controller_aim_location_get(const wmXrData *xr, float r_location[3]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || - (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) { + (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) + { zero_v3(r_location); return false; } @@ -487,7 +491,8 @@ bool WM_xr_session_state_controller_aim_rotation_get(const wmXrData *xr, float r_rotation[4]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || - (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) { + (subaction_idx >= BLI_listbase_count(&xr->runtime->session_state.controllers))) + { unit_qt(r_rotation); return false; } @@ -729,7 +734,8 @@ static bool wm_xr_session_modal_action_test(const ListBase *active_modal_actions return true; } if (action->ot == active_modal_action->ot && - IDP_EqualsProperties(action->op_properties, active_modal_action->op_properties)) { + IDP_EqualsProperties(action->op_properties, active_modal_action->op_properties)) + { /* Don't allow duplicate modal operators since this can lead to unwanted modal handler * behavior. */ return false; @@ -847,12 +853,14 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, const float *state = &((float *)action->states)[subaction_idx]; float *state_prev = &((float *)action->states_prev)[subaction_idx]; if (test_float_state( - state, action->float_thresholds[subaction_idx], action->axis_flags[subaction_idx])) { + state, action->float_thresholds[subaction_idx], action->axis_flags[subaction_idx])) + { curr = true; } if (test_float_state(state_prev, action->float_thresholds[subaction_idx], - action->axis_flags[subaction_idx])) { + action->axis_flags[subaction_idx])) + { prev = true; } *state_prev = *state; @@ -861,14 +869,15 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, case XR_VECTOR2F_INPUT: { const float(*state)[2] = &((float(*)[2])action->states)[subaction_idx]; float(*state_prev)[2] = &((float(*)[2])action->states_prev)[subaction_idx]; - if (test_vec2f_state(*state, - action->float_thresholds[subaction_idx], - action->axis_flags[subaction_idx])) { + if (test_vec2f_state( + *state, action->float_thresholds[subaction_idx], action->axis_flags[subaction_idx])) + { curr = true; } if (test_vec2f_state(*state_prev, action->float_thresholds[subaction_idx], - action->axis_flags[subaction_idx])) { + action->axis_flags[subaction_idx])) + { prev = true; } copy_v2_v2(*state_prev, *state); @@ -893,7 +902,8 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, haptic_subaction_path, &action->haptic_duration, &action->haptic_frequency, - &action->haptic_amplitude)) { + &action->haptic_amplitude)) + { wm_xr_session_haptic_action_add( active_haptic_actions, action, haptic_subaction_path, time_now); } @@ -909,8 +919,8 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, wm_xr_session_modal_action_test_add(active_modal_actions, action); } if (haptic && ((action->haptic_flag & XR_HAPTIC_REPEAT) != 0)) { - if (!wm_xr_session_haptic_action_find( - active_haptic_actions, action, haptic_subaction_path)) { + if (!wm_xr_session_haptic_action_find(active_haptic_actions, action, haptic_subaction_path)) + { /* Apply haptics. */ if (WM_xr_haptic_action_apply(xr, action_set_name, @@ -918,7 +928,8 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, haptic_subaction_path, &action->haptic_duration, &action->haptic_frequency, - &action->haptic_amplitude)) { + &action->haptic_amplitude)) + { wm_xr_session_haptic_action_add( active_haptic_actions, action, haptic_subaction_path, time_now); } @@ -944,7 +955,8 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, haptic_subaction_path, &action->haptic_duration, &action->haptic_frequency, - &action->haptic_amplitude)) { + &action->haptic_amplitude)) + { wm_xr_session_haptic_action_add( active_haptic_actions, action, haptic_subaction_path, time_now); } @@ -986,7 +998,8 @@ static bool wm_xr_session_action_test_bimanual(const wmXrSessionState *session_s const float *state = &((float *)action->states)[*r_subaction_idx_other]; if (test_float_state(state, action->float_thresholds[*r_subaction_idx_other], - action->axis_flags[*r_subaction_idx_other])) { + action->axis_flags[*r_subaction_idx_other])) + { bimanual = true; } break; @@ -995,7 +1008,8 @@ static bool wm_xr_session_action_test_bimanual(const wmXrSessionState *session_s const float(*state)[2] = &((float(*)[2])action->states)[*r_subaction_idx_other]; if (test_vec2f_state(*state, action->float_thresholds[*r_subaction_idx_other], - action->axis_flags[*r_subaction_idx_other])) { + action->axis_flags[*r_subaction_idx_other])) + { bimanual = true; } break; @@ -1116,8 +1130,8 @@ static void wm_xr_session_events_dispatch(wmXrData *xr, const bool haptic = (GHOST_XrGetActionCustomdata( xr_context, action_set_name, action->haptic_name) != NULL); - for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths; - ++subaction_idx) { + for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths; ++subaction_idx) + { short val = KM_NOTHING; /* Interpret action states (update modal/haptic action lists, apply haptics, etc). */ @@ -1368,8 +1382,9 @@ bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data, char err_out[256] = "unknown"; bool failure = false; - eGPUTextureFormat format = - GPU_R8; /* Initialize with some unsupported format to check following switch statement. */ + + /* Initialize with some unsupported format to check following switch statement. */ + eGPUTextureFormat format = GPU_R8; switch (draw_view->swapchain_format) { case GHOST_kXrSwapchainFormatRGBA8: diff --git a/source/creator/blender_launcher_win32.c b/source/creator/blender_launcher_win32.c index 49acc591487..4fb314596a5 100644 --- a/source/creator/blender_launcher_win32.c +++ b/source/creator/blender_launcher_win32.c @@ -110,7 +110,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine STRSAFE_NULL_ON_FAILURE, L"\"%s\" %s", path, - pCmdLine) != S_OK) { + pCmdLine) != S_OK) + { free(buffer); return -1; } diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 0b34d8bb8ba..e30dd772675 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -149,8 +149,8 @@ static bool parse_int_range_relative(const char *str, const char **r_err_msg) { if (parse_int_relative(str, str_end_range, pos, neg, &r_value_range[0], r_err_msg) && - parse_int_relative( - str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg)) { + parse_int_relative(str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg)) + { return true; } return false; @@ -329,7 +329,8 @@ static int (*parse_int_range_relative_clamp_n(const char *str, parse_int_range_relative_clamp( str, str_end_range, str_end, pos, neg, min, max, values[i], r_err_msg) : parse_int_relative_clamp( - str, str_end, pos, neg, min, max, &values[i][0], r_err_msg)) { + str, str_end, pos, neg, min, max, &values[i][0], r_err_msg)) + { if (str_end_range == NULL) { values[i][1] = values[i][0]; } @@ -395,7 +396,8 @@ static void arg_py_context_restore(bContext *C, struct BlendePyContextStore *c_p /* script may load a file, check old data is valid before using */ if (c_py->has_win) { if ((c_py->win == NULL) || ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) && - (BLI_findindex(&c_py->wm->windows, c_py->win) != -1))) { + (BLI_findindex(&c_py->wm->windows, c_py->win) != -1))) + { CTX_wm_window_set(C, c_py->win); } } @@ -1675,7 +1677,8 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data) MINAFRAME, MAXFRAME, &frames_range_len, - &err_msg)) == NULL) { + &err_msg)) == NULL) + { fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]); return 1; } @@ -1774,7 +1777,8 @@ static int arg_handle_frame_start_set(int argc, const char **argv, void *data) MINAFRAME, MAXFRAME, &scene->r.sfra, - &err_msg)) { + &err_msg)) + { fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]); } else { @@ -1807,7 +1811,8 @@ static int arg_handle_frame_end_set(int argc, const char **argv, void *data) MINAFRAME, MAXFRAME, &scene->r.efra, - &err_msg)) { + &err_msg)) + { fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]); } else { diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c index c733ee617cb..0912aa12019 100644 --- a/source/creator/creator_signals.c +++ b/source/creator/creator_signals.c @@ -98,20 +98,20 @@ static void sig_handle_crash(int signum) if (wm && wm->undo_stack) { struct MemFile *memfile = BKE_undosys_stack_memfile_get_active(wm->undo_stack); if (memfile) { - char fname[FILE_MAX]; + char filepath[FILE_MAX]; if (!(G_MAIN && G_MAIN->filepath[0])) { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), "crash.blend"); + BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_base(), "crash.blend"); } else { - STRNCPY(fname, G_MAIN->filepath); - BLI_path_extension_replace(fname, sizeof(fname), ".crash.blend"); + STRNCPY(filepath, G_MAIN->filepath); + BLI_path_extension_replace(filepath, sizeof(filepath), ".crash.blend"); } - printf("Writing: %s\n", fname); + printf("Writing: %s\n", filepath); fflush(stdout); - BLO_memfile_write_file(memfile, fname); + BLO_memfile_write_file(memfile, filepath); } } # endif @@ -119,17 +119,18 @@ static void sig_handle_crash(int signum) FILE *fp; char header[512]; - char fname[FILE_MAX]; + char filepath[FILE_MAX]; if (!(G_MAIN && G_MAIN->filepath[0])) { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), "blender.crash.txt"); + BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_base(), "blender.crash.txt"); } else { - BLI_path_join(fname, sizeof(fname), BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath)); - BLI_path_extension_replace(fname, sizeof(fname), ".crash.txt"); + BLI_path_join( + filepath, sizeof(filepath), BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath)); + BLI_path_extension_replace(filepath, sizeof(filepath), ".crash.txt"); } - printf("Writing: %s\n", fname); + printf("Writing: %s\n", filepath); fflush(stdout); # ifndef BUILD_DATE @@ -147,11 +148,11 @@ static void sig_handle_crash(int signum) /* open the crash log */ errno = 0; - fp = BLI_fopen(fname, "wb"); + fp = BLI_fopen(filepath, "wb"); if (fp == NULL) { fprintf(stderr, "Unable to save '%s': %s\n", - fname, + filepath, errno ? strerror(errno) : "Unknown error opening file"); } else { diff --git a/tests/python/bl_usd_export_test.py b/tests/python/bl_usd_export_test.py index 1080acaf7e6..917a47b8baa 100644 --- a/tests/python/bl_usd_export_test.py +++ b/tests/python/bl_usd_export_test.py @@ -8,6 +8,7 @@ import unittest from pxr import Usd from pxr import UsdUtils from pxr import UsdGeom +from pxr import UsdShade from pxr import Gf import bpy @@ -124,6 +125,75 @@ class USDExportTest(AbstractUSDTest): Gf.Vec3d(extent[1]), Gf.Vec3d(0.7515701, 0.5500924, 0.9027928) ) + def test_opacity_threshold(self): + # Note that the scene file used here is shared with a different test. + # Here we assume that it has a Principled BSDF material with + # a texture connected to its Base Color input. + bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "usd_materials_export.blend")) + + export_path = self.tempdir / "opaque_material.usda" + res = bpy.ops.wm.usd_export( + filepath=str(export_path), + export_materials=True, + evaluation_mode="RENDER", + ) + self.assertEqual({'FINISHED'}, res, f"Unable to export to {export_path}") + + # Inspect and validate the exported USD for the opaque blend case. + stage = Usd.Stage.Open(str(export_path)) + shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF") + shader = UsdShade.Shader(shader_prim) + opacity_input = shader.GetInput('opacity') + self.assertEqual(opacity_input.HasConnectedSource(), False, + "Opacity input should not be connected for opaque material") + self.assertAlmostEqual(opacity_input.Get(), 1.0, "Opacity input should be set to 1") + + # The material already has a texture input to the Base Color. + # Now also link this texture to the Alpha input. + # Set an opacity threshold appropriate for alpha clipping. + mat = bpy.data.materials['Material'] + bsdf = mat.node_tree.nodes['Principled BSDF'] + tex_output = bsdf.inputs['Base Color'].links[0].from_node.outputs['Color'] + alpha_input = bsdf.inputs['Alpha'] + mat.node_tree.links.new(tex_output, alpha_input) + bpy.data.materials['Material'].blend_method = 'CLIP' + bpy.data.materials['Material'].alpha_threshold = 0.01 + export_path = self.tempdir / "alphaclip_material.usda" + res = bpy.ops.wm.usd_export( + filepath=str(export_path), + export_materials=True, + evaluation_mode="RENDER", + ) + self.assertEqual({'FINISHED'}, res, f"Unable to export to {export_path}") + + # Inspect and validate the exported USD for the alpha clip case. + stage = Usd.Stage.Open(str(export_path)) + shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF") + shader = UsdShade.Shader(shader_prim) + opacity_input = shader.GetInput('opacity') + opacity_thres_input = shader.GetInput('opacityThreshold') + self.assertEqual(opacity_input.HasConnectedSource(), True, "Alpha input should be connected") + self.assertGreater(opacity_thres_input.Get(), 0.0, "Opacity threshold input should be > 0") + + # Modify material again, this time with alpha blend. + bpy.data.materials['Material'].blend_method = 'BLEND' + export_path = self.tempdir / "alphablend_material.usda" + res = bpy.ops.wm.usd_export( + filepath=str(export_path), + export_materials=True, + evaluation_mode="RENDER", + ) + self.assertEqual({'FINISHED'}, res, f"Unable to export to {export_path}") + + # Inspect and validate the exported USD for the alpha blend case. + stage = Usd.Stage.Open(str(export_path)) + shader_prim = stage.GetPrimAtPath("/_materials/Material/Principled_BSDF") + shader = UsdShade.Shader(shader_prim) + opacity_input = shader.GetInput('opacity') + opacity_thres_input = shader.GetInput('opacityThreshold') + self.assertEqual(opacity_input.HasConnectedSource(), True, "Alpha input should be connected") + self.assertEqual(opacity_thres_input.Get(), None, "Opacity threshold should not be specified for alpha blend") + def main(): global args -- 2.30.2 From 66080891f2c2f39bc2d8ef912de6a4b8ed7ccd10 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 3 May 2023 14:16:01 +0200 Subject: [PATCH 79/96] FIX: CPU device needs to register globals. --- intern/cycles/device/cpu/device_impl.h | 2 +- intern/cycles/device/multi/device.cpp | 62 +++++++++++++------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/intern/cycles/device/cpu/device_impl.h b/intern/cycles/device/cpu/device_impl.h index b16c3c62349..abaa83a3246 100644 --- a/intern/cycles/device/cpu/device_impl.h +++ b/intern/cycles/device/cpu/device_impl.h @@ -88,7 +88,7 @@ class CPUDevice : public Device { vector &kernel_thread_globals) override; virtual void *get_cpu_osl_memory() override; - virtual void upload_changed(vector ) override {} ; + //virtual void upload_changed(vector ) override {} ; protected: virtual bool load_kernels(uint /*kernel_features*/) override; }; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 27f0c908b2d..fe7fe29eb54 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -487,37 +487,39 @@ class MultiDevice : public Device { virtual void upload_changed(vector buffers) override { - //foreach (const vector &island, peer_islands) { - parallel_for_each (peer_islands.begin(), peer_islands.end(), [&](const vector &island) { - for (const device_memory *buffer: buffers) { - VLOG_INFO << "Checking " << buffer->name << " on " << this; - if (buffer->modified) { - device_ptr existing_key = buffer->device_pointer; - device_ptr key = (existing_key) ? existing_key : unique_key++; - size_t existing_size = buffer->device_size; + // foreach (const vector &island, peer_islands) { + parallel_for_each( + peer_islands.begin(), peer_islands.end(), [&](const vector &island) { + for (const device_memory *buffer : buffers) { + VLOG_INFO << "Checking " << buffer->name << " on " << this; + if (buffer->modified) { + device_ptr existing_key = buffer->device_pointer; + device_ptr key = (existing_key) ? existing_key : unique_key++; + size_t existing_size = buffer->device_size; - SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); - Device *sub_device = owner_sub->device.get(); - device_ptr sub_device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0; - device_memory_clone sub_mem(*buffer, sub_device, sub_device_pointer); - - VLOG_INFO << "Uploading to " << buffer->name; - owner_sub->device->mem_copy_to(sub_mem, existing_size, 0); - owner_sub->ptr_map[key] = sub_mem.device_pointer; - - if (sub_mem.type == MEM_GLOBAL || sub_mem.type == MEM_TEXTURE) { - /* Need to create texture objects and update pointer in kernel globals on all devices */ - foreach (SubDevice *island_sub, island) { - if (island_sub != owner_sub) { - island_sub->device->mem_copy_to(sub_mem, existing_size, 0); - } - } - } - stats.mem_alloc(sub_mem.device_size - existing_size); - } - } - } - ); + SubDevice *owner_sub = find_suitable_mem_device(existing_key, island); + Device *sub_device = owner_sub->device.get(); + device_ptr sub_device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : + 0; + device_memory_clone sub_mem(*buffer, sub_device, sub_device_pointer); + + VLOG_INFO << "Uploading to " << buffer->name; + owner_sub->device->mem_copy_to(sub_mem, existing_size, 0); + owner_sub->ptr_map[key] = sub_mem.device_pointer; + + if (sub_mem.type == MEM_GLOBAL || sub_mem.type == MEM_TEXTURE) { + /* Need to create texture objects and update pointer in kernel globals on all + * devices */ + foreach (SubDevice *island_sub, island) { + if (island_sub != owner_sub) { + island_sub->device->mem_copy_to(sub_mem, existing_size, 0); + } + } + } + stats.mem_alloc(sub_mem.device_size - existing_size); + } + } + }); } }; -- 2.30.2 From d01c68f4b0cf4c9bbbf215a90ee0866153f46f60 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 3 May 2023 14:16:38 +0200 Subject: [PATCH 80/96] FIX: program_name should be name only broken on window --- source/blender/blenlib/intern/path_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f07cb901fa8..ce3df9a43b2 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1140,7 +1140,7 @@ bool BLI_path_abs_from_cwd(char *path, const size_t maxlen) * environment variable (Windows-only) onto `name` in turn until such a file is found. * Returns success/failure. */ -bool BLI_path_program_extensions_add_win32(char *program_name, const size_t maxlen) +bool BLI_path_program_extensions_add_win32(char *name, const size_t maxlen) { bool retval = false; int type; -- 2.30.2 From c9b8ee956d531865fa89d0265214ae1163b5d7d0 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 4 May 2023 09:32:03 +0200 Subject: [PATCH 81/96] FIX: Don't upload buffers with 0 size --- intern/cycles/device/multi/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index fe7fe29eb54..a6e01966028 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -492,7 +492,7 @@ class MultiDevice : public Device { peer_islands.begin(), peer_islands.end(), [&](const vector &island) { for (const device_memory *buffer : buffers) { VLOG_INFO << "Checking " << buffer->name << " on " << this; - if (buffer->modified) { + if (buffer->modified && buffer->device_size > 0) { device_ptr existing_key = buffer->device_pointer; device_ptr key = (existing_key) ? existing_key : unique_key++; size_t existing_size = buffer->device_size; -- 2.30.2 From a87d9843d76e85efd969faf78f0609dbecf282d9 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 4 May 2023 10:07:31 +0200 Subject: [PATCH 82/96] FIX: Reinstate lock and context for build_optix_bvh --- intern/cycles/device/optix/device_impl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index 8fbc92dbc33..53c1525e01f 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -1007,6 +1007,9 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, * from running out of memory (since both original and compacted acceleration structure memory * may be allocated at the same time for the duration of this function). The builds would * otherwise happen on the same CUDA stream anyway. */ + static thread_mutex mutex; + thread_scoped_lock lock(mutex); + const CUDAContextScope scope(this); const bool use_fast_trace_bvh = (bvh->params.bvh_type == BVH_TYPE_STATIC); /* Compute memory usage. */ @@ -1076,10 +1079,12 @@ bool OptiXDevice::build_optix_bvh(BVHOptiX *bvh, use_fast_trace_bvh ? 1 : 0)); bvh->traversable_handle = static_cast(out_handle); + /* Wait for all operations to finish. */ + cuda_assert(cuStreamSynchronize(NULL)); + /* Compact acceleration structure to save memory (do not do this in viewport for faster builds). */ if (use_fast_trace_bvh) { - const CUDAContextScope scope(this); uint64_t compacted_size = sizes.outputSizeInBytes; cuda_assert(cuMemcpyDtoH(&compacted_size, compacted_size_prop.result, sizeof(compacted_size))); -- 2.30.2 From df0fba0d7d4ca6ed345ecc22cebb5f89e0952a54 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 4 May 2023 10:09:09 +0200 Subject: [PATCH 83/96] FIX: Upload buffer if data_size is not zero This was incorrectly set to be device_size which is not set until it is allocated on the device. --- intern/cycles/device/multi/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index a6e01966028..818d329e630 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -492,7 +492,7 @@ class MultiDevice : public Device { peer_islands.begin(), peer_islands.end(), [&](const vector &island) { for (const device_memory *buffer : buffers) { VLOG_INFO << "Checking " << buffer->name << " on " << this; - if (buffer->modified && buffer->device_size > 0) { + if (buffer->modified && buffer->data_size > 0) { device_ptr existing_key = buffer->device_pointer; device_ptr key = (existing_key) ? existing_key : unique_key++; size_t existing_size = buffer->device_size; -- 2.30.2 From 3cec5c199ee772975addfe7b1938fb8ff00a2a80 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Thu, 4 May 2023 16:56:31 +0200 Subject: [PATCH 84/96] Move buffer list to Scene --- intern/cycles/device/metal/device_impl.h | 2 -- intern/cycles/device/multi/device.cpp | 27 +++++++++++---------- intern/cycles/scene/geometry.cpp | 8 +++--- intern/cycles/scene/image.cpp | 31 ++++++++++++++++++------ intern/cycles/scene/scene.cpp | 28 +++++++++++++++++++++ intern/cycles/scene/scene.h | 2 +- 6 files changed, 71 insertions(+), 27 deletions(-) diff --git a/intern/cycles/device/metal/device_impl.h b/intern/cycles/device/metal/device_impl.h index 982a76d93fe..38823678b53 100644 --- a/intern/cycles/device/metal/device_impl.h +++ b/intern/cycles/device/metal/device_impl.h @@ -180,8 +180,6 @@ class MetalDevice : public Device { void tex_free(device_texture &mem); void flush_delayed_free_list(); - - void upload_changed() {}; }; CCL_NAMESPACE_END diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index a8f966d0425..06dff85c710 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -245,7 +245,8 @@ class MultiDevice : public Device { /* Skip building a bottom level acceleration structure for non-instanced geometry on * Embree (since they are put into the top level directly, see bvh_embree.cpp) */ if (!params.top_level && params.bvh_layout == BVH_LAYOUT_EMBREE && - !bvh_multi->geometry[0]->is_instanced()) { + !bvh_multi->geometry[0]->is_instanced()) + { } else { bvh_multi->sub_bvhs[id] = std::unique_ptr(BVH::create( @@ -487,8 +488,8 @@ class MultiDevice : public Device { virtual void upload_changed(vector buffers) override { // foreach (const vector &island, peer_islands) { - parallel_for_each( - peer_islands.begin(), peer_islands.end(), [&](const vector &island) { + parallel_for(size_t(0), peer_islands.size(), [&](const size_t idx) { + vector &island = peer_islands[idx]; for (const device_memory *buffer : buffers) { VLOG_INFO << "Checking " << buffer->name << " on " << this; if (buffer->modified && buffer->data_size > 0) { @@ -506,16 +507,16 @@ class MultiDevice : public Device { owner_sub->device->mem_copy_to(sub_mem, existing_size, 0); owner_sub->ptr_map[key] = sub_mem.device_pointer; - if (sub_mem.type == MEM_GLOBAL || sub_mem.type == MEM_TEXTURE) { - /* Need to create texture objects and update pointer in kernel globals on all - * devices */ - foreach (SubDevice *island_sub, island) { - if (island_sub != owner_sub) { - island_sub->device->mem_copy_to(sub_mem, existing_size, 0); - } - } - } - stats.mem_alloc(sub_mem.device_size - existing_size); + // if (sub_mem.type == MEM_GLOBAL || sub_mem.type == MEM_TEXTURE) { + // /* Need to create texture objects and update pointer in kernel globals on all + // * devices */ + // foreach (SubDevice *island_sub, island) { + // if (island_sub != owner_sub) { + // island_sub->device->mem_copy_to(sub_mem, existing_size, 0); + // } + // } + // } + //stats.mem_alloc(sub_mem.device_size - existing_size); } } }); diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 421688ad44f..e6d3fd604ca 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -944,7 +944,7 @@ void GeometryManager::device_update(Device *device, &dscene->objects }; - device->upload_changed(buffers); + device->upload_changed(scene->scene_buffers); parallel_for( size_t(0), num_scenes, [=, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, @@ -1183,7 +1183,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( {"device_update (displacement: copy meshes to device)", time}); } }); - sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); } { scoped_callback_timer timer([scene](double time) { @@ -1191,8 +1191,10 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( scene->update_stats->geometry.times.add_entry({"displacement: copy attributes to device", time}); } }); - sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); + //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } + device->upload_changed(scene->scene_buffers); + /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); diff --git a/intern/cycles/scene/image.cpp b/intern/cycles/scene/image.cpp index 94626b402bd..90c51e73834 100644 --- a/intern/cycles/scene/image.cpp +++ b/intern/cycles/scene/image.cpp @@ -714,7 +714,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, /* Create new texture. */ if (type == IMAGE_DATA_TYPE_FLOAT4) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); float *pixels = (float *)img->mem->alloc(1, 1); @@ -726,7 +727,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_FLOAT) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); float *pixels = (float *)img->mem->alloc(1, 1); @@ -735,7 +737,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_BYTE4) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); uchar *pixels = (uchar *)img->mem->alloc(1, 1); @@ -747,7 +750,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_BYTE) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); uchar *pixels = (uchar *)img->mem->alloc(1, 1); @@ -756,7 +760,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_HALF4) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); half *pixels = (half *)img->mem->alloc(1, 1); @@ -768,7 +773,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_USHORT) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); uint16_t *pixels = (uint16_t *)img->mem->alloc(1, 1); @@ -777,7 +783,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_USHORT4) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); uint16_t *pixels = (uint16_t *)img->mem->alloc(1, 1); @@ -789,7 +796,8 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, } } else if (type == IMAGE_DATA_TYPE_HALF) { - if (!file_load_image(img, texture_limit)) { + bool status = file_load_image(img, texture_limit); + if (!status) { /* on failure to load, we set a 1x1 pixels pink image */ thread_scoped_lock device_lock(device_mutex); half *pixels = (half *)img->mem->alloc(1, 1); @@ -811,8 +819,14 @@ void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, #endif { + VLOG_INFO << "BEGIN Copy texture:" << img->mem->name; thread_scoped_lock device_lock(device_mutex); + VLOG_INFO << "LOCK Copy texture:" << img->mem->name; + //vector image{img->mem}; + //img->mem->modified = true; + //img->mem->device->upload_changed(image); img->mem->copy_to_device(); + VLOG_INFO << "END Copy texture:" << img->mem->name; } /* Cleanup memory in image loader. */ @@ -839,6 +853,7 @@ void ImageManager::device_free_image(Device *, size_t slot) if (img->mem) { thread_scoped_lock device_lock(device_mutex); delete img->mem; + img->mem = NULL; } delete img->loader; diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index c3b64ee3769..3926940fcec 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -69,6 +69,34 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) }); memset((void *)&dscene.data, 0, sizeof(dscene.data)); + /* Set up the buffers to upload */ + // Geometry buffers + scene_buffers.push_back(&dscene.tri_verts); + scene_buffers.push_back(&dscene.tri_shader); + scene_buffers.push_back(&dscene.tri_vnormal); + scene_buffers.push_back(&dscene.tri_vindex); + scene_buffers.push_back(&dscene.tri_patch); + scene_buffers.push_back(&dscene.tri_patch_uv); + + scene_buffers.push_back(&dscene.curve_keys); + scene_buffers.push_back(&dscene.curves); + scene_buffers.push_back(&dscene.curve_segments); + + scene_buffers.push_back(&dscene.points); + scene_buffers.push_back(&dscene.points_shader); + + scene_buffers.push_back(&dscene.patches); + + // Attribute buffers + scene_buffers.push_back(&dscene.attributes_map); + scene_buffers.push_back(&dscene.attributes_float); + scene_buffers.push_back(&dscene.attributes_float2); + scene_buffers.push_back(&dscene.attributes_float3); + scene_buffers.push_back(&dscene.attributes_float4); + scene_buffers.push_back(&dscene.attributes_uchar4); + + scene_buffers.push_back(&dscene.objects); + /* Stats time logging allocate memory to store times for each device */ size_t device_count = this->dscenes.size(); this->times.resize(device_count); diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 1d284cc134c..90b11fbc981 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -187,7 +187,7 @@ class Scene : public NodeOwner { /* Stores a DeviceScene for each sub-device */ std::vector> dscenes; - + vector scene_buffers; /* Stats time logging */ struct SceneTimes { double mesh; -- 2.30.2 From 9f146557f6262e190832a3480c31b3ff097c44a3 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 12:22:22 +0200 Subject: [PATCH 85/96] Move copy to device outside parallel_for --- intern/cycles/scene/geometry.cpp | 86 +++++++++++++------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index e6d3fd604ca..d19b856599e 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -706,25 +706,26 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, // the correct data sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); - /* Upload geometry and attribute buffers to the device */ - { - scoped_callback_timer timer([scene, idx](double time) { - if (scene->update_stats) { - // Save copy mesh to device duration for later logging - scene->times[idx].mesh = time; - } - }); - //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); - } + // /* Upload geometry and attribute buffers to the device */ + // { + // scoped_callback_timer timer([scene, idx](double time) { + // if (scene->update_stats) { + // // Save copy mesh to device duration for later logging + // scene->times[idx].mesh = time; + // } + // }); + // //sub_device->upload_changed(scene->scene_buffers); + // //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); + // } - { - scoped_callback_timer timer([scene, idx](double time) { - if (scene->update_stats) { - scene->times[idx].attrib = time; - } - }); - //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); - } + // { + // scoped_callback_timer timer([scene, idx](double time) { + // if (scene->update_stats) { + // scene->times[idx].attrib = time; + // } + // }); + // //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + // } sub_dscene->device_scene_clear_modified(); device_init_update_bvh(scene); @@ -910,41 +911,24 @@ void GeometryManager::device_update(Device *device, can_refit_scene_bvh = device_update_bvh_preprocess(device, dscene, scene, progress); } { - //device->upload_changed(); - size_t num_scenes = scene->dscenes.size(); - VLOG_INFO << "Rendering using " << num_scenes << " devices"; /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ - vector buffers { - // Geometry buffers - &dscene->tri_verts, - &dscene->tri_shader, - &dscene->tri_vnormal, - &dscene->tri_vindex, - &dscene->tri_patch, - &dscene->tri_patch_uv, - - &dscene->curve_keys, - &dscene->curves, - &dscene->curve_segments, - - &dscene->points, - &dscene->points_shader, - - &dscene->patches, - - // Attribute buffers - &dscene->attributes_map, - &dscene->attributes_float, - &dscene->attributes_float2, - &dscene->attributes_float3, - &dscene->attributes_float4, - &dscene->attributes_uchar4, - - &dscene->objects - }; - - device->upload_changed(scene->scene_buffers); + size_t num_scenes = scene->dscenes.size(); + /* Upload geometry and attribute buffers to the device */ + { + scoped_callback_timer timer([scene, num_scenes](double time) { + if (scene->update_stats) { + // Save copy mesh to device duration for later logging + for(int i = 0;i < num_scenes;i++) { + scene->times[0].mesh = time; + } + } + }); + device->upload_changed(scene->scene_buffers); + //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); + } + + VLOG_INFO << "Rendering using " << num_scenes << " devices"; parallel_for( size_t(0), num_scenes, [=, &progress](const size_t idx) { device_data_xfer_and_bvh_update(idx, -- 2.30.2 From 8f50b28fa84652287ca0da5694caaac4204f26b9 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 13:12:07 +0200 Subject: [PATCH 86/96] Move device_memory list into DeviceScene --- intern/cycles/device/device.cpp | 15 ++--- intern/cycles/device/device.h | 1 - intern/cycles/scene/devicescene.cpp | 28 ++++++++ intern/cycles/scene/devicescene.h | 1 + intern/cycles/scene/geometry.cpp | 101 +++++++++++----------------- intern/cycles/scene/geometry.h | 1 + intern/cycles/scene/scene.cpp | 28 -------- intern/cycles/scene/scene.h | 2 +- 8 files changed, 75 insertions(+), 102 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 248a95f413f..85add0f5d16 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -645,18 +645,11 @@ void GPUDevice::move_textures_to_host(size_t size, bool for_texture) load_texture_info(); } -// void Device::register_buffer(device_memory *mem) -// { -// VLOG_INFO << "Register buffer " << mem->name; -// /* Insert into set of buffers. */ -// thread_scoped_lock lock(device_buffer_mutex); -// device_buffers.insert(mem); -// } - -void Device::upload_changed(vector buffers) { - for (const auto& buffer : buffers) { +void Device::upload_changed(vector buffers) +{ + for (const auto &buffer : buffers) { VLOG_INFO << "Checking " << buffer->name; - if(buffer->modified) { + if (buffer->modified && (buffer->data_size > 0)) { VLOG_INFO << "Uploading to " << buffer->name; this->mem_copy_to(*buffer, buffer->device_size, 0); } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index f15b0d812bf..a7357cf2e85 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -300,7 +300,6 @@ protected: */ virtual void upload_changed(vector buffers); - //virtual void register_buffer(device_memory *); protected: /* Memory allocation, only accessed through device_memory. */ friend class MultiDevice; diff --git a/intern/cycles/scene/devicescene.cpp b/intern/cycles/scene/devicescene.cpp index 17eebf5575e..0532810bf39 100644 --- a/intern/cycles/scene/devicescene.cpp +++ b/intern/cycles/scene/devicescene.cpp @@ -65,6 +65,34 @@ DeviceScene::DeviceScene(Device *device) ies_lights(device, "ies", MEM_GLOBAL) { memset((void *)&data, 0, sizeof(data)); + + /* Set up the buffers to upload */ + /* Geometry buffers */ + geom_buffers.push_back(&tri_verts); + geom_buffers.push_back(&tri_shader); + geom_buffers.push_back(&tri_vnormal); + geom_buffers.push_back(&tri_vindex); + geom_buffers.push_back(&tri_patch); + geom_buffers.push_back(&tri_patch_uv); + + geom_buffers.push_back(&curve_keys); + geom_buffers.push_back(&curves); + geom_buffers.push_back(&curve_segments); + + geom_buffers.push_back(&points); + geom_buffers.push_back(&points_shader); + + geom_buffers.push_back(&patches); + + /* Attribute buffers */ + geom_buffers.push_back(&attributes_map); + geom_buffers.push_back(&attributes_float); + geom_buffers.push_back(&attributes_float2); + geom_buffers.push_back(&attributes_float3); + geom_buffers.push_back(&attributes_float4); + geom_buffers.push_back(&attributes_uchar4); + + geom_buffers.push_back(&objects); } void DeviceScene::device_free_geometry(bool force_free) diff --git a/intern/cycles/scene/devicescene.h b/intern/cycles/scene/devicescene.h index d64ee9adff6..9d73d1a6c9d 100644 --- a/intern/cycles/scene/devicescene.h +++ b/intern/cycles/scene/devicescene.h @@ -100,6 +100,7 @@ class DeviceScene { /* IES lights */ device_vector ies_lights; + vector geom_buffers; KernelData data; DeviceScene(Device *device); diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index d19b856599e..0235fef946c 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -691,6 +691,7 @@ void GeometryManager::pretess_disp_normal_and_vertices_setup(Device *device, */ void GeometryManager::device_data_xfer_and_bvh_update(int idx, Scene *scene, + Device *device, DeviceScene *dscene, const BVHLayout bvh_layout, size_t num_bvh, @@ -698,36 +699,26 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, bool need_update_scene_bvh, Progress &progress) { - auto sub_dscene = scene->dscenes[idx].get(); - sub_dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; - // Get the device to use for this DeviceScene from one of the buffers - Device *sub_device = sub_dscene->tri_verts.device; + dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; + // Assign the host_pointers to the sub_dscene so that they access // the correct data - sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); + if (dscene != &(scene->dscene)) { + dscene->device_update_host_pointers(device, &(scene->dscene), &(scene->geom_sizes)); + } - // /* Upload geometry and attribute buffers to the device */ - // { - // scoped_callback_timer timer([scene, idx](double time) { - // if (scene->update_stats) { - // // Save copy mesh to device duration for later logging - // scene->times[idx].mesh = time; - // } - // }); - // //sub_device->upload_changed(scene->scene_buffers); - // //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); - // } + /* Upload geometry and attribute buffers to the device */ + { + scoped_callback_timer timer([scene, idx](double time) { + if (scene->update_stats) { + // Save copy mesh to device duration for later logging + scene->times[idx].mesh = time; + } + }); + device->upload_changed(dscene->geom_buffers); + } - // { - // scoped_callback_timer timer([scene, idx](double time) { - // if (scene->update_stats) { - // scene->times[idx].attrib = time; - // } - // }); - // //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); - // } - - sub_dscene->device_scene_clear_modified(); + dscene->device_scene_clear_modified(); device_init_update_bvh(scene); { scoped_callback_timer timer([scene, idx](double time) { @@ -736,14 +727,13 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, } }); TaskPool pool; - + size_t i = 0; /* Build the Object BVHs */ foreach (Geometry *geom, scene->geometry) { if (geom->is_modified() || geom->need_update_bvh_for_offset) { pool.push(function_bind( - &Geometry::compute_bvh, geom, sub_device, sub_dscene, &scene->params, &progress, i, num_bvh)); - //geom->compute_bvh(sub_device, sub_dscene, &scene->params, &progress, i, num_bvh); + &Geometry::compute_bvh, geom, device, dscene, &scene->params, &progress, i, num_bvh)); if (geom->need_build_bvh(bvh_layout)) { i++; } @@ -754,15 +744,15 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, VLOG_WORK << "Objects BVH build pool statistics:\n" << summary.full_report(); } - if(need_update_scene_bvh) { + if (need_update_scene_bvh) { scoped_callback_timer timer([scene, idx](double time) { if (scene->update_stats) { scene->times[idx].scene_bvh = time; } }); /* Build the scene BVH */ - device_update_bvh(sub_device, sub_dscene, scene, can_refit, 1, 1, progress); - sub_dscene->device_update_bvh2(sub_device, scene->bvh, progress); + device_update_bvh(device, dscene, scene, can_refit, 1, 1, progress); + dscene->device_update_bvh2(device, scene->bvh, progress); } } @@ -914,32 +904,21 @@ void GeometryManager::device_update(Device *device, /* Parallel upload the geometry data to the devices and calculate or refit the BVHs */ size_t num_scenes = scene->dscenes.size(); - /* Upload geometry and attribute buffers to the device */ - { - scoped_callback_timer timer([scene, num_scenes](double time) { - if (scene->update_stats) { - // Save copy mesh to device duration for later logging - for(int i = 0;i < num_scenes;i++) { - scene->times[0].mesh = time; - } - } - }); - device->upload_changed(scene->scene_buffers); - //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); - } - - VLOG_INFO << "Rendering using " << num_scenes << " devices"; - parallel_for( - size_t(0), num_scenes, [=, &progress](const size_t idx) { - device_data_xfer_and_bvh_update(idx, - scene, - dscene, - bvh_layout, - num_bvh, - can_refit_scene_bvh, - need_update_scene_bvh, - progress); - }); + + VLOG_INFO << "Rendering using " << num_scenes << " devices"; + parallel_for(size_t(0), num_scenes, [=, &progress](const size_t idx) { + DeviceScene *sub_dscene = scene->dscenes[idx].get(); + Device *sub_device = sub_dscene->tri_verts.device; + device_data_xfer_and_bvh_update(idx, + scene, + sub_device, + sub_dscene, + bvh_layout, + num_bvh, + can_refit_scene_bvh, + need_update_scene_bvh, + progress); + }); if (need_update_scene_bvh) { device_update_bvh_postprocess(device, dscene, scene, progress); } @@ -952,7 +931,7 @@ void GeometryManager::device_update(Device *device, max_mesh_time = max(max_mesh_time, scene->times[i].mesh); max_attrib_time = max(max_attrib_time, scene->times[i].attrib); max_object_bvh_time = max(max_object_bvh_time, scene->times[i].object_bvh); - max_scene_bvh_time = max(max_scene_bvh_time, scene->times[i].scene_bvh); + max_scene_bvh_time = max(max_scene_bvh_time, scene->times[i].scene_bvh); } scene->update_stats->geometry.times.add_entry( {"device_update (copy meshes to device)", max_mesh_time}); @@ -961,7 +940,7 @@ void GeometryManager::device_update(Device *device, scene->update_stats->geometry.times.add_entry( {"device_update (build object BVHs)", max_object_bvh_time}); scene->update_stats->geometry.times.add_entry( - {"device_update (build scene BVH)", max_scene_bvh_time}); + {"device_update (build scene BVH)", max_scene_bvh_time}); } } @@ -1177,7 +1156,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( }); //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } - device->upload_changed(scene->scene_buffers); + device->upload_changed(dscene->geom_buffers); /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 0f20dfa7971..7f6f1ea8186 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -262,6 +262,7 @@ class GeometryManager { void clear_geometry_update_and_modified_tags(Scene *scene); void device_data_xfer_and_bvh_update(int idx, Scene *scene, + Device *device, DeviceScene *dscene, const BVHLayout bvh_layout, size_t num_bvh, diff --git a/intern/cycles/scene/scene.cpp b/intern/cycles/scene/scene.cpp index 3926940fcec..ccdce96004c 100644 --- a/intern/cycles/scene/scene.cpp +++ b/intern/cycles/scene/scene.cpp @@ -68,34 +68,6 @@ Scene::Scene(const SceneParams ¶ms_, Device *device) this->dscenes.push_back(std::move(sub_dscene)); }); memset((void *)&dscene.data, 0, sizeof(dscene.data)); - - /* Set up the buffers to upload */ - // Geometry buffers - scene_buffers.push_back(&dscene.tri_verts); - scene_buffers.push_back(&dscene.tri_shader); - scene_buffers.push_back(&dscene.tri_vnormal); - scene_buffers.push_back(&dscene.tri_vindex); - scene_buffers.push_back(&dscene.tri_patch); - scene_buffers.push_back(&dscene.tri_patch_uv); - - scene_buffers.push_back(&dscene.curve_keys); - scene_buffers.push_back(&dscene.curves); - scene_buffers.push_back(&dscene.curve_segments); - - scene_buffers.push_back(&dscene.points); - scene_buffers.push_back(&dscene.points_shader); - - scene_buffers.push_back(&dscene.patches); - - // Attribute buffers - scene_buffers.push_back(&dscene.attributes_map); - scene_buffers.push_back(&dscene.attributes_float); - scene_buffers.push_back(&dscene.attributes_float2); - scene_buffers.push_back(&dscene.attributes_float3); - scene_buffers.push_back(&dscene.attributes_float4); - scene_buffers.push_back(&dscene.attributes_uchar4); - - scene_buffers.push_back(&dscene.objects); /* Stats time logging allocate memory to store times for each device */ size_t device_count = this->dscenes.size(); diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 90b11fbc981..1d284cc134c 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -187,7 +187,7 @@ class Scene : public NodeOwner { /* Stores a DeviceScene for each sub-device */ std::vector> dscenes; - vector scene_buffers; + /* Stats time logging */ struct SceneTimes { double mesh; -- 2.30.2 From e04384f20d06b0889a320775901f33aa65beeb7c Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 13:38:20 +0200 Subject: [PATCH 87/96] FIX: get_device_bvh returns the MultiBVH if the device is the MultiDevice If the device was the MultiDevice it previously returned the first BVH. This was incorrect it should return the MultiBVH. Also, if it cannot find the device then it should return NULL. --- intern/cycles/bvh/multi.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/intern/cycles/bvh/multi.cpp b/intern/cycles/bvh/multi.cpp index 386ae266e3d..6ba100cff19 100644 --- a/intern/cycles/bvh/multi.cpp +++ b/intern/cycles/bvh/multi.cpp @@ -22,9 +22,19 @@ BVHMulti::~BVHMulti() { } BVH *BVHMulti::get_device_bvh(const Device *subdevice) { - int id = device->device_number(subdevice); - resize_sub_bvhs_if_needed(id); - return sub_bvhs[id].get(); + BVH *bvh = NULL; + if (subdevice == device) { + bvh = this; + } + else { + int id = device->device_number(subdevice); + assert(id != -1); + if (id != -1) { + resize_sub_bvhs_if_needed(id); + bvh = sub_bvhs[id].get(); + } + } + return bvh; } void BVHMulti::set_device_bvh(const Device *subdevice, BVH *bvh) -- 2.30.2 From b1be09d44980416ced83a40932e8d26da5f882cf Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 15:53:14 +0200 Subject: [PATCH 88/96] Move the BVH layout determination into a method for reuse This code was duplicated in MultiDevice and geometry_bvh.cpp so this removed that duplication. --- intern/cycles/device/device.h | 3 +++ intern/cycles/device/multi/device.cpp | 36 +++++++++++++++------------ intern/cycles/scene/geometry_bvh.cpp | 11 +------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index a7357cf2e85..93e3500cf64 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -168,6 +168,9 @@ protected: } virtual BVHLayoutMask get_bvh_layout_mask(uint kernel_features) const = 0; + virtual BVHLayout get_bvh_layout(Device *device, BVHLayout layout) { + return layout; + } /* statistics */ Stats &stats; Profiler &profiler; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 06dff85c710..5ddaec4eb97 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -199,6 +199,24 @@ class MultiDevice : public Device { return true; } + BVHLayout get_bvh_layout(Device *device, BVHLayout bvh_layout) override + { + if (bvh_layout == BVH_LAYOUT_MULTI_OPTIX) + bvh_layout = BVH_LAYOUT_OPTIX; + else if (bvh_layout == BVH_LAYOUT_MULTI_METAL) + bvh_layout = BVH_LAYOUT_METAL; + else if (bvh_layout == BVH_LAYOUT_MULTI_HIPRT) + bvh_layout = BVH_LAYOUT_HIPRT; + else if (bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : BVH_LAYOUT_EMBREE; + else if (bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : BVH_LAYOUT_EMBREE; + else if (bvh_layout == BVH_LAYOUT_MULTI_HIPRT_EMBREE) + bvh_layout = device->info.type == DEVICE_HIPRT ? BVH_LAYOUT_HIPRT : BVH_LAYOUT_EMBREE; + + return bvh_layout; + } + void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override { /* Try to build and share a single acceleration structure, if possible */ @@ -226,21 +244,7 @@ class MultiDevice : public Device { if (!bvh_multi->sub_bvhs[id]) { BVHParams params = bvh_multi->params; - if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) - params.bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) - params.bvh_layout = BVH_LAYOUT_METAL; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_HIPRT) - params.bvh_layout = BVH_LAYOUT_HIPRT; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - params.bvh_layout = sub->device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : - BVH_LAYOUT_EMBREE; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - params.bvh_layout = sub->device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : - BVH_LAYOUT_EMBREE; - else if (bvh_multi->params.bvh_layout == BVH_LAYOUT_MULTI_HIPRT_EMBREE) - params.bvh_layout = sub->device->info.type == DEVICE_HIPRT ? BVH_LAYOUT_HIPRT : - BVH_LAYOUT_EMBREE; + params.bvh_layout = get_bvh_layout(sub->device, bvh_multi->params.bvh_layout); /* Skip building a bottom level acceleration structure for non-instanced geometry on * Embree (since they are put into the top level directly, see bvh_embree.cpp) */ @@ -516,7 +520,7 @@ class MultiDevice : public Device { // } // } // } - //stats.mem_alloc(sub_mem.device_size - existing_size); + stats.mem_alloc(sub_mem.device_size - existing_size); } } }); diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index 7692b02d310..be1dc28fe4a 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -174,16 +174,7 @@ void GeometryManager::device_update_sub_bvh(Device *device, // Yes, so setup the device specific sub_bvh in the multi-bvh. BVHParams bparams = bvh->params; // Set the layout to the correct one for the device - if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX) - bparams.bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL) - bparams.bvh_layout = BVH_LAYOUT_METAL; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - bparams.bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : - BVH_LAYOUT_EMBREE; - else if (bvh->params.bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - bparams.bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : - BVH_LAYOUT_EMBREE; + bparams.bvh_layout = device->get_bvh(device, bvh->params.bvh_layout); if (sub_bvh != NULL) { delete sub_bvh; } -- 2.30.2 From ab21849d86b9234fdf11dee23fc0868ade6e06d7 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 15:54:38 +0200 Subject: [PATCH 89/96] Remove the parallel_for over devices The parallel_for for is replaced by many parallel_for's one for the upload, one for each Object BVH and one for the scene BVH. --- intern/cycles/scene/geometry.cpp | 37 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 0235fef946c..13316b9c4b1 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -906,19 +906,28 @@ void GeometryManager::device_update(Device *device, size_t num_scenes = scene->dscenes.size(); VLOG_INFO << "Rendering using " << num_scenes << " devices"; - parallel_for(size_t(0), num_scenes, [=, &progress](const size_t idx) { - DeviceScene *sub_dscene = scene->dscenes[idx].get(); - Device *sub_device = sub_dscene->tri_verts.device; - device_data_xfer_and_bvh_update(idx, - scene, - sub_device, - sub_dscene, - bvh_layout, - num_bvh, - can_refit_scene_bvh, - need_update_scene_bvh, - progress); - }); + // parallel_for(size_t(0), num_scenes, [=, &progress](const size_t idx) { + // DeviceScene *sub_dscene = scene->dscenes[idx].get(); + // Device *sub_device = sub_dscene->tri_verts.device; + // device_data_xfer_and_bvh_update(idx, + // scene, + // sub_device, + // sub_dscene, + // bvh_layout, + // num_bvh, + // can_refit_scene_bvh, + // need_update_scene_bvh, + // progress); + // }); + device_data_xfer_and_bvh_update(0, + scene, + device, + dscene, + bvh_layout, + num_bvh, + can_refit_scene_bvh, + need_update_scene_bvh, + progress); if (need_update_scene_bvh) { device_update_bvh_postprocess(device, dscene, scene, progress); } @@ -927,7 +936,7 @@ void GeometryManager::device_update(Device *device, double max_attrib_time = 0.0f; double max_object_bvh_time = 0.0f; double max_scene_bvh_time = 0.0f; - for (size_t i = 0; i < num_scenes; i++) { + for (size_t i = 0; i < 1 /*num_scenes*/; i++) { max_mesh_time = max(max_mesh_time, scene->times[i].mesh); max_attrib_time = max(max_attrib_time, scene->times[i].attrib); max_object_bvh_time = max(max_object_bvh_time, scene->times[i].object_bvh); -- 2.30.2 From a4b3b8e1fe5da4beee93fe04ca833dd2f6eebdcf Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 8 May 2023 09:31:00 +0200 Subject: [PATCH 90/96] Add missed changes to select the correct layout. --- intern/cycles/device/multi/device.cpp | 2 +- intern/cycles/scene/geometry_bvh.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 5ddaec4eb97..6c6d53d3a36 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -244,7 +244,7 @@ class MultiDevice : public Device { if (!bvh_multi->sub_bvhs[id]) { BVHParams params = bvh_multi->params; - params.bvh_layout = get_bvh_layout(sub->device, bvh_multi->params.bvh_layout); + params.bvh_layout = get_bvh_layout(sub->device.get(), bvh_multi->params.bvh_layout); /* Skip building a bottom level acceleration structure for non-instanced geometry on * Embree (since they are put into the top level directly, see bvh_embree.cpp) */ diff --git a/intern/cycles/scene/geometry_bvh.cpp b/intern/cycles/scene/geometry_bvh.cpp index be1dc28fe4a..66c98cf68fb 100644 --- a/intern/cycles/scene/geometry_bvh.cpp +++ b/intern/cycles/scene/geometry_bvh.cpp @@ -174,7 +174,7 @@ void GeometryManager::device_update_sub_bvh(Device *device, // Yes, so setup the device specific sub_bvh in the multi-bvh. BVHParams bparams = bvh->params; // Set the layout to the correct one for the device - bparams.bvh_layout = device->get_bvh(device, bvh->params.bvh_layout); + bparams.bvh_layout = device->get_bvh_layout(device, bvh->params.bvh_layout); if (sub_bvh != NULL) { delete sub_bvh; } -- 2.30.2 From 565bc7576940e8fa360929ecccad98b31098d774 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Fri, 5 May 2023 13:38:20 +0200 Subject: [PATCH 91/96] FIX: get_device_bvh returns the MultiBVH if the device is the MultiDevice If the device was the MultiDevice it previously returned the first BVH. This was incorrect it should return the MultiBVH. Also, if it cannot find the device then it should return NULL. --- intern/cycles/bvh/multi.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/intern/cycles/bvh/multi.cpp b/intern/cycles/bvh/multi.cpp index 386ae266e3d..6ba100cff19 100644 --- a/intern/cycles/bvh/multi.cpp +++ b/intern/cycles/bvh/multi.cpp @@ -22,9 +22,19 @@ BVHMulti::~BVHMulti() { } BVH *BVHMulti::get_device_bvh(const Device *subdevice) { - int id = device->device_number(subdevice); - resize_sub_bvhs_if_needed(id); - return sub_bvhs[id].get(); + BVH *bvh = NULL; + if (subdevice == device) { + bvh = this; + } + else { + int id = device->device_number(subdevice); + assert(id != -1); + if (id != -1) { + resize_sub_bvhs_if_needed(id); + bvh = sub_bvhs[id].get(); + } + } + return bvh; } void BVHMulti::set_device_bvh(const Device *subdevice, BVH *bvh) -- 2.30.2 From df7d92a33ef51fcf7c4731a8dda42fae3f6e78d6 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 8 May 2023 11:19:17 +0200 Subject: [PATCH 92/96] FIX: Size used should be the data_size --- intern/cycles/device/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 85add0f5d16..709bc0d05dd 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -651,7 +651,7 @@ void Device::upload_changed(vector buffers) VLOG_INFO << "Checking " << buffer->name; if (buffer->modified && (buffer->data_size > 0)) { VLOG_INFO << "Uploading to " << buffer->name; - this->mem_copy_to(*buffer, buffer->device_size, 0); + this->mem_copy_to(*buffer, buffer->data_size, 0); } } } -- 2.30.2 From ed1b9719486274e46f8757d5613617ddafb0d954 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 8 May 2023 16:55:06 +0200 Subject: [PATCH 93/96] FIX: Use memory_size and upload_changed in the correct places --- intern/cycles/device/device.cpp | 2 +- intern/cycles/scene/geometry.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 709bc0d05dd..a24859c0823 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -651,7 +651,7 @@ void Device::upload_changed(vector buffers) VLOG_INFO << "Checking " << buffer->name; if (buffer->modified && (buffer->data_size > 0)) { VLOG_INFO << "Uploading to " << buffer->name; - this->mem_copy_to(*buffer, buffer->data_size, 0); + this->mem_copy_to(*buffer, buffer->memory_size(), 0); } } } diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 13316b9c4b1..f05a1de6ae2 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -715,6 +715,8 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, scene->times[idx].mesh = time; } }); + //dscene->device_update_attributes(device, &(scene->attrib_sizes), progress); + //dscene->device_update_mesh(device, &(scene->geom_sizes), progress); device->upload_changed(dscene->geom_buffers); } @@ -1156,6 +1158,7 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( } }); //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); + device->upload_changed(dscene->geom_buffers); } { scoped_callback_timer timer([scene](double time) { @@ -1165,7 +1168,6 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( }); //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); } - device->upload_changed(dscene->geom_buffers); /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); -- 2.30.2 From 72be875f3c36b700ff9996926cb655ce30286364 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Mon, 8 May 2023 16:48:48 +0200 Subject: [PATCH 94/96] FIX: BVH layout determination is the same across all devices. --- intern/cycles/device/device.h | 17 ++++++++++++++++- intern/cycles/device/multi/device.cpp | 18 ------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 93e3500cf64..1614c305665 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -168,9 +168,24 @@ protected: } virtual BVHLayoutMask get_bvh_layout_mask(uint kernel_features) const = 0; - virtual BVHLayout get_bvh_layout(Device *device, BVHLayout layout) { + BVHLayout get_bvh_layout(Device *device, BVHLayout layout) + { + if (layout == BVH_LAYOUT_MULTI_OPTIX) + layout = BVH_LAYOUT_OPTIX; + else if (layout == BVH_LAYOUT_MULTI_METAL) + layout = BVH_LAYOUT_METAL; + else if (layout == BVH_LAYOUT_MULTI_HIPRT) + layout = BVH_LAYOUT_HIPRT; + else if (layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) + layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : BVH_LAYOUT_EMBREE; + else if (layout == BVH_LAYOUT_MULTI_METAL_EMBREE) + layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : BVH_LAYOUT_EMBREE; + else if (layout == BVH_LAYOUT_MULTI_HIPRT_EMBREE) + layout = device->info.type == DEVICE_HIPRT ? BVH_LAYOUT_HIPRT : BVH_LAYOUT_EMBREE; + return layout; } + /* statistics */ Stats &stats; Profiler &profiler; diff --git a/intern/cycles/device/multi/device.cpp b/intern/cycles/device/multi/device.cpp index 6c6d53d3a36..c8d2ad7c20d 100644 --- a/intern/cycles/device/multi/device.cpp +++ b/intern/cycles/device/multi/device.cpp @@ -199,24 +199,6 @@ class MultiDevice : public Device { return true; } - BVHLayout get_bvh_layout(Device *device, BVHLayout bvh_layout) override - { - if (bvh_layout == BVH_LAYOUT_MULTI_OPTIX) - bvh_layout = BVH_LAYOUT_OPTIX; - else if (bvh_layout == BVH_LAYOUT_MULTI_METAL) - bvh_layout = BVH_LAYOUT_METAL; - else if (bvh_layout == BVH_LAYOUT_MULTI_HIPRT) - bvh_layout = BVH_LAYOUT_HIPRT; - else if (bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) - bvh_layout = device->info.type == DEVICE_OPTIX ? BVH_LAYOUT_OPTIX : BVH_LAYOUT_EMBREE; - else if (bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) - bvh_layout = device->info.type == DEVICE_METAL ? BVH_LAYOUT_METAL : BVH_LAYOUT_EMBREE; - else if (bvh_layout == BVH_LAYOUT_MULTI_HIPRT_EMBREE) - bvh_layout = device->info.type == DEVICE_HIPRT ? BVH_LAYOUT_HIPRT : BVH_LAYOUT_EMBREE; - - return bvh_layout; - } - void build_bvh(BVH *bvh, DeviceScene *dscene, Progress &progress, bool refit) override { /* Try to build and share a single acceleration structure, if possible */ -- 2.30.2 From b7a80ba6efc0dbb9b809b3a429aed0727e15bff5 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Tue, 9 May 2023 11:09:12 +0200 Subject: [PATCH 95/96] FIX: Enable local intersection testing on BVH The scen bvh layout was set to NONE which disabled the local intersection testing used for he bevel effect. This removes that line and also refactors the code to make it cleaner. --- intern/cycles/scene/geometry.cpp | 33 ++++++++++++-------------------- intern/cycles/scene/geometry.h | 3 ++- intern/cycles/scene/scene.h | 15 ++++++++------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index f05a1de6ae2..babb4f45af7 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -689,7 +689,7 @@ void GeometryManager::pretess_disp_normal_and_vertices_setup(Device *device, * Uploads the mesh data to the device and then builds or refits the BVH * using the uploaded data. */ -void GeometryManager::device_data_xfer_and_bvh_update(int idx, +void GeometryManager::device_data_xfer_and_bvh_update(SceneTimes *times, Scene *scene, Device *device, DeviceScene *dscene, @@ -699,8 +699,6 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, bool need_update_scene_bvh, Progress &progress) { - dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE; - // Assign the host_pointers to the sub_dscene so that they access // the correct data if (dscene != &(scene->dscene)) { @@ -709,10 +707,10 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, /* Upload geometry and attribute buffers to the device */ { - scoped_callback_timer timer([scene, idx](double time) { + scoped_callback_timer timer([scene, times](double time) { if (scene->update_stats) { // Save copy mesh to device duration for later logging - scene->times[idx].mesh = time; + times->mesh = time; } }); //dscene->device_update_attributes(device, &(scene->attrib_sizes), progress); @@ -723,9 +721,9 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, dscene->device_scene_clear_modified(); device_init_update_bvh(scene); { - scoped_callback_timer timer([scene, idx](double time) { + scoped_callback_timer timer([scene, times](double time) { if (scene->update_stats) { - scene->times[idx].object_bvh = time; + times->object_bvh = time; } }); TaskPool pool; @@ -747,9 +745,9 @@ void GeometryManager::device_data_xfer_and_bvh_update(int idx, } if (need_update_scene_bvh) { - scoped_callback_timer timer([scene, idx](double time) { + scoped_callback_timer timer([scene, times](double time) { if (scene->update_stats) { - scene->times[idx].scene_bvh = time; + times->scene_bvh = time; } }); /* Build the scene BVH */ @@ -911,7 +909,7 @@ void GeometryManager::device_update(Device *device, // parallel_for(size_t(0), num_scenes, [=, &progress](const size_t idx) { // DeviceScene *sub_dscene = scene->dscenes[idx].get(); // Device *sub_device = sub_dscene->tri_verts.device; - // device_data_xfer_and_bvh_update(idx, + // device_data_xfer_and_bvh_update(&(scene->times[0]), // scene, // sub_device, // sub_dscene, @@ -921,7 +919,7 @@ void GeometryManager::device_update(Device *device, // need_update_scene_bvh, // progress); // }); - device_data_xfer_and_bvh_update(0, + device_data_xfer_and_bvh_update(&(scene->times[0]), scene, device, dscene, @@ -1148,7 +1146,9 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( DeviceScene *sub_dscene = scene->dscenes.front().get(); Device *sub_device = sub_dscene->tri_verts.device; - sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); + if(sub_dscene != &(scene->dscene)) { + sub_dscene->device_update_host_pointers(sub_device, dscene, &(scene->geom_sizes)); + } { scoped_callback_timer timer([scene](double time) { @@ -1157,17 +1157,8 @@ bool GeometryManager::displacement_and_curve_shadow_transparency( {"device_update (displacement: copy meshes to device)", time}); } }); - //sub_dscene->device_update_attributes(sub_device, &(scene->attrib_sizes), progress); device->upload_changed(dscene->geom_buffers); } - { - scoped_callback_timer timer([scene](double time) { - if (scene->update_stats) { - scene->update_stats->geometry.times.add_entry({"displacement: copy attributes to device", time}); - } - }); - //sub_dscene->device_update_mesh(sub_device, &(scene->geom_sizes), progress); - } /* Copy constant data needed by shader evaluation. */ sub_device->const_copy_to("data", &dscene->data, sizeof(dscene->data)); diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index 7f6f1ea8186..469154ed715 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -25,6 +25,7 @@ class Mesh; class Progress; class RenderStats; class Scene; +struct SceneTimes; struct GeometrySizes; struct AttributeSizes; class SceneParams; @@ -260,7 +261,7 @@ class GeometryManager { bool &need_update_scene_bvh); void clear_shader_update_tags(Scene *scene); void clear_geometry_update_and_modified_tags(Scene *scene); - void device_data_xfer_and_bvh_update(int idx, + void device_data_xfer_and_bvh_update(SceneTimes *times, Scene *scene, Device *device, DeviceScene *dscene, diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h index 1d284cc134c..c38b25e236d 100644 --- a/intern/cycles/scene/scene.h +++ b/intern/cycles/scene/scene.h @@ -76,6 +76,14 @@ struct AttributeSizes { size_t attr_uchar4_size; }; +/* Stats time logging */ +struct SceneTimes { + double mesh; + double attrib; + double object_bvh; + double scene_bvh; +}; + /* Scene Parameters */ class SceneParams { @@ -188,13 +196,6 @@ class Scene : public NodeOwner { /* Stores a DeviceScene for each sub-device */ std::vector> dscenes; - /* Stats time logging */ - struct SceneTimes { - double mesh; - double attrib; - double object_bvh; - double scene_bvh; - }; vector times; /* parameters */ -- 2.30.2 From 21d9481a76b0a0d711fa7986ce7149d40381e4e1 Mon Sep 17 00:00:00 2001 From: William Leeson Date: Wed, 17 May 2023 09:44:29 +0200 Subject: [PATCH 96/96] FIX: Adds missing device import for MacOS bvh.mm --- intern/cycles/device/metal/bvh.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/cycles/device/metal/bvh.mm b/intern/cycles/device/metal/bvh.mm index 47da7a54271..3b23a364c38 100644 --- a/intern/cycles/device/metal/bvh.mm +++ b/intern/cycles/device/metal/bvh.mm @@ -13,6 +13,7 @@ # include "device/device.h" # include "device/metal/bvh.h" # include "device/metal/util.h" +# include "device/device.h" CCL_NAMESPACE_BEGIN -- 2.30.2