intersectsRay_Plane
Definition
-- @/lua/common/mathlib.lua:1423
-- returns signed distance of plane on the ray
function intersectsRay_Plane(rpos, rdir, plpos, pln)
tmpv1:setSub2(plpos, rpos)
return min(tmpv1:dot(pln) / rdir:dot(pln), math.huge)
end
Callers
@/lua/ge/extensions/editor/gen/world.lua
local vp = u:cross(vec3(0,0,1))
local d = intersectsRay_Plane(ray.pos, ray.dir,
base2world(desc, ij), vp)
local d = intersectsRay_Plane(ray.pos, ray.dir, p, u:cross(v))
local t = ray.pos + d*ray.dir
lo('?? idh:'..idh..':'..tostring(sbase[idh]))
local d1 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh+1,base)-U.mod(idh,base)))
local d2 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh-1,base)-U.mod(idh,base)))
local d1 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh+1,base)-U.mod(idh,base)))
local d2 = intersectsRay_Plane(sbase[idh], vec3(0,0,1), top, (top-U.mod(idh,base)):cross(U.mod(idh-1,base)-U.mod(idh,base)))
local dh = math.min(d1,d2)
local ic = apair[1][1]
dh = intersectsRay_Plane(sdata[n].av[1], vec3(0,0,1),
d.av[2], (d.av[2]-d.av[1]):cross(d.av[4]-d.av[1]))
U.dump(ij, '?? wallHit:'..tostring(desc.afloor[ij[1]].base[ij[2]])..':'..tostring(desc.pos)..':'..tostring(desc.afloor[ij[1]].pos)..':')
local d = intersectsRay_Plane(ray.pos, ray.dir,
desc.afloor[ij[1]].base[ij[2]] + desc.pos + desc.afloor[ij[1]].pos,
local h = forHeight(desc.afloor, ifloor)
local d = intersectsRay_Plane(ray.pos, ray.dir, vec3(0, 0, h), vn)
local p = ray.pos + d*ray.dir - desc.pos - floor.pos
end
local d = intersectsRay_Plane(ray.pos, ray.dir, smouse, vn)
cmouse = ray.pos + d*ray.dir
local p = rayCast.pos
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
lo('?? dragStart:'..tostring(p)..':'..tostring(d))
-- get mouse shift
local d = intersectsRay_Plane(ray.pos, ray.dir, cedit.cval['DragPos'].pos, vec3(0,0,1))
local dp = ray.pos + d*ray.dir - cedit.cval['DragPos'].pos
local ray = getCameraMouseRay()
local d = intersectsRay_Plane(ray.pos, ray.dir, rayCast.pos, ray.dir)
local p = ray.pos + d*ray.dir
local p = base2world(desc, ij)
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
local t = ray.pos + d*ray.dir
if not cedit.cval['DragPos'].pairend then
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vec3(0,0,1))
local t = ray.pos + d*ray.dir
local center = U.boxMark(dmesh[cmesh].obj, out)
local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, center, vec3(0,0,1))
cedit.cval['Drag'] = {
end
local cterrain = intersectsRay_Plane(core_camera.getPosition(), dirhit, cedit.cval['Drag'].center, vec3(0,0,1))
local dv = cterrain * dirhit - cedit.cval['Drag'].terrain
-- distance to hit point
local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, ccenter, dirface)
-- local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, ccenter, dirobj)
local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, ccenter, dirface)
-- local d = intersectsRay_Plane(core_camera.getPosition(), dirhit, ccenter, dirobj)
local phit = core_camera.getPosition() + dirhit*d
-- local ray = getCameraMouseRay()
-- local d = intersectsRay_Plane(ray.pos, ray.dir, smouse, vn)
-- cmouse = ray.pos + d*ray.dir
local vn = wall.u:cross(wall.v):normalized()
local d = intersectsRay_Plane(ray.pos, ray.dir, p, vn)
U.dump(wall, '?? for_wall:'..tostring(p)..' d:'..tostring(d))
local h = forHeight(adesc[cedit.mesh].afloor)
local d = intersectsRay_Plane(ray.pos, ray.dir, vec3(0, 0, h), vn)
local p = ray.pos + d*ray.dir - adesc[cedit.mesh].pos - lastFloor.pos
(mdata.verts[mdata.faces[i].v+1] - mdata.verts[mdata.faces[i+1].v+1]):cross(mdata.verts[mdata.faces[i+1].v+1] - mdata.verts[mdata.faces[i+2].v+1])
local d = intersectsRay_Plane(orig.pos, orig.dir, mdata.verts[mdata.faces[i].v+1], vn)
if math.abs(d)
local ray = getCameraMouseRay()
local d = intersectsRay_Plane(ray.pos, ray.dir, smouse, vn)
cmouse = ray.pos + d*ray.dir
@/lua/ge/extensions/gameplay/markers/inspectVehicleMarker.lua
-- project icon position on plane
local dist = intersectsRay_Plane(self.iconPos, zVector, data.camPos, tmpNormal)
@/lua/ge/extensions/editor/gen/utils.lua
for i,p in pairs(aplane) do
local d = intersectsRay_Plane(line[1], line[2]-line[1], p[1], (p[2]-p[1]):cross(p[3]-p[1]))
-- U.dump(p, '?? linePlaneHit:'..d..':'..tostring(line[1])..':'..tostring(line[2]), true)
U.ray2plane = function(ray, p, norm)
local d = intersectsRay_Plane(ray.pos, ray.dir, p, norm)
if d and not isnan(d) then
-- local dirhit = (rayCast.pos - core_camera.getPosition()):normalized()
local d = intersectsRay_Plane(campos, dirhit, p, norm)
-- lo('?? onPlane:'..d..':'..tostring(dirhit)..':'..tostring(p)..':'..tostring(norm)..':'..tostring(campos))
@/lua/ge/extensions/gameplay/markers/parkingMarker.lua
-- project icon position on plane
local dist = intersectsRay_Plane(self.iconPos, zVector, data.camPos, tmpNormal)
@/lua/ge/extensions/core/cameraModes/bigMap.lua
local function getRayCastHit(ray, relativeToCam)
local dist = intersectsRay_Plane(ray.pos, ray.dir, core_terrain.getTerrain() and core_terrain.getTerrain():getWorldBox().minExtents or vec3(0,0,0), vec3(0,0,1))
local hitPoint = ray.pos + ray.dir * dist
@/lua/ge/extensions/editor/gen/mesh.lua
-- local vn = vec3(0,0,1)
-- local d = intersectsRay_Plane(ray.pos, ray.dir, smouse, vn)
local dmi,imi = math.huge
@/lua/ge/extensions/util/screenshotCreator.lua
local camPosBasedOnVertical = bbUpperPoint - upperCamFovDir * intersectsRay_Plane(bbUpperPoint, -upperCamFovDir, bbCenter + camOffsetAxis, camUp)
local camPosBasedOnHorizontal = bbForwardPoint - rightCamFovDir * intersectsRay_Plane(bbForwardPoint, -rightCamFovDir, bbCenter + camOffsetAxis, camLeft)
@/lua/ge/extensions/gameplay/race/pacenote.lua
if sMin <= 0 and sMax >= 1 then
local t = intersectsRay_Plane(rPos, rDir, self.pos, self.normal)
t = t*len
@/lua/ge/extensions/freeroam/bigMapMode.lua
local planeNormal = upperCamFovDir:cross(xVector)
local camPos = lowerEdgePoint - lowerCamFovDir * intersectsRay_Plane(lowerEdgePoint, -lowerCamFovDir, upperEdgePoint, planeNormal)
if not useCamYaw then
@/lua/ge/extensions/gameplay/race/pathnode.lua
if sMin <= 0 and sMax >= 1 then
local t = intersectsRay_Plane(rPos, rDir, self.pos, self.normal)
t = t*len
@/lua/common/mathlib.lua
minhit, maxhit = minhit * invrdplen, maxhit * invrdplen
local plhita, plhitb = intersectsRay_Plane(rpos, rdir, cposa, cpnorm), intersectsRay_Plane(rpos, rdir, cposb, cpnorm)
minhit, maxhit = max(minhit, min(plhita, plhitb)), min(maxhit, max(plhita, plhitb))
minhit, maxhit = minhit * invrdplen, maxhit * invrdplen
local plhita, plhitb = intersectsRay_Plane(rpos, rdir, cposa, cpnorm), intersectsRay_Plane(rpos, rdir, cposb, cpnorm)
minhit, maxhit = max(minhit, min(plhita, plhitb)), min(maxhit, max(plhita, plhitb))
@/lua/ge/extensions/gameplay/rally/notebook/pacenoteWaypoint.lua
-- -- check both directions of the plane so we dont have to worry about having the normal in the right direction when editing pacenoteWaypoints.
-- local t1 = intersectsRay_Plane(rPos, rDir, self.pos, self.normal)
-- -- local t2 = intersectsRay_Plane(rPos, rDir, self.pos, -self.normal)
-- local t1 = intersectsRay_Plane(rPos, rDir, self.pos, self.normal)
-- -- local t2 = intersectsRay_Plane(rPos, rDir, self.pos, -self.normal)
-- t1 = t1*len