Skip to content

Instantly share code, notes, and snippets.

@ruccho
ruccho / HungarianMatcher.cs
Created June 21, 2025 13:47
Allocation-less hungarian algorithm implementation written in C#
Span<float> cost = stackalloc float[16];
Span<float> tempCost = stackalloc float[16];
Span<int> result = stackalloc int[4];
var random = new Random();
for (var i = 0; i < 100; i++)
{
for (var j = 0; j < cost.Length; j++) cost[j] = random.NextSingle();
cost.CopyTo(tempCost);
@ruccho
ruccho / Generate SDF.lua
Created May 20, 2025 12:23
Aseprite script that generates SDF (Signed Distance Field)
----------------------------------------------------------------------
-- Generate SDF
--
-- It works only for RGB color mode.
----------------------------------------------------------------------
if app.apiVersion < 1 then
return app.alert("Unsupported version")
end
@ruccho
ruccho / STask.cs
Created October 24, 2024 15:36
minimum Task-like implementation only for single-thread use
using System.Runtime.CompilerServices;
using System;
using System.Collections.Generic;
using System.Threading;
namespace STask
{
[AsyncMethodBuilder(typeof(STaskMethodBuilder))]
public struct STaskVoid
{
@ruccho
ruccho / Disposable.cs
Last active October 1, 2024 09:03
The minimal implementation of pooled IDisposable.
#define THREADSAFE
using System;
using System.Collections.Generic;
using System.Threading;
public static class Disposable
{
public static Disposable<T> Create<T>(Action<T> dispose, T state)
{
@ruccho
ruccho / PbdStrip.cs
Created January 8, 2024 10:03
2D small-step XPBD strip implementation with bending constraint for Unity.
using System.Runtime.InteropServices;
using System.Threading;
using Unity.Burst;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
namespace Spring2D
{
@ruccho
ruccho / C932_net6.html
Created October 1, 2022 14:27
Shift_JIS table in Unity / .Net Framework 4.8 / .NET 6
<!DOCTYPE html>
<html>
<body>
<table>
<tr>
<th></th>
<th>0</th>
<th>1</th>
<th>2</th>
@ruccho
ruccho / InstAnime.cs
Last active March 12, 2022 07:33
UniTaskベースのコンパクトなアニメーションライブラリ。工事中
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Triggers;
using UnityEngine;
using UnityEngine.UI;
namespace InstAnime
{
public abstract class InstantAnimator : IDisposable
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace Ruccho.Utilities
{
public abstract class VolumeProfileExposition
{
public abstract void Update(VolumeProfile profile);
@ruccho
ruccho / PostProcessProfileExposition.cs
Last active May 29, 2021 07:57
PostProcessingStackのVolumeのパラメータをSerializeFieldとして露出し、Animatorなどで制御可能にするやつ
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
namespace Ruccho.Utilities
{
public abstract class PostProcessSettingsExposition
{
public abstract void Update(PostProcessProfile profile);
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Ruccho.Utilities
{
public class LockerSubject
{
public bool IsLocked => Keys.Count > 0;