Skip to content

Instantly share code, notes, and snippets.

View JSandusky's full-sized avatar

Jonathan Sandusky JSandusky

  • Ohio, United States
View GitHub Profile
@JSandusky
JSandusky / MotionControl.as
Created September 30, 2015 01:55
Animation motion controller
//=====================================
// MotionControl.as
//
// Controls animations based on the movements of a node:
// Automatically switches between strafing/forward/reverse/run/fall/jump
//=====================================
//=====================================
// class: AnimSet
//
animation
designer
allnoneselection() -> None :
C++ signature :
void allnoneselection()allnoneselection = <Boost.Python.function object at 0x000002027EA2C190>
arrayclone() -> None :
float ColorCurve::GetY(float pos) const
{
for (int i = 0; i < knots_.size() - 1; ++i)
{
Vec2 cur = knots_[i];
Vec2 next = knots_[i + 1];
if (pos >= cur.x && pos <= next.x)
{
float t = (pos - cur.x) / (next.x - cur.x);
@JSandusky
JSandusky / SphericalHarmonics.cpp
Created September 8, 2016 03:44
Urho3D Spherical Harmonics
//
// Copyright (c) 2008-2015 the Urho3D project.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
@JSandusky
JSandusky / DataInTheGraph.h
Last active September 14, 2016 20:35
Graph snippets
class Graph
{
Node* masterNode_;
std::vector<Node*> nodes_; // List of all of the contained nodes
std::vector<Node*> entryNodes_; // Nodes that are known to be possible points of entry
std::multimap<Socket*, Socket*> upstreamEdges_; // link edges that go right->left, input -> output, we only ever allow a single upstream edge - except for with flowControl
std::multimap<Socket*, Socket*> downstreamEdges_; // link edges that go left->right, output -> input, flow control sockets can only have 1 downstream edge
unsigned currentExecutionContext_;
}
@JSandusky
JSandusky / BasicDensityCalc.cl
Created December 3, 2016 04:00
OpenCL Naive Surface nets
// Fills a grid of density values, the grid is vertex based, so for a 64^3 cells the grid must be 65^3 to include the extra vertex for the last cell
// This code expects to be combined with other code for a "DensityFunc" before being compiled.
#define VERTEX_SIZE 65
int vertex_index(const int4 pos)
{
int x = clamp(pos.x, 0, VERTEX_SIZE - 1);
int y = clamp(pos.y, 0, VERTEX_SIZE - 1);
int z = clamp(pos.z, 0, VERTEX_SIZE - 1);
@JSandusky
JSandusky / UrhoResourceCache.cpp
Created May 24, 2017 02:06
Resource cache printing
#include "UrhoResourceCache.h"
#include <Urho3D/Core/Context.h>
#include <Urho3D/IO/FileSystem.h>
#include <Urho3D/Resource/ResourceCache.h>
#include <Urho3D/Core/StringUtils.h>
using namespace Urho3D;
namespace UrhoEditor
@JSandusky
JSandusky / Context.cs
Created November 20, 2017 05:59
Code generator for serialization code
// only included in case some of the ctx weirdness needs explanation
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
namespace SprueKit.Data
{
// When we have a broken path have to have a means to fix it
// Vector2 into Vector2 swizzles
public static Vector2 XX(this Vector2 v) { return new Vector2(v.X, v.X); }
public static Vector2 YX(this Vector2 v) { return new Vector2(v.Y, v.X); }
public static Vector2 YY(this Vector2 v) { return new Vector2(v.Y, v.Y); }
// Vector2 into Vector3 swizzles
public static Vector3 XXX(this Vector2 v) { return new Vector3(v.X, v.X, v.X); }
public static Vector3 XXY(this Vector2 v) { return new Vector3(v.X, v.X, v.Y); }
public static Vector3 XYX(this Vector2 v) { return new Vector3(v.X, v.Y, v.X); }
public static Vector3 XYY(this Vector2 v) { return new Vector3(v.X, v.Y, v.Y); }
public static Vector3 YXX(this Vector2 v) { return new Vector3(v.Y, v.X, v.X); }
@JSandusky
JSandusky / ParseSrc.txt
Created February 5, 2018 10:01
Graph helpers
// vmath = float, vector, matrix
// matrix = float3x3 or float4x4
// scalar = float, vector
// vector = float2, float3, float4
// any = int, float, float2, float3, float4, matrix, bool, object
//======================================================
// basic math
//======================================================
vmath radians(vmath value);