BVH overlap() failing to detect intersection due to bmesh rotation not updating until script ends #50721
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#50721
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
System Information
Windows 10
NVIDIA GeForce GTX 460M
Blender Version
Blender 2.78,a,b
Short description of error
overlap() failing to detect intersection of objects that have been rotated, however it succeeds when running independently (scripts included) on the same objects.
Exact steps for others to reproduce the error
I have included a .blend file with two scripts, first one makes copies of objects on one of the selected planes. The overlap() function fails when a copy of an object is rotated. However, when running the second script with exact same overlap detection it works fine. Please see the blend file it includes more instructions for reproducing the error.
In summary: bmesh location updates, but bmesh rotation does not until after the script ends.
intersect_bug.blend
intersect_bug.py
testing_bug_intersect.py
Changed status to: 'Open'
Added subscriber: @valera-8
Added subscriber: @mano-wii
Mathutils.BVHTree does not take into account the matrix when creating a bvhtree. It is as if bvhtree were using the local coordinates of the object.
That's why in raycasts or nearest, the ray or point need to be transformed with the inverse matrix.
For overlap you need to create the BVHTree with the object coordinates already transformed.
It is not practical to analyze possible errors in scripts that do not come with blender, you need to be more specific with the problem.
You can ask questions in the blenderartists.org forum to make sure it is a bug.
Germano, please see the .blend files, scripts are included and test scene is setup with extra instructions.
That is exactly how the script works:
The overlap() test works as long as the objects are not rotated.
I've tested your script and it seems to be working...
I also tested this script with rotated objects:
As you can see, the overlap is working.
Did I miss something?
Your case worked because the objects already exist in the scene, I assume. If the objects already exist overalp() works for me as well as demonstrated in testing_intersect.py
Take a look at the image below after I run the script to place the objects:
2 - as you can see spheres failed the overlap test
1 - In this case 4 spheres should have been placed since there is room for 4, unless objects have not been rotated (1 and 3 have the same length in x, y)
I should have been more clear that:
testing_intersect.py only used to prove that the objects intersect while using the same intersection testing code as intersect_bug.py
intersect_bug.py is the one one failing to detect intersection of rotated objects
Changed status from 'Open' to: 'Archived'
I took a quick look at your script and... this is not a bug.
You are changing the quaternion rotation of an object expecting its matrix to be automatically updated within the script.
Instead of doing this, try changing the matrix directly
A good place to ask questions like this is here ;)
https://blenderartists.org/forum/forumdisplay.php?11-Python-Support
Thanks! I was so convinced this was a bug, should have check the forums or stack overflow first..