Merge branch 'blender-v4.0-release'
This commit is contained in:
@@ -44,6 +44,17 @@ struct RecentCache {
|
||||
Map<std::string, int> logical_time_by_str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sometimes every search item has multiple parts. For example, when using menu search, each nested
|
||||
* menu is a separate part. Usually, one of those parts is highlighted in the UI and should be
|
||||
* prioritized in the search.
|
||||
*/
|
||||
enum class MainWordsHeuristic {
|
||||
FirstGroup,
|
||||
LastGroup,
|
||||
All,
|
||||
};
|
||||
|
||||
/**
|
||||
* Non templated base class so that its methods can be implemented outside of this header.
|
||||
*/
|
||||
@@ -52,6 +63,7 @@ class StringSearchBase {
|
||||
LinearAllocator<> allocator_;
|
||||
Vector<SearchItem> items_;
|
||||
const RecentCache *recent_cache_ = nullptr;
|
||||
MainWordsHeuristic main_words_heuristic_;
|
||||
|
||||
protected:
|
||||
void add_impl(StringRef str, void *user_data, int weight);
|
||||
@@ -70,9 +82,10 @@ class StringSearchBase {
|
||||
*/
|
||||
template<typename T> class StringSearch : private StringSearchBase {
|
||||
public:
|
||||
StringSearch(const RecentCache *recent_cache = nullptr)
|
||||
StringSearch(const RecentCache *recent_cache, const MainWordsHeuristic main_words_heuristic)
|
||||
{
|
||||
this->recent_cache_ = recent_cache;
|
||||
recent_cache_ = recent_cache;
|
||||
main_words_heuristic_ = main_words_heuristic;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -487,7 +487,24 @@ void StringSearchBase::add_impl(const StringRef str, void *user_data, const int
|
||||
const int recent_time = recent_cache_ ?
|
||||
recent_cache_->logical_time_by_str.lookup_default(str, -1) :
|
||||
-1;
|
||||
const int main_group_id = word_group_ids.is_empty() ? 0 : word_group_ids.last();
|
||||
int main_group_id = 0;
|
||||
if (!word_group_ids.is_empty()) {
|
||||
switch (main_words_heuristic_) {
|
||||
case MainWordsHeuristic::FirstGroup: {
|
||||
main_group_id = 0;
|
||||
break;
|
||||
}
|
||||
case MainWordsHeuristic::LastGroup: {
|
||||
main_group_id = word_group_ids.last();
|
||||
break;
|
||||
}
|
||||
case MainWordsHeuristic::All: {
|
||||
main_group_id = 0;
|
||||
word_group_ids.fill(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main_group_length = 0;
|
||||
for (const int i : words.index_range()) {
|
||||
|
||||
@@ -28,7 +28,11 @@ void read_recent_searches_file();
|
||||
*/
|
||||
template<typename T> class StringSearch : public blender::string_search::StringSearch<T> {
|
||||
public:
|
||||
StringSearch() : blender::string_search::StringSearch<T>(get_recent_cache_or_null()) {}
|
||||
StringSearch(const blender::string_search::MainWordsHeuristic main_word_heuristic =
|
||||
blender::string_search::MainWordsHeuristic::LastGroup)
|
||||
: blender::string_search::StringSearch<T>(get_recent_cache_or_null(), main_word_heuristic)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace blender::ui::string_search
|
||||
|
||||
@@ -453,7 +453,8 @@ static void id_search_cb_tagged(const bContext *C,
|
||||
ListBase *lb = template_ui->idlb;
|
||||
const int flag = RNA_property_flag(template_ui->prop);
|
||||
|
||||
blender::string_search::StringSearch<ID> search;
|
||||
blender::string_search::StringSearch<ID> search{nullptr,
|
||||
blender::string_search::MainWordsHeuristic::All};
|
||||
|
||||
/* ID listbase */
|
||||
LISTBASE_FOREACH (ID *, id, lb) {
|
||||
|
||||
@@ -847,12 +847,19 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (scene->toolsettings->auto_normalize) {
|
||||
const int vgroup_num = BLI_listbase_count(&me->vertex_group_names);
|
||||
bool *lock_flags = BKE_object_defgroup_lock_flags_get(ob, vgroup_num);
|
||||
bool *vgroup_validmap = BKE_object_defgroup_validmap_get(ob, vgroup_num);
|
||||
if (vgroup_validmap != nullptr) {
|
||||
MDeformVert *dvert = dverts;
|
||||
for (int i = 0; i < me->totvert; i++) {
|
||||
if ((data.vert_cache->elem[i].flag & WPGradient_vertStore::VGRAD_STORE_IS_MODIFIED) != 0) {
|
||||
BKE_defvert_normalize_lock_single(&dvert[i], vgroup_validmap, vgroup_num, data.def_nr);
|
||||
if (lock_flags != nullptr) {
|
||||
BKE_defvert_normalize_lock_map(
|
||||
&dvert[i], vgroup_validmap, vgroup_num, lock_flags, vgroup_num);
|
||||
}
|
||||
else {
|
||||
BKE_defvert_normalize_lock_single(&dvert[i], vgroup_validmap, vgroup_num, data.def_nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_freeN(vgroup_validmap);
|
||||
|
||||
@@ -361,7 +361,8 @@ static void link_drag_search_update_fn(
|
||||
storage.update_items_tag = false;
|
||||
}
|
||||
|
||||
ui::string_search::StringSearch<SocketLinkOperation> search;
|
||||
ui::string_search::StringSearch<SocketLinkOperation> search{
|
||||
string_search::MainWordsHeuristic::All};
|
||||
|
||||
for (SocketLinkOperation &op : storage.search_link_ops) {
|
||||
search.add(op.name, &op, op.weight);
|
||||
|
||||
Reference in New Issue
Block a user