From 5c83e4e5b5fe415964db4a6f72f4558d026bfaf1 Mon Sep 17 00:00:00 2001
From: Christian Schmitt <chris@ilovelinux.de>
Date: Thu, 10 Jan 2013 16:17:18 +0100
Subject: [PATCH] tg_chopper.cxx: do not exit the process completely if we
 encounter the same amount of nodes after clipping as before. Instead, only
 return and keep processing.

---
 src/Lib/terragear/tg_chopper.cxx | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/Lib/terragear/tg_chopper.cxx b/src/Lib/terragear/tg_chopper.cxx
index b1a170c2..13e6fba5 100644
--- a/src/Lib/terragear/tg_chopper.cxx
+++ b/src/Lib/terragear/tg_chopper.cxx
@@ -161,10 +161,9 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
 
         bottom_clip = tgPolygon::Intersect( subject, bottom );
 
-        // the texparam should be constant over each clipped poly.
-        // when they are reassembled, we want the texture map to
-        // be seamless
-        Add( bottom_clip, type );
+        if ( (bottom_clip.TotalNodes() > 0) && (bottom_clip.TotalNodes() != subject.TotalNodes()) ) {
+            Add( bottom_clip, type );
+        }
     }
 
     {
@@ -185,12 +184,10 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
 
         top_clip = tgPolygon::Intersect( subject, top );
 
-        if ( top_clip.TotalNodes() == subject.TotalNodes() ) {
-            SG_LOG( SG_GENERAL, SG_DEBUG, "Generating top half - total nodes is the same after clip" << subject.TotalNodes() );
-            exit(0);
-        }
-
-        Add( top_clip, type );
+        if ( (top_clip.TotalNodes() > 0) && (top_clip.TotalNodes() != subject.TotalNodes()) ) {
+            Add( top_clip, type );
+        } else
+            return;
     }
 }