Skip to content

Instantly share code, notes, and snippets.

View crud89's full-sized avatar
2️⃣
#pragma twice

Carsten Rudolph crud89

2️⃣
#pragma twice
View GitHub Profile
@crud89
crud89 / PointCloud.cs
Created May 28, 2024 08:08
Varjo exerpimental point cloud reconstruction adapter for Unity.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using UnityEngine;
/// <summary>
/// A component that allows to capture point clouds through the experimental Varjo SDK.
/// </summary>
@crud89
crud89 / ranges_benchmark.cxx
Last active December 20, 2023 10:25
Benchmarking different ways to return ranges from functions in C++23.
//
// This benchmark compares different ways to return ranges from functions. As of today (Dec. 1st 2023), no compiler implements `std::generator`, so I used the reference implementation by Lewis Baker (see below).
//
// Most efficient is to simply return a reference to a range (naturally). However, this is also most restrictive since it does not
// allow any processing before returning.
// Processing the range before returning involves a copy, which can be inefficient for large ranges. I added a test without
// `std::ranges` for comparison, which is second fastest.
// `std::ranges` has a significant impact on runtime. Returning the view directly is most efficient in this case. However, this
// restricts the interface of the class owning the view. For example you might want to write an pure interface that does simply
// return "something iteratable", in which case you do not want to return a specific view directly, as it might not even be possible
@crud89
crud89 / CppCliDispose.cpp
Last active November 28, 2019 13:48
A small program that can be used to test the order of dispose/finalize calls for C++/CLI classes.
//#include "pch.h"
using namespace System;
public interface class IForceDisposable : IDisposable {
public:
property bool IsDisposed { bool get(); }
};
public ref class Base abstract : IForceDisposable {
@crud89
crud89 / opencv-remapper.cpp
Last active April 17, 2019 08:13
Small program that replaces pixels in an image with similar pixels of the same image. It does this in a multithreaded fashion and repeats itself multiple times with the purpose of investigating the footprint on repeatedly running a parallel loop with OpenCV. More detail here: https://stackoverflow.com/q/54466572/1254352 .
#include "stdafx.h"
#include <iostream>
#include <chrono>
#include <random>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
@crud89
crud89 / FindOpenEXR.cmake
Last active March 18, 2019 08:47
CMake find module to search OpenEXR import libraries and DLL's under Windows.
###################################################################################################
# adapted from FindOpenEXR.cmake in Pixar's USD distro.
#
# The original license is as follows:
#
# Copyright 2016 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it: