Skip to content

Instantly share code, notes, and snippets.

View danielytics's full-sized avatar
🚰

Dan Kersten danielytics

🚰
  • Dublin, Ireland
View GitHub Profile
@danielytics
danielytics / Metaverse.md
Created July 22, 2023 12:53
GPT-4’s evaluation of the Metaverse concept

Pros of Metaverse:

  1. Enhanced Social Connectivity: Opportunities to interact and form communities on a global scale.
  2. Shared Ownership: Potential for users to own digital assets and control their virtual environments.
  3. Integration & Interoperability: Potential for experiences and assets to seamlessly exist across different platforms.
  4. Immersive Experiences: More engaging and interactive digital experiences.
  5. Decentralization: Aims to democratize power and control over virtual spaces.

Cons of Metaverse:

  1. Implementation Challenges: Significant technical hurdles to achieve interoperability and scalability.
  2. Unclear Economic Incentives: Financial benefits for users and platform providers are not fully clarified or realized.
#ifndef __STBTTF_HPP__
#define __STBTTF_HPP__
#include <SDL.h>
#include "stb_rect_pack.h"
#include "stb_truetype.h"
/* STBTTF: A quick and dirty SDL2 text renderer based on stb_truetype and stdb_rect_pack.
* Benoit Favre 2019
void mergeEntity (entt::registry& source_registry, entt::registry& destination_registry, entt::entity source_entity, entt::entity destination_entity, bool overwrite_components)
{
for(auto [id, source_storage]: source_registry.storage()) {
auto destination_storage = destination_registry.storage(id);
if (destination_storage != nullptr && source_storage.contains(source_entity)) {
if (! destination_storage->contains(destination_entity)) {
destination_storage->emplace(destination_entity, source_storage.get(source_entity));
// If destination already contains the component, then either skip or "overwrite"
} else if (overwrite_components) {
destination_storage->erase(destination_entity);
using storage_type = typename entt::storage_traits<entt::entity, MyComponent::storage_type;
storage_type::const_iterable g_iterable;
storage_type::const_iterable::const_iterator g_iterator;
extern "C" void setup ()
{
const auto& storage = registry.storage<MyComponent>();
g_iterable = storage.each();
g_iterator = g_iterable.begin();
@danielytics
danielytics / entt_polystorage.hpp
Created March 28, 2022 14:52
entt polystorage based registry and entity copy
#pragma once
#include <entt/core/utility.hpp>
#include <entt/entity/poly_storage.hpp>
#include <cstring>
enum OnComponentCollision {
Replace,
Skip,
};
@danielytics
danielytics / frame_buttons.txt
Created September 27, 2021 11:31
UGEE M708 V2 raw input samples
003:014:002:STREAM 1632742116.042551
02 F0 01 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742116.278540
02 F0 00 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742117.102424
02 F0 02 00 00 00 00 00 00 00 00 00
003:014:002:STREAM 1632742117.342543
@danielytics
danielytics / benchmark.cpp
Last active August 27, 2021 02:57
std::regex benchmark
#include <string>
#include <regex>
#include <iostream>
#include <random>
#include <vector>
#include "plf_nanotimer.h"
bool find_regex (const std::string& input)

Compile with:

clang++ -std=c++11 main.cpp -o assignment

Compile tests with:

clang++ -std=c++11 main.cpp -o assignment -DTESTS

Run with:

@danielytics
danielytics / also_working.cpp
Created June 8, 2021 15:49
EnTT poly_storage registry copying
#include <iostream>
#include <entt/entity/registry.hpp>
struct A {
};
struct B {
int x;
@danielytics
danielytics / copy_entity.cpp
Created April 18, 2021 23:53
EnTT copy entity from one registry to another, from discord, saving for later
entt::entity EntityLayout::Build(entt::registry& reg, entt::hashed_string entName)
{
auto ConfigIt = g_entityConfigs.find(entName);
if (ConfigIt == g_entityConfigs.end())
{
return entt::null;
}
const EntityConfig& config = (*ConfigIt).second;
if (config.protoEnt_ == entt::null)
{