Skip to content

Instantly share code, notes, and snippets.

View techgeek1's full-sized avatar

Austin Rife techgeek1

  • Bay Area, CA
View GitHub Profile
@techgeek1
techgeek1 / techgeek1-links.md
Last active July 19, 2024 04:05
Resources for game and engine dev I've found while building Eden
/// AVX implementation of the Harley-Seal algorithm for counting the number of bits in a bitset
///
/// # Safety
/// Assumes that the input is `BITSET_SIZE_IN_WORDS` in length
pub unsafe fn cardinality(bitset: &[u64]) -> usize {
debug_assert!(bitset.len() == BITSET_SIZE_IN_WORDS);
let d = bitset.as_ptr() as *const Register;
@techgeek1
techgeek1 / thunk.rs
Created April 26, 2019 20:09
A lazily evaluated value store
use std::cell::Cell;
/// A thunk used for lazy generation and caching of values
struct Thunk<T: Copy> {
/// Cached value stored in the thunk
value: Cell<Option<T>>,
/// Generator function to generate a missing value
generator: fn() -> T
}
@techgeek1
techgeek1 / hibitset_mem_calc.rs
Created December 22, 2018 00:55
Calculator to determine the approximate memory space required for a hierarchical bitvector of a specified size
const COUNT: i32 = 500_000;
const BLOCK_SIZE: i32 = 1024;
fn main() {
let mut count = COUNT;
let mut block_count = 0;
let mut layer_count = 1;
while count > BLOCK_SIZE {
let blocks = (count as f32 / (BLOCK_SIZE as f32)).ceil() as i32;
@techgeek1
techgeek1 / ecs_iteration_idea.rs
Created September 18, 2018 17:11
Testing ideas for iterating the intersection of entities with a specified subset of components in a system
extern crate rand; // 0.5.5
use std::default::Default;
use rand;
macro_rules! declare_components {
($($name:ident),*) => {
$(
struct $name {
pub value: i32
@techgeek1
techgeek1 / ecs_test_2.rs
Last active September 16, 2018 15:38
Attempt two at an ecs api. This time encoding as much data in the type system as possible via associated types
#![feature(const_fn, const_type_id)]
#[macro_use]
mod macros {
macro_rules! foreach_permutation {
($action:ident!(), $type:ident) => {
$action!($type);
};
($action:ident!(), $type_lead:ident, $($type:ident),*) => {
$action!($type_lead, $($type),*);
@techgeek1
techgeek1 / ecs_test.rs
Created September 12, 2018 00:32
Attempt at one API for ECS system/component declaration
use std::any::TypeId;
macro_rules! depends_on {
($($type:ty),*) => {
fn dependencies(&self) -> &'static [TypeId] {
$(<$type as System>::__assert_is_system();)*
&[$(TypeId::of::<$type>()),*]
}
}
@techgeek1
techgeek1 / .gitignore
Created July 17, 2018 15:32
Custom gitignore for Unity
# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
/[Bb]uild/
/[Ll]ibrary/
# ======================================== #
# Visual Studio / Android Studio generated #
@techgeek1
techgeek1 / .gitattributes
Created July 17, 2018 15:30
.gitattributes with LFS setup for Unity
# Audio
*.wav filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
# Models
*.obj filter=lfs diff=lfs merge=lfs -text
*.dae filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
*.mat filter=lfs diff=lfs merge=lfs -text
@techgeek1
techgeek1 / vector3.rs
Created March 28, 2018 23:38
Vector3 implementation in rust
use std::ops::*;
#[derive(Copy, Clone)]
struct Vector3 {
x: f32,
y: f32,
z: f32
}
#[allow(dead_code)]