Attributes: Add quaternion rotation type #108678

Merged
Hans Goudey merged 10 commits from HooglyBoogly/blender:attributes-quaternion-type into main 2023-06-12 15:49:57 +02:00
Member

Add a quaternion attribute type that will be used in combination with
rotation sockets for geometry nodes to give a more intuitive experience
and better performance when using rotations.

The most interesting part is probably the interpolation. We need to
interpolate multiple values with different weights. Based on Sybren's
suggestion, I used the expmap methods from 4805a54525
for that. That seemed to work well with the point cloud merge by distance
mixing.

I also refactored SimpleMixerWithAccumulationType to use an explicit
callback rather than a static cast to convert to the accumulation type.

See #92967

Add a quaternion attribute type that will be used in combination with rotation sockets for geometry nodes to give a more intuitive experience and better performance when using rotations. The most interesting part is probably the interpolation. We need to interpolate multiple values with different weights. Based on Sybren's suggestion, I used the `expmap` methods from 4805a54525eaa8eb234e for that. That seemed to work well with the point cloud merge by distance mixing. I also refactored `SimpleMixerWithAccumulationType` to use an explicit callback rather than a static cast to convert to the accumulation type. See #92967
Hans Goudey added 3 commits 2023-06-06 21:37:11 +02:00
Hans Goudey requested review from Jacques Lucke 2023-06-06 21:38:24 +02:00
Hans Goudey added the
Interest
Animation & Rigging
Interest
Geometry Nodes
labels 2023-06-06 21:38:38 +02:00
Hans Goudey added this to the 4.0 milestone 2023-06-06 21:38:44 +02:00
Hans Goudey added this to the Nodes & Physics project 2023-06-06 21:38:50 +02:00
Member

@blender-bot build

@blender-bot build
Jacques Lucke reviewed 2023-06-08 22:51:04 +02:00
@ -11,6 +11,7 @@
#include "BLI_index_mask.hh"
#include "BLI_math_base.hh"
#include "BLI_math_color.hh"
#include "BLI_math_quaternion.hh"
Member

Why this include?

Why this include?
Author
Member

Currently that's the best way I found to solve this build error. But I don't fully understand why isn't necessary. I thought I'd just be able to include it in resample_curves.cc, rather than the header. It's the same reason that BLI_math_color.hh is there though.

/home/hans/blender-git/blender/source/blender/blenkernel/BKE_attribute_math.hh:37:48:   required from ‘void blender::bke::attribute_math::convert_to_static_type(const blender::CPPType&, const Func&) [with Func = blender::geometry::resample_to_uniform(const blender::bke::CurvesGeometry&, const blender::fn::Field<bool>&, const blender::fn::Field<int>&, const ResampleCurvesOutputAttributeIDs&)::<lambda(blender::index_mask::IndexMaskSegment)>::<lambda(auto:173)>]’
/home/hans/blender-git/blender/source/blender/geometry/intern/resample_curves.cc:324:50:   required from here
/home/hans/blender-git/blender/source/blender/blenlib/BLI_math_base.hh:208:29: error: no match for ‘operator+’ (operand types are ‘blender::math::QuaternionBase<float>’ and ‘blender::math::QuaternionBase<float>’)
  208 |   auto result = a * (1 - t) + b * t;
      |                 ~~~~~~~~~~~~^~~~~~~
In file included from /home/hans/blender-git/blender/source/blender/blenlib/BLI_linear_allocator.hh:15,
                 from /home/hans/blender-git/blender/source/blender/blenlib/BLI_index_mask.hh:13,
                 from /home/hans/blender-git/blender/source/blender/blenlib/BLI_length_parameterize.hh:11:
/home/hans/blender-git/blender/source/blender/blenlib/BLI_string_ref.hh:590:20: note: candidate: ‘std::string blender::operator+(StringRef, StringRef)’
  590 | inline std::string operator+(StringRef a, StringRef b)
      |                    ^~~~~~~~
/home/hans/blender-git/blender/source/blender/blenlib/BLI_string_ref.hh:590:40: note:   no known conversion for argument 1 from ‘blender::math::QuaternionBase<float>’ to ‘blender::StringRef’
  590 | inline std::string operator+(StringRef a, StringRef b)
      |                              ~~~~~~~~~~^
Currently that's the best way I found to solve this build error. But I don't fully understand why isn't necessary. I thought I'd just be able to include it in `resample_curves.cc`, rather than the header. It's the same reason that `BLI_math_color.hh` is there though. ``` /home/hans/blender-git/blender/source/blender/blenkernel/BKE_attribute_math.hh:37:48: required from ‘void blender::bke::attribute_math::convert_to_static_type(const blender::CPPType&, const Func&) [with Func = blender::geometry::resample_to_uniform(const blender::bke::CurvesGeometry&, const blender::fn::Field<bool>&, const blender::fn::Field<int>&, const ResampleCurvesOutputAttributeIDs&)::<lambda(blender::index_mask::IndexMaskSegment)>::<lambda(auto:173)>]’ /home/hans/blender-git/blender/source/blender/geometry/intern/resample_curves.cc:324:50: required from here /home/hans/blender-git/blender/source/blender/blenlib/BLI_math_base.hh:208:29: error: no match for ‘operator+’ (operand types are ‘blender::math::QuaternionBase<float>’ and ‘blender::math::QuaternionBase<float>’) 208 | auto result = a * (1 - t) + b * t; | ~~~~~~~~~~~~^~~~~~~ In file included from /home/hans/blender-git/blender/source/blender/blenlib/BLI_linear_allocator.hh:15, from /home/hans/blender-git/blender/source/blender/blenlib/BLI_index_mask.hh:13, from /home/hans/blender-git/blender/source/blender/blenlib/BLI_length_parameterize.hh:11: /home/hans/blender-git/blender/source/blender/blenlib/BLI_string_ref.hh:590:20: note: candidate: ‘std::string blender::operator+(StringRef, StringRef)’ 590 | inline std::string operator+(StringRef a, StringRef b) | ^~~~~~~~ /home/hans/blender-git/blender/source/blender/blenlib/BLI_string_ref.hh:590:40: note: no known conversion for argument 1 from ‘blender::math::QuaternionBase<float>’ to ‘blender::StringRef’ 590 | inline std::string operator+(StringRef a, StringRef b) | ~~~~~~~~~~^ ```
@ -669,6 +669,16 @@ template<typename T> Euler3Base<T> to_euler(const QuaternionBase<T> &quat, Euler
/** \name Conversion from/to Expmap
* \{ */
template<typename T> T mod_inline(const T a, const T b)
Member

Missing inline keyword. Same below. Also a comment would be useful. Not really obvious to me what mod_inline means.

Missing `inline` keyword. Same below. Also a comment would be useful. Not really obvious to me what `mod_inline` means.
HooglyBoogly marked this conversation as resolved
@ -87,2 +87,2 @@
int typemap[52];
char _pad[4];
int typemap[53];
// char _pad[4];
Member

Remove padding line.

Remove padding line.
HooglyBoogly marked this conversation as resolved
Hans Goudey added 6 commits 2023-06-09 13:35:46 +02:00
Member

@blender-bot build

@blender-bot build
Hans Goudey added 1 commit 2023-06-09 23:29:34 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
7a8dc0809d
Merge branch 'main' into attributes-quaternion-type
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke approved these changes 2023-06-12 14:35:34 +02:00
Hans Goudey merged commit 1e4b80fed9 into main 2023-06-12 15:49:56 +02:00
Hans Goudey deleted branch attributes-quaternion-type 2023-06-12 15:49:58 +02:00
Sign in to join this conversation.
No reviewers
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 Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#108678
No description provided.