Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
michaelbartnett / LICENSE.txt
Last active October 17, 2022 10:29
Tuple implementation for use with Unity3d
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@michaelbartnett
michaelbartnett / UnityApiUx.cs
Created February 5, 2016 23:40
particle system modules are weird
ParticleSystem ps = GetComponent<ParticleSystem>();
ps.enableEmission = false;
// warning CS0618: `UnityEngine.ParticleSystem.enableEmission' is obsolete: `enableEmission property is deprecated. Use emission.enable instead.'
ps.emission.enable = false;
// error CS1061: Type `UnityEngine.ParticleSystem.EmissionModule' does not contain a definition for `enable' and no extension method `enable' of type `UnityEngine.ParticleSystem.EmissionModule' could be found (are you missing a using directive or an assembly reference?)
ps.emission.enabled = false;
// error CS1612: Cannot modify a value type return value of `UnityEngine.ParticleSystem.emission'. Consider storing the value in a temporary variable

I think about wanting to play with one of the C/C++ killers (rust, nim, zig, odin, jai if it ever sees wide release, etc.) I get excited about many safety nets and advanced features I could benefit from. I <3 the comptime keyword in Zig

And then I think about the side projects I want to work on, and how so many involve C++-only libs or are made easier by using the C++ version of libs (i.e. ImGui, Wwise, bgfx) and I really don't want to spend my free time writing C wrappers to make ffi easier.

And then I think about how I want to work on either my macbook or my windows desktop, so just getting something going means spending time fucking around with the current crop of meta build systems because I can't stomach defaulting to cmake

And so rather than deal with this I go and watch anime or whatever.

It's the concept of "programming war crimes" yet again. How many interesting projects or research breakthroughs don't happen because the person who would have made them happen decided it wasn't worth the incident

@michaelbartnett
michaelbartnett / premake.lua
Created February 25, 2020 10:12
list of xcode warnings it complained about bc premake5's xcode generator is out of date
xcodeprojectopts {
-- MACOSX_DEPLOYMENT_TARGET="10.6",
-- -- ALWAYS_SEARCH_USER_PATHS = "YES",
-- ONLY_ACTIVE_ARCH = "YES",
-- ENABLE_TESTABILITY = "YES",
-- CLANG_WARN_INFINITE_RECURSION = "YES",
-- CLANG_WARN_UNREACHABLE_CODE = "YES",
-- GCC_WARN_UNUSED_FUNCTION = "YES",
@michaelbartnett
michaelbartnett / NullTest.cs
Last active July 30, 2019 15:35
unity null fun
using UnityEngine;
interface ISomeInterface
{
}
public class TestScript : MonoBehaviour, ISomeInterface
{
}
@michaelbartnett
michaelbartnett / .gitattributes
Created November 10, 2012 21:24
Git meta files for a Unity Project
*.meta -diff
*.asset -diff
*.unity -diff
#include <type_traits>
#include <cstdint>
#include <iostream>
template<typename T_ENUM>
class EnumFlags
{
static_assert(std::is_enum<T_ENUM>::value, "T_ENUM must be an enum type");
public:
@michaelbartnett
michaelbartnett / enumshit.cpp
Created February 6, 2019 09:38
enums with max and string
template<typename Enum>
constexpr Enum get_enum_max()
{
//static_assert(false, "missing get_enum_max implementation");
return ~0;
}
template<typename Enum>
const char *get_enum_member_name(Enum val);
// {
@michaelbartnett
michaelbartnett / better_narrowing.cpp
Last active January 17, 2019 11:02
truly horrible constepxr function template for narrowing numeric conversions. doesn't allow conversions between integral and floating point. -std=c++11 and -fno-exceptions compatible. the worst.
// what a mess
#if NDEBUG
template<typename TOut, typename TIn>
constexpr TOut narrowed(TIn&& inp) noexcept
{
return static_cast<TOut>(inp);
}
#define NARROWED(TOut, expr) static_cast<TOut>(expr)
#include <type_traits>
#include <assert>
// debug = gsl::narrow, release = gsl::narrow_cast
namespace util
{
template <class T, class U>
constexpr T narrowcast(U&& u) noexcept