From: curt Date: Wed, 28 May 2003 19:02:43 +0000 (+0000) Subject: Make gen_surface_points accessible through the API. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8b8a82bb67eec2966872a3b02d0fe8c04b4159d9;p=simgear.git Make gen_surface_points accessible through the API. --- diff --git a/simgear/scene/tgdb/leaf.cxx b/simgear/scene/tgdb/leaf.cxx index 0700ae20..e5cdd14a 100644 --- a/simgear/scene/tgdb/leaf.cxx +++ b/simgear/scene/tgdb/leaf.cxx @@ -66,8 +66,9 @@ static void random_pt_inside_tri( float *res, } -static void gen_random_surface_points( ssgLeaf *leaf, ssgVertexArray *lights, - double factor ) { +void sgGenRandomSurfacePoints( ssgLeaf *leaf, double factor, + ssgVertexArray *lights ) +{ int tris = leaf->getNumTriangles(); if ( tris > 0 ) { short int n1, n2, n3; @@ -108,6 +109,13 @@ static void gen_random_surface_points( ssgLeaf *leaf, ssgVertexArray *lights, } +ssgVertexArray *sgGenRandomSurfacePoints( ssgLeaf *leaf, double factor ) { + ssgVertexArray *result = new ssgVertexArray(); + sgGenRandomSurfacePoints( leaf, factor, result ); + + return result; +} + //////////////////////////////////////////////////////////////////////// // Scenery loaders. @@ -251,7 +259,7 @@ ssgLeaf *sgMakeLeaf( const string& path, << coverage << ", pushing up to 10000"); coverage = 10000; } - gen_random_surface_points(leaf, lights, coverage); + sgGenRandomSurfacePoints(leaf, coverage, lights ); } } diff --git a/simgear/scene/tgdb/leaf.hxx b/simgear/scene/tgdb/leaf.hxx index 772489b5..66fbdd1c 100644 --- a/simgear/scene/tgdb/leaf.hxx +++ b/simgear/scene/tgdb/leaf.hxx @@ -56,4 +56,14 @@ ssgLeaf *sgMakeLeaf( const string& path, const bool calc_lights, ssgVertexArray *lights ); +// return a newly created list of points randomly spread across the +// specified leaf. "factor" specifies density ... on average there +// will be one object per the area specified by "factor" in m^2 A +// larger factor will mean fewer objects. +ssgVertexArray *sgGenRandomSurfacePoints( ssgLeaf *leaf, double factor ); + +// Another varient of the same routine. +void sgGenRandomSurfacePoints( ssgLeaf *leaf, double factor, + ssgVertexArray *lights ); + #endif // _SG_LEAF_HXX