Skip to content

Instantly share code, notes, and snippets.

@shelllee
shelllee / trim
Created December 6, 2017 04:05
trim for std::string c++11
// https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
#include <algorithm>
#include <cctype>
#include <locale>
// trim from start (in place)
static inline void ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
return !std::isspace(ch);
@shelllee
shelllee / SpiralBlurCustomDepth
Created November 14, 2017 11:20 — forked from tomlooman/SpiralBlurCustomDepth
Spiral Blur modified to sample Custom depth buffer for soft object outlines.
float3 CurColor=0;
float2 NewUV = UV;
int i=0;
float StepSize = Distance / (int) DistanceSteps;
float CurDistance=0;
float2 CurOffset=0;
float SubOffset = 0;
float TwoPi = 6.283185;
float accumdist=0;
@shelllee
shelllee / ASMutator_WeaponReplacement.cpp
Created November 14, 2017 10:01 — forked from tomlooman/ASMutator_WeaponReplacement.cpp
Test Gist: ASMutator_WeaponReplacement
bool ASMutator_WeaponReplacement::CheckRelevance_Implementation(AActor* Other)
{
ASWeaponPickup* WeaponPickup = Cast<ASWeaponPickup>(Other);
if (WeaponPickup)
{
for (int32 i = 0; i < WeaponsToReplace.Num(); i++)
{
const FReplacementInfo& Info = WeaponsToReplace[i];
if (Info.FromWeapon == WeaponPickup->WeaponClass)
@shelllee
shelllee / imgui_node_graph_test.cpp
Created April 12, 2016 09:50 — forked from ocornut/imgui_node_graph_test.cpp
Node graph editor basic demo for ImGui
// Creating a node graph editor for ImGui
// Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff.
// Better version by @daniel_collin here https://gist.github.com/emoon/b8ff4b4ce4f1b43e79f2
// See https://github.com/ocornut/imgui/issues/306
// v0.02
// Animated gif: https://cloud.githubusercontent.com/assets/8225057/9472357/c0263c04-4b4c-11e5-9fdf-2cd4f33f6582.gif
// NB: You can use math functions/operators on ImVec2 if you #define IMGUI_DEFINE_MATH_OPERATORS and #include "imgui_internal.h"
// Here we only declare simple +/- operators so others don't leak into the demo code.
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }