Guest User

Untitled

a guest
Apr 22nd, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. /****************** HEADER ******************/
  2. #pragma once
  3.  
  4. #include "Kismet/BlueprintFunctionLibrary.h"
  5. #include "BlueprintNode_TruncatePrecision.generated.h"
  6.  
  7. UCLASS()
  8. class ARDUINO_API UBlueprintNode_TruncatePrecision : public UBlueprintFunctionLibrary
  9. {
  10.     GENERATED_BODY()
  11.    
  12.     static UFUNCTION(BlueprintPure, meta = (DisplayName = "Truncate Floats with int fixed past coma precision", CompactNodeTitle = "Trunc", Keywords = "truncate floats precision"), Category = "Personal Blueprint Nodes")
  13.     float TruncatePrecision(float in, int precision);
  14. };
  15.  
  16.  
  17. /****************** CPP ******************/
  18. #include "Arduino.h"
  19. #include "BlueprintNode_TruncatePrecision.h"
  20. #include <cmath>
  21.  
  22. /** Truncate Precision Blueprint Node Code **/
  23. UFUNCTION(BlueprintPure, meta = (DisplayName = "Truncate Floats with precision", CompactNodeTitle = "Trunc", Keywords = "truncate floats precision"), Category = "PersonalBlueprintNodes")
  24. float UBlueprintNode_TruncatePrecision::TruncatePrecision(float in, int precision)
  25. {
  26.     return std::trunc(in*(precision * 10)) / (precision * 10);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment