Tweaks to electricity "line" generation
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 22s

This commit is contained in:
Stephen Seo 2023-08-24 16:10:22 +09:00
parent ff45edbece
commit 8e8a8b0684
3 changed files with 10 additions and 2 deletions

View file

@ -26,13 +26,20 @@ ElectricityEffect::ElectricityEffect(Vector3 center, float radius,
next = positions.front(); next = positions.front();
positions.pop(); positions.pop();
dir = Vector3Normalize(center - next);
dir = Vector3Normalize(Vector3{call_js_get_random() * 2.0F - 1.0F, 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}); call_js_get_random() * 2.0F - 1.0F} +
dir);
auto coll = GetRayCollisionSphere(Ray{.position = next, .direction = dir}, auto coll = GetRayCollisionSphere(Ray{.position = next, .direction = dir},
center, radius); 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}); cylinders.push_back(Cylinder{.start = next, .end = coll.point});
dir = Vector3Normalize(center - coll.point); dir = Vector3Normalize(center - coll.point);

View file

@ -11,6 +11,7 @@ constexpr int CYLINDER_SPLIT_COUNT = 3;
constexpr int CYLINDER_SIDES = 3; constexpr int CYLINDER_SIDES = 3;
constexpr float CYLINDER_MAX_RADIUS = 0.03F; constexpr float CYLINDER_MAX_RADIUS = 0.03F;
constexpr float CYLINDER_EDGE_OFFSET = 0.01F; constexpr float CYLINDER_EDGE_OFFSET = 0.01F;
constexpr float CYLINDER_LINE_MAX_LENGTH = 1.5F;
class ElectricityEffect { class ElectricityEffect {
public: public:

View 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_TIME_TRI_DRAW = 3.0F;
constexpr float SURFACE_RESET_Y_OFFSET = 40.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 { class TRunnerScreen : public Screen {
public: public: