Skip to content

Instantly share code, notes, and snippets.

@keijiro
keijiro / ExpEase.cs
Created April 28, 2011 23:02
Exponential easing out utility for Unity
// Example:
//
// currentPos = ExpEase.Out(currentPos, targetPos, -4.0);
//
// or
//
// ExpEase.Out2(currentPos, targetPos, -4.0); // This modifies currentPos.
//
using UnityEngine;
@ChemiKhazi
ChemiKhazi / EnumFlagAttribute.cs
Created April 29, 2014 09:59
Unity3d property drawer for automatically making enums flags into mask fields in the inspector.
using UnityEngine;
public class EnumFlagAttribute : PropertyAttribute
{
public string enumName;
public EnumFlagAttribute() {}
public EnumFlagAttribute(string name)
{
@Alexanderallenbrown
Alexanderallenbrown / pydugoff.py
Last active January 4, 2024 11:49
simply python/numpy Dugoff tire model
from numpy import *
from matplotlib.pyplot import *
# A Dugoff Tire model implementation in python/numpy
#Alexander Brown, Ph.D.
# brownaa@lafayette.edu
class DugoffTire:
""" This python class implements the Dugoff tire model based on friction coefficients, cornering stiffnesses.
Forces are applied in same sign as slip angle, so be aware of this when you implement.
@1995eaton
1995eaton / regex_utils.cc
Created April 21, 2015 04:46
Regex Utils for C++11
#include <iostream>
#include <algorithm>
#include <vector>
#include <regex>
std::regex::flag_type parse_flags(const std::string& flag_str) {
std::regex::flag_type grammar = std::regex::ECMAScript;
std::regex::flag_type flags = grammar ^ grammar;
for (const auto& c: flag_str) {
switch (c) {
using UnityEngine;
using UnityEditor;
using System.Reflection;
using Type = System.Type;
public class InlineCurveEditor
{
private object curveEditor;
private Type curveType;
@podgorskiy
podgorskiy / FrustumCull.h
Created July 12, 2017 10:33
Ready to use frustum culling code. Depends only on GLM. The input is only bounding box and ProjectionView matrix. Based on Inigo Quilez's code.
#include <glm/matrix.hpp>
class Frustum
{
public:
Frustum() {}
// m = ProjectionMatrix * ViewMatrix
Frustum(glm::mat4 m);
@aras-p
aras-p / example.shader
Created May 31, 2019 05:23
DX10 HLSL style textures and samplers in Unity
// Example of using DX10-style HLSL texture and sampler objects in
// Unity shaders
Shader "Unlit/Example"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
@jeffvella
jeffvella / RaycastUnderPointerSystem.cs
Created July 16, 2019 07:18
Unity Physics in ECS Raycasting
using BovineLabs.Entities.Systems;
using Unity.Burst;
using Unity.Entities;
using Unity.Jobs;
using Unity.Collections;
using Unity.Physics;
using Unity.Physics.Systems;
using UnityEngine;
[UpdateAfter(typeof(BuildPhysicsWorld)), UpdateBefore(typeof(EndFramePhysicsSystem))]
@travisstaloch
travisstaloch / fields.zig
Last active May 12, 2024 23:19
zig iterate over struct fields and print
const std = @import("std");
test "fields" {
const U1s = packed struct {
a: u1,
b: u1,
c: u1,
};
const x = U1s{ .a = 1, .b = 0, .c = 0 };
@memononen
memononen / biasgaininf.c
Last active February 2, 2022 10:09
bias gain inflection point
float evalCurve(float x, float tx, float ty, float sa, float sb)
{
const float EPS = 1e-6f;
if (x < tx) {
return (ty * x) / (x + sa * (tx - x) + EPS);
} else {
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f;
}
}