mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Adding new 2D visual logging shapes
This commit is contained in:
parent
b9f9657cc0
commit
f7c6bc20dc
25
Source/StevesUEHelpers/Private/StevesVisualLogger.cpp
Normal file
25
Source/StevesUEHelpers/Private/StevesVisualLogger.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "StevesVisualLogger.h"
|
||||||
|
#include "VisualLogger/VisualLogger.h"
|
||||||
|
|
||||||
|
|
||||||
|
void FStevesVisualLogger::InternalPolyLogfImpl(const UObject* Object,
|
||||||
|
const FLogCategoryBase& Category,
|
||||||
|
ELogVerbosity::Type Verbosity,
|
||||||
|
const TArray<FVector>& Points,
|
||||||
|
const FColor& Color,
|
||||||
|
const uint16 Thickness)
|
||||||
|
{
|
||||||
|
const FName CategoryName = Category.GetCategoryName();
|
||||||
|
|
||||||
|
SCOPE_CYCLE_COUNTER(STAT_VisualLog); \
|
||||||
|
UWorld *World = nullptr; \
|
||||||
|
FVisualLogEntry *CurrentEntry = nullptr; \
|
||||||
|
if (FVisualLogger::CheckVisualLogInputInternal(Object, CategoryName, Verbosity, &World, &CurrentEntry) == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EVisualLoggerShapeElement::Path doesn't support a label, so description is always blank
|
||||||
|
CurrentEntry->AddElement(Points, CategoryName, Verbosity, Color, "", Thickness);
|
||||||
|
|
||||||
|
}
|
122
Source/StevesUEHelpers/Public/StevesVisualLogger.h
Normal file
122
Source/StevesUEHelpers/Public/StevesVisualLogger.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
class STEVESUEHELPERS_API FStevesVisualLogger
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
static void InternalPolyLogfImpl(const UObject* LogOwner,
|
||||||
|
const FLogCategoryBase& Category,
|
||||||
|
ELogVerbosity::Type Verbosity,
|
||||||
|
const TArray<FVector>& Points,
|
||||||
|
const FColor& Color,
|
||||||
|
const uint16 Thickness);
|
||||||
|
|
||||||
|
|
||||||
|
static void InternalPolyLogf(const UObject* LogOwner,
|
||||||
|
const FLogCategoryBase& Category,
|
||||||
|
ELogVerbosity::Type Verbosity,
|
||||||
|
const FVector& Center,
|
||||||
|
const FVector& UpAxis,
|
||||||
|
const float OuterRadius,
|
||||||
|
const float InnerRadius,
|
||||||
|
const int NumPoints,
|
||||||
|
const FColor& Color,
|
||||||
|
const uint16 Thickness)
|
||||||
|
{
|
||||||
|
|
||||||
|
const bool bIsStar = !FMath::IsNearlyEqual(OuterRadius, InnerRadius);
|
||||||
|
|
||||||
|
const FQuat Rotation = FQuat::FindBetweenNormals(FVector::UpVector, UpAxis);
|
||||||
|
const FVector YAxis = Rotation.RotateVector(FVector::YAxisVector);
|
||||||
|
|
||||||
|
const int Count = bIsStar ? NumPoints * 2 : NumPoints;
|
||||||
|
const float RotInc = UE_TWO_PI / Count;
|
||||||
|
TArray<FVector> Vertices;
|
||||||
|
// Start
|
||||||
|
Vertices.Add(Center + YAxis * OuterRadius);
|
||||||
|
for (int i = 1; i < Count; ++i)
|
||||||
|
{
|
||||||
|
const float Scale = bIsStar && (i % 2) != 0 ? InnerRadius : OuterRadius;
|
||||||
|
const FQuat Rot = FQuat(UpAxis, RotInc * i);
|
||||||
|
const FVector V = Center + Rot.RotateVector(YAxis * Scale);
|
||||||
|
Vertices.Add(V);
|
||||||
|
}
|
||||||
|
// End
|
||||||
|
Vertices.Add(Center + YAxis * OuterRadius);
|
||||||
|
|
||||||
|
InternalPolyLogfImpl(LogOwner, Category, Verbosity, Vertices, Color, Thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void TriangleLogf(const UObject* LogOwner, const FLogCategoryBase& Category, ELogVerbosity::Type Verbosity, const FVector& Center, const FVector& UpAxis, const float Radius, const FColor& Color, const uint16 Thickness)
|
||||||
|
{
|
||||||
|
InternalPolyLogf(LogOwner, Category, Verbosity, Center, UpAxis, Radius, Radius, 3, Color, Thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SquareLogf(const UObject* LogOwner, const FLogCategoryBase& Category, ELogVerbosity::Type Verbosity, const FVector& Center, const FVector& UpAxis, const float Radius, const FColor& Color, const uint16 Thickness)
|
||||||
|
{
|
||||||
|
InternalPolyLogf(LogOwner, Category, Verbosity, Center, UpAxis, Radius, Radius, 4, Color, Thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PolyLogf(const UObject* LogOwner, const FLogCategoryBase& Category, ELogVerbosity::Type Verbosity, const FVector& Center, const FVector& UpAxis, const float Radius, const int NumPoints, const FColor& Color, const uint16 Thickness)
|
||||||
|
{
|
||||||
|
InternalPolyLogf(LogOwner, Category, Verbosity, Center, UpAxis, Radius, Radius, NumPoints, Color, Thickness);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StarLogf(const UObject* LogOwner, const FLogCategoryBase& Category, ELogVerbosity::Type Verbosity, const FVector& Center, const FVector& UpAxis, const float OuterRadius, const float InnerRadius, const int NumPoints, const FColor& Color, const uint16 Thickness)
|
||||||
|
{
|
||||||
|
InternalPolyLogf(LogOwner, Category, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, Thickness);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#if ENABLE_VISUAL_LOG
|
||||||
|
|
||||||
|
// 2D Triangle shape
|
||||||
|
#define UE_VLOG_TRIANGLE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color) if(FVisualLogger::IsRecording()) FStevesVisualLogger::TriangleLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, Color, 0)
|
||||||
|
#define UE_CVLOG_TRIANGLE(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_TRIANGLE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, 0);}
|
||||||
|
#define UE_VLOG_TRIANGLE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness) if(FVisualLogger::IsRecording()) FStevesVisualLogger::TriangleLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, Color, Thickness)
|
||||||
|
#define UE_CVLOG_TRIANGLE_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_TRIANGLE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness);}
|
||||||
|
|
||||||
|
// 2D Square shape
|
||||||
|
#define UE_VLOG_SQUARE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color) if(FVisualLogger::IsRecording()) FStevesVisualLogger::SquareLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, Color, 0)
|
||||||
|
#define UE_CVLOG_SQUARE(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_SQUARE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, 0);}
|
||||||
|
#define UE_VLOG_SQUARE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness) if(FVisualLogger::IsRecording()) FStevesVisualLogger::SquareLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, Color, Thickness)
|
||||||
|
#define UE_CVLOG_SQUARE_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_SQUARE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color, Thickness);}
|
||||||
|
|
||||||
|
// 2D poly shape
|
||||||
|
#define UE_VLOG_POLY(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color) if(FVisualLogger::IsRecording()) FStevesVisualLogger::PolyLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, NumPoints, Color, 0)
|
||||||
|
#define UE_CVLOG_POLY(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_POLY(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color, 0);}
|
||||||
|
#define UE_VLOG_POLY_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color, Thickness) if(FVisualLogger::IsRecording()) FStevesVisualLogger::PolyLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, Radius, NumPoints, Color, Thickness)
|
||||||
|
#define UE_CVLOG_POLY_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color, Thickness) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_POLY_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color, Thickness);}
|
||||||
|
|
||||||
|
// 2D star shape
|
||||||
|
#define UE_VLOG_STAR(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color) if(FVisualLogger::IsRecording()) FStevesVisualLogger::StarLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, 0)
|
||||||
|
#define UE_CVLOG_STAR(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_STAR(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, 0);}
|
||||||
|
#define UE_VLOG_STAR_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, Thickness) if(FVisualLogger::IsRecording()) FStevesVisualLogger::StarLogf(LogOwner, CategoryName, ELogVerbosity::Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, Thickness)
|
||||||
|
#define UE_CVLOG_STAR_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, Thickness) if(FVisualLogger::IsRecording() && Condition) {UE_VLOG_STAR_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color, Thickness);}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define UE_VLOG_TRIANGLE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_CVLOG_TRIANGLE(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_VLOG_TRIANGLE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_CVLOG_TRIANGLE_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
|
||||||
|
// Square shape
|
||||||
|
#define UE_VLOG_SQUARE(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_CVLOG_SQUARE(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_VLOG_SQUARE_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
#define UE_CVLOG_SQUARE_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, Color)
|
||||||
|
|
||||||
|
// 2D poly shape
|
||||||
|
#define UE_VLOG_POLY(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color)
|
||||||
|
#define UE_CVLOG_POLY(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color)
|
||||||
|
#define UE_VLOG_POLY_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color)
|
||||||
|
#define UE_CVLOG_POLY_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, Radius, NumPoints, Color)
|
||||||
|
|
||||||
|
// Any 2D star shape
|
||||||
|
#define UE_VLOG_STAR(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color)
|
||||||
|
#define UE_CVLOG_STAR(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color)
|
||||||
|
#define UE_VLOG_STAR_THICK(LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color)
|
||||||
|
#define UE_CVLOG_STAR_THICK(Condition, LogOwner, CategoryName, Verbosity, Center, UpAxis, OuterRadius, InnerRadius, NumPoints, Color)
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user