|
|
@@ -7,19 +7,18 @@
|
|
|
|
|
|
namespace BansheeEngine
|
|
|
{
|
|
|
+ /**
|
|
|
+ * @brief Types of coordinates used in 2D debug drawing.
|
|
|
+ */
|
|
|
enum class DebugDrawCoordType
|
|
|
{
|
|
|
Pixel,
|
|
|
Normalized
|
|
|
};
|
|
|
|
|
|
- enum class DrawStyle
|
|
|
- {
|
|
|
- Fill,
|
|
|
- Border,
|
|
|
- FillAndBorder
|
|
|
- };
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @brief Internal type that determines how is a debug object drawn.
|
|
|
+ */
|
|
|
enum class DebugDrawType
|
|
|
{
|
|
|
ClipSpace,
|
|
|
@@ -27,6 +26,10 @@ namespace BansheeEngine
|
|
|
WorldSpace
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Command containing all data requires for drawing a single
|
|
|
+ * debug draw object.
|
|
|
+ */
|
|
|
struct DebugDrawCommand
|
|
|
{
|
|
|
HMesh mesh;
|
|
|
@@ -40,19 +43,46 @@ namespace BansheeEngine
|
|
|
float endTime;
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Abstract interface for a draw helper class. Allows a set of draw commands to be queued
|
|
|
+ * and retrieved by the renderer.
|
|
|
+ */
|
|
|
class BS_EXPORT DrawHelperTemplateBase
|
|
|
{
|
|
|
public:
|
|
|
+ /**
|
|
|
+ * @brief Called by the renderer when it is ready to render objects into the provided camera.
|
|
|
+ */
|
|
|
void render(const HCamera& camera, DrawList& drawList);
|
|
|
|
|
|
protected:
|
|
|
UnorderedMap<const Viewport*, Vector<DebugDrawCommand>> mCommandsPerViewport;
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Provides dimension-independant methods used for creating geometry
|
|
|
+ * and drawing various common objects.
|
|
|
+ */
|
|
|
template <class T>
|
|
|
class BS_EXPORT DrawHelperTemplate : public DrawHelperTemplateBase
|
|
|
{
|
|
|
protected:
|
|
|
+ /**
|
|
|
+ * @brief Fills the mesh data with vertices representing a per-pixel line.
|
|
|
+ *
|
|
|
+ * @param a Start point of the line.
|
|
|
+ * @param b End point of the line.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param meshData Mesh data that will be populated.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ *
|
|
|
+ * @note Provided MeshData must have some specific elements at least:
|
|
|
+ * T VES_POSITION
|
|
|
+ * UINT32 VES_COLOR
|
|
|
+ * 32bit index buffer
|
|
|
+ * Enough space for 2 vertices and 2 indices
|
|
|
+ */
|
|
|
void line_Pixel(const T& a, const T& b, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
|
|
|
{
|
|
|
UINT32* indexData = meshData->getIndices32();
|
|
|
@@ -65,6 +95,24 @@ namespace BansheeEngine
|
|
|
line_Pixel(a, b, color, positionData, colorData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the mesh data with vertices representing an anti-aliased line of specific width. Antialiasing is done using alpha blending.
|
|
|
+ *
|
|
|
+ * @param a Start point of the line.
|
|
|
+ * @param b End point of the line.
|
|
|
+ * @param width Width of the line.
|
|
|
+ * @param borderWidth Width of the anti-aliased border.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param meshData Mesh data that will be populated by this method.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ *
|
|
|
+ * @note Provided MeshData must have some specific elements at least:
|
|
|
+ * T VES_POSITION
|
|
|
+ * UINT32 VES_COLOR
|
|
|
+ * 32bit index buffer
|
|
|
+ * Enough space for 8 vertices and 30 indices
|
|
|
+ */
|
|
|
void line_AA(const T& a, const T& b, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
|
|
|
{
|
|
|
UINT32* indexData = meshData->getIndices32();
|
|
|
@@ -77,6 +125,21 @@ namespace BansheeEngine
|
|
|
line_AA(a, b, width, borderWidth, color, positionData, colorData, vertexOffset, meshData->getVertexDesc()->getVertexStride(), indexData, indexOffset);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the mesh data with vertices representing per-pixel lines.
|
|
|
+ *
|
|
|
+ * @param linePoints A list of start and end points for the lines. Must be a multiple of 2.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param meshData Mesh data that will be populated.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ *
|
|
|
+ * @note Provided MeshData must have some specific elements at least:
|
|
|
+ * T VES_POSITION
|
|
|
+ * UINT32 VES_COLOR
|
|
|
+ * 32bit index buffer
|
|
|
+ * Enough space for (numLines * 2) vertices and (numLines * 2) indices
|
|
|
+ */
|
|
|
void lineList_Pixel(const typename Vector<T>& linePoints, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
|
|
|
{
|
|
|
assert(linePoints.size() % 2 == 0);
|
|
|
@@ -101,6 +164,23 @@ namespace BansheeEngine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the mesh data with vertices representing anti-aliased lines of specific width. Antialiasing is done using alpha blending.
|
|
|
+ *
|
|
|
+ * @param linePoints A list of start and end points for the lines. Must be a multiple of 2.
|
|
|
+ * @param width Width of the line.
|
|
|
+ * @param borderWidth Width of the anti-aliased border.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param meshData Mesh data that will be populated by this method.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ *
|
|
|
+ * @note Provided MeshData must have some specific elements at least:
|
|
|
+ * T VES_POSITION
|
|
|
+ * UINT32 VES_COLOR
|
|
|
+ * 32bit index buffer
|
|
|
+ * Enough space for (numLines * 8) vertices and (numLines * 30) indices
|
|
|
+ */
|
|
|
void lineList_AA(const typename Vector<T>& linePoints, float width, float borderWidth, const Color& color, const MeshDataPtr& meshData, UINT32 vertexOffset, UINT32 indexOffset)
|
|
|
{
|
|
|
assert(linePoints.size() % 2 == 0);
|
|
|
@@ -125,6 +205,19 @@ namespace BansheeEngine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the provided buffers with vertices representing a per-pixel line.
|
|
|
+ *
|
|
|
+ * @param a Start point of the line.
|
|
|
+ * @param b End point of the line.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param outVertices Output buffer that will store the vertex position data.
|
|
|
+ * @param outColors Output buffer that will store the vertex color data.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
|
|
|
+ * @param outIndices Output buffer that will store the index data. Indices are 32bit.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ */
|
|
|
void line_Pixel(const T& a, const T& b, const Color& color, UINT8* outVertices, UINT8* outColors,
|
|
|
UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
|
|
|
{
|
|
|
@@ -148,12 +241,51 @@ namespace BansheeEngine
|
|
|
outIndices[1] = vertexOffset + 1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the provided buffers with vertices representing an antialiased line with a custom width.
|
|
|
+ *
|
|
|
+ * @param a Start point of the line.
|
|
|
+ * @param b End point of the line.
|
|
|
+ * @param width Width of the line.
|
|
|
+ * @param borderWidth Width of the anti-aliased border.
|
|
|
+ * @param color Color of the line.
|
|
|
+ * @param outVertices Output buffer that will store the vertex position data.
|
|
|
+ * @param outColors Output buffer that will store the vertex color data.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
|
|
|
+ * @param outIndices Output buffer that will store the index data. Indices are 32bit.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ */
|
|
|
virtual void line_AA(const T& a, const T& b, float width, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors,
|
|
|
UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) = 0;
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the provided buffers with vertices representing an antialiased polygon.
|
|
|
+ *
|
|
|
+ * @param points Points defining the polygon. First point is assumed to be the start and end point.
|
|
|
+ * @param borderWidth Width of the anti-aliased border.
|
|
|
+ * @param color Color of the polygon.
|
|
|
+ * @param outVertices Output buffer that will store the vertex position data.
|
|
|
+ * @param outColors Output buffer that will store the vertex color data.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
|
|
|
+ * @param outIndices Output buffer that will store the index data. Indices are 32bit.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ */
|
|
|
virtual void polygon_AA(const typename Vector<T>& points, float borderWidth, const Color& color, UINT8* outVertices, UINT8* outColors,
|
|
|
UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset) = 0;
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the provided buffers with position data and indices representing an inner
|
|
|
+ * area of a polygon (basically a normal non-antialiased polygon).
|
|
|
+ *
|
|
|
+ * @param points Points defining the polygon. First point is assumed to be the start and end point.
|
|
|
+ * @param outVertices Output buffer that will store the vertex position data.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
|
|
|
+ * @param outIndices Output buffer that will store the index data. Indices are 32bit.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ */
|
|
|
void polygonFill_Pixel(const typename Vector<T>& points, UINT8* outVertices,
|
|
|
UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
|
|
|
{
|
|
|
@@ -178,6 +310,18 @@ namespace BansheeEngine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief Fills the provided buffers with vertices representing a pixel-wide polygon border.
|
|
|
+ *
|
|
|
+ * @param points Points defining the polygon. First point is assumed to be the start and end point.
|
|
|
+ * @param color Color of the border.
|
|
|
+ * @param outVertices Output buffer that will store the vertex position data.
|
|
|
+ * @param outColors Output buffer that will store the vertex color data.
|
|
|
+ * @param vertexOffset Offset in number of vertices from the start of the buffer to start writing at.
|
|
|
+ * @param vertexStride Size of a single vertex, in bytes. (Same for both position and color buffer)
|
|
|
+ * @param outIndices Output buffer that will store the index data. Indices are 32bit.
|
|
|
+ * @param indexOffset Offset in number of indices from the start of the buffer to start writing at.
|
|
|
+ */
|
|
|
void polygonBorder_Pixel(const typename Vector<T>& points, const Color& color, UINT8* outVertices, UINT8* outColors,
|
|
|
UINT32 vertexOffset, UINT32 vertexStride, UINT32* outIndices, UINT32 indexOffset)
|
|
|
{
|