BLI: Bounds: Add basic functions #118964
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118964
Loading…
Reference in New Issue
No description provided.
Delete Branch "filedescriptor/blender:basic-bounds-functions"
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?
The overall goal is to be able to eventually replace the
BLI_rect.h
C-style API.This only adds come basic functions and tests.
@blender-bot build
@blender-bot build
@ -19,0 +24,4 @@
void translate(const T &offset);
void scale_from_center(const T &scale);
void resize(const T &new_size);
Might it can be named constructor? Something like:
Right now I'm trying to just follow what
BLI_rect.h
is doing, so we can replace it. Adding new functions later would be no problem.Seems like a fine place to start! I don't have strong a strong opinion about free functions vs. class methods here, so going this route seems fine. Might be nice to get the opinion of someone else who worked on our C++ math API too.
@ -119,0 +120,4 @@
} // namespace bounds
template<typename T, int Size>
[[nodiscard]] inline bool less_or_equal_than(const VecBase<T, Size> &a, const VecBase<T, Size> &b)
This can go in a detail namespace. Or is it already implemented for
VecBase
inBLI_math_vector.hh
? That seems like a better place for itIt's not implemented there. I have a feeling that was a deliberate choice, so I put this here for now. We can only use
==
and!=
on vector types.I think it would be ok to use an operator overload for this. If not, then this function should probably at least have some more information about how it determines whether one vector is less than the other.
@ -119,0 +132,4 @@
template<typename T> inline bool Bounds<T>::is_empty() const
{
if (std::is_integral<T>::value || std::is_floating_point<T>::value) {
if constexpr
(that requires you to write "else" below)@ -119,0 +174,4 @@
this->translate(offset);
}
template<typename T> void Bounds<T>::pad(const T &padding)
I'd add another template argument for the padding type, so we can pad a
Bounds<float2>
with afloat
for exampleI suppose the same should be done for e.g.
translate
etc. ?I think there can be just an overload for
VecBase
type with the same number of axis and for single value. Not sure howfloat2
should be used infloat3
bounds.Not sure about
translate
, better to be a bit conservative with that@blender-bot build
@ -119,0 +134,4 @@
} // namespace detail
template<typename T> inline bool Bounds<T>::is_empty() const
It feels a bit like this could be a little bit misleading. The
min
andmax
are usually inclusive. So if I have aBounds<int>
withmin = max = 5
, then it feels like there is something in the bounds and it's not empty.Right I had the same thought when looking at
BLI_rcti_is_empty
/BLI_rctf_is_empty
.I can add a comment saying that it's trying to replicate the same behavior as those functions if that helps.
Maybe that is
is_empty_volume
?Well for one, you can have a
Bounds<int>
so just two numbers. So it doesn't have to be a volume.I think
Bounds<T>::is_empty()
is pretty clear.I'm missing some comments explaining what some of the methods do. Especially the behavior of
resize
andrecenter
is not really obvious to me when looking at the name.@JacquesLucke Added docstrings to the functions 👍
@HooglyBoogly Are you ok with me landing this?