Skip to content

Instantly share code, notes, and snippets.

View nadult's full-sized avatar
😎

Krzysztof Jakubowski nadult

😎
View GitHub Profile
@nadult
nadult / !vector.h
Last active August 19, 2020 06:34
fwk::Vector: improves compilation speed of whole project by ~20%, decreases binary size by 50% (compared with std::vector)
// Copyright (C) Krzysztof Jakubowski <nadult@fastmail.fm>
// This file is part of libfwk. See license.txt for details.
#pragma once
#include "fwk/base_vector.h"
#include "fwk/span.h"
#include "fwk/sys_base.h"
namespace fwk {
// Prosta klasa parsera
// Jest oznaczona EXCEPT, to znaczy, że każda funkcja z tej klasy może rzucić wyjątek
class EXCEPT TextParser {
TextParser &operator>>(double &);
TextParser &operator>>(bool &);
...
};
struct Params {
string name;
// Prosta klasa parsera
// Jest oznaczona EXCEPT, to znaczy, że każda funkcja z tej klasy może rzucić wyjątek
class EXCEPT TextParser {
TextParser &operator>>(double &);
TextParser &operator>>(bool &);
...
};
struct Params {
string name;
@nadult
nadult / !csg.h
Last active February 9, 2020 10:37
CSG based on exact integer arithmetic
#pragma once
#include "gen_base.h"
#include "geom/immutable_graph.h"
#include "geom_base.h"
namespace geom {
// TODO: flagi (neutral jest niezależne od intersection & subtraction, addition niepotrzebne)
DEFINE_ENUM(CSGEdgeType, addition, intersection, subtraction, neutral);
@nadult
nadult / constrained_delaunay_triangulation.cpp
Last active March 28, 2019 18:48
Constrained delaunay triangulation
#include "geom/delaunay.h"
#include "geom/segment_grid.h"
#include "geom/voronoi.h"
#include "small_vector.h"
#include <fwk/math/direction.h>
#include <numeric>
#include "instantiator.h"
#include "investigate.h"
@nadult
nadult / hex_voxelizer.cpp
Last active February 9, 2020 09:38
Voxelizer based on hexagonal grid using rational arithmetic.
// This code turns 3D mesh into hexagonal-based voxel grid
// Most features should be preserved (algorithm is similar to Dual Contouring)
// Computations are performed on rational arithmetic to make it 100% robust
#include "vis/voxel_map.h"
#include "fwk_profile.h"
#include "geom/plane_graph.h"
#include "geom/plane_graph_builder.h"
#include "geom/visualizer.h"
class MTRand {
public:
typedef unsigned int u32;
MTRand(u32 s=5489) :p(0) {
for(int i=0;i<n;i++) state[i]=0;
seed(s);
}
void seed(u32 s) {
state[0] = s & 0xFFFFFFFFUL;
@nadult
nadult / sse_f32x4.hpp
Created November 3, 2013 11:59
SSE float wrapper class. Written in 2009.
#ifndef VECLIB_SSE_F32_H
#define VECLIB_SSE_F32_H
#include "sse/base.h"
class f32x4b;
class f32x4bn;
class f32x4
@nadult
nadult / navi_map.cpp
Created November 3, 2013 11:57
3D navigational heightmap from FreeFT. It allows to quickly find shortest (in most cases) paths between both static & dynamic objects. A* algorithm is utilized.
/* Copyright (C) 2013 Krzysztof Jakubowski <nadult@fastmail.fm>
This file is part of FreeFT.
FreeFT is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
FreeFT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@nadult
nadult / !texture_cache.hpp
Last active March 2, 2020 18:58
Class responsible for caching multiple small textures into few big ones. It allows to reduce number of glBindTexture calls and greatly improving performance on some cheaper hardware (integrated GPUs).
/* Copyright (C) 2013 Krzysztof Jakubowski <nadult@fastmail.fm>
This file is part of FreeFT.
FreeFT is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
FreeFT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the