This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "math/vec.hpp" | |
| #include <vector> | |
| #include <array> | |
| #include <algorithm> | |
| #include <iostream> | |
| #include <cstdint> | |
| using namespace yks; | |
| template <typename T> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ogmo | |
| - Position | |
| - Sprite | |
| - Character animator | |
| - Box collider | |
| - Velocity | |
| - Gravity | |
| - Creature motion | |
| - Local player input | |
| Level blocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn alias(&self, name: &str) -> Flag { | |
| Flag { | |
| aliases: std::vec::append_one(self.aliases.to_owned(), name.to_owned()), | |
| ..self.clone() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]) | |
| ^~~~~ |