intersectsRay_Sphere
Definition
-- @/lua/common/mathlib.lua:1442
function intersectsRay_Sphere(rpos, rdir, cpos, cr)
local rcpos = cpos - rpos
local dcr = rdir:dot(rcpos)
local s = dcr*dcr - rcpos:squaredLength() + cr*cr
if s < 0 then return math.huge, math.huge end
s = sqrt(s)
return dcr - s, dcr + s
end
Callers
@/lua/ge/extensions/editor/tech/roadArchitect/utilities.lua
if not node.isLocked then -- Do not consider locked nodes.
local a, b = intersectsRay_Sphere(rayPos, rayDir, node.p, mouseToNodetol) -- Get the two intersection points between the ray and sphere, if any exist.
if min(a, b) < maxRayDist then -- If they do exist, the mouse is over this node, so we have found target.
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/vePartTree.lua
if imguiNotHovered then
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, nodePos, nodeCollisionRadius)
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veJBeamPicker.lua
if imguiNotHovered then
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, nodePos, nodeSelectedRadius)
@/lua/ge/extensions/editor/rallyEditor/drivelineTab.lua
local tolerance = 0.5 + math.sqrt(dist) * 0.15 -- Distance-adaptive tolerance
local intA, intB = intersectsRay_Sphere(rayPos, rayDir, node, tolerance)
if intA and intB then
@/lua/ge/extensions/editor/toolUtilities/splineInput.lua
local adaptiveTol = getAdaptiveTolerance(rayPos, nodes[j], 'node')
local intA, intB = intersectsRay_Sphere(rayPos, rayDir, nodes[j], adaptiveTol)
if intA and intB then
local adaptiveTol = getAdaptiveTolerance(rayPos, ribPoints[j], 'rib')
local intA, intB = intersectsRay_Sphere(rayPos, rayDir, ribPoints[j], adaptiveTol)
if intA and intB then
local adaptiveTol = getAdaptiveTolerance(rayPos, ribPoints[j], 'rib')
local intA, intB = intersectsRay_Sphere(rayPos, rayDir, ribPoints[j], adaptiveTol)
if intA and intB then
local adaptiveTol = getAdaptiveTolerance(rayPos, barPoints[j], 'bar')
local intA, intB = intersectsRay_Sphere(rayPos, rayDir, barPoints[j], adaptiveTol)
if intA and intB then
@/lua/ge/extensions/gameplay/race/pacenote.lua
rDir:normalize()
local sMin, sMax = intersectsRay_Sphere(rPos, rDir, self.pos, self.radius)
--adjust for normlized rDir
@/lua/ge/extensions/gameplay/race/pathnode.lua
if self.hasNormal then
local sMin, sMax = intersectsRay_Sphere(rPos, rDir, self.pos, self.radius)
--adjust for normlized rDir
else
local t, _ = intersectsRay_Sphere(rPos, rDir, self.pos, self.radius)
t = t*len
@/lua/ge/extensions/gameplay/rally/notebook/pacenoteWaypoint.lua
-- local rad = self.intersectRadius
-- local sMin, sMax = intersectsRay_Sphere(rPos, rDir, self.pos, rad)
-- --adjust for normlized rDir
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veFlexbodyDebug.lua
local nodePos = vEditor.vehicle:getNodeAbsPosition(nodeID)
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, nodePos, nodeRenderRadius)
local vertPos = flexbodyObj:getDebugVertexPos(i) + vehPos
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, vertPos, nodeRenderRadius)
local vertPos = flexbodyObj:getDebugVertexPos(i) + vehPos
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, vertPos, nodeRenderRadius)
@/lua/ge/extensions/editor/aiViz.lua
local node = mapNodes[nid]
local minSphereHitDist, _ = intersectsRay_Sphere(ray.pos, rayDir, node.pos, node.radius)
if minSphereHitDist and minSphereHitDist < minHitDist then
@/lua/ge/extensions/editor/toolUtilities/geom.lua
for j = 1, #nodes do
local a, b = intersectsRay_Sphere(rayPos, rayDir, nodes[j], mouseToNodetol) -- Get any intersection points between the ray and node sphere.
if min(a, b) < maxRayDist then -- If they do exist, the mouse is over this node, so we have found target.
for j = 2, #ribPoints, 2 do
local a, b = intersectsRay_Sphere(rayPos, rayDir, ribPoints[j], mouseToNodetol) -- The intersection points between ray and node sphere.
if min(a, b) < maxRayDist then -- If one exists, the mouse is over this rib point.
for j = 1, #ribPoints do
local a, b = intersectsRay_Sphere(rayPos, rayDir, ribPoints[j], mouseToNodetol) -- The intersection points between ray and node sphere.
if min(a, b) < maxRayDist then -- If one exists, the mouse is over this rib point.
for j = 1, #barPoints do
local a, b = intersectsRay_Sphere(rayPos, rayDir, barPoints[j], mouseToNodetol) -- The intersection points between ray and node sphere.
if min(a, b) < maxRayDist then -- If one exists, the mouse is over this bar point.
for key, node in pairs(nodes) do
local a, b = intersectsRay_Sphere(rayPos, rayDir, node, mouseToNodetol) -- Get any intersection points between the ray and node sphere.
if min(a, b) < maxRayDist then -- If they do exist, the mouse is over this node, so we have found target.
@/lua/ge/extensions/editor/tech/roadArchitect/geometry.lua
rayDir:normalize()
local q1, q2 = intersectsRay_Sphere(a, rayDir, c, r)
local isct1, isct2 = a + q1 * rayDir, a + q2 * rayDir
@/lua/common/mathlib.lua
rdp:setScaled(invrdplen)
local minhit, maxhit = intersectsRay_Sphere(newLuaVec3xyz(0, 0, 0), rdp, cp, cR)
minhit, maxhit = minhit * invrdplen, maxhit * invrdplen
@/lua/ge/extensions/editor/barriersEditor.lua
for _, pos in ipairs(prefab.objects) do
local t1,t2 = intersectsRay_Sphere(camPos, rayDir, pos, 1.5)
if t1>0 and t1 ~= math.huge then
@/lua/ge/extensions/editor/slotTrafficEditor.lua
if not tableContains(tempNodes, nid) then
local minSphereHitDist, _ = intersectsRay_Sphere(ray.pos, rayDir, node.pos, node.radius)
if minSphereHitDist and minSphereHitDist < minHitDist then
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/vePropTransformer.lua
if imguiNotHovered and not transforming then
local dist, _ = intersectsRay_Sphere(rayStartPos, rayDir, nodePos, nodeCollisionRadius)