From fe6e896c4ba488810029eeb927e0517cbcd53bc2 Mon Sep 17 00:00:00 2001
From: bobarna <barnabas.borcsok@gmail.com>
Date: Sun, 29 Nov 2020 03:32:17 +0100
Subject: [PATCH] put back previous working propagation

---
 src/geometries/PBDSimulation.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/geometries/PBDSimulation.cpp b/src/geometries/PBDSimulation.cpp
index 3bc81bd..17b303a 100644
--- a/src/geometries/PBDSimulation.cpp
+++ b/src/geometries/PBDSimulation.cpp
@@ -20,11 +20,23 @@ PBDSimulation::PBDSimulation(HeadObject *_head, size_t _nr_sims, size_t _nr_segm
 }
 
 void PBDSimulation::propagateHead() {
-    vec3 origin(0, 0, 0);
+    srand(time(nullptr));
+    vec3 head(0,0,0);
+    float step = M_PI / nrStrands;
+    float currAngle = M_PI;
+    float r = 0.20f;
+
+    // if there is only one strand, then place it in the middle
+    if (nrStrands == 1) r = 0.0;
+
     for (size_t i = 0; i < nrStrands; i++) {
         vec3 color = util::getRandomRGBColorAround(vec3(222.0f, 101.0f, 32.0f), vec3(40.0f, 20.0f, 20.0f));
-        strands.emplace_back(CreateStrand(nrSegments, lSeg, origin, color));
+        vec3 curr_pos(head.x + cosf(currAngle) * r * 1.2f, head.y + sinf(currAngle) * r * 1.1f, head.z);
+
+        strands.emplace_back(CreateStrand(nrSegments, lSeg, curr_pos, color));
+        currAngle -= step;
     }
+
 }
 
 void PBDSimulation::update(float dt) {
-- 
GitLab