BLI: IndexMask: Comparison operators #117814
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117814
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:index_mask_cmp"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Support
==
and!=
operators forIndexMask
.This implementation is single thread and avoid any allocation.
@ -760,2 +760,4 @@
template void IndexMask::to_indices(MutableSpan<int64_t>) const;
template<int Count, typename Func>
static void foreach_sequence(std::array<IndexMask, Count> masks, Func &&func)
Not sure I fully understand this function yet. Maybe you can add a comment and maybe also add a test for this function specifically?
I added comment to describe this function few more. Not sure this function can be covered by test: this function is template right now, not sure i want to move this in header or make it more generic.
I'd like to implement more general version of this function (to handle any number of any mask (offset and size) and default values) in order to make more optimized merge/diff/... functions for #117805 (as like
Segment::==
calls in this case). But i think this is enough for now.@ -868,4 +868,104 @@ template IndexMask IndexMask::from_indices(Span<int64_t>, IndexMaskMemory &);
template void IndexMask::to_indices(MutableSpan<int32_t>) const;
template void IndexMask::to_indices(MutableSpan<int64_t>) const;
/* Any mask is built from segments. Even if masks is the same, segments fragmentation might be
I think an simple example as part of the description would make this more clear.
Added.
@ -871,0 +871,4 @@
/* Any mask is built from segments. Even if masks is the same, segments fragmentation might be
* different. Produce re-fragmentation of each mask on the fly to have segment of each mask in some
* certain range and call function for them. */
template<int Count, typename Func>
IndexMaskNum
@ -871,0 +875,4 @@
static void foreach_sequence(std::array<IndexMask, Count> masks, Func &&func)
{
BLI_assert(std::all_of(masks.begin() + 1, masks.end(), [&](const IndexMask &maks) {
return masks[0].size() == maks.size();
typo:
maks
.@ -871,0 +886,4 @@
std::array<IndexMaskSegment, Count> segments;
while (segment_iter[0] != masks[0].segments_num()) {
Where is
masks[1].segments_num()
taken into consideration? Looks like we could go out of range somewhere.Added comment about this.
@ -871,0 +893,4 @@
}
}
int16_t min_sequence_size = std::numeric_limits<int16_t>::max();
Maybe use
max_segment_size
instead?Maybe can also call this
next_common_sequence_size
.@ -871,0 +920,4 @@
}
}
static bool operator==(const IndexMaskSegment &a, const IndexMaskSegment &b)
Need to be a bit careful here, because
IndexMaskSegment
is currently actually analias
forOffsetSpan<int64_t, int16_t>
, but this comparison function does not work forOffsetSpan<int64_t, int16_t>
in general.Solution could be to make it so that
IndexMaskSegment
derives fromOffsetSpan
instead.I really want to make this inheritance at some point to gather all methods to process mask segments in segment class.
This is static operator, more specific overload instead of template operator for this type (if such will be added). I see that this might be not so clear and be error-prone, for now, this operator could be done as just function.
@ -871,0 +882,4 @@
* in positions space. Indices can be any.
*/
template<int IndexMaskNum, typename Func>
static void foreach_sequence(std::array<IndexMask, IndexMaskNum> masks, Func &&func)
The function generally looks ok, but I think it would still be nice if we could have tests specifically for it. I recommend exposing the function as a static method on
IndexMask
like so:It doesn't seem necessary that the function is templated for now. Maybe that can be an optimization later if it ever becomes necessary.
Much better example case of fragmentation.
@blender-bot build