Attributes: Add 2D integer vector attribute type #106677
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106677
Loading…
Reference in New Issue
No description provided.
Delete Branch "HooglyBoogly/blender:attributes-int2"
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?
This type will be used to store mesh edges in #106638, but it could
be used for anything else too. This commit adds support for:
The attribute uses the
blender::int2
type in most code, andthe
vec2i
DNA type in C code when necessary. The enum namesare based on
INT32_2D
for consistency withINT8
andINT32
.Generally looks good, but please merge
main
again.@ -123,1 +129,4 @@
template<> inline int2 mix3(const float3 &weights, const int2 &v0, const int2 &v1, const int2 &v2)
{
return weights.x * v0 + weights.y * v1 + weights.z * v2;
Please check if this does the right thing. VSCode indicates that this might call an
operator*(int a, int2 b)
. Same inmix4
.A cast to
float2
solves this, I'm not sure there's much better to do here.@ -159,1 +175,4 @@
static bool int2_to_bool(const int2 &a)
{
return a.x > 0 && a.y > 0;
This behavior is quite different compared to e.g.
float2_to_bool
orbyte_color_to_bool
. Not exactly sure what to do here, but needs some thought.Ah, right, I forgot to mention that. Not sure what's best here either. Our
int_to_bool
andfloat_to_bool
implementations usevalue > 0
currently. I find it strange (and probably wrong?) that our vector to boolean conversions useis_zero
instead. It seems like that was overlooked when we made the initial change tovalue > 0
in the first place. Do you remember that any better than me?We might have overlooked it, but also also not obvious how the
> 0
behavior can apply to more-dimensional data. Comparing to zero might be the only reasonable thing (and is likely also the fastest).@ -160,0 +183,4 @@
}
static int int2_to_int(const int2 &a)
{
return float2_to_int(int2_to_float2(a));
Should be possible to compute the average without resorting to floats.
Took a bit of research, it's surprisingly subtle! I took the
std::midpoint
implementation from C++20, which avoids overflow for all integral types.@ -160,0 +183,4 @@
}
static int int2_to_int(const int2 &a)
{
return (a.x + a.y) / 2;
This form is susceptible to overflow. You can borrow the implementation of
std::midpoint
(c++20 only) in the meantime: https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00146_source.html#l00214@ -197,0 +209,4 @@
inline int2 mix4(
const float4 &weights, const int2 &v0, const int2 &v1, const int2 &v2, const int2 &v3)
{
return weights.x * v0 + weights.y * v1 + weights.z * v2 + weights.w * v3;
Probably needs the same fix with converting to
float2
as above.@ -1895,2 +1895,2 @@
/* 46: CD_HAIRMAPPING */ /* UNUSED */
{-1, "", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 46: CD_PROP_INT32_2D */
{sizeof(vec2i), "vec2i", 1, N_("Int2"), nullptr, nullptr, nullptr, nullptr, nullptr},
Also use
Int 2D
or something similar as name instead ofInt2
.@ -159,1 +175,4 @@
static bool int2_to_bool(const int2 &a)
{
return math::is_zero(a);
There should be a
!
@ -160,0 +191,4 @@
}
static float int2_to_float(const int2 &a)
{
return float2_to_float(int2_to_float2(a));
can also call
float2
directly instead ofint2_to_float2