initialize seed with chrono
using rand without seeding it was generating the same sequence of results on every iteration.
This PR initializes it with a new seed on every state machine instance.
Diffs=
3734d9bac initialize seed with chrono (#7285)
Co-authored-by: hernan <hernan@rive.app>
diff --git a/.rive_head b/.rive_head
index 1070542..036d288 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-45b998e68b849e0c8741bf254a2193e31844c405
+3734d9bac071052acbcfdbec576ba9532bc84e3b
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp
index e5e387d..2400ced 100644
--- a/src/animation/state_machine_instance.cpp
+++ b/src/animation/state_machine_instance.cpp
@@ -27,6 +27,7 @@
#include "rive/math/math_types.hpp"
#include "rive/audio_event.hpp"
#include <unordered_map>
+#include <chrono>
using namespace rive;
namespace rive
@@ -51,6 +52,10 @@
m_anyStateInstance = layer->anyState()->makeInstance(instance).release();
m_layer = layer;
changeState(m_layer->entryState());
+ auto now = std::chrono::high_resolution_clock::now();
+ auto nanos =
+ std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
+ srand(nanos);
}
void updateMix(float seconds)