Skip to content

Instantly share code, notes, and snippets.

View dwilliamson's full-sized avatar

Don Williamson dwilliamson

View GitHub Profile
Removed all domain mapping code:
* There isn't a single mapping function that will uniformly map voxels to the sphere. The best mapping is perfect on the centre of each cube face, but as they get closer to each other, they skew significantly. They also change size! This is an unacceptable compromise simply to allow Minecraft-style editing of the world.
* All complexity is off-loaded the clients in that they have to continuously map between domains. This makes stuff like the SVO, sculpting, normal calculations and any voxel reasoning of the world (e.g. voxel based AO or lighting), much much harder (and slower).
* I would still need to build a system that can host 6 octrees with 1 per face and seamlessly tessellate between them.
* The entire thing is completely non-intuitive and just an extra thing to remember that will trip me up constantly when working with this system.
There needs to be another solution...
@dwilliamson
dwilliamson / gist:4666484
Created January 29, 2013 18:38
Erm... something's a little broken...
rend::Voxel svo::GetVoxel(Database& db, NodeData& node_data, const math::vec3i& voxel_index)
{
013017A0 55 push ebp
013017A1 8B EC mov ebp,esp
return LookupVoxel(db, node_data, voxel_index);
013017A3 8B 45 14 mov eax,dword ptr [voxel_index]
013017A6 50 push eax
013017A7 8B 4D 10 mov ecx,dword ptr [node_data]
013017AA 51 push ecx
013017AB 8B 55 0C mov edx,dword ptr [db]
@dwilliamson
dwilliamson / gist:5509314
Last active December 16, 2015 22:48
What is new_value?
struct Type
{
Type(float value) : value(value);
operator float() const { return value; }
float value;
};
Type t(1.5f);
float new_value = true ? t : 1;
@dwilliamson
dwilliamson / Dirty C++ tricks
Created December 3, 2013 12:12
Assuming all functions that receive a pointer must assert-check for null... Container can define members that are references, require no assert checks and yet don't require dependent types to be included at the point of definition.
//
// Oh dear!
//
struct Container
{
Container();
~Container();
struct DependentTypeA& a;
@dwilliamson
dwilliamson / How I like my C++ math interfaces
Created December 13, 2013 12:47
Can be a little tedious on the fingers (actually, who am I kidding - I rarely modify stuff that it's a pleasure to dip back into a simple set of interfaces now and again).
// ----- math.h --------------------------------------
namespace math
{
// Simple types with exposed data members, no constructors and multiple addressing modes
// No templates in the public API
struct quatf
{
union
@dwilliamson
dwilliamson / VS and PS 1.0-1.4 Compile-time Shader Assembler
Last active January 4, 2016 02:39
This allowed you to composite shader fragments at runtime using compile-time assembled shader instructions, within DX8. Common technique at the time was to composite using strings/sprintf and use the D3D API to compile at runtime. I found that hideous and slow :) Examples of use are given at the bottom of the file in VShaderFragments.h One of th…
// =====================================================================================================================
// Assembler.h
// =====================================================================================================================
// COMPILE-TIME SHADER ASSEMBLER
#ifndef _INCLUDED_ASSEMBLER_H
I already have this separation:
*CmpActionSelect*: C++ native component that controls which action is active for the entity.
*ActionSelectWindow*: Javascript browser class that displays an action select HUD.
Whenever *CmpActionSelect* does something, it needs to tell *ActionSelectWindow* to update. I have these options:
1. Finish complete object replication feature that allows Javascript code to inspect native objects. *ActionSelectWindow* then periodically polls state of *CmpActionSelect* or reacts to specific object/property changes remotely.
2. Send RPC messages from *CmpActionSelect* to *ActionSelectWindow* whenever new actions are selected.
3. Create an intermediate native component that reacts to event changes in *CmpActionSelect* and sends RPC messages to *ActionSelectWindow*.
@dwilliamson
dwilliamson / gist:9336903
Created March 3, 2014 23:30
Another minor trick to keep header inclusions down
// Assume a header file with a container of items
// Container.h
// -------------------------------------------------
#include <vector>
// Forward-declared to avoid included header file
struct Item;
struct Container
{
#
# Correcting Art of Assembly's flawed acos implementation in Chapter 14
# http://flint.cs.yale.edu/cs422/doc/art-of-asm/pdf/CH14.PDF
#
import math
# Alias commonly used math functions
@dwilliamson
dwilliamson / cuda_error_lookup.cpp
Created May 9, 2014 17:00
CUDA error lookup with clReflect
const char* cudaGetErrorEnum(cudaError_t error)
{
const clcpp::Enum* enum_type = clcpp::GetType<cudaError_t>()->AsEnum();
for (u32 i = 0; i < enum_type->constants.size; i++)
{
const clcpp::EnumConstant* constant = enum_type->constants[i];
if (constant->value == error)
return constant->name.text;
}