Class DebugDrawer

Synopsis

#include <Source/Falcor/Utils/UI/DebugDrawer.h>

class dlldecl DebugDrawer

Description

Utility class to assist in drawing debug geometry

Methods

addBoundingBoxAdds a world space AABB
addLineAdds a line segment
addQuadAdds a quad described by four corner points
clearClears vertices
createCreate a new object for drawing debug geometry.
getVaoGet the Vao of vertex data
getVertexCountGet how many vertices are currently pushed
renderRenders the contents of the debug drawer
setColorSets the color for following geometry

Source

Lines 41-108 in Source/Falcor/Utils/UI/DebugDrawer.h.

class dlldecl DebugDrawer
{
public:
    using SharedPtr = std::shared_ptr<DebugDrawer>;
    using SharedConstPtr = std::shared_ptr<const DebugDrawer>;
    static const uint32_t kMaxVertices = 10000;     ///< Default max number of vertices per DebugDrawer instance
    static const uint32_t kPathDetail = 10;         ///< Segments between keyframes
    using Quad = std::array<float3, 4>;
    /** Create a new object for drawing debug geometry.
        \param[in] maxVertices Maximum number of vertices that will be drawn.
        \return New object, or throws an exception if creation failed.
    */
    static SharedPtr create(uint32_t maxVertices = kMaxVertices);
    /** Sets the color for following geometry
    */
    void setColor(const float3& color) { mCurrentColor = color; }
    /** Adds a line segment
    */
    void addLine(const float3& a, const float3& b);
    /** Adds a quad described by four corner points
    */
    void addQuad(const Quad& quad);
    /** Adds a world space AABB
    */
    void addBoundingBox(const BoundingBox& aabb);
    /** Renders the contents of the debug drawer
    */
    void render(RenderContext* pContext, GraphicsState* pState, GraphicsVars* pVars, Camera *pCamera);
    /** Get how many vertices are currently pushed
    */
    uint32_t getVertexCount() const { return (uint32_t)mVertexData.size(); }
    /** Get the Vao of vertex data
    */
    const Vao::SharedPtr& getVao() const { return mpVao; };
    /** Clears vertices
    */
    void clear() { mVertexData.clear(); mDirty = true; }
private:
    void uploadBuffer();
    DebugDrawer(uint32_t maxVertices);
    float3 mCurrentColor;
    struct LineVertex
    {
        float3 position;
        float3 color;
    };
    Vao::SharedPtr mpVao;
    std::vector<LineVertex> mVertexData;
    bool mDirty = true;
};





Add Discussion as Guest

Log in to DocsForge