Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Spatial::Volume Struct Reference

Axis-aligned bounding box (AABB) representing a rectangular 3D region. More...

#include <Volume.hpp>

Public Member Functions

 Volume ()
 Default constructor.
 
 Volume (float w, float h, float d, Math::Vector3 position=Math::Vector3(0.0f, 0.0f, 0.0f))
 Constructs a volume with specified dimensions and position.
 
float leftBound ()
 Gets the minimum X coordinate (left edge).
 
float rightBound ()
 Gets the maximum X coordinate (right edge).
 
float topBound ()
 Gets the maximum Y coordinate (top edge).
 
float bottomBound ()
 Gets the minimum Y coordinate (bottom edge).
 
float frontBound ()
 Gets the minimum Z coordinate (front edge).
 
float backBound ()
 Gets the maximum Z coordinate (back edge).
 
float volume ()
 Calculates the total volume (cubic units).
 

Public Attributes

float width
 Total width of the volume along the X-axis.
 
float height
 Total height of the volume along the Y-axis.
 
float depth
 Total depth of the volume along the Z-axis.
 
Math::Vector3 position
 Center position of the volume in world space.
 

Detailed Description

Axis-aligned bounding box (AABB) representing a rectangular 3D region.

Volume defines a three-dimensional rectangular region in world space, specified by its dimensions (width, height, depth) and center position. This is the standard representation for axis-aligned bounding volumes throughout the Infinity Engine's procedural generation systems.

The volume is always axis-aligned (cannot be rotated), making it efficient for spatial queries, collision detection, and region-based generation. All dimensions extend equally from the center position in both positive and negative directions.

Common use cases in procedural generation:

  • Spatial bounds for procedural content generation regions
  • Culling volumes for optimization
  • Distribution regions for scatter/placement systems
  • Collision volumes for procedural objects
  • Chunk/sector boundaries in world generation
  • Query regions for spatial data structures
  • Constraint volumes for procedural algorithms
  • Level-of-detail (LOD) trigger regions
Note
The volume is axis-aligned and cannot be rotated.
Dimensions represent full extents (not half-extents): width/height/depth are the total size.
The position represents the center of the volume, not a corner.
Use bound methods to get world-space edge coordinates.

Example usage:

// Create a volume for a generation region
Volume region(100.0f, 50.0f, 100.0f, Vector3{0.0f, 25.0f, 0.0f});
// This creates a 100x50x100 box centered at (0, 25, 0)
// Check if a point is inside the volume
Vector3 point{10.0f, 30.0f, 15.0f};
bool inside = (point.x >= region.leftBound() && point.x <= region.rightBound() &&
point.y >= region.bottomBound() && point.y <= region.topBound() &&
point.z >= region.frontBound() && point.z <= region.backBound());
// Use for scatter generation
Volume scatterRegion(200.0f, 10.0f, 200.0f, Vector3{0.0f, 0.0f, 0.0f});
Array<Vector3> positions;
for (int i = 0; i < 1000; ++i) {
positions.push_back(Vector3{
randomFloat(scatterRegion.leftBound(), scatterRegion.rightBound()),
randomFloat(scatterRegion.bottomBound(), scatterRegion.topBound()),
randomFloat(scatterRegion.frontBound(), scatterRegion.backBound())
});
}
// Use with ProceduralSystem
system->setIn("generation_bounds", region);
// Calculate volume for density-based generation
float vol = region.volume();
int objectCount = static_cast<int>(vol * density);
Axis-aligned bounding box (AABB) representing a rectangular 3D region.
Definition Volume.hpp:71
Volume()
Default constructor.

Constructor & Destructor Documentation

◆ Volume() [1/2]

Infinity::Types::Spatial::Volume::Volume ( )

Default constructor.

Creates a volume with zero dimensions at the origin.

◆ Volume() [2/2]

Infinity::Types::Spatial::Volume::Volume ( float  w,
float  h,
float  d,
Math::Vector3  position = Math::Vector3(0.0f, 0.0f, 0.0f) 
)

Constructs a volume with specified dimensions and position.

Parameters
wWidth (X-axis extent).
hHeight (Y-axis extent).
dDepth (Z-axis extent).
positionCenter position in world space (default: origin).
// 100x50x100 box centered at (0, 25, 0)
Volume box(100.0f, 50.0f, 100.0f, Vector3{0.0f, 25.0f, 0.0f});

Member Function Documentation

◆ backBound()

float Infinity::Types::Spatial::Volume::backBound ( )

Gets the maximum Z coordinate (back edge).

Calculates position.z + depth/2.

Returns
World-space Z coordinate of the back face.

◆ bottomBound()

float Infinity::Types::Spatial::Volume::bottomBound ( )

Gets the minimum Y coordinate (bottom edge).

Calculates position.y - height/2.

Returns
World-space Y coordinate of the bottom face.

◆ frontBound()

float Infinity::Types::Spatial::Volume::frontBound ( )

Gets the minimum Z coordinate (front edge).

Calculates position.z - depth/2.

Returns
World-space Z coordinate of the front face.

◆ leftBound()

float Infinity::Types::Spatial::Volume::leftBound ( )

Gets the minimum X coordinate (left edge).

Calculates position.x - width/2.

Returns
World-space X coordinate of the left face.

◆ rightBound()

float Infinity::Types::Spatial::Volume::rightBound ( )

Gets the maximum X coordinate (right edge).

Calculates position.x + width/2.

Returns
World-space X coordinate of the right face.

◆ topBound()

float Infinity::Types::Spatial::Volume::topBound ( )

Gets the maximum Y coordinate (top edge).

Calculates position.y + height/2.

Returns
World-space Y coordinate of the top face.

◆ volume()

float Infinity::Types::Spatial::Volume::volume ( )

Calculates the total volume (cubic units).

Computes width × height × depth.

Returns
Volume in cubic units.
Note
Useful for density-based calculations (e.g., objects per cubic unit).
float vol = region.volume();
int treeCount = static_cast<int>(vol * treeDensity);

Member Data Documentation

◆ depth

float Infinity::Types::Spatial::Volume::depth

Total depth of the volume along the Z-axis.

Full extent from front to back. The volume extends depth/2 in both positive and negative Z directions from the center position.

◆ height

float Infinity::Types::Spatial::Volume::height

Total height of the volume along the Y-axis.

Full extent from bottom to top. The volume extends height/2 in both positive and negative Y directions from the center position.

◆ position

Math::Vector3 Infinity::Types::Spatial::Volume::position

Center position of the volume in world space.

The volume is centered at this position, with dimensions extending equally in all directions.

◆ width

float Infinity::Types::Spatial::Volume::width

Total width of the volume along the X-axis.

Full extent from left to right. The volume extends width/2 in both positive and negative X directions from the center position.