]> git.seodisparate.com - jumpartifact.com_demo_0/commitdiff
Tweaks to electricity "line" generation
authorStephen Seo <seo.disparate@gmail.com>
Thu, 24 Aug 2023 07:10:22 +0000 (16:10 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 24 Aug 2023 07:10:22 +0000 (16:10 +0900)
src/electricity_effect.cc
src/electricity_effect.h
src/screen_trunner.h

index a9123afd922908bc933f808b722997c70109d50f..33eebcc586e51af7a1cdbf387c40a95a21806e97 100644 (file)
@@ -26,13 +26,20 @@ ElectricityEffect::ElectricityEffect(Vector3 center, float radius,
     next = positions.front();
     positions.pop();
 
+    dir = Vector3Normalize(center - next);
     dir = Vector3Normalize(Vector3{call_js_get_random() * 2.0F - 1.0F,
                                    call_js_get_random() * 2.0F - 1.0F,
-                                   call_js_get_random() * 2.0F - 1.0F});
+                                   call_js_get_random() * 2.0F - 1.0F} +
+                           dir);
 
     auto coll = GetRayCollisionSphere(Ray{.position = next, .direction = dir},
                                       center, radius);
 
+    if (coll.distance > CYLINDER_LINE_MAX_LENGTH) {
+      coll.point =
+          next + Vector3Normalize(coll.point - next) * CYLINDER_LINE_MAX_LENGTH;
+    }
+
     cylinders.push_back(Cylinder{.start = next, .end = coll.point});
 
     dir = Vector3Normalize(center - coll.point);
index d61e91485b5316b4d535defd571e97b8117d3c50..bb43010ef354d10eb61670e01688ddf2d39c6d1e 100644 (file)
@@ -11,6 +11,7 @@ constexpr int CYLINDER_SPLIT_COUNT = 3;
 constexpr int CYLINDER_SIDES = 3;
 constexpr float CYLINDER_MAX_RADIUS = 0.03F;
 constexpr float CYLINDER_EDGE_OFFSET = 0.01F;
+constexpr float CYLINDER_LINE_MAX_LENGTH = 1.5F;
 
 class ElectricityEffect {
  public:
index c1cbdceb753ee1b355c5a6dccb2b0cf9f05dd6df..2289d72f99a3191318312512a2737537a9b4fec9 100644 (file)
@@ -29,7 +29,7 @@ constexpr float SURFACE_RESET_TIME = 4.0F;
 constexpr float SURFACE_RESET_TIME_TRI_DRAW = 3.0F;
 constexpr float SURFACE_RESET_Y_OFFSET = 40.0F;
 
-constexpr int ELECTRICITY_EFFECT_LINE_COUNT = 50;
+constexpr int ELECTRICITY_EFFECT_LINE_COUNT = 35;
 
 class TRunnerScreen : public Screen {
  public: