This code is part of a function that is called thousands of times in the render stepped function of my code. Thing is, this takes up 1/3 of the time in the function and yet it isnt iterating through anything! This is a huge bottle neck and I want to see how I can make this faster. It’s goal is to return the min and max coordinates of a bounding box of a triangle
local a=Vector2.new(math.floor(aP.X), math.floor(aP.Y))
local b=Vector2.new(math.floor(bP.X), math.floor(bP.Y))
local c=Vector2.new(math.floor(cP.X), math.floor(cP.Y))
local maxX = a.x
local maxY = a.y
local minX = a.x
local minY = a.y
--max coordinate
if maxX < b.x then
maxX = b.x
end
if maxX < c.x then
maxX = c.x
end
if maxY < b.y then
maxY = b.y
end
if maxY < c.y then
maxY = c.y
end
--min coordinate
if minX >= b.x then
minX = b.x
end
if minX >= c.x then
minX = c.x
end
if minY >= b.y then
minY = b.y
end
if minY >= c.y then
minY = c.y
end