Getting actual AABB of an object

I’m trying to get the actual AABB of an object in the editor.

The mesh.bounds are an AABB for the object in it’s default transform. (Magenta)

If you transform the mesh.bounds using the objects transform matrix, (red)
you get the results of the object.renderbounds (yellow)

What I want is an AABB that extents to the min and max of the actual mesh (green)

Right now I loop through every vertex in the mesh. I transform it by the objects transform matrix. Then check for minimum and maximum values. Is there a better way to do this?

I only need it in the editor, but I’m assuming it’s not very efficient looping through mesh verts like that.

Pseudocode:

for each vertex in mesh
    point = vertex.position * object.worldMatrix

    if (point > max)
        max = point 

    if (point < min)
        min = point 

@robertbu Thanks for the link. That’s pretty much what I’m doing at the moment. Was just wondering if there is something built-in that might be faster/more optimized. I’ll just keep using what I have then.

@numberkruncher Yes, but you don’t have to compute a bounding box from the transformed mesh bounds. Each object already has renderbounds built-in (object.renderer.bounds) that you can use. I used that for illustration purposes since I didn’t know at first why the render bounds were bigger than the actual object.

Thanks for the replies. I’ll consider my question answered then.