Skip to content

Instantly share code, notes, and snippets.

View intaxwashere's full-sized avatar
🏠
Working from home

Intax intaxwashere

🏠
Working from home
  • Türkiye
View GitHub Profile
@intaxwashere
intaxwashere / customthunkexample.md
Last active August 31, 2024 10:12
Custom Thunks Unreal Engine TL;DR

Custom thunks TL;DR

This smol post assumes you worked on a custom thunk implementation before but no idea how it works, why you're using cursed macros from 1990s etc. If you don't have any programming experience or relatively new to Unreal world, it's likely you might not understand anything from this post, not because concepts are too difficult to grasp, but rather because this post is written for the people who has an understanding of how Unreal works since a while and want to expand their knowledge of custom thunks implementation.

Part 1:

  • A thunk is a function that you can save and call later, so if you had an array of TFunction<void()>s, you would have an array of custom thunks that you can bind/unbind new function pointers to existing TFunctions.
  • Custom thunks of Blueprints are the same, they're a fancy array/list of function pointers. Imagine for each node you placed to graph, Blueprints have a place for that node in it's list of custom thunks. For example the + node in Blueprints that
/**
* A templated class for a priority queue implementation.
* The priority queue is a data structure that works like a standard queue but each element has a priority.
* The elements will be processed based on their priority (given by a comparison function), not based on their insertion order in the queue.
* Specifically, this priority queue uses a binary heap data structure.
*/
template<typename Type>
class IntaxPriorityQueue
{
using ComparatorType = bool(*)(const Type&, const Type&);
@intaxwashere
intaxwashere / YourProjectEditorModule.cpp
Last active April 25, 2024 11:01
Automatically adding category sections to editor
// add this code to your StartupModule() function of your EDITOR module
// if it doesnt work, try setting loading phase to "postdefault" -- no idea if this will produce side effects though.
// basically idea is looping all CDOs (i.e. UClasses) and their properties, getting their "category" meta value and registering them to
// property sections
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
static constexpr bool bAddSubcategories = false; // you probably want this to be false
auto ProcessCategory = [&PropertyModule](const FName ClassName, const FString& Category)
@intaxwashere
intaxwashere / gist:829f49e43d4ad27534dd65e285926d8e
Created November 19, 2022 05:24
Macro versions of set world transform fast path from MassSample
// macro version of static function if performance is very very very critical and you want to ensure function will be inlined.
#define SET_WORLD_TRANSFORM_FAST(InComp, InTransform) \
InComp->SetComponentToWorld(InTransform); \
InComp->UpdateBounds(); \
\
InComp->MarkRenderTransformDirty(); \
for (auto Component : InComp->GetAttachChildren()) \
{ \
InTransform = Component->GetRelativeTransform() * InTransform; \
\
@intaxwashere
intaxwashere / FunctionCallerObject.cpp
Last active March 20, 2022 22:04
Creating an instanced object to call UFUNCTIONs
void UFunctionCallerObject::Update()
{
if (CanUpdate() && IsValid(Function) && GetOuter())
{
GetOuter()->ProcessEvent(Function, nullptr);
}
}
#if WITH_EDITOR
void UFunctionCallerObject::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)