Skip to content

Instantly share code, notes, and snippets.

View Cifram's full-sized avatar

Aubrey Powell Cifram

View GitHub Profile
@Cifram
Cifram / norm_to_cubic.rs
Last active April 12, 2022 02:28
Normal Vector to Cubic Map
let point_abs = point.abs();
// This giant if statement determines which face the point is on. Then, it
// returns the cosine of the x and y angle on that face (in fullx and fully)
// and the index of the face itself, in a tuple.
let (fullx, fully, face) =
if point_abs.x >= point_abs.y && point_abs.x > point_abs.z {
if point.x > 0.0 {
(
point.z / (point.x*point.x + point.z*point.z).sqrt(),
point.y / (point.x*point.x + point.y*point.y).sqrt(),
@Cifram
Cifram / results
Created January 3, 2015 04:43
Benchmarks for hash seed
test bench_perlin2 ... bench: 27 ns/iter (+/- 5)
test bench_perlin3 ... bench: 67 ns/iter (+/- 2)
test bench_perlin4 ... bench: 81 ns/iter (+/- 3)
test bench_simplectic2 ... bench: 40 ns/iter (+/- 5)
test bench_simplectic3 ... bench: 94 ns/iter (+/- 11)
test bench_simplectic4 ... bench: 188 ns/iter (+/- 7)
test bench_simplex2 ... bench: 45 ns/iter (+/- 5)
test bench_simplex3 ... bench: 107 ns/iter (+/- 12)
@Cifram
Cifram / benches.rs
Created January 3, 2015 04:33
Benchmark Black Boxing
// Copyright 2013 The noise-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
extern crate cgmath;
use self::cgmath::Matrix4;
use scene::MeshComponent;
macro_rules! scene(
($($comp_name:ident($comp_adder:ident, $comp_getter:ident, $comp_remover:ident, $comp_foreach:ident): $comp:ident),*) => (
pub struct Scene {
transforms: Vec<Option<Matrix4<f32>>>,