Use array<> for polygon clipping points
This commit is contained in:
parent
11769c5fc0
commit
82467a49c9
|
@ -141,7 +141,7 @@ void clip_line(g3s_point *&p0,g3s_point *&p1,ubyte codes_or)
|
|||
#endif
|
||||
|
||||
|
||||
static int clip_plane(int plane_flag,g3s_point **const src,g3s_point **const dest,int *nv,g3s_codes *cc)
|
||||
static int clip_plane(int plane_flag,polygon_clip_points &src,polygon_clip_points &dest,int *nv,g3s_codes *cc)
|
||||
{
|
||||
//copy first two verts to end
|
||||
src[*nv] = src[0];
|
||||
|
@ -186,21 +186,21 @@ static int clip_plane(int plane_flag,g3s_point **const src,g3s_point **const des
|
|||
return j;
|
||||
}
|
||||
|
||||
|
||||
g3s_point **clip_polygon(g3s_point **src,g3s_point **dest,int *nv,g3s_codes *cc)
|
||||
const polygon_clip_points &clip_polygon(polygon_clip_points &rsrc,polygon_clip_points &rdest,int *nv,g3s_codes *cc)
|
||||
{
|
||||
polygon_clip_points *src = &rsrc, *dest = &rdest;
|
||||
for (int plane_flag=1;plane_flag<16;plane_flag<<=1)
|
||||
|
||||
if (cc->uor & plane_flag) {
|
||||
|
||||
*nv = clip_plane(plane_flag,src,dest,nv,cc);
|
||||
*nv = clip_plane(plane_flag,*src,*dest,nv,cc);
|
||||
|
||||
if (cc->uand) //clipped away
|
||||
return dest;
|
||||
return *dest;
|
||||
|
||||
std::swap(src, dest);
|
||||
}
|
||||
|
||||
return src; //we swapped after we copied
|
||||
return *src; //we swapped after we copied
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ struct g3s_point;
|
|||
struct polygon_clip_points : array<g3s_point *, MAX_POINTS_IN_POLY> {};
|
||||
|
||||
extern void free_temp_point(g3s_point *p);
|
||||
extern g3s_point **clip_polygon(g3s_point **src,g3s_point **dest,int *nv,g3s_codes *cc);
|
||||
const polygon_clip_points &clip_polygon(polygon_clip_points &src,polygon_clip_points &dest,int *nv,g3s_codes *cc);
|
||||
extern void init_free_points(void);
|
||||
void clip_line(g3s_point *&p0,g3s_point *&p1,ubyte codes_or);
|
||||
|
||||
|
|
|
@ -107,9 +107,7 @@ bool do_facing_check(const array<const g3s_point *, 3> &vertlist)
|
|||
static bool must_clip_flat_face(int nv,g3s_codes cc, polygon_clip_points &Vbuf0, polygon_clip_points &Vbuf1)
|
||||
{
|
||||
bool ret=0;
|
||||
g3s_point **bufptr;
|
||||
|
||||
bufptr = clip_polygon(&Vbuf0[0],&Vbuf1[0],&nv,&cc);
|
||||
auto &bufptr = clip_polygon(Vbuf0,Vbuf1,&nv,&cc);
|
||||
|
||||
if (nv>0 && !(cc.uor&CC_BEHIND) && !cc.uand) {
|
||||
|
||||
|
@ -244,9 +242,7 @@ void _g3_draw_tmap(unsigned nv,const g3s_point *const *const pointlist,const g3s
|
|||
|
||||
static void must_clip_tmap_face(int nv,g3s_codes cc,grs_bitmap *bm,polygon_clip_points &Vbuf0, polygon_clip_points &Vbuf1)
|
||||
{
|
||||
g3s_point **bufptr;
|
||||
bufptr = clip_polygon(&Vbuf0[0],&Vbuf1[0],&nv,&cc);
|
||||
|
||||
auto &bufptr = clip_polygon(Vbuf0,Vbuf1,&nv,&cc);
|
||||
if (nv && !(cc.uor&CC_BEHIND) && !cc.uand) {
|
||||
|
||||
for (int i=0;i<nv;i++) {
|
||||
|
@ -261,7 +257,7 @@ static void must_clip_tmap_face(int nv,g3s_codes cc,grs_bitmap *bm,polygon_clip_
|
|||
}
|
||||
}
|
||||
|
||||
(*tmap_drawer_ptr)(bm,nv,bufptr);
|
||||
(*tmap_drawer_ptr)(bm,nv,&bufptr[0]);
|
||||
}
|
||||
|
||||
free_points:
|
||||
|
|
Loading…
Reference in a new issue