## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csTiledCoverageBuffer Class Reference
[Geometry utilities]

The tiled coverage Buffer. More...

`#include <csgeom/tcovbuf.h>`

Inheritance diagram for csTiledCoverageBuffer:

[legend]
List of all members.

## Public Member Functions

int | AddWriteQueueTest (const csTestRectData &maindata, const csTestRectData &data, bool &relevant)
| Add a rectangle for a write queue test.
virtual csTicks | Benchmark (int num_iterations)
| Perform a benchmark.
int | CountNotCulledObjects (const csBox2Int &bbox)
| Count the number of objects that were already culled away previously for the given rectangle.
| csTiledCoverageBuffer (int w, int h)
| Create a new coverage buffer with the given dimensions.
virtual bool | DebugCommand (const char *)
| Perform a debug command as defined by the module itself.
virtual void | Dump (iGraphics3D *g3d)
| Do a graphical dump of the current state of this object.
virtual csPtr< iString > | Dump ()
| Do a text dump of the current state of this object.
virtual int | GetSupportedTests () const
| Return a bit field indicating what types of functions this specific unit test implementation supports.
void | Initialize ()
| Initialize the coverage buffer to empty.
int | InsertOutline (const csReversibleTransform &trans, float fov, float sx, float sy, csVector3 *verts, size_t num_verts, bool *used_verts, int *edges, size_t num_edges, bool splat_outline, csBox2Int &modified_bbox)
| Insert an outline in the coverage buffer.
int | InsertPolygon (csVector2 *verts, size_t num_verts, float max_depth, csBox2Int &modified_bbox)
| Insert a polygon in the coverage buffer.
void | InsertPolygonInverted (csVector2 *verts, size_t num_verts, float max_depth)
| Insert an inverted polygon in the coverage buffer.
void | InsertPolygonInvertedNoDepth (csVector2 *verts, size_t num_verts)
| Insert an inverted polygon in the coverage buffer.
int | InsertPolygonNoDepth (csVector2 *verts, size_t num_verts)
| Insert a polygon in the coverage buffer.
void | MarkCulledObject (const csTestRectData &data)
| Mark the given rectangle as being culled away.
bool | PrepareTestRectangle (const csBox2 &rect, csTestRectData &data)
| Prepare data for TestRectangle.
int | PrepareWriteQueueTest (const csTestRectData &data, float min_depth)
| Prepare a write queue test for the given rectangle.
bool | QuickTestRectangle (const csTestRectData &data, float min_depth)
| Quickly test a rectangle with the coverage buffer.
void | Setup (int w, int h)
| Setup coverage buffer for given size.
virtual csPtr< iString > | StateTest ()
| Perform a state test.
int | StatusNoDepth ()
| Return status of coverage buffer (ignoring depth information).
bool | TestPoint (const csVector2 &point, float min_depth)
| Test a point with the coverage buffer.
bool | TestPolygon (csVector2 *verts, size_t num_verts, float min_depth)
| Test if a polygon would modify the coverage buffer if it was inserted.
bool | TestRectangle (const csTestRectData &data, float min_depth)
| Test a rectangle with the coverage buffer.
virtual csPtr< iString > | UnitTest ()
| Perform a unit test.
virtual | ~csTiledCoverageBuffer ()
| Destroy the coverage buffer.

## Public Attributes

iBugPlug * | bugplug

## Detailed Description

The tiled coverage Buffer.

This is a black-and-white bitmap represented by 32-bit ints arranged in rows. For example, a 128x128 bitmap is represented by 4 rows of 128 ints. Every int represents a column of 32 pixels. In addition there is also a maximum depth value for every 8x8 pixels. The screen buffer is divided into tiles of 64x32 or 32x64 pixels.

Definition at line 476 of file tcovbuf.h.

## Constructor & Destructor Documentation

csTiledCoverageBuffer::csTiledCoverageBuffer | ( | int | w,
|  | int | h
| ) |

| Create a new coverage buffer with the given dimensions.

virtual csTiledCoverageBuffer::~csTiledCoverageBuffer | ( |  | ) | `[virtual]`

| Destroy the coverage buffer.

## Member Function Documentation

int csTiledCoverageBuffer::AddWriteQueueTest | ( | const csTestRectData & | maindata,
|  | const csTestRectData & | data,
|  | bool & | relevant
| ) |

| Add a rectangle for a write queue test. This returns the number of tiles that were covered. If 'relevant' is set to false by this function then that means the rectangle couldn't affect the result because it only affects tiles that are already fully covering the object we are testing.

virtual csTicks csTiledCoverageBuffer::Benchmark | ( | int | num_iterations | ) | `[inline, virtual]`

| Perform a benchmark. This function will return a number indicating how long the benchmark lasted in milliseconds. Implements iDebugHelper. Definition at line 719 of file tcovbuf.h.

int csTiledCoverageBuffer::CountNotCulledObjects | ( | const csBox2Int & | bbox | ) |

| Count the number of objects that were already culled away previously for the given rectangle.

virtual bool csTiledCoverageBuffer::DebugCommand | ( | const char * |  | ) | `[inline, virtual]`

| Perform a debug command as defined by the module itself. Returns 'false' if the command was not recognized. Implements iDebugHelper. Definition at line 731 of file tcovbuf.h.

virtual void csTiledCoverageBuffer::Dump | ( | iGraphics3D * | g3d | ) | `[inline, virtual]`

| Do a graphical dump of the current state of this object. Implements iDebugHelper. Definition at line 727 of file tcovbuf.h.

virtual csPtr<iString> csTiledCoverageBuffer::Dump | ( |  | ) | `[inline, virtual]`

| Do a text dump of the current state of this object. Returns 0 if not supported or else a string which you should DecRef() after use. Implements iDebugHelper. Definition at line 723 of file tcovbuf.h.

virtual int csTiledCoverageBuffer::GetSupportedTests | ( |  | ) | const`[inline, virtual]`

Return a bit field indicating what types of functions this specific unit test implementation supports.

This will return a combination of the CS_DBGHELP_... flags:

- CS_DBGHELP_UNITTEST
- CS_DBGHELP_BENCHMARK
- CS_DBGHELP_TXTDUMP
- CS_DBGHELP_GFXDUMP
- CS_DBGHELP_STATETEST

Implements iDebugHelper.

Definition at line 704 of file tcovbuf.h.

References CS_DBGHELP_BENCHMARK, CS_DBGHELP_GFXDUMP, CS_DBGHELP_TXTDUMP, and CS_DBGHELP_UNITTEST.

void csTiledCoverageBuffer::Initialize | ( |  | ) |

| Initialize the coverage buffer to empty.

int csTiledCoverageBuffer::InsertOutline | ( | const csReversibleTransform & | trans,
|  | float | fov,
|  | float | sx,
|  | float | sy,
|  | csVector3 * | verts,
|  | size_t | num_verts,
|  | bool * | used_verts,
|  | int * | edges,
|  | size_t | num_edges,
|  | bool | splat_outline,
|  | csBox2Int & | modified_bbox
| ) |

Insert an outline in the coverage buffer.

It will update the screen buffer. 'bbox' will contain the screen space box that was modified by this function. Function returns false if outline was not visible (i.e. screen buffer was not modified). The given array of edges is an array of two integers (vertex indices) per edge. The 'used_verts' contains true for all vertices that are used. If 'splat_outline' is true then outline splatting is used.

If this function returns the number of tiles that were modified.

int csTiledCoverageBuffer::InsertPolygon | ( | csVector2 * | verts,
|  | size_t | num_verts,
|  | float | max_depth,
|  | csBox2Int & | modified_bbox
| ) |

Insert a polygon in the coverage buffer.

This function will not do any backface culling and it will work perfectly in all orientations. Polygon has to be convex. It will update the screen buffer. 'modified_bbox' will be updated to contain the union of the previous contents of 'modified_bbox' and also the screen space box that was modified by this function.

If this function returns the number of tiles that were modified.

void csTiledCoverageBuffer::InsertPolygonInverted | ( | csVector2 * | verts,
|  | size_t | num_verts,
|  | float | max_depth
| ) |

| Insert an inverted polygon in the coverage buffer.

void csTiledCoverageBuffer::InsertPolygonInvertedNoDepth | ( | csVector2 * | verts,
|  | size_t | num_verts
| ) |

| Insert an inverted polygon in the coverage buffer. This function ignores depth in the depth buffer and should only be used if you don't plan to use depth information nor depend on it.

int csTiledCoverageBuffer::InsertPolygonNoDepth | ( | csVector2 * | verts,
|  | size_t | num_verts
| ) |

| Insert a polygon in the coverage buffer. This function will not do any backface culling and it will work perfectly in all orientations. Polygon has to be convex. It will update the screen buffer. If this function returns the number of tiles that were modified. This function ignores depth in the depth buffer and should only be used if you don't plan to use depth information nor depend on it.

void csTiledCoverageBuffer::MarkCulledObject | ( | const csTestRectData & | data | ) |

| Mark the given rectangle as being culled away. For every affected tile this will increase the objects_culled field.

bool csTiledCoverageBuffer::PrepareTestRectangle | ( | const csBox2 & | rect,
|  | csTestRectData & | data
| ) |

| Prepare data for TestRectangle. If this returns false you have an early exit since the rectangle cannot be visible regardless of depth and coverage buffer contents.

int csTiledCoverageBuffer::PrepareWriteQueueTest | ( | const csTestRectData & | data,
|  | float | min_depth
| ) |

| Prepare a write queue test for the given rectangle. This returns the number of uncovered tiles. Use AddWriteQueueTest() to add additional rectangles.

bool csTiledCoverageBuffer::QuickTestRectangle | ( | const csTestRectData & | data,
|  | float | min_depth
| ) |

| Quickly test a rectangle with the coverage buffer. This is only a very rough test but it is faster then TestRectangle(). If this function returns false then the rectangle is not visible. If this function returns true it is possible that the rectangle is visible.

void csTiledCoverageBuffer::Setup | ( | int | w,
|  | int | h
| ) |

| Setup coverage buffer for given size.

virtual csPtr<iString> csTiledCoverageBuffer::StateTest | ( |  | ) | `[inline, virtual]`

| Perform a state test. This function will test if the current state of the object is ok. It will return 0 if it is ok. Otherwise an iString is returned containing some information about the errors. DecRef() this returned string after using it. Implements iDebugHelper. Definition at line 715 of file tcovbuf.h.

int csTiledCoverageBuffer::StatusNoDepth | ( |  | ) |

| Return status of coverage buffer (ignoring depth information). If this returns 1 the buffer is full. If it returns -1 the buffer is empty. If it returns 0 the buffer is partially full.

bool csTiledCoverageBuffer::TestPoint | ( | const csVector2 & | point,
|  | float | min_depth
| ) |

| Test a point with the coverage buffer. Function returns false if point was not visible (i.e. screen buffer would not have been modified).

bool csTiledCoverageBuffer::TestPolygon | ( | csVector2 * | verts,
|  | size_t | num_verts,
|  | float | min_depth
| ) |

| Test if a polygon would modify the coverage buffer if it was inserted. This function will not do any backface culling and it will work perfectly in all orientations. Polygon has to be convex. It will NOT update the screen buffer. Function returns false if polygon was not visible (i.e. screen buffer was not modified).

bool csTiledCoverageBuffer::TestRectangle | ( | const csTestRectData & | data,
|  | float | min_depth
| ) |

| Test a rectangle with the coverage buffer. Function returns false if rectangle was not visible (i.e. screen buffer would not have been modified). Call PrepareTestRectangle() to fill in csTestRectData.

virtual csPtr<iString> csTiledCoverageBuffer::UnitTest | ( |  | ) | `[inline, virtual]`

| Perform a unit test. This function will try to test as much as possible of the given module. This function returns 0 if the test succeeded. Otherwise an iString is returned containing some information about the errors. DecRef() this returned string after using it. Implements iDebugHelper. Definition at line 711 of file tcovbuf.h.

The documentation for this class was generated from the following file:

- csgeom/tcovbuf.h