Skip to content

Instantly share code, notes, and snippets.

View trentpolack's full-sized avatar

Trent Polack trentpolack

View GitHub Profile
@trentpolack
trentpolack / EnumerationType.h
Last active September 23, 2024 12:16
Enumerations in Unreal Engine 4
// Generally, developers in UE4 tend towards the following convention for enumerations:
UENUM( BlueprintType )
enum class ENoiseGeneratorCellularType : uint8
{
NGCT_Natural UMETA( DisplayName = "Natural" ),
NGCT_Euclidean UMETA( DisplayName = "Euclidean" ),
NGCT_Manhattan UMETA( DisplayName = "Manhattan" ),
NGCT_Max UMETA( Hidden )
};
@trentpolack
trentpolack / AccessorMacroGenerators.h
Last active January 26, 2018 19:48
Unreal Engine 4 -- Member Accessor Method Macros (NOTE: This does not result in the accessors being available for blueprint-use as they're not UFUNCTIONs).
// NOTE: This does not result in the accessors being available for blueprint-use as they're not UFUNCTIONs.
UCLASS( )
class URawr : public UObject
{
GENERATED_CLASS( )
protected:
float RawrValue;
@trentpolack
trentpolack / MovementComponent_TrentsHighlights.cpp
Last active August 4, 2024 09:42
The "Fun" to be had (i.e. a big rant) in writing a general-purpose physical movement component (compound colliders representing static and skeletal meshes and more, but still interacting with the world as a physical entity). NOTE: All comments in this gist are by me.
// Comments are left by me, not from the code.
// Because why not have a default set or make the method abstract or, really, anything but this. Luckily no one would ever
// think to use ::GetMaxSpeed as a divisor or anything.
inline float UMovementComponent::GetMaxSpeed() const
{
return 0.f;
}
// FUN FACT: UMovementComponent defines a plethora of methods for managing the maximum speed of a component. It does not,
@trentpolack
trentpolack / Fun With Macros.md
Last active July 18, 2019 19:13
Old-School #pragma Messages to Yourself

The Ol' #pragma Message

For particularly necessary to-do reminders, the JM_TODO macro below will print to the build console (and on the warning/error list) as a trivial warning -- so it won't interfere with builds that treat warnings as errrors. Then you can just double-click it and jump to that spot.

jmtodo-in-action

The Code

#define JM_PRAGMA_STRING2(x) #x
#define JM_PRAGMA_STRING(x) JM_PRAGMA_STRING2(x)
@trentpolack
trentpolack / UE4EditorViewLocation.cpp
Created July 6, 2018 01:07
Get the actual camera location in the UE4 viewport? MAYBE?
auto world = GetWorld();
if(world == nullptr)
return;
auto viewLocations = world->ViewLocationsRenderedLastFrame;
if(viewLocations.Num() == 0)
return;
FVector camLocation = viewLocations[0];
@syoyo
syoyo / gist:831c4b1926aa88c0da9221211723da2d
Created December 17, 2018 13:12
C++ implementaion of "A simple method to construct isotropic quasirandom blue noise point sequences"
//
// C++ implementaion of "A simple method to construct isotropic quasirandom blue
// noise point sequences"
//
// http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/
//
// Assume 0 <= x
static double myfmod(double x) { return x - std::floor(x); }