DebugDrawer

Engine/source/gfx/sim/debugDraw.h

Debug output class.

More...

Classes:

ddrawmeth Debug Draw Methods

enum
_Anonymous_ {  DD_INFINITE = U32_MAX
}

Set the TTL for the last item we entered...

drawCapsule(const Point3F & a, const F32 & radius, const F32 & height, const LinearColorF & color)

Render a wireframe view of the given polyhedron.

Render the plane indices, edge indices, edge direction indicators, and point coordinates of the given polyhedron for debugging.

setLastZTest(bool enabled)

Disable/enable z testing on the last primitive.

Private Types

Parent 

Private Static Attributes

Public Functions

render(bool clear)

Called globally to render debug draw state. Also does state updates.

bool

Public Static Functions

init()

Called at engine init to set up the global debug draw object.

Private Functions

Detailed Description

Debug output class.

This class provides you with a flexible means of drawing debug output. It is often useful when debugging collision code or complex 3d algorithms to have them draw debug information, like culling hulls or bounding volumes, normals, simple lines, and so forth. In TGE1.2, which was based directly on a simple OpenGL rendering layer, it was a simple matter to do debug rendering directly inline.

Unfortunately, this doesn't hold true with more complex rendering scenarios, where render modes and targets may be in abritrary states. In addition, it is often useful to be able to freeze frame debug information for closer inspection.

Therefore, Torque provides a global DebugDrawer instance, called gDebugDraw, which you can use to draw debug information. It exposes a number of methods for drawing a variety of debug primitives, including lines, triangles and boxes. Internally, DebugDrawer maintains a list of active debug primitives, and draws the contents of the list after each frame is done rendering. This way, you can be assured that your debug rendering won't interfere with TSE's various effect rendering passes or render-to-target calls.

The DebugDrawer can also be used for more interesting uses, like freezing its primitive list so you can look at a situation more closely, or dumping the primitive list to disk for closer analysis.

DebugDrawer is accessible by script under the name DebugDrawer, and by C++ under the symbol gDebugDraw. There are a variety of methods available for drawing different sorts of output; see the class reference for more information.

DebugDrawer works solely in worldspace. Primitives are rendered with cull mode of none.

ddrawmeth Debug Draw Methods

@87

Enumerator

DD_INFINITE = U32_MAX

Set the TTL for the last item we entered...

Primitives default to lasting one frame (ie, ttl=0)

drawBoxOutline(const Point3F & a, const Point3F & b, const LinearColorF & color)

drawTransformedBoxOutline(const Point3F & a, const Point3F & b, const LinearColorF & color, const MatrixF & transform)

drawBox(const Point3F & a, const Point3F & b, const LinearColorF & color)

drawLine(const Point3F & a, const Point3F & b, const LinearColorF & color)

drawTri(const Point3F & a, const Point3F & b, const Point3F & c, const LinearColorF & color)

drawText(const Point3F & pos, const String & text, const LinearColorF & color)

drawCapsule(const Point3F & a, const F32 & radius, const F32 & height, const LinearColorF & color)

drawDirectionLine(const Point3F & a, const Point3F & b, const LinearColorF & color)

drawOutlinedText(const Point3F & pos, const String & text, const LinearColorF & color, const LinearColorF & colorOutline)

drawPolyhedron(const AnyPolyhedron & polyhedron, const LinearColorF & color)

Render a wireframe view of the given polyhedron.

drawPolyhedronDebugInfo(const AnyPolyhedron & polyhedron, const MatrixF & transform, const Point3F & scale)

Render the plane indices, edge indices, edge direction indicators, and point coordinates of the given polyhedron for debugging.

Green lines are plane normals. Red lines point from edge midpoints along the edge direction (i.e. to the second vertex). This shows if the orientation is correct to yield CW ordering for face[0]. Indices and coordinates of vertices are shown in white. Plane indices are rendered in black. Edge indices and their plane indices are rendered in white.

setLastTTL(U32 ms)

setLastZTest(bool enabled)

Disable/enable z testing on the last primitive.

Primitives default to z testing on.

Private Types

typedef SimObject Parent 

Private Static Attributes

DebugDrawer * sgDebugDrawer 

Private Attributes

bool isDrawing 
bool isFrozen 
Resource< GFont > mFont 
DebugPrim * mHead 
FreeListChunker< DebugPrim > mPrimChunker 
GFXStateBlockRef mRenderAlpha 
GFXStateBlockRef mRenderZOffSB 
GFXStateBlockRef mRenderZOnSB 
bool shouldToggleFreeze 

Public Functions

DebugDrawer()

~DebugDrawer()

DECLARE_CONOBJECT(DebugDrawer )

render(bool clear)

Called globally to render debug draw state. Also does state updates.

toggleDrawing()

toggleFreeze()

willDraw()

Public Static Functions

get()

init()

Called at engine init to set up the global debug draw object.

Private Functions

setupStateBlocks()