Functions related to primitive clipping.
More...
|
| file | clipping.c |
| |
| file | clipping.h |
| |
| enum | ClipPlane {
PLANE_LEFT
, PLANE_RIGHT
, PLANE_BOTTOM
, PLANE_TOP
,
PLANE_NEAR
, PLANE_FAR
, PLANE_COUNT
} |
| |
| static uint8_t | computeClipCode (const SRPVertexShaderOut *v) |
| |
| static size_t | clipAgainstPlane (SRPVertexShaderOut *in, size_t inCount, ClipPlane plane, const SRPShaderProgram *sp, SRPVertexShaderOut *out) |
| |
| static void | interpolateVertex (const SRPVertexShaderOut *a, const SRPVertexShaderOut *b, float t, const SRPShaderProgram *sp, SRPVertexShaderOut *out) |
| |
| static float | planeDistance (const SRPVertexShaderOut *v, ClipPlane p) |
| |
| bool | clipLine (SRPLine *line, const SRPShaderProgram *sp) |
| |
| bool | clipPoint (SRPPoint *p) |
| |
| size_t | clipTriangle (const SRPTriangle *in, const SRPShaderProgram *sp, SRPTriangle *out) |
| |
Functions related to primitive clipping.
◆ ClipPlane
Represents all possible clip planes
◆ clipAgainstPlane()
Clip a polygon against specified plane (Sutherland-Hodgman)
- Parameters
-
| [in] | in | Vertices of an input polygon |
| [in] | inCount | Amount of vertices the input polygon has |
| [in] | plane | The plane to clip against |
| [in] | sp | The shader program being used |
| [out] | out | Vertices of a clipped polygon |
- Returns
- Amount of vertices the clipped polygon has
◆ clipLine()
Clip the line in-place using Liang-Barsky algorithm
- Parameters
-
| [in] | line | The line to clip |
| [in] | sp | The shader program being used |
- Returns
true if clipped fully (nothing left), false if clipped partially
◆ clipPoint()
Determine whether or not a point should be clipped
- Parameters
-
- Returns
true if point is clipped, false otherwise
◆ clipTriangle()
Clip the triangle using Sutherland-Hodgman algorithm
- Parameters
-
| [in] | in | The triangle to clip |
| [in] | sp | The shader program being used |
| [out] | out | The returned array of triangles |
- Returns
- Amount of outputted triangles
◆ computeClipCode()
Compute the clip code for a vertex. 0 if inside all 6 clip planes, else 1 in a specific bit.
- Parameters
-
- Returns
- Clip code
◆ interpolateVertex()
Create new vertex via interpolating between two existing ones
- Parameters
-
| [in] | a | First vertex |
| [in] | b | Second vertex |
| [in] | t | Interpolation parameter: 0 -> first vertex, 1 -> second vertex |
| [in] | sp | The shader program being used |
| [in] | out | Interpolated vertex |
- Todo:
- this is disgusting
◆ planeDistance()
Calculate the distance from the vertex to the specified clip plane
- Parameters
-
| [in] | v | Vertex |
| [in] | p | Clip plane |
- Returns
- The distance from the vertex to the specified clip plane