mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2026-08-21 21:17:24 +00:00
fixes ctld.getSecureDistanceFromUnit
This commit is contained in:
@@ -1923,6 +1923,22 @@ function ctld.spawnCrateAtPoint(_side, _weight, _point, _hdg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
||||||
|
if Unit.getByName(_unitName) then
|
||||||
|
local unitBoundingBox = Unit.getByName(_unitName):getDesc().box
|
||||||
|
local widht = unitBoundingBox.max.x - unitBoundingBox.min.x
|
||||||
|
local longer = unitBoundingBox.max.z - unitBoundingBox.min.z
|
||||||
|
local hight = unitBoundingBox.max.y - unitBoundingBox.min.y
|
||||||
|
|
||||||
|
-- distanceFromCenterToCorner = 1/2√(l² + w² + h²)
|
||||||
|
local squaresSum = longer^2 + widht^2 + hight^2 -- sum of squares
|
||||||
|
local squareRoots = math.sqrt(squaresSum) -- square roots
|
||||||
|
local distanceFromCenterToCorner = squareRoots / 2 -- Calculating distance (half square root)
|
||||||
|
return distanceFromCenterToCorner
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
function ctld.getSecureDistanceFromUnit_old(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
||||||
if Unit.getByName(_unitName) then
|
if Unit.getByName(_unitName) then
|
||||||
local unitBoundingBox = Unit.getByName(_unitName):getDesc().box
|
local unitBoundingBox = Unit.getByName(_unitName):getDesc().box
|
||||||
local deltaX = unitBoundingBox.max.x - unitBoundingBox.min.x
|
local deltaX = unitBoundingBox.max.x - unitBoundingBox.min.x
|
||||||
@@ -1934,10 +1950,10 @@ function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end ]]--
|
||||||
|
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
-- Repack vehicules crates functions
|
-- Repack vehicules crates functions
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
ctld.repackRequestsStack = {} -- table to store the repack request
|
ctld.repackRequestsStack = {} -- table to store the repack request
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user