Skip to content

Commit

Permalink
Removed unused linear_allocator.ts
Browse files Browse the repository at this point in the history
* Updated misc types
  • Loading branch information
LucasDower committed Nov 4, 2023
1 parent 1d051db commit a1d0fa1
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 84 deletions.
16 changes: 8 additions & 8 deletions Core/src/colour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,35 +221,35 @@ export namespace RGBAUtil {
}

export class OtS_Colours {
public static get BLACK() {
public static get BLACK(): RGBA {
return { r: 0.0, g: 0.0, b: 0.0, a: 1.0 };
}

public static get WHITE() {
public static get WHITE(): RGBA {
return { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
}

public static get RED() {
public static get RED(): RGBA {
return { r: 1.0, g: 0.0, b: 0.0, a: 1.0 };
}

public static get GREEN() {
public static get GREEN(): RGBA {
return { r: 0.0, g: 1.0, b: 0.0, a: 1.0 };
}

public static get BLUE() {
public static get BLUE(): RGBA {
return { r: 0.0, g: 0.0, b: 1.0, a: 1.0 };
}

public static get YELLOW() {
public static get YELLOW(): RGBA {
return { r: 1.0, g: 1.0, b: 0.0, a: 1.0 };
}

public static get CYAN() {
public static get CYAN(): RGBA {
return { r: 0.0, g: 1.0, b: 1.0, a: 1.0 };
}

public static get MAGENTA() {
public static get MAGENTA(): RGBA {
return { r: 1.0, g: 0.0, b: 1.0, a: 1.0 };
}
}
48 changes: 0 additions & 48 deletions Core/src/linear_allocator.ts

This file was deleted.

10 changes: 6 additions & 4 deletions Core/src/ots_block_mesh_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ export class OtS_BlockMesh_Converter {
let bestDistance = Infinity;
let bestCandidate: (string | null) = null;

const visibility = neighbourhood.getFaceVisibility(position.x, position.y, position.z);
if (visibility === null) {
return null;
}

for (const block of this._config.mode.data.blocks) {
const visibility = neighbourhood.getFaceVisibility(position.x, position.y, position.z);
if (visibility === null) {
return null;
}


const averageColour: RGBA = { r: 0, g: 0, b: 0, a: 0 };
{
Expand Down
24 changes: 0 additions & 24 deletions Core/tests/linear_allocator.test.ts

This file was deleted.

63 changes: 63 additions & 0 deletions Core/tests/ots_block_mesh_converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,66 @@ test('Per-block', () => {
expect(blockMesh.isBlockAt(2, 0, 0)).toBe(true);
expect(blockMesh.getBlockAt(2, 0, 0)?.name).toBe('BLUE-BLOCK');
});

test('Per-face', () => {
const voxelMesh = new OtS_VoxelMesh();
voxelMesh.addVoxel(0, 0, 0, OtS_Colours.RED);
voxelMesh.addVoxel(0, -1, 0, OtS_Colours.BLUE);
voxelMesh.addVoxel(1, 0, 0, OtS_Colours.BLUE);
voxelMesh.addVoxel(-1, 0, 0, OtS_Colours.BLUE);
voxelMesh.addVoxel(0, 0, 1, OtS_Colours.BLUE);
voxelMesh.addVoxel(0, 0, -1, OtS_Colours.BLUE);

const converter = new OtS_BlockMesh_Converter();
converter.setConfig({
mode: {
type: 'per-face', data: {
blocks: [
{
name: 'RED-TOP-BLOCK',
textures: {
up: 'RED',
down: 'BLACK',
north: 'BLACK',
south: 'BLACK',
east: 'BLACK',
west: 'BLACK',
},
},
{
name: 'BLUE-BLOCK',
textures: {
up: 'BLUE',
down: 'BLUE',
north: 'BLUE',
south: 'BLUE',
east: 'BLUE',
west: 'BLUE',
},
},
{
name: 'KINDA-RED-BLOCK',
textures: {
up: 'KINDA-RED',
down: 'KINDA-RED',
north: 'KINDA-RED',
south: 'KINDA-RED',
east: 'KINDA-RED',
west: 'KINDA-RED',
},
}
],
textures: {
'RED': OtS_Colours.RED,
'BLACK': OtS_Colours.BLACK,
'BLUE': OtS_Colours.BLUE,
'KINDA-RED': { r: 0.5, g: 0.0, b: 0.0, a: 1.0 },
},
}
},
});

const blockMesh = converter.process(voxelMesh);
expect(blockMesh.getBlockCount()).toBe(6);
expect(blockMesh.getBlockAt(0, 0, 0)?.name).toBe('RED-TOP-BLOCK');
});

0 comments on commit a1d0fa1

Please sign in to comment.