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
pull/1/head
aramis_acg 2010-02-28 01:28:00 +00:00
parent 78f27eef13
commit df13041f42
1 changed files with 7 additions and 27 deletions

View File

@ -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 /** @file Implements Assimp::SceneCombiner. This is a smart utility
* class that can be used to combine several scenes, meshes, ... * class that combines multiple scenes, meshes, ... into one. Currently
* in one. Currently these utilities are used by the IRR and LWS * these utilities are used by the IRR and LWS loaders and the
* loaders and by the OptimizeGraph step. * OptimizeGraph step.
*/ */
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "AssimpPCH.h" #include "AssimpPCH.h"
@ -52,26 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Hash.h" #include "Hash.h"
#include "time.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 <boost/random/uniform_int.hpp>
# include <boost/random/variate_generator.hpp>
# include <boost/random/mersenne_twister.hpp>
#endif
namespace Assimp { namespace Assimp {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -299,11 +279,12 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master,
// Generate unique names for all named stuff? // Generate unique names for all named stuff?
if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES) if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES)
{ {
#if 0
// Construct a proper random number generator // Construct a proper random number generator
boost::mt19937 rng( ::clock() ); boost::mt19937 rng( );
boost::uniform_int<> dist(1u,1 << 24u); boost::uniform_int<> dist(1u,1 << 24u);
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rndGen(rng, dist); boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rndGen(rng, dist);
#endif
for (unsigned int i = 1; i < src.size();++i) for (unsigned int i = 1; i < src.size();++i)
{ {
//if (i != duplicates[i]) //if (i != duplicates[i])
@ -315,8 +296,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master,
// continue; // continue;
//} //}
const unsigned int random = rndGen(); src[i].idlen = ::sprintf(src[i].id,"$%.6X$_",i);
src[i].idlen = ::sprintf(src[i].id,"$%.6X$_",random);
if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) { if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) {