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
| // Draft only, untested, might contain errors!!! | |
| // Note: spin-lock implementation taken from https://en.cppreference.com/w/cpp/atomic/atomic_flag.html | |
| #include <atomic> | |
| #include <vector> | |
| template <class T> class ObjectPool { | |
| public: | |
| std::function<T*()> factory; |
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
| using UnityEngine; | |
| public class FpsCounter : MonoBehaviour | |
| { | |
| float prev = -1; | |
| float fps = 0; | |
| void Update() | |
| { | |
| var now = Time.realtimeSinceStartup; |
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
| // Origin: https://github.com/ivanfratric/polypartition | |
| // Commit: 5dcc93c9c023a2296610ec98539e2377f4285d30 | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Runtime.CompilerServices; | |
| using tppl_float = System.Double; | |
| using TPPLPolyList = System.Collections.Generic.LinkedList<TPPLPoly>; |
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
| function addOverlayImage(url, scale) { | |
| let e = document.createElement('img'); | |
| e.style.visibility = 'hidden'; | |
| e.src = url; | |
| let w, h, r = 0; | |
| function setSize() { | |
| if (r) { | |
| let winR = window.innerWidth / window.innerHeight; | |
| let s = scale * (r > winR ? window.innerWidth / w : window.innerHeight / h); | |
| e.width = w * s; |
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
| // Adapted from https://makandracards.com/makandra/46681-javascript-how-to-query-the-state-of-a-promise | |
| function promiseState(promise, callback) { | |
| const uniqueValue = /unique/; | |
| Promise.race([promise, Promise.resolve(uniqueValue)]) | |
| .then( | |
| (value) => callback(value === uniqueValue ? 'pending' : 'fulfilled'), | |
| (reason) => callback(`rejected (${reason})`)); | |
| } | |
| function debugPromiseState(promise) { | |
| promiseState(promise, (state) => { |