Determine if a Point is Inside a Mesh #28173
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#28173
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?
%%%This patch adds the functionality to determine if a point lies inside a given mesh. It makes the assumption the mesh has normals calculated "outside" and that the point is in object space. Clearly inside/outside only makes sense if the mesh is closed, no check is made of this and it will still return a result if the mesh is open.
The code determines which side of the nearest face the given point lies on by comparing the displacement from the nearest point to the normal at the nearest point. If this is negative, then the point lies "behind" the face and is therefore inside the mesh if the above assumption is made. Hence, if the mesh is open, and the point in question lies behind the nearest face, it will still return true.%%%
Changed status to: 'Open'
%%%Updated to r39834
This new patch fixes a problem which may occur due to precision errors and only finding the closest point on the meshes faces. The new method works as follows, the closest vertex on the mesh is found, its position and normal are stored. The distance to the nearest point is then decreased by 0.000001f to account for precision errors and the test is run again using the mesh edges this time. This process is repeated from edges to faces. By ensuring that the nearest subsequent point is at least a precision increment closer we can account for any errors that enter the calculations.
Cheers,
Andrew%%%
%%%Attached the file.%%%
%%%Hi Truman,
I tested like this with c = default-cube : for i in range(10): c.point_inside_mesh(Vector((0,0, 1.5 - i/10)))
> False * 6 True * 4
Looks good ;-)
BUT if I move the cube out ot fthe way nothing changes.
Suggestion: a next parameter to use world coordinates and not the local ones?
Changed status from 'Open' to: 'Archived'
While this patch is reasonable. Lukas is looking into having a Python KD-Tree module,
I'd rather expose more functionality though this. So you would get a KD-Tree from a mesh, then perform queries on it.
See: D133, archiving