Vector Math Bug. #85734

Closed
opened 2021-02-17 11:33:32 +01:00 by paul geraskin · 26 comments
Member

System Information
Operating system:
Graphics card:

Blender Version
Broken: 2.90+
Worked: 2.83.12

Short description of error
I did a tool called "Draw Clones" for 2.7 then I updated it for 2.81 and it worked fine. But it was broken in 2.90+. Could you check it please? I guess there is something with vector math. I attached my addon, a testing blender scene, a screenshot and video.
mifth_tools.zip
tmp1.blend
image.png
tmp_vid1.mp4

You could check my file "mifth_tools_cloning.py" and a class "MFTDrawClones". And the "mft_pick_and_clone" fuction where all this happens.
Also, you could check "create_z_orient" function which I took from here https://devtalk.blender.org/t/bpy-ops-transform-rotate-option-axis/6235/9

And something is broken in Blender. I suppose this is on Blender's side.

Exact steps for others to reproduce the error

  • Install my attached addon. Select "Mifth" tab in 3dViewport.
  • Select amonkey in a scene and press "Pick Object"
  • Then Select a Sphere in the scene and press Draw Clones.
    Results in 2.83 and 2.90+ are different. 2.83 is correct.
**System Information** Operating system: Graphics card: **Blender Version** Broken: 2.90+ Worked: 2.83.12 **Short description of error** I did a tool called "Draw Clones" for 2.7 then I updated it for 2.81 and it worked fine. But it was broken in 2.90+. Could you check it please? I guess there is something with vector math. I attached my addon, a testing blender scene, a screenshot and video. [mifth_tools.zip](https://archive.blender.org/developer/F9811756/mifth_tools.zip) [tmp1.blend](https://archive.blender.org/developer/F9811786/tmp1.blend) ![image.png](https://archive.blender.org/developer/F9811754/image.png) [tmp_vid1.mp4](https://archive.blender.org/developer/F9811757/tmp_vid1.mp4) You could check my file "mifth_tools_cloning.py" and a class "MFTDrawClones". And the "mft_pick_and_clone" fuction where all this happens. Also, you could check "create_z_orient" function which I took from here https://devtalk.blender.org/t/bpy-ops-transform-rotate-option-axis/6235/9 And something is broken in Blender. I suppose this is on Blender's side. **Exact steps for others to reproduce the error** - Install my attached addon. Select "Mifth" tab in 3dViewport. - Select amonkey in a scene and press "Pick Object" - Then Select a Sphere in the scene and press Draw Clones. Results in 2.83 and 2.90+ are different. 2.83 is correct.
Author
Member

Added subscriber: @PaulGeraskin

Added subscriber: @PaulGeraskin
Member

Added subscriber: @CharlieJolly

Added subscriber: @CharlieJolly
Member

Confirmed in 2.93 Alpha too. @PaulGeraskin Can you isolate or confirm the Python function that is not working?

Confirmed in 2.93 Alpha too. @PaulGeraskin Can you isolate or confirm the Python function that is not working?
Author
Member

@CharlieJolly Thanks for a confirmation.

I think either create_z_orient() or mft_pick_and_clone() functions do work incorrectly. But I cannot understand where exactly. Somewhere in vector math.
I guess lines 41-60 and 518-623 affect the math.

Or as another guess that raycast() function creates a incorrect normal direction (line 392 in my code) .

The file is mifth_tools_cloning.py

@CharlieJolly Thanks for a confirmation. I think either create_z_orient() or mft_pick_and_clone() functions do work incorrectly. But I cannot understand where exactly. Somewhere in vector math. I guess lines 41-60 and 518-623 affect the math. Or as another guess that raycast() function creates a incorrect normal direction (line 392 in my code) . The file is mifth_tools_cloning.py
Member

HI @PaulGeraskin, I'm getting a few warnings from your add-on. It looks like your script needs updating to use collections.

There were Python API changes in 2.90 relating to matrices: https://wiki.blender.org/wiki/Reference/Release_Notes/2.90/Python_API and fa7ace2215

This may be helpful to you.

I'm not responsible for triaging bugs so this is as much as I can help.

HI @PaulGeraskin, I'm getting a few warnings from your add-on. It looks like your script needs updating to use collections. There were Python API changes in 2.90 relating to matrices: https://wiki.blender.org/wiki/Reference/Release_Notes/2.90/Python_API and fa7ace2215 This may be helpful to you. I'm not responsible for triaging bugs so this is as much as I can help.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I think either create_z_orient() or mft_pick_and_clone() functions do work incorrectly. But I cannot understand where exactly. Somewhere in vector math.

Hi and thx reporting!
It would be good to provide a simple example that isolates this more.
Please understand that it takes considerable time to chase this down in a complex piece of code.
Try to isolate the exact calls that behave differently in 2.83 in 2.90.

> I think either create_z_orient() or mft_pick_and_clone() functions do work incorrectly. But I cannot understand where exactly. Somewhere in vector math. Hi and thx reporting! It would be good to provide a simple example that isolates this more. Please understand that it takes considerable time to chase this down in a complex piece of code. Try to isolate the exact calls that behave differently in 2.83 in 2.90.
Member

Added subscriber: @nBurn

Added subscriber: @nBurn
Member

I noticed some unusual results with Exact Edit between the 2.8x and 2.9x version of Blender that were related to this issue.

I wrote some basic code to test rotations when I was updating Exact Edit in the past.
I wrapped that code in a basic add-on for ease of use:

test_rotate_op.py

These are the results from using my test code against recent Blender releases:

Note: Creation dates may be off by 1-2 days

Bug status in Blender versions before 2.93

blender-2.83.13-windows64/blender.exe
exe file creation date: 2021-03-09
matrix_world match expected? True

blender-2.92.0-windows64/blender.exe
exe file creation date: 2021-02-25
matrix_world match expected? False


Bug status in 2.93 commits / builds

blender-2.93.0-62987a6f9845-windows64/blender.exe
exe file creation date: 2021-03-22
matrix_world match expected? False

blender-2.93.0 699b2d98553f2b0c4bb74dc263d3251600fadd25
commit log date: 2021-02-06
matrix_world match expected? False

blender-2.93.0 e94c38e005103ced62c4b0b8033a0df8ca932c8d
commit title: Merge branch 'blender-v2.92-release'
commit log date: 2021-02-01 05:01:29
matrix_world match expected? False

blender-2.93.0 171f2e4949837ca3537d9b998a42590fd88c5ad8
commit title: Merge branch 'blender-v2.92-release'
commit log date: 2021-01-29 11:09:58
matrix_world match expected? True

blender-2.93.0 985bc08688b7fb58a910171c63a1417580cffece
commit log date: 2021-01-21
commit title: Merge branch 'blender-v2.92-release'
matrix_world match expected? True

blender-2.93.0-1e8ed36a907c-windows64/blender.exe
exe file creation date: 2021-01-16
matrix_world match expected? True
I noticed some unusual results with Exact Edit between the 2.8x and 2.9x version of Blender that were related to this issue. I wrote some basic code to test rotations when I was updating Exact Edit in the past. I wrapped that code in a basic add-on for ease of use: [test_rotate_op.py](https://archive.blender.org/developer/F9905592/test_rotate_op.py) These are the results from using my test code against recent Blender releases: ``` Note: Creation dates may be off by 1-2 days Bug status in Blender versions before 2.93 blender-2.83.13-windows64/blender.exe exe file creation date: 2021-03-09 matrix_world match expected? True blender-2.92.0-windows64/blender.exe exe file creation date: 2021-02-25 matrix_world match expected? False Bug status in 2.93 commits / builds blender-2.93.0-62987a6f9845-windows64/blender.exe exe file creation date: 2021-03-22 matrix_world match expected? False blender-2.93.0 699b2d98553f2b0c4bb74dc263d3251600fadd25 commit log date: 2021-02-06 matrix_world match expected? False blender-2.93.0 e94c38e005103ced62c4b0b8033a0df8ca932c8d commit title: Merge branch 'blender-v2.92-release' commit log date: 2021-02-01 05:01:29 matrix_world match expected? False blender-2.93.0 171f2e4949837ca3537d9b998a42590fd88c5ad8 commit title: Merge branch 'blender-v2.92-release' commit log date: 2021-01-29 11:09:58 matrix_world match expected? True blender-2.93.0 985bc08688b7fb58a910171c63a1417580cffece commit log date: 2021-01-21 commit title: Merge branch 'blender-v2.92-release' matrix_world match expected? True blender-2.93.0-1e8ed36a907c-windows64/blender.exe exe file creation date: 2021-01-16 matrix_world match expected? True ```
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Thx checking, @nBurn !
Will have another look then.

Thx checking, @nBurn ! Will have another look then.
Author
Member

Hi, apologies. Had no time to optimize the code. Thank you.

Hi, apologies. Had no time to optimize the code. Thank you.
Member

@lichtwerk no problem.

I forgot to mention in my earlier post, but before you run my addon to test rotations you should be in object mode with only a "default" cube selected (a cube object at position (0, 0, 0) with no transformations done to it).

@lichtwerk no problem. I forgot to mention in my earlier post, but before you run my addon to test rotations you should be in object mode with only a "default" cube selected (a cube object at position (0, 0, 0) with no transformations done to it).
Member

Weird, I was sure my rotation test code was throwing an AttributeError earlier when run directly from Blender 2.93's text editor. This is why I wrapped it in an addon. But I just tried it again a few minutes ago and it worked fine when run from 2.93's text editor.

Try running this code directly from the text editor first. If it doesn't work, you can use the "test_rotate_op.py" file addon as a backup option:

rotate_test_basic_280.py

Weird, I was sure my rotation test code was throwing an AttributeError earlier when run directly from Blender 2.93's text editor. This is why I wrapped it in an addon. But I just tried it again a few minutes ago and it worked fine when run from 2.93's text editor. Try running this code directly from the text editor first. If it doesn't work, you can use the "test_rotate_op.py" file addon as a backup option: [rotate_test_basic_280.py](https://archive.blender.org/developer/F9906179/rotate_test_basic_280.py)
Member

I did some more testing and It seems like the "orient_matrix" argument in "bpy.ops.transform.rotate" is being ignored entirely. I ran my rotate test code twice, once with an orient_matrix argument and once without and there was no difference in the matrix_world of the transformed object.

I'm not sure what the situation is in 2.93, but when I was trying to figure out how that argument worked after it was added in 2.80 I think the relevant files were:

  • transform.h
  • transform.c
  • transform_generics.c
  • transform_orientations.c

These were in the directory:

  • blender/source/blender/editors/transform
I did some more testing and It seems like the "orient_matrix" argument in "bpy.ops.transform.rotate" is being ignored entirely. I ran my rotate test code twice, once with an orient_matrix argument and once without and there was no difference in the matrix_world of the transformed object. I'm not sure what the situation is in 2.93, but when I was trying to figure out how that argument worked after it was added in 2.80 I think the relevant files were: - transform.h - transform.c - transform_generics.c - transform_orientations.c These were in the directory: - blender/source/blender/editors/transform
Member

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Member

@lichtwerk I've narrowed down the commits where the my test code stopped working.

It looks like the "orient_matrix" argument for "bpy.ops.transform.rotate" worked from at least this commit (possibly earlier):

  • commit: 626a9aae6d
  • Date: 2020-12-21 05:50:38
  • Title: Fix part of #84004: Some 2.92 alpha UI strings can't be translated.

Until this commit which caused the "orient_matrix" argument to stop functioning

  • commit: 216ebe0b73
  • Date: 2021-01-30 10:55:07
  • Title: Fix #83092: Direction of rotation with View orientation changed in 2.91

I made some small updates to my testing code to allow for external test data. Here is the updated code:
rotate_test_basic_280b.py

And here is the additional tests that can be run from my testing code:
rotate_unit_tests.py

It appears the most recent commits related to this area of Blender's codebase were done by @mano-wii, maybe he might be of assistance?

@lichtwerk I've narrowed down the commits where the my test code stopped working. It looks like the "orient_matrix" argument for "bpy.ops.transform.rotate" worked from at least this commit (possibly earlier): - commit: 626a9aae6d140badb1910bdb18ac0ab6c199a701 - Date: 2020-12-21 05:50:38 - Title: Fix part of #84004: Some 2.92 alpha UI strings can't be translated. Until this commit which caused the "orient_matrix" argument to stop functioning - commit: 216ebe0b7392d6da484cbf369402c65b3c6352f8 - Date: 2021-01-30 10:55:07 - Title: Fix #83092: Direction of rotation with View orientation changed in 2.91 I made some small updates to my testing code to allow for external test data. Here is the updated code: [rotate_test_basic_280b.py](https://archive.blender.org/developer/F9923486/rotate_test_basic_280b.py) And here is the additional tests that can be run from my testing code: [rotate_unit_tests.py](https://archive.blender.org/developer/F9923483/rotate_unit_tests.py) It appears the most recent commits related to this area of Blender's codebase were done by @mano-wii, maybe he might be of assistance?

This issue was referenced by 0515ff70ec

This issue was referenced by 0515ff70ec09694d11e36e90212119574c65ada9

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Germano Cavalcante self-assigned this 2021-04-09 23:27:46 +02:00

Although this was closed as resolved, the behavior after 0515ff70ec is not the same as before as there are differences in rotation with and without constraint.

Although this was closed as resolved, the behavior after 0515ff70ec is not the same as before as there are differences in rotation with and without constraint.
Author
Member

Thanks a lot. I'll test it with a nightly build when it gets an update.

Thanks a lot. I'll test it with a nightly build when it gets an update.
Author
Member

Hi,
I have just tested the daily build and the issue still exists.
image.png

I tested this build.
image.png

I'll make a new test case this evening and write here.

Hi, I have just tested the daily build and the issue still exists. ![image.png](https://archive.blender.org/developer/F9929309/image.png) I tested this build. ![image.png](https://archive.blender.org/developer/F9929311/image.png) I'll make a new test case this evening and write here.
Member

@mano-wii!! Thanks for looking into this and for the tip about constraints! I didn't expect changing the "constraint_axis" argument would get my "ops.transform.rotate" code working again in 2.93. I guess I must have given up on that argument after changing it didn't fix this issue in Blender 2.92.0.

As for 0515ff70ec, I tried a recent build with that commit applied, but it didn't appear to change the situation related needing a constraint applied for "orient_matrix".
I'm fine the code as-is now that I know adding a constraint fixes the issue though.

If it helps, here's the code I used to test out your changes. It generates a sort of pseudo truth table:

rotate_test_multi_280.py

And my results:

mult_test_results.txt

@PaulGeraskin, try adding this in your arguments for "bpy.ops.transform.rotate":

constraint_axis=(False, False, True),

@mano-wii!! Thanks for looking into this and for the tip about constraints! I didn't expect changing the "constraint_axis" argument would get my "ops.transform.rotate" code working again in 2.93. I guess I must have given up on that argument after changing it didn't fix this issue in Blender 2.92.0. As for 0515ff70ec09, I tried a recent build with that commit applied, but it didn't appear to change the situation related needing a constraint applied for "orient_matrix". I'm fine the code as-is now that I know adding a constraint fixes the issue though. If it helps, here's the code I used to test out your changes. It generates a sort of pseudo truth table: [rotate_test_multi_280.py](https://archive.blender.org/developer/F9930102/rotate_test_multi_280.py) And my results: [mult_test_results.txt](https://archive.blender.org/developer/F9930103/mult_test_results.txt) @PaulGeraskin, try adding this in your arguments for "bpy.ops.transform.rotate": `constraint_axis=(False, False, True),`

In #85734#1144826, @nBurn wrote:
As for 0515ff70ec, I tried a recent build with that commit applied, but it didn't appear to change the situation related needing a constraint applied for "orient_matrix".

The result changed, without constraint the object rotates in the other direction.
I'm not sure if your problem is the same as reported however.

> In #85734#1144826, @nBurn wrote: > As for 0515ff70ec09, I tried a recent build with that commit applied, but it didn't appear to change the situation related needing a constraint applied for "orient_matrix". The result changed, without constraint the object rotates in the other direction. I'm not sure if your problem is the same as reported however.
Author
Member

Hi, I looked again into my addon and I fixed the rotation issue. I had to negate angle for blender 2.91+.

image.png
image.png

All works fin now. Thanks.

Hi, I looked again into my addon and I fixed the rotation issue. I had to negate angle for blender 2.91+. ![image.png](https://archive.blender.org/developer/F10241489/image.png) ![image.png](https://archive.blender.org/developer/F10241492/image.png) All works fin now. Thanks.
Sign in to join this conversation.
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
6 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#85734
No description provided.