Add 64 Bit Vectors

I want 64 bit vectors because 32 bit floating points don’t have enough precision to make accurate physical systems. While programming a lot of times I find myself needing to divide the end calculation by some magic number like 1.1 because after so many calculations, the precision is so lost that it ends up adding energy to the physical system in some cases leading to unstable numbers and infinite numbers which could’ve been easily avoided with something like Vector3float64.

I know this is pretty much against Roblox’ policy for keeping simple a API that 13 year olds can understand easily. But Roblox also needs to realize that the “grownups” whom create the majority of the games can deal with complicated APIs.

For example I had to do:

EngineCF.UpVector * ((math.sign(BackForce:Dot(EngineCF.RightVector)))*BackForce.magnitude*CarDistToBackTireFromCOM/1.3)

instead of:

BackForce:Cross(EngineCF.LookVector*CarDistToBackTireFromCOM)/1.8

to keep a bit more precision in some edge cases. Constantly thinking about the implications of using 32 bit numbers is tiresome and annoying. Identifying when this is an issue is even harder.

Before anyone argues that 32 bit is enough, it is NOT. There are some solutions to the problem but both of them are not as good as just adding this library: Creating a Vector3 library in pure Lua is quite inefficient. Typing out every x,y,z variable and doing the calculations that way is very cumbersome.

Edit because people wanted more examples:

While creating my 2D physics engine, 32 bits were not enough because I couldn’t get rigid bodies to come to a rest efficiently, they would randomly add or lose energy from collisions. I had to read tens of physics sim articles and hundreds of forum posts to find an efficient solution. I could not find an efficient solution and decided to use individual numbers while calculating instead.

In my custom particle engine, sinking through objects effect is way more pronounced than it should’ve been due to 32 bit .

In a game that calculates the lift force on individual wings/propellers, the small mistakes that floating point rounding made used to add up and destabilise the vehicle. This was because a small perturbation in the velocity would add even more perturbations since the forces acting on the object scaled exponentially. The solution was to average it in a couple frames, clamp the values and add magic numbers to divide the last equations so that the system overall would lose energy that it would’ve gained.

Calculations with objects that are far away from the center just becomes so bad that making large worlds also becomes cumbersome. The more you let the engine handle the calculations, the more you lose the control over the behaviour of the objects.

When constantly changing a position relative to another position, unless you store the initial state, they start to drift apart from each other.

65 Likes

The reason this isn’t implemented is probably due to higher memory consumption.
Storing a Single precision floating point number costs around 4 bytes while a Double precision floating point number costs around 8 bytes which increases memory consumption and requires higher computanial power for something that isn’t often needed.
Also I think only Unreal and Godot support double precision out of the box (altough you have to compile Godot if you want higher precision).

2 Likes

Note that you would not be required to use 64-bit vectors were this added. The point of the feature request is to ask for the ability to use higher precision vectors in cases where it’s important, not force everyone to use higher precision. Many Roblox classes (such as ViewportFrames) are not easy on the engine when used irresponsibly; however, having the ability to use them when needed is a massive boon.

The same applies for 64-bit vectors. You don’t need that level of precision for most things, but when you DO need the precision (as the OP does) they’re a necessity and you’d be OK with a bigger memory footprint. It’s a tradeoff.

6 Likes

take a game like space sailors for example. the rocket begins to shake like crazy almost instantly, it’s a bit dumb we cant get anything to fix or reduce the error

1 Like