WEMRayIntersect¶
- MLModule¶
author
package
dll
definition
keywords
Purpose¶
The WEMRayIntersect allows for the intersection of a ray with WEM triangle patches. It utilizes a bounding volume hierarchy (BVH) internally to ensure fast intersection. The information of the first hit point is provided as field values, while a list of all hit points is available as a marker list.
The precision of the ray intersection is limited to float precision, as the underlying Embree library does not support double precision.
Access to the BVH wrapper is also possible via the outBVH field using:
bvh = ctx.field("outBVH").object()
result = bvh.rayIntersectClosest([30., 0., 0.], [-1., 0., 0.])
Another alternative is to avoid using the WEMRayIntersect module entirely and instead create the BVH in Python:
wem = ctx.field("SomeWEMModule.outWEM").object()
bvh = MLAB.createMLBaseObject("WEMBoundingVolumeHierarchy", [wem])
result = bvh.rayIntersectClosest([30., 0., 0.], [-1., 0., 0.])
This allows for performing ray intersection directly from Python code.
For more details on scripting, have a look at the MLWEMBoundingVolumeHierarchyWrapper.
Output Fields¶
outBVH¶
- name: outBVH, type: WEMBoundingVolumeHierarchy(MLBase)¶
For accessing this object via scripting, see the Scripting Reference:
MLWEMBoundingVolumeHierarchyWrapper.
Parameter Fields¶
Field Index¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Visible Fields¶
Intersect Mode¶
- name: intersectMode, type: Enum, default: RemoveDuplicateHits¶
Defines the intersection mode.
Values:
Title |
Name |
Description |
|---|---|---|
All Hits |
AllHits |
This collects all hits; it can contain duplicate hits on neighboring triangle edges or nodes. |
Remove Duplicate Hits |
RemoveDuplicateHits |
This removes duplicate hits by checking whether the hits are close to each other within a certain epsilon and if they face the same direction relative to the ray direction. |
Update¶
- name: update, type: Trigger¶
When pressed, the BVH from the input WEM is updated.
Ready¶
- name: ready, type: Bool, persistent: no¶
Shows whether the module is ready for ray intersections.
Position¶
- name: position, type: Vector3, default: 0 0 0¶
Sets the origin of the ray.
Direction¶
- name: direction, type: Vector3, default: 0 0 0¶
Sets the start direction of the ray. This should be normalized.
Ray Near¶
- name: rayNear, type: Float, default: 0¶
Sets the near distance for the ray.
The intersection starts from
position + direction * rayNear.
Ray Far¶
- name: rayFar, type: Float, default: 3.4028235e+38¶
Sets the far distance for the ray.
The intersection stops at
position + direction * rayFar.
Cast Ray¶
- name: castRay, type: Trigger¶
When pressed, a ray is cast.
Hit Valid¶
- name: hitValid, type: Bool, persistent: no¶
Shows whether the hit is valid.
Hit Position¶
- name: hitPosition, type: Vector3, persistent: no¶
Shows the hit position of the closest triangle.
Hit Face Normal¶
- name: hitFaceNormal, type: Vector3, persistent: no¶
Shows the face normal of the hit triangle.
Hit Bary Coord¶
- name: hitBaryCoord, type: Vector3, persistent: no¶
Shows the barycentric coordinate of the hit triangle.
Hit Face Index¶
- name: hitFaceIndex, type: Integer, persistent: no¶
Shows the face index of the hit triangle.
Hit Patch Index¶
- name: hitPatchIndex, type: Integer, persistent: no¶
Shows the WEM patch index of the hit triangle.