Skip to content

Instantly share code, notes, and snippets.

FYI anyone who's using Unreal Engine and want to get Flecs Explorer to show FString here's a serializer that i'm using.
Its probably not the best solution, but i just wanted to quickly debug some entities tonight and needed to just see FStrings visible & couldn't find anyone else who's suffered through this (which historically indicates its a mistake on my part)
// Begin defining how the ECS system should handle the Unreal `FString` component.
ECSWorld->component<FString>()
// Specify the internal representation type (flecs::String) used by Flecs for this FString component.
.opaque(flecs::String)
10:09 PM]m1GUNO: Rendering vs. ECS question (code structure): How should I integrate the rendering part of the code (e.g., via SDL) with the ECS part when it comes to drawing/rendering?
Option 1: Create a draw system that is one of the many systems in the ECS.
Option 2: Use the engine's normal draw/update method for drawing, and use a query/filter in this method.
Option 1 means that drawing is now coupled to the ECS ticks (unless using a separate tick source for the ECS?), whereas option 2 seems to be the way to intentionally decouple the ECS (which for me is more the physics/sim part) from the drawing/rendering.
[10:50 PM]dogbread: you can also run a different pipeline (= query for systems)
################################################################################################
[5:06 AM]Sander: Query variables are (currently) only supported for flecs::rule, so you'll have to pass one into a system, something like:
[5:51 AM]Sander: For system sets you can also do this (little known feature but can be useful):
flecs::entity s1 = world.system<A, B>()...;
flecs::entity s2 = world.system<A, B>()...;
flecs::entity s3 = world.system<A, B>()...;
flecs::entity p = world.prefab()
.add(s1).add(s2).add(s3);
p.disable(); // disables all systems
################################################################################################
@Jak-o-Shadows
Jak-o-Shadows / multiprocessing tqdm.py
Created April 14, 2022 13:14
multiprocessing tqdm
import multiprocessing
import tqdm
def unwrap(args):
return fcn(*args)
numProcesses = 8
with multiprocessing.Pool(numProcesses, maxtasksperchild = 60) as p:
for _ in tqdm.tqdm(p.imap(unwrap, args), total=len(args)):
pass
@Jak-o-Shadows
Jak-o-Shadows / main.py
Created April 5, 2021 04:06
GUI for displaying plots
import sys
import time
import numpy as np
from matplotlib.backends.qt_compat import QtCore, QtWidgets, QtGui
if QtCore.qVersion() >= "5.":
from matplotlib.backends.backend_qt5agg import (
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
else:
import os
import pandas as pd
import matplotlib.pyplot as plt
if __name__ == "__main__":
path_data = "path/to/your/data.csv"
df = pd.read_csv(path_data)
0,69.121,-10.006,69.121,-10.006
0.52632,64.133,-5.3841,64.133,-5.3841
0.52632,59.104,-0.45808,59.104,-0.45808
0.52632,53.974,4.805,53.974,4.805
0.52632,48.67,10.457,48.67,10.457
0.52632,43.093,16.577,43.093,16.577
0.52632,37.099,23.295,37.099,23.295
0.52632,30.441,30.826,30.441,30.826
0.52632,22.627,39.596,22.627,39.596
0.52632,12.236,50.706,12.236,50.706
EXTERN(vector_table)
ENTRY(reset_handler)
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K
}
SECTIONS
{
.text : {
@Jak-o-Shadows
Jak-o-Shadows / stm32
Created July 6, 2016 05:24
Help with my stm32f103c8t6 stuff
####################################### main.c ##############################################
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
/* Set STM32 to 24 MHz. */
static void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_24mhz();
/* Enable GPIOC clock. */
def chi2_col( chi2dof ):
"""
Function that takes a list of lists of chi2/dof's
Returns a list of same length depending on what the chi2/dof value was
chi2/dof <= 1.50 = green
1.50 < chi2/dof < 2 = yellow
chi2/dof >= 2 = red
"""