An inner inner loop using 'j', in the build
function is trashing the outer loop 'j'. This
led to a std::bad_alloc in my Ubuntu.
You can read the full details of this, including
a bt, in the forum, posted for me by 'gazzatav' -
http://www.flightgear.org/forums/viewtopic.php?f=5&t=9629
I added a 'k' to the top, and changed the inner
most loop to use 'k'...
I also moved the convGeodNodes outside the
loops completely, to save regenerating this
vector over and over...
Attached is a patch... hope this can get
into the tg-cs repo soonest...
Thanks, and regards,
Geoff.
attached: tg-genobj.patch
--- genobj-org.cxx 2010-09-24 12:50:12.000000000 +0200
+++ genobj.cxx 2010-10-01 15:33:08.000000000 +0200
@@ -147,7 +147,7 @@
// build the necessary output structures based on the triangulation
// data
int TGGenOutput::build( TGConstruct& c ) {
- int i, j;
+ int i, j, k;
TGTriNodes trinodes = c.get_tri_nodes();
@@ -183,7 +183,11 @@
cout << "calculating texture coordinates" << endl;
cout << "c.get_useUKGrid() = " << c.get_useUKGrid() << endl;
tex_coords.clear();
-
+ std::vector < SGGeod > convGeodNodes;
+ for ( k = 0; k < geod_nodes.size(); k++ ) {
+ Point3D node = geod_nodes[k];
+ convGeodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
+ }
for ( i = 0; i < TG_MAX_AREA_TYPES; ++i ) {
// cout << " area = " << i << endl;
for ( j = 0; j < (int)fans[i].size(); ++j ) {
@@ -203,20 +207,15 @@
if( (c.get_useUKGrid()) && (isInUK(ourPosition)) ) {
point_list tp_list;
tp_list = UK_calc_tex_coords( b, geod_nodes, fans[i][j], 1.0 );
- for ( int k = 0; k < (int)tp_list.size(); ++k ) {
+ for ( k = 0; k < (int)tp_list.size(); ++k ) {
// cout << " tc = " << tp_list[k] << endl;
int index = tex_coords.simple_add( tp_list[k] );
ti_list.push_back( index );
}
} else {
- std::vector < SGGeod > convGeodNodes;
- for ( j = 0; j < geod_nodes.size(); j++ ) {
- Point3D node = geod_nodes[j];
- convGeodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
- }
std::vector< SGVec2f > tp_list = sgCalcTexCoords( b, convGeodNodes, fans[i][j] );
- for ( j = 0; j < (int)tp_list.size(); ++j ) {
- SGVec2f tc = tp_list[j];
+ for ( k = 0; k < (int)tp_list.size(); ++k ) {
+ SGVec2f tc = tp_list[k];
// SG_LOG(SG_GENERAL, SG_DEBUG, "base_tc = " << tc);
int index = tex_coords.simple_add( Point3D( tc.x(), tc.y(), 0 ) );
ti_list.push_back( index );
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel