Skip to content

Instantly share code, notes, and snippets.

View trentpolack's full-sized avatar

Trent Polack trentpolack

View GitHub Profile
@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];
@trentpolack
trentpolack / WebGL-frameworks-libraries.md
Created June 2, 2018 23:04 — forked from dmnsgn/WebGL-WebGPU-frameworks-libraries.md
A collection of WebGL frameworks and libraries

A non-exhaustive list of WebGL frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are outdated/not maintained anymore.

Engines and libraries

  • three.js: JavaScript 3D library
  • stack.gl: an open software ecosystem for WebGL, built on top of browserify and npm.
  • PixiJS: Super fast HTML 5 2D rendering engine that uses webGL with canvas fallback
  • Pex: Pex is a javascript 3d library / engine allowing for seamless development between Plask and WebGL in the browser.
  • Babylon.js: a complete JavaScript framework for building 3D games with HTML 5 and WebGL
  • AwayJS: AwayJS is a graphics library for javascript written in typescript
  • SceneJS: An extensible WebGL-based engine for high-detail 3D visualisation
@trentpolack
trentpolack / typemap
Last active February 9, 2023 10:44
Perforce Typemap (UE4-focused)
# Perforce File Type Mapping Specifications.
#
# TypeMap: a list of filetype mappings; one per line.
# Each line has two elements:
#
# Filetype: The filetype to use on 'p4 add'.
#
# Path: File pattern which will use this filetype.
#
# See 'p4 help typemap' for more information.
@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 / MovementComponent_TrentsHighlights.cpp
Last active December 26, 2022 12:21
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 / MechPartDataBase.h
Last active July 3, 2018 22:29
A sample data structure and its corresponding UE4 object for easy JSON serialization/deserialization.
// FMechPartDataBase Data Structure.
// This structure is solely for serialization/deserialization purposes (it gets transferred to the UObject instance after that process is done).
USTRUCT( )
struct FMechPartDataBase_SerializationStructure
{
GENERATED_BODY( )
public:
FMechPartDataBase_SerializationStructure( )
: ConfigName( NAME_None )
@trentpolack
trentpolack / HoudiniEngineRuntime.Build.cs
Last active December 31, 2017 18:15
Houdini Engine for Unreal (Improved Path Handling on Windows)
// [GIST NOTE] Added at the bottom of the existing class (for editor and runtime).
// Check the system environment variables for HOUDINI_PATH (instead of just hard-coded path searching like the default plugin does).
public static bool GetHoudiniPath( int PluginVersionMajor, int PluginVersionMinor, int PluginVersionPatch, out string HoudiniPathOut )
{
string version = null;
// Do the easy check: an environment variable I recommend to people (trent, 12/31/17).
HoudiniPathOut = System.Environment.GetEnvironmentVariable("HOUDINI_PATH", System.EnvironmentVariableTarget.User);
if ( !string.IsNullOrEmpty( HoudiniPathOut ) )
@trentpolack
trentpolack / WorstThing.h
Last active December 27, 2017 22:58
Getting around a series of annoying issues (C++'s existence and UE4's syntactical quirks) through a lambda-as-function-pointer-with-arguments.
// Structure to define a lambda object, return type, and any arguments to pass into the lambda expression upon execution.
template< typename O, typename R, typename ... A >
struct LambdaExpression
{
O _object;
R( O::*_function )( A... ) const;
LambdaExpression( const O & object )
: _object( object ), _function( &decltype( _object )::operator() )
{ }
@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 / EnumerationType.h
Last active June 7, 2021 18:30
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 )
};