2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
29 CLIP_LEFT, CLIP_RIGHT,
30 CLIP_BOTTOM, CLIP_TOP,
34 /* Generic polygon clipper
36 * 1 -> fully inside, not clipped
37 * 0 -> straddling the plane and clipped
38 * -1 -> fully outside, not clipped
39 * in all cases, vertices are copied to vout, and the vertex count is written
40 * to wherever voutnum is pointing
42 int clip_poly(struct vertex *vout, int *voutnum,
43 const struct vertex *vin, int vnum, struct cplane *plane);
45 /* only checks if the polygon would be clipped by the plane, and classifies it
46 * as inside/outside/straddling, without actually producing a clipped polygon.
47 * return values are the same as clip_poly.
49 int check_clip_poly(const struct vertex *v, int vnum, struct cplane *plane);
51 /* Special-case frustum clipper (might be slightly faster) */
52 int clip_frustum(struct vertex *vout, int *voutnum,
53 const struct vertex *vin, int vnum, int fplane);
55 #endif /* POLYCLIP_H_ */