Well, I’ll just give the example I have right now. I have a part with a size of 20, 30, 40, and an orientation of 20, 90, 150. I measured its height at around 47.5 studs, but your script outputs a Y value of around 28.7.
Here, I “borrowed” some of @zeuxcg’s code for fast AABBs, used in GetExtentsSize, and simplified it for a single part:
-- returns the size of the axis=-aligned bounding box of a given part
function GetAABB(part)
local abs = math.abs
local cf = part.CFrame
local size = part.Size
local sx, sy, sz = size.X, size.Y, size.Z
local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = cf:components()
local wsx = abs(R00) * sx + abs(R01) * sy + abs(R02) * sz
local wsy = abs(R10) * sx + abs(R11) * sy + abs(R12) * sz
local wsz = abs(R20) * sx + abs(R21) * sy + abs(R22) * sz
return Vector3.new(wsx, wsy, wsz)
end
I found zeux’s code through this post originally.
That’s slightly slower than the GetWorldSize
function I originally posted (not that this level of optimization really matters), but also will work for any orientation. Not just 90 degree increments.
12 Likes