Skip to content

Instantly share code, notes, and snippets.

View dwilliamson's full-sized avatar

Don Williamson dwilliamson

View GitHub Profile
@dwilliamson
dwilliamson / Adjacency.cpp
Last active February 26, 2023 10:34
Simple, fast adjacency builder
struct Adjacency
{
struct Vertex
{
// Vertices are shared by a variable number of edges. This indexes the global EdgeRef array.
uint32_t edgeStartRef;
uint32_t nbEdges;
};
union EdgeRef
- Wednesday 25/07 ---------------------------------------------------------------
+ Thusrday (all-nighter!)
Fixed timer speeding up when wrapping.
Improved handling again (no longer get pulled to the side if the road has
any form of banking).
Replaced white texture allocation in the dreamcast renderer with a mini patch
on the stack, also deleted the big vertex buffer in the destructor.
struct GlobalHeapAllocator : public memAllocator
{
void* malloc(size_t size) override
{
return ::malloc(size);
}
void free(void* ptr) override
{
return ::free(ptr);
struct MEMORY_API memStackAllocatorBlock
{
memStackAllocatorBlock(uint32_t size)
: data_start(nullptr)
, data_end(nullptr)
, next(nullptr)
{
// Allocate block memory
data_start = (uint8_t*)::malloc(size);
data_end = data_start + size;
@dwilliamson
dwilliamson / MarchToSurface.cl
Created December 19, 2019 12:22
March To Surface
cmp_device_fn SamplePoint TryMarchToSurface(Texture3Du<short> tex_voxel_cache, RayMarch rm)
{
// Record an initial sample position for when locating the surface fails
SamplePoint initial_sample = rm.sample;
// Don't ray march if a normal couldn't be calculated
if (rm.ray_dir.x == (float)(1<<17))
return initial_sample;
// Want max traversal distance in terms of cells
# <pep8-80 compliant>
bl_info = {
"name": "Star mesh format (.starmesh)",
"author": "Don Williamson",
"version": (0, 1),
"blender": (2, 6, 3),
"location": "File > Import-Export > Star Mesh (.starmesh) ",
"description": "Import-Export Star Mesh",
#include "FunctionalPropertyModifiers.h"
void fpmCallStore::CallAll(double time)
{
for (auto i : m_FunctionCallMap)
{
const fpmFunctionCalls& calls = i->value;
calls.call_all_fn(i->key, calls, time);
@dwilliamson
dwilliamson / ConvexPolygon.cpp
Created July 1, 2019 15:53
2D Convex Hull Calculation
// REPLACE WITH STACK ALLOCATOR !!!
#include "ConvexPolygon.h"
#include <sdla/SDLWrap.h>
#include <algorithm>
// This is a non-randomised algorithm that sorts the input points so that each new point added
// to the convex polygon is outside the one already defined. Normally this would be grossly
// polygen.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define CHAR_VALUE(c, x, y) (c[y] & (1 << (7 - x)))
@dwilliamson
dwilliamson / TheNew.cpp
Created May 19, 2019 21:46
Command buffers
// LIB
using Buffer = std::vector<uint8_t>;
// LIB
struct Command
{
int size;
// NOTE: This *does not* need to be virtual - it's just the way std::function achieves it...
virtual void Call() = 0;