Python: bvh.ray_cast doesn't find a plane facing in the other direction under certain circumstances #46521

Closed
opened 2015-10-17 19:57:58 +02:00 by Jacques Lucke · 11 comments
Member

System Information
Windows 7 64 bit
Nvidia Quadro 600

Blender Version
Broken: bfdb420

Short description of error
The ray_cast function returns (None, None, ..) although there is a polygon.
bvh_bug.blend
bvh bug.PNG
In the file is a python script, when you execute it you will find that it prints "None" in the Console, but instead it should print "<Vector (4.0000, 0.0000, 0.0000)>"

There are multiple things you can do so that the function finds the plane:

  • Rotate the plane around the z axis so that the normal points to the center ( >= 90 degree)
  • Move the plane a bit on the Y or Z axis
  • Change the direction parameter a bit. eg from Vector((1, 0, 0)) -> Vector((1, 0.00001, 0))
  • Change the ray start parameter a bit (not on the X axis)
**System Information** Windows 7 64 bit Nvidia Quadro 600 **Blender Version** Broken: bfdb420 **Short description of error** The ray_cast function returns (None, None, ..) although there is a polygon. [bvh_bug.blend](https://archive.blender.org/developer/F245689/bvh_bug.blend) ![bvh bug.PNG](https://archive.blender.org/developer/F245693/bvh_bug.PNG) In the file is a python script, when you execute it you will find that it prints "None" in the Console, but instead it should print "<Vector (4.0000, 0.0000, 0.0000)>" There are multiple things you can do so that the function finds the plane: - Rotate the plane around the z axis so that the normal points to the center ( >= 90 degree) - Move the plane a bit on the Y or Z axis - Change the direction parameter a bit. eg from Vector((1, 0, 0)) -> Vector((1, 0.00001, 0)) - Change the ray start parameter a bit (not on the X axis)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke

Added subscriber: @mont29

Added subscriber: @mont29

There is also another thing you can do here - increase epsilon of bvhtree (even such a small value as 1e-9 is enough)…

Will check further what happens here, but this may be due to numeric instability/imprecision, which is precisely why non-zero epsilon is usually needed. ;)

There is also another thing you can do here - increase epsilon of bvhtree (even such a small value as 1e-9 is enough)… Will check further what happens here, but this may be due to numeric instability/imprecision, which is precisely why non-zero epsilon is usually needed. ;)
Sergey Sharybin was assigned by Bastien Montagne 2015-10-18 12:29:44 +02:00

Added subscriber: @Sergey

Added subscriber: @Sergey

OK, so issue is with isect_ray_tri_watertight_v3() not detecting rayhit on a border (remember your square is split in two triangles, which means your ray would hit exactly on the limit between those two tris).

Now, I won’t pretend to understand that dark piece of art of black magic that is watertight, so will let @Sergey decide whether this is known limitation/expected behavior, or actual real bug.

OK, so issue is with `isect_ray_tri_watertight_v3()` not detecting rayhit on a border (remember your square is split in two triangles, which means your ray would hit exactly on the limit between those two tris). Now, I won’t pretend to understand that dark piece of art of black magic that is watertight, so will let @Sergey decide whether this is known limitation/expected behavior, or actual real bug.

Watertight intersection is aimed to solve issues caused by ray hitting exact edge. There's one difference from the original paper which is fallback to double precision in the cease if U == 0.0f || V == 0.0f || W == 0.0f. We don't do this in Cycles because doubles aren't available in consumer GPUs and doing float to double precision conversion is not really cheap. But here i think we should implement such a fallback.

Watertight intersection is aimed to solve issues caused by ray hitting exact edge. There's one difference from the original paper which is fallback to double precision in the cease if `U == 0.0f || V == 0.0f || W == 0.0f`. We don't do this in Cycles because doubles aren't available in consumer GPUs and doing float to double precision conversion is not really cheap. But here i think we should implement such a fallback.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Tested and even after adding the double fallback its still returning None, see: P274

Tested and even after adding the double fallback its still returning `None`, see: [P274](https://archive.blender.org/developer/P274.txt)

This issue was referenced by 0d54aa9c02

This issue was referenced by 0d54aa9c024261851bef24a3ebfd2bd875fec380

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
No Assignees
5 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#46521
No description provided.