From bc1f3b69a819b03cfa8d94dc224b574cebe44ff7 Mon Sep 17 00:00:00 2001 From: COW_ILLUMINATI Date: Tue, 30 Apr 2024 21:40:39 -0400 Subject: [PATCH] relativity --- src/Simulator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Simulator.cpp b/src/Simulator.cpp index ace33e9..7c790d8 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -16,7 +16,9 @@ class Vector3; std::clock_t startTime = std::clock(); // Sets the constant -const float sol = 10.0; // Speed of light *should* be 1, but 10.0 make it compatible with old settings so I don't need to change the text in the creator +const float sol = 3.5; // Speed of light *should* be 1, but 3.5 make it compatible with old settings so I don't need to change the text in the creator +const float invsolsqr = 1.0f/(sol*sol); + // Defines a pointer to the screen size (needs to be accessible everywhere, but the Vector3 class is still undefined!) Vector3 *screenSize; @@ -239,7 +241,8 @@ struct Star void tick(float dt, bool relativistic) { if (true){ - acceleration = acceleration * (sol - sqrt(velocity.SqrMagnitude()))/sol; + // Lorentz scaling + acceleration = acceleration * sqrt(std::max(0.0f, (1 - velocity.SqrMagnitude()*invsolsqr))); }