Skip to content

Commit

Permalink
fix: issue karimnaaji#9
Browse files Browse the repository at this point in the history
  • Loading branch information
“qwiff-dogg” committed Aug 30, 2022
1 parent 5679a2b commit fac8397
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions test/volume_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "../voxelizer.h"

TEST_CASE("Volume", "[volume]") {
static constexpr float PRECISION_FACTOR = 0.1f;
static constexpr float PRECISION_FACTOR = 0.f;

SECTION("Cube") {
static constexpr float VOXEL_SIZE = 0.5f;
Expand All @@ -28,8 +28,8 @@ TEST_CASE("Volume", "[volume]") {
SECTION("Bunny") {
static constexpr float VOXEL_SIZE = 0.01f;
static constexpr float PRECISION = VOXEL_SIZE * PRECISION_FACTOR;
static constexpr size_t SHELL_VOXELS = 975;
static constexpr size_t INTERIOR_VOXELS = 181;
static constexpr size_t SHELL_VOXELS = 828;
static constexpr size_t INTERIOR_VOXELS = 259;

auto* mesh = load_obj_mesh("example/models/bunny.obj");
REQUIRE(mesh != nullptr);
Expand Down Expand Up @@ -58,8 +58,8 @@ TEST_CASE("Volume", "[volume]") {
SECTION("Monkey") {
static constexpr float VOXEL_SIZE = 0.05f;
static constexpr float PRECISION = VOXEL_SIZE * PRECISION_FACTOR;
static constexpr size_t SHELL_VOXELS = 9220;
static constexpr size_t INTERIOR_VOXELS = 5709;
static constexpr size_t SHELL_VOXELS = 7765;
static constexpr size_t INTERIOR_VOXELS = 6556;

auto* mesh = load_obj_mesh("example/models/suzanne.obj");
REQUIRE(mesh != nullptr);
Expand Down Expand Up @@ -88,8 +88,8 @@ TEST_CASE("Volume", "[volume]") {
SECTION("Dragon") {
static constexpr float VOXEL_SIZE = 0.05f;
static constexpr float PRECISION = VOXEL_SIZE * PRECISION_FACTOR;
static constexpr size_t SHELL_VOXELS = 4495;
static constexpr size_t INTERIOR_VOXELS = 953;
static constexpr size_t SHELL_VOXELS = 4164;
static constexpr size_t INTERIOR_VOXELS = 882;

auto* mesh = load_obj_mesh("example/models/dragon.obj");
REQUIRE(mesh != nullptr);
Expand Down
4 changes: 2 additions & 2 deletions voxelizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ vx_mesh_t* vx_color_mesh_alloc(int nvertices, int nindices)

float vx__map_to_voxel(float position, float voxelSize, bool min)
{
float vox = (position + (position < 0.f ? -1.f : 1.f) * voxelSize * 0.5f) / voxelSize;
return (min ? floor(vox) : ceil(vox)) * voxelSize;
float vox = roundf(position / voxelSize);
return (min ? (vox - 1) : (vox + 1)) * voxelSize;
}

vx_vec3_t vx__vec3_cross(vx_vec3_t* v1, vx_vec3_t* v2)
Expand Down

0 comments on commit fac8397

Please sign in to comment.