From df13041f42735f56181880d77f92ad43c4d7979f Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sun, 28 Feb 2010 01:28:00 +0000 Subject: [PATCH] Remove randomness from SceneCombiner. This offers two advantages: firstly, boost::random isn't used by Assimp at all with these changes. Secondly, the results of the IRR/LWS loaders are guaranteed to be identical on each run now. That's crucial of course, I just failed to recognize it in the past. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@559 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/SceneCombiner.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index fd35f432a..74eb4ebda 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -41,9 +41,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ---------------------------------------------------------------------------- /** @file Implements Assimp::SceneCombiner. This is a smart utility - * class that can be used to combine several scenes, meshes, ... - * in one. Currently these utilities are used by the IRR and LWS - * loaders and by the OptimizeGraph step. + * class that combines multiple scenes, meshes, ... into one. Currently + * these utilities are used by the IRR and LWS loaders and the + * OptimizeGraph step. */ // ---------------------------------------------------------------------------- #include "AssimpPCH.h" @@ -52,26 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Hash.h" #include "time.h" -// ---------------------------------------------------------------------------- -// We need boost::random here. The workaround uses rand() instead of a proper -// Mersenne twister, but I think it should still be 'random' enough for our -// purposes. -// ---------------------------------------------------------------------------- -#ifdef ASSIMP_BUILD_BOOST_WORKAROUND - -# include "../include/BoostWorkaround/boost/random/uniform_int.hpp" -# include "../include/BoostWorkaround/boost/random/variate_generator.hpp" -# include "../include/BoostWorkaround/boost/random/mersenne_twister.hpp" - -#else - -# include -# include -# include - -#endif - - namespace Assimp { // ------------------------------------------------------------------------------------------------ @@ -299,11 +279,12 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, // Generate unique names for all named stuff? if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) { +#if 0 // Construct a proper random number generator - boost::mt19937 rng( ::clock() ); + boost::mt19937 rng( ); boost::uniform_int<> dist(1u,1 << 24u); boost::variate_generator > rndGen(rng, dist); - +#endif for (unsigned int i = 1; i < src.size();++i) { //if (i != duplicates[i]) @@ -315,8 +296,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master, // continue; //} - const unsigned int random = rndGen(); - src[i].idlen = ::sprintf(src[i].id,"$%.6X$_",random); + src[i].idlen = ::sprintf(src[i].id,"$%.6X$_",i); if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) {