Resources | ||
Source/UnrealFixedMath | ||
.gitignore | ||
LICENSE | ||
README.md | ||
UnrealFixedMath.uplugin |
UnrealFixedMath
A fixed point math library for Unreal Engine.
This library provides a fixed point number primitive with corresponding data types that are useful for game development (i.e. vector, rotator, transform).
This library aims to closely match the interface and functionality of the existing math library in Unreal Engine. If you are a developer who has used Unreal Engine and has used the FMath and UKismetMathLibrary classes you should find this library familiar.
To-Do
- Fixed point number implementation
- Fixed point version of FVector2D
- FFixedVector2D class implementation
- Corresponding FMath and UKismetMathLibrary utility functions
- Fixed point version of FVector
- FFixedVector class implementation
- Corresponding FMath and UKismetMathLibrary utility functions
- Fixed point version of FRotator
- FFixedRotator class implementation
- Corresponding FMath and UKismetMathLibrary utility functions
- Blueprints
- Expose fixed arithmatic as pure Blueprint nodes
- Ability to edit fixed nums with float sliders/input fields
- Automatically do float <> fixed conversion when tweaking fixed point numbers in the editor
- Plugin config
- Configure how fixed nums are shown in editor when exposed as UPROPERTY (as floats only, as float and underlying int, as underlying int only)
- Handling errors and edge cases
- Overflow
- Infinity
What is fixed point math?
Fixed point math is math that uses an INT data type format (i.e. int, long, long long) rather than a floating point format (i.e. float or double). Unlike normal integers, which represent entirely whole numbers, fixed point can represent fractional numbers. The way this works is a portion of the bits of the underlying data type are reserved for the fractional portion of the value, while the rest of the bits are reserved for the whole number portion.
For more detailed information on how this works see the Wikipedia article.
Why use fixed point over floating point?
In short, some projects require your game simulation to be fully deterministic, meaning given a set of inputs and an initial "world state" of your game, the resulting update will be the same each time.
Due to the nature of floating point numbers, calculations may result in slight differences between platforms or CPU architecture. This means your game simulation will not be fully deterministic. This can cause desyncs when implementing the lock-step or rollback networking models.
There are ways to get deterministic behavior for floating point operations between architectures with compilar flags, but this is not guaranteed or particularly easy. This also may not be feasible if you are using precompiled binaries, like would be the case when using the installed version of Unreal Engine. See this Gaffer On Games article for more information.
Setup
Clone this repository into the Plugins folder of your game project or your Unreal Engine installation.
Engine - /[UE Root]/Engine/Plugins/ Game - /[Project Root]/Plugins/
Usage
Coming soon...
Known Issues
None so far...
Licensing
This library is available under The MIT License. This library is free for commercial and non-commercial use. Attribution is not required, but is greatly appreciated.