]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/netradiant-src/tools/quake3/common/polylib.c
Update netRadiant source
[voretournament/voretournament.git] / misc / source / netradiant-src / tools / quake3 / common / polylib.c
index 34dd173ecbd0473715dd3a688ce22ac785f6756d..1d59dd4b3d57cef56cb8f31bdb8899dba53b7369 100644 (file)
@@ -67,7 +67,7 @@ winding_t     *AllocWinding (int points)
                if (c_active_windings > c_peak_windings)
                        c_peak_windings = c_active_windings;
        }
-       s = sizeof(vec_t)*3*points + sizeof(int);
+       s = sizeof(*w) + (points ? sizeof(w->p[0])*(points-1) : 0);
        w = safe_malloc (s);
        memset (w, 0, s); 
        return w;
@@ -95,7 +95,7 @@ winding_accu_t *AllocWindingAccu(int points)
                if (c_active_windings > c_peak_windings)
                        c_peak_windings = c_active_windings;
        }
-       s = sizeof(vec_accu_t) * 3 * points + sizeof(int);
+       s = sizeof(*w) + (points ? sizeof(w->p[0])*(points-1) : 0);
        w = safe_malloc(s);
        memset(w, 0, s); 
        return w;
@@ -536,7 +536,7 @@ winding_t   *ReverseWinding (winding_t *w)
 ClipWindingEpsilon
 =============
 */
-void   ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, 
+void   ClipWindingEpsilonStrict (winding_t *in, vec3_t normal, vec_t dist, 
                                vec_t epsilon, winding_t **front, winding_t **back)
 {
        vec_t   dists[MAX_POINTS_ON_WINDING+4];
@@ -573,6 +573,10 @@ void       ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
        
        *front = *back = NULL;
 
+       if (!counts[0] && !counts[1])
+       {
+               return;
+       }
        if (!counts[0])
        {
                *back = CopyWinding (in);
@@ -643,6 +647,15 @@ void       ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist,
                Error ("ClipWinding: MAX_POINTS_ON_WINDING");
 }
 
+void   ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, 
+                               vec_t epsilon, winding_t **front, winding_t **back)
+{
+       ClipWindingEpsilonStrict(in, normal, dist, epsilon, front, back);
+       /* apparently most code expects that in the winding-on-plane case, the back winding is the original winding */
+       if(!*front && !*back)
+               *back = CopyWinding(in);
+}
+
 
 /*
 =============