# Constructor Overload to make 3D Box from FVector Center and float Size

**URL:** <https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597 "2014-03-11T02:31:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/1 "2014-03-11T02:31:10Z")

</div>

Dear Friends at Epic,

I wrote this function and think it would be a fun addition to your FBox.h library 🙂

It would make for a great constructor overload 🙂

```
//Box from World Space Center and Size
FORCEINLINE FBox BoxFromPointWithSize(const FVector& InCenter, const float& Size)
{
	return FBox(
		InCenter+(FVector(1,1,1) * -Size/2),
		InCenter+(FVector(1,1,1) * Size/2)
	);
}

```

#Summary

Simple additional constructor to make a 3D box from a single point the box is centered around, and the desired size of the box 🙂

#Pic of my Vertex Snap Editor Plugin

I used the above function for one of the drawing modes of verticies in my [Vertex Snap Editor Mode Plugin][1] 🙂

 ![box.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/9/85957f8db7fb3c730c518ed44415a4e585b2d0ac.jpeg)

Enjoy!

Rama

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/2 "2014-03-11T02:31:11Z")

</div>

Hi Rama,  
An exploratory remark, this kind of reminds me of voxel technology.

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/3 "2014-03-11T02:31:11Z")

</div>

hee hee!

Actually **InstancedStaticMeshComponents** are really good for voxel-like stuff

I got upwards of **4000** 3d cubes on screen without much slowdown of any kind!

🙂

Rama

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/4 "2014-03-11T02:31:12Z")

</div>

Hi Rama,

It’s not exactly the same, but check out

```
static FBox BuildAABB( const FVector& Origin, const FVector& Extent )

```

in Box.h. Same base concept, but allows for non-square boxes.

Cheers!

Jeff

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/5 "2014-03-11T02:31:12Z")

</div>

ahhh I did not see that one !

I was hoping for a constructor that took in a point and a size/extent

FBox NewBox(Origin - Extent, Origin + Extent);

“BuildAABB” is not as intuitive for me as FBox(Center,Extent)

It’s a minor point but I consider it my rocket-tester-duty to report what I consider to be greater convenience usage of base classes 🙂

just **turning BuildAABB() into a overloaded constructor** would be more than sufficient 🙂

Thanks Jeff!

Rama

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/6 "2014-03-11T02:31:12Z")

</div>

That’s a good suggestion, but unfortunately we already have a constructor matching that signature that takes the corners.

```
FBox( const FVector& InMin, const FVector& InMax )

```

So we can’t add a Center/Extent overload. That said, your

```
FBox NewBox(Origin - Extent, Origin + Extent);

```

syntax looks like a pretty clean approach to me.

Jeff

---

<div class="post-metadata">

**Author:** ![ue4-archive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ue4-archive](https://forums.unrealengine.com/u/ue4-archive)\
**Post date:** [March 11, 2014, 2:31am UTC](https://forums.unrealengine.com/t/constructor-overload-to-make-3d-box-from-fvector-center-and-float-size/275597/7 "2014-03-11T02:31:13Z")

</div>

_“we already have a constructor matching that signature that takes the corners.”_

**ahh that’s a good point,**

well this then is my last comment hee hee,

THIS constructor signature is not taken, the one I originally posted, hee hee!

```
FBox( const FVector& Center, const float& Size )

```

Yes it limits you to a cube but that was the basis of my original post anyways, fast way to make squares/cubes 🙂

Nice to hear from you Jeff!

Rama
