Initial commit
This commit is contained in:
parent
478bb36fa9
commit
1b9a3b684f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Binaries
|
||||
Intermediate
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) 2023 Kevin Poretti (kevinporetti.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
52
README.md
52
README.md
@ -1,3 +1,53 @@
|
||||
# UnrealFixedPoint
|
||||
|
||||
A fixed point math library for Unreal Engine
|
||||
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
|
||||
|
||||
### 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](https://en.wikipedia.org/wiki/Computer_number_format#Fixed-point_numbers).
|
||||
|
||||
### 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](https://www.gafferongames.com/post/floating_point_determinism/).
|
||||
|
||||
### 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](https://mit-license.org/). This library is free for commercial and non-commercial use. Attribution is not required, but is greatly appreciated.
|
BIN
Resources/Icon128.png
Normal file
BIN
Resources/Icon128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
22
Source/UnrealFixedPoint/Private/UnrealFixedPoint.cpp
Normal file
22
Source/UnrealFixedPoint/Private/UnrealFixedPoint.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "UnrealFixedPoint.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FUnrealFixedPointModule"
|
||||
|
||||
void FUnrealFixedPointModule::StartupModule()
|
||||
{
|
||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||
|
||||
}
|
||||
|
||||
void FUnrealFixedPointModule::ShutdownModule()
|
||||
{
|
||||
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
|
||||
// we call this function before unloading the module.
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FUnrealFixedPointModule, UnrealFixedPoint)
|
@ -0,0 +1,16 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "UnrealFixedPointBPLibrary.h"
|
||||
#include "UnrealFixedPoint.h"
|
||||
|
||||
UUnrealFixedPointBPLibrary::UUnrealFixedPointBPLibrary(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float UUnrealFixedPointBPLibrary::UnrealFixedPointSampleFunction(float Param)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
14
Source/UnrealFixedPoint/Public/UnrealFixedPoint.h
Normal file
14
Source/UnrealFixedPoint/Public/UnrealFixedPoint.h
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FUnrealFixedPointModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
32
Source/UnrealFixedPoint/Public/UnrealFixedPointBPLibrary.h
Normal file
32
Source/UnrealFixedPoint/Public/UnrealFixedPointBPLibrary.h
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "UnrealFixedPointBPLibrary.generated.h"
|
||||
|
||||
/*
|
||||
* Function library class.
|
||||
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
|
||||
*
|
||||
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
|
||||
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
|
||||
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
|
||||
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
|
||||
* Its lets you name the node using characters not allowed in C++ function names.
|
||||
* CompactNodeTitle - the word(s) that appear on the node.
|
||||
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
|
||||
* Good example is "Print String" node which you can find also by using keyword "log".
|
||||
* Category - the category your node will be under in the Blueprint drop-down menu.
|
||||
*
|
||||
* For more info on custom blueprint nodes visit documentation:
|
||||
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
|
||||
*/
|
||||
UCLASS()
|
||||
class UUnrealFixedPointBPLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Execute Sample function", Keywords = "UnrealFixedPoint sample test testing"), Category = "UnrealFixedPointTesting")
|
||||
static float UnrealFixedPointSampleFunction(float Param);
|
||||
};
|
51
Source/UnrealFixedPoint/UnrealFixedPoint.Build.cs
Normal file
51
Source/UnrealFixedPoint/UnrealFixedPoint.Build.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// Some copyright should be here...
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class UnrealFixedPoint : ModuleRules
|
||||
{
|
||||
public UnrealFixedPoint(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
// ... add any modules that your module loads dynamically here ...
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
24
UnrealFixedPoint.uplugin
Normal file
24
UnrealFixedPoint.uplugin
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "1.0",
|
||||
"FriendlyName": "UnrealFixedPoint",
|
||||
"Description": "This library provides a fixed point number primitive with corresponding data types that are useful for game development (i.e. vector, rotator, transform).",
|
||||
"Category": "Math",
|
||||
"CreatedBy": "Kevin Poretti",
|
||||
"CreatedByURL": "https://kevinporetti.com",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "",
|
||||
"SupportURL": "",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": true,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "UnrealFixedPoint",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PreLoadingScreen"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user