From c49880c8c673df87643601a6ed6d3c7764d50c08 Mon Sep 17 00:00:00 2001 From: Kp Date: Thu, 13 Nov 2014 03:19:45 +0000 Subject: [PATCH] Pass clip_line arg by *&, not ** --- common/3d/clipper.cpp | 21 ++++++++++----------- common/3d/clipper.h | 2 +- common/3d/draw.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/common/3d/clipper.cpp b/common/3d/clipper.cpp index 34df182fa..f63dd2524 100644 --- a/common/3d/clipper.cpp +++ b/common/3d/clipper.cpp @@ -10,6 +10,8 @@ #include "clipper.h" #include "dxxerror.h" +#include "compiler-exchange.h" + int free_point_num=0; g3s_point temp_points[MAX_POINTS_IN_POLY]; @@ -116,30 +118,27 @@ static g3s_point *clip_edge(int plane_flag,g3s_point *on_pnt,g3s_point *off_pnt) return tmp; } +#ifndef OGL //clips a line to the viewing pyramid. -void clip_line(g3s_point **p0,g3s_point **p1,ubyte codes_or) +void clip_line(g3s_point *&p0,g3s_point *&p1,ubyte codes_or) { - g3s_point *old_p1; - //might have these left over - (*p0)->p3_flags &= ~(PF_UVS|PF_LS); - (*p1)->p3_flags &= ~(PF_UVS|PF_LS); + p0->p3_flags &= ~(PF_UVS|PF_LS); + p1->p3_flags &= ~(PF_UVS|PF_LS); for (int plane_flag=1;plane_flag<16;plane_flag<<=1) if (codes_or & plane_flag) { - if ((*p0)->p3_codes & plane_flag) - std::swap(*p0, *p1); - - old_p1 = *p1; - - *p1 = clip_edge(plane_flag,*p0,*p1); + if (p0->p3_codes & plane_flag) + std::swap(p0, p1); + const auto old_p1 = exchange(p1, clip_edge(plane_flag,p0,p1)); if (old_p1->p3_flags & PF_TEMP_POINT) free_temp_point(old_p1); } } +#endif static int clip_plane(int plane_flag,g3s_point **src,g3s_point **dest,int *nv,g3s_codes *cc) diff --git a/common/3d/clipper.h b/common/3d/clipper.h index 514bc61bb..6d2bd2238 100644 --- a/common/3d/clipper.h +++ b/common/3d/clipper.h @@ -23,7 +23,7 @@ struct g3s_point; extern void free_temp_point(g3s_point *p); extern g3s_point **clip_polygon(g3s_point **src,g3s_point **dest,int *nv,g3s_codes *cc); extern void init_free_points(void); -extern void clip_line(g3s_point **p0,g3s_point **p1,ubyte codes_or); +void clip_line(g3s_point *&p0,g3s_point *&p1,ubyte codes_or); #endif diff --git a/common/3d/draw.cpp b/common/3d/draw.cpp index 632905209..986774248 100644 --- a/common/3d/draw.cpp +++ b/common/3d/draw.cpp @@ -42,7 +42,7 @@ static bool must_clip_line(g3s_point *p0,g3s_point *p1,ubyte codes_or) else { - clip_line(&p0,&p1,codes_or); + clip_line(p0,p1,codes_or); ret = g3_draw_line(p0,p1); }