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
| package main | |
| import "core:fmt" | |
| import "core:math" | |
| import "core:math/linalg" | |
| import rl "vendor:raylib" | |
| main :: proc() { | |
| rl.SetConfigFlags({.VSYNC_HINT, .WINDOW_RESIZABLE, .MSAA_4X_HINT}) | |
| rl.InitWindow(800, 600, "collision") |
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
| // Port of some collision functions to Odin by Jakub Tomšů. | |
| // | |
| // from Real-Time Collision Detection by Christer Ericson, published by Morgan Kaufmann Publishers, © 2005 Elsevier Inc | |
| // | |
| // This should serve as an reference implementation for common collision queries for games. | |
| // The goal is good numerical robustness, handling edge cases and optimized math equations. | |
| // The code isn't necessarily very optimized. | |
| // | |
| // There are a few cases you don't want to use the procedures below directly, but instead manually inline the math and adapt it to your needs. | |
| // In my experience this method is clearer when writing complex level queries where I need to handle edge cases differently etc. |
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
| #+vet shadowing unused | |
| package morton | |
| import "base:intrinsics" | |
| // https://fgiesen.wordpress.com/2022/09/09/morton-codes-addendum/ | |
| // https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ | |
| @(require_results) | |
| morton_encode_2d_u8 :: proc "contextless" (p: [2]u8) -> u16 #no_bounds_check { |
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
| /* | |
| The examples on the front page of odin-lang.org aren't very good. | |
| This is my proposal for a new replacement. The following examples | |
| should introduce most of the core language features. | |
| They were written with C, Go and Python programmers in mind. | |
| I've tried to make the code relatively similar to what one | |
| would write in practice in a real project, while keeping the line |
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
| /* | |
| Odin core:math/linalg benchmarking code | |
| Primarily optimizes 3xf32 math in -o:speed mode! | |
| However I spent a lot of effort ensuring the code doesn't get significantly slower | |
| in non-optimized builds. | |
| The results can looks something like this (-o:speed, amd64 skylake) | |
| NAME | Cycles/Elem | Total Cycles | Ms | Speedup |
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
| package curves | |
| Curve_Kind :: enum u8 { | |
| Linear, | |
| Bezier, | |
| Hermite, | |
| Catmull_Rom, | |
| B_Spline, | |
| } |
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
| // Bindings for qoa.h | |
| package cqoa | |
| foreign import lib "qoa.lib" | |
| RECORD_TOTAL_ERROR :: true | |
| MIN_FILESIZE :: 16 | |
| MAX_CHANNELS :: 8 |
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
| package import_scan | |
| import "core:strings" | |
| import "core:strconv" | |
| import "core:path/filepath" | |
| import "core:fmt" | |
| import "core:os/os2" | |
| import "core:odin/ast" | |
| import "core:odin/parser" | |
| import "core:odin/tokenizer" |
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
| package foo | |
| import "base:intrinsics" | |
| import "core:math" | |
| import "core:fmt" | |
| import "core:time" | |
| // https://www.desmos.com/calculator/i17pexccum | |
| a: f32 = 1.0 |
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
| // Micro-fmt | |
| // | |
| // Extremely stripped down `core:fmt` alternative. | |
| // Supports only %s, %f, %i, %x, %% | |
| // NOTE: curly braces don't need to be doubled ({{ and }}) like in `core:fmt` | |
| // | |
| // By Jakub Tomšů | |
| package ufmt | |
| import "base:runtime" |
NewerOlder