Fix #119178: Geometry Nodes: Its possible to write non-normalized quaternion attribute from python API #119628

Open
Lleu Yang wants to merge 2 commits from megakite/blender:fix-119178 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

A setter is added for the QuaternionAttribute.value RNA property, which
provides additional check and normalization for non-normalized inputs.

Edit: added benchmark.

A setter is added for the QuaternionAttribute.value RNA property, which provides additional check and normalization for non-normalized inputs. Edit: added benchmark.
Lleu Yang force-pushed fix-119178 from b7736d56c1 to a816dd50b9 2024-03-18 15:35:26 +01:00 Compare
Iliya Katushenock added this to the Nodes & Physics project 2024-03-18 16:33:50 +01:00
Iliya Katushenock added the
Module
Python API
Interest
Geometry Nodes
labels 2024-03-18 16:33:58 +01:00
Iliya Katushenock requested review from Jacques Lucke 2024-03-18 16:34:04 +01:00
Iliya Katushenock requested review from Hans Goudey 2024-03-18 16:34:05 +01:00
Iliya Katushenock reviewed 2024-03-18 16:35:34 +01:00
@ -309,0 +313,4 @@
using blender::math::Quaternion;
float *fs = static_cast<float *>(ptr->data);
auto q = Quaternion(VecBase<float, 4>(values));

const Quaternion src = math::normalize(Quaternion(VecBase<float, 4>(values)));
?

`const Quaternion src = math::normalize(Quaternion(VecBase<float, 4>(values)));` ?
Author
Contributor

This is indeed better since math::normalize provides both unit scale validation and normalization. Will change. Thanks!

Edit: Sorry for the frustration. I have looked into the wrong function. In fact math::normalize doesn't check before actual calculation. I wonder if there's any practical difference in performance between the check-before-calc method and calc-immediately method?

This is indeed better since `math::normalize` provides both unit scale validation and normalization. Will change. Thanks! Edit: Sorry for the frustration. I have looked into the wrong function. In fact `math::normalize` doesn't check before actual calculation. I wonder if there's any practical difference in performance between the check-before-calc method and calc-immediately method?

Not sure if branch with non-zero cost check actually will make it faster.

Not sure if branch with non-zero cost check actually will make it faster.
Author
Contributor

I have done a quick benchmark, and it shows that there's little difference between the two methods. I will change my code since your line reduces unnecessary complexity. Again, thanks!

I have done a quick [benchmark](https://projects.blender.org/attachments/e3421f8c-f30e-4afd-b455-27928ff518c8), and it shows that there's little difference between the two methods. I will change my code since your line reduces unnecessary complexity. Again, thanks!
megakite marked this conversation as resolved
Lleu Yang added 1 commit 2024-03-19 16:59:00 +01:00

On the last geometry nodes meeting we decide that this also might make sense to ask @brecht about this/
Mainly this still looks like additional overhead and not so explicit for API user.

On the last geometry nodes meeting we decide that this also might make sense to ask @brecht about this/ Mainly this still looks like additional overhead and not so explicit for API user.

Quaternion rotations on objects are not normalized, I'm not sure why they should be here. That kind of normalization does not work with manual keyframing. I would rather expect any place using this quaternion to normalize it if needed.

Quaternion rotations on objects are not normalized, I'm not sure why they should be here. That kind of normalization does not work with manual keyframing. I would rather expect any place using this quaternion to normalize it if needed.

This means we have to change a lot of geometry nodes / bli code to have math functions to deal with non-normalized quaternions.

This means we have to change a lot of geometry nodes / bli code to have math functions to deal with non-normalized quaternions.
Author
Contributor

I see. Would it be better if I mark this PR as WIP for further operations?

I see. Would it be better if I mark this PR as WIP for further operations?

Not sure if this PR should be changed in some way for now at all\

Not sure if this PR should be changed in some way for now at all\
Merge conflict checking is in progress. Try again in few moments.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix-119178:megakite-fix-119178
git checkout megakite-fix-119178
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
3 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#119628
No description provided.