Skip to content

Instantly share code, notes, and snippets.

View rms80's full-sized avatar

Ryan Schmidt rms80

View GitHub Profile
@rms80
rms80 / gist:771761c98dc96f17383cff63f754e2b2
Created December 9, 2016 16:20
profiling different ways to represent vector3f in C#
class vector1
{
public float x, y, z;
public vector1(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
public float this[int key]
{
get { return (key == 0) ? x : (key == 1) ? y : z; }
set { if (key == 0) x = value; else if (key == 1) y = value; else z = value; }
}
}
@rms80
rms80 / gist:67f0a6164b701241f889dcf776530864
Created April 20, 2017 16:52
func to generate borders of HUDShapes
public static fCurveGameObject MakeBackgroundMeshBorder(HUDShape Shape, float LineWidth, Colorf LineColor)
{
if (Shape.Type == HUDShapeType.Disc) {
fCircleGameObject go = GameObjectFactory.CreateCircleGO("border", Shape.Radius, LineColor, LineWidth);
go.SetSteps(Shape.Slices);
return go;
} else if (Shape.Type == HUDShapeType.Rectangle) {
List<Vector3f> Vertices = new List<Vector3f>() {
new Vector3f(-Shape.Width / 2, 0, -Shape.Height / 2),
new Vector3f(Shape.Width / 2, 0, -Shape.Height / 2),
@rms80
rms80 / gist:58e0cc959027ddbb57056ac9317b814c
Created May 15, 2017 18:46
vsmac install failure log
[2017-05-13 03:13:20.112] [Info] Installation ID: 14d6dc45-bf24-45fe-a790-c834d82648df
[2017-05-13 03:13:20.114] [Info] Operating system: Mac OS X v10.11.6 (10.11.6; Mac OS X 10.11.6 (10.11.6 build version: 15G1217)), 64-bit
[2017-05-13 03:13:20.115] [Info] Installer product: Visual Studio
[2017-05-13 03:13:20.115] [Info] Installer version: 4.0.0.308 (HEAD detached at 1d420fd9) (1d420fd9f355adc77406dc2ec9677b6c2bd7ff14 on 11/05/2017 13:22:51)
[2017-05-13 03:13:20.115] [Info] Status: in progress
[2017-05-13 03:13:21.161] [Debug] Waiting for manifests to finish downloading.
[2017-05-13 03:13:21.161] [Debug] Initial task executing (WaitingForActivation). Waiting for it to finish.
[2017-05-13 03:13:21.368] [Info] Retrieving installation manifest.
[2017-05-13 03:13:21.368] [Info] Downloading from 'https://www.xamarin.com/installer_assets/v3/vsmac/1d420fd9f355adc77406dc2ec9677b6c2bd7ff14/Mac/Universal/InstallationManifest.xml'.
[2017-05-13 03:13:21.369] [Debug] Setting download timeout for 'https://www.xamarin.com/
@rms80
rms80 / gist:d5a654be7a98af7e4370c50f545c63e7
Created May 23, 2017 19:26
eigensolver test matrices
// make wilkinson matrix
int N = 7;
double[] matrix = new double[] {
3, 1, 0, 0, 0, 0, 0,
1, 2, 1, 0, 0, 0, 0,
0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 1, 1, 1, 0,
0, 0, 0, 0, 1, 2, 1,
// Tool that should be immediately applied on Activation.
// Not clear how to end it though...don't know hand!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using g3;
float voxelSize = 1.0f;
DMeshSO meshSO = CotangentUI.ActiveScene.FindSceneObjectsOfType<DMeshSO>()[0];
AxisAlignedBox3f bounds = meshSO.GetTransformedBoundingBox();
bounds.Expand(2*voxelSize);
Vector3i gridSize = (Vector3i)(bounds.Diagonal / voxelSize);
Bitmap3d bitmap = new Bitmap3d(gridSize);
foreach ( Vector3i idx in bitmap.Indices() ) {
@rms80
rms80 / grab_latest_submodules.bat
Created November 10, 2017 19:17
update each submodule to most recent commit to master branch
REM grab latest commits from server
git submodule update --recursive --remote
REM above command will set current branch to detached HEAD. set back to master.
git submodule foreach git checkout master
REM now do pull to fast-forward to latest commit
git submodule foreach git pull origin master
@rms80
rms80 / gist:c1512d32e9f8ea6ce539801ef111bbf2
Created April 13, 2018 03:16
MeshInsertUVPolyCurve debugging code
// at top of Apply()
DMesh3 saveMesh = new DMesh3(Mesh);
insert_corners();
DMesh3 pokedMesh = new DMesh3(Mesh);
// to append segments to pokedMesh (in si loop)
MeshEditor.AppendLine(pokedMesh, new Segment3d(Mesh.GetVertex(i0_vid), Mesh.GetVertex(i1_vid)), 0.003f);
@rms80
rms80 / gist:11f680a32bd36b3c82ef572bb3c18982
Created July 4, 2018 16:58
Setting face colors in mesh shader
//int N = 256;
//Texture2D tex = new Texture2D(N, N, TextureFormat.RFloat, false);
//float[] buffer = new float[N * N];
//foreach (int tid in startMesh.TriangleIndices()) {
// int v = tid / N;
// int u = tid % N;
// int n = 0;
// Vector3d c = startMesh.GetTriCentroid(tid);
// if (c.x > startMesh.CachedBounds.Center.x)
@rms80
rms80 / gist:daec2304f44ea344486669b7e404e4c0
Last active October 19, 2020 02:01
Monte Carlo Walk-on-Spheres sampling of a vector field defined on mesh surfaces
// Copyright Ryan Schmidt 2020
// Released under the terms of the Boost License: https://www.boost.org/LICENSE_1_0.txt
static FVector ComputeMonteCarloVectorFieldSample(
FDynamicMesh3& Mesh,
FDynamicMeshAABBTree3& AABBTree,
FVector3d FixedDirection, // target fixed direction. This will be projected onto mesh normals to create vector field that is interpolated
FVector3d WorldPosition, // position we want to sample at
int NumSamples, // How many monte-carlo paths to compute and average
float Epsilon, // path is terminated when we are within Epsilon of boundary constraints (ie mesh)