Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************** HEADER ******************/
- #pragma once
- #include "Kismet/BlueprintFunctionLibrary.h"
- #include "BlueprintNode_TruncatePrecision.generated.h"
- UCLASS()
- class ARDUINO_API UBlueprintNode_TruncatePrecision : public UBlueprintFunctionLibrary
- {
- GENERATED_BODY()
- static UFUNCTION(BlueprintPure, meta = (DisplayName = "Truncate Floats with int fixed past coma precision", CompactNodeTitle = "Trunc", Keywords = "truncate floats precision"), Category = "Personal Blueprint Nodes")
- float TruncatePrecision(float in, int precision);
- };
- /****************** CPP ******************/
- #include "Arduino.h"
- #include "BlueprintNode_TruncatePrecision.h"
- #include <cmath>
- /** Truncate Precision Blueprint Node Code **/
- UFUNCTION(BlueprintPure, meta = (DisplayName = "Truncate Floats with precision", CompactNodeTitle = "Trunc", Keywords = "truncate floats precision"), Category = "PersonalBlueprintNodes")
- float UBlueprintNode_TruncatePrecision::TruncatePrecision(float in, int precision)
- {
- return std::trunc(in*(precision * 10)) / (precision * 10);
- }
Advertisement
Add Comment
Please, Sign In to add comment