Skip to content

Instantly share code, notes, and snippets.

View yuriks's full-sized avatar

Yuri Kunde Schlesner yuriks

View GitHub Profile
@yuriks
yuriks / main.cpp
Created October 13, 2013 02:02
WIP Entity-Component system
#include "math/vec.hpp"
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <cstdint>
using namespace yks;
template <typename T>
Ogmo
- Position
- Sprite
- Character animator
- Box collider
- Velocity
- Gravity
- Creature motion
- Local player input
Level blocks
struct LightSample {
vec3 point;
float pdf;
};
vec3 uniform_vector_in_cone(float a, float b, float cos_angle) {
const float cos_theta = (1.0f - a) + a * cos_angle;
const float sin_theta = std::sqrt(1.0f - sqr(cos_theta));
const float phi = b * two_pi;
return mvec3(std::cos(phi) * sin_theta, cos_theta, std::sin(phi) * sin_theta);
use std::io::{File, SeekSet};
use std::num::min;
pub struct ChunkReader<'a> {
data_file: &'a mut File,
chunk_pos: i64,
chunk_start: i64,
chunk_end: i64,
}
2 yuriks@reinforce ~/projects/OpenVikings/tools-ng (git)-[master] % make :(
rustc -O -L ./lib --dep-info build/liblvtools-42c25618-0.0.rlib.d src/lvtools/lib.rs --out-dir lib/
src/lvtools/util.rs:56:17: 56:81 error: internal compiler error: Cannot relate bound region: ReScope(848) <= ReLateBound(803, BrNamed(syntax::ast::DefId{crate: 0u32, node: 833u32}, a))
This message reflects a bug in the Rust compiler.
We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
src/lvtools/util.rs:56 Req => Value(arg_iter.next().expect("Impossibly missing required argument.").clone()),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile:28: recipe for target 'lib/liblvtools-42c25618-0.0.rlib' failed
make: *** [lib/liblvtools-42c25618-0.0.rlib] Error 101
fn test_func() {
let flags = [
flag("--banana", "Desc").alias("-b").required().has_option(Required),
flag("--012345", "Desc").alias("-a").has_option(Required).default("20"),
flag("--kiwi", "Desc").alias("-k"),
flag("-p", "Desc").has_option(Optional).default("30"),
flag("-l", "Desc").has_option(Required).multiple(),
];
let params = [
parameter("foo", Required),
pub fn alias(&self, name: &str) -> Flag {
Flag {
aliases: std::vec::append_one(self.aliases.to_owned(), name.to_owned()),
..self.clone()
}
}
impl<'a> Flag {
pub fn alias(&'a mut self, name: &str) -> &'a mut Flag {
self.aliases.push(name.to_owned()); self
}
pub fn required(&'a mut self) -> &'a mut Flag {
self.is_required = Required; self
}
pub fn has_option(&'a mut self, required: IsRequired) -> &'a mut Flag {
impl Flag {
pub fn alias(mut self, name: &str) -> Flag {
self.aliases.push(name.to_owned()); self
}
pub fn required(mut self) -> Flag {
self.is_required = Required; self
}
pub fn has_option(mut self, required: IsRequired) -> Flag {
rustc -O --test --dep-info build/lib.rs.d src/lib.rs -o build/argparse-test
src/lib.rs:118:46: 118:51 error: cannot move out of `flags` because it is borrowed
src/lib.rs:118 handle_help(flags, params, argparse_args(flags, params, args.slice_from(1)), args[0])
^~~~~
src/lib.rs:118:17: 118:22 note: borrow of `(*flags)[]` occurs here
src/lib.rs:118 handle_help(flags, params, argparse_args(flags, params, args.slice_from(1)), args[0])
^~~~~