Skip to content

Commit

Permalink
Merge pull request #109 from LucasDower/0.7.1
Browse files Browse the repository at this point in the history
0.7.1 Hotfix
  • Loading branch information
LucasDower committed Feb 10, 2023
2 parents 86a23ea + 2135d2f commit ba161ad
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "objtoschematic",
"private": true,
"version": "0.7.0",
"version": "0.7.1",
"description": "A tool to convert .obj files into voxels and then into Minecraft Schematic files",
"main": "./dist/src/main.js",
"engines": {
Expand Down
9 changes: 5 additions & 4 deletions src/block_mesh.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fs from 'fs';

import { Atlas, TAtlasBlock } from './atlas';
import { AtlasPalette, EFaceVisibility } from './block_assigner';
import { BlockInfo } from './block_atlas';
Expand Down Expand Up @@ -163,8 +161,11 @@ export class BlockMesh {
ProgressManager.Get.progress(taskHandle, index / grassLikeBlocksBuffer.length);
const examined = grassLikeBlocksBuffer[index];
const examinedBlock = this._blocks[examined.id];
const topBlockId = this._blocks.findIndex((b) => b.voxel.position.equals(Vector3.add(examinedBlock.voxel.position, new Vector3(0, 1, 0))));
if (topBlockId > -1 && !AppRuntimeConstants.Get.TRANSPARENT_BLOCKS.includes(this._blocks[topBlockId].blockInfo.name)) {

const topBlockPosition = Vector3.add(examinedBlock.voxel.position, new Vector3(0, 1, 0));
const topBlockIndex = this._voxelMesh.getVoxelIndex(topBlockPosition);

if (topBlockIndex !== undefined && !AppRuntimeConstants.Get.TRANSPARENT_BLOCKS.includes(this._blocks[topBlockIndex].blockInfo.name)) {
const block = atlasPalette.getBlock(examined.voxelColour, nonGrassLikeBlockCollection, examined.faceVisibility, examined.errWeight);
examinedBlock.blockInfo = block;
this._blocks[examined.id] = examinedBlock;
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AppConfig {

private constructor() {
this.RELEASE_MODE = true;
this.RELEASE_VERSION = '0.7.0r';
this.RELEASE_VERSION = '0.7.1r';
this.VOXEL_BUFFER_CHUNK_SIZE = 5_000;

const configFile = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'config.json'), 'utf8');
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export class AppRuntimeConstants {
this.TRANSPARENT_BLOCKS = JSON.parse(transparentBlocksString).transparent_blocks;

const emissiveBlocksString = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'emissive_blocks.json'), 'utf-8');
this.GRASS_LIKE_BLOCKS = JSON.parse(emissiveBlocksString).emissive_blocks;
this.EMISSIVE_BLOCKS = JSON.parse(emissiveBlocksString).emissive_blocks;

const grassLikeBlocksString = fs.readFileSync(PathUtil.join(AppPaths.Get.resources, 'grass_like_blocks.json'), 'utf-8');
this.EMISSIVE_BLOCKS = JSON.parse(grassLikeBlocksString).grass_like_blocks;
this.GRASS_LIKE_BLOCKS = JSON.parse(grassLikeBlocksString).grass_like_blocks;
}
}
14 changes: 11 additions & 3 deletions src/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export class Texture {
}
}

private _correctTexcoord(a: number) {
if (Number.isInteger(a)) {
return a > 0.5 ? 1.0 : 0.0;
}
const frac = Math.abs(a) - Math.floor(Math.abs(a));
return a < 0.0 ? 1.0 - frac : frac;
}

/**
* UV can be in any range and is not limited to [0, 1]
*/
Expand All @@ -114,13 +122,13 @@ export class Texture {
uv.u = clamp(inUV.u, 0.0, 1.0);
uv.v = clamp(inUV.v, 0.0, 1.0);
} else {
uv.u = Math.abs(inUV.u) - Math.floor(Math.abs(inUV.u));
uv.v = Math.abs(inUV.v) - Math.floor(Math.abs(inUV.v));
uv.u = this._correctTexcoord(inUV.u);
uv.v = this._correctTexcoord(inUV.v);
}
ASSERT(uv.u >= 0.0 && uv.u <= 1.0, 'Texcoord UV.u OOB');
ASSERT(uv.v >= 0.0 && uv.v <= 1.0, 'Texcoord UV.v OOB');
uv.v = 1.0 - uv.v;

const diffuse = (interpolation === 'nearest') ?
this._getNearestRGBA(this._image, uv) :
this._getLinearRGBA(this._image, uv);
Expand Down

0 comments on commit ba161ad

Please sign in to comment.