Code Monkey home page Code Monkey logo

voxelizer's People

Contributors

karimnaaji avatar mgerhardy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voxelizer's Issues

Missing some Voxel near of origin of scene

Hi.
For a project witch need to make fastly collisions for stages, I test yours solution to make voxels.

After getting the resulting point_cloud from yours functions, I add a algo to reduce the numbers of voxels by merging them into a Axis-Scaled-Voxel.
By trying to do this, I noticed there is some duplicate voxels (voxel on the same place because of float precisions : X.0002 vs Y.9999 , with Y = X -1).

The final result is I have some missing voxels, specially near of the plane Y=0, some with Z>0 and X>0. I temporaly solve the problem by using yours precision to be 20% of the voxel size.
But, that create more voxels we need, specially on walking objects.

So I search a little, I see a little mistake on the function vx__map_to_voxel() :

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;
}
The problem is if you have a something about y~=0.5, you want the AABB.minimum.y=0, but you have 0.0 or 1.0 depending of being just bottom or up of 0.5,
0.51 + 0.5 = 1.01 => 1.0 with floor
0.49999 + 0.5 = 0.9999 => 0.0 with floor.
In case of having 1.0 with floor, you get the reason why there is some voxel on the same place.
I give a example with Y, but X and Z are also impacted.

By adding +0.5, without the "is min" condition, just decal the trouble of float precision. (I know you want to deal with the fact for negative the floor() function don't give what you want).

As we want all possibles voxels (and the validation of them is done after), I propose this solution :
float vx__map_to_voxel(float position, float voxelSize, bool min)
{
float vox = roundf(position / voxelSize);
return (min ? (vox - 1) : (vox + 1)) * voxelSize;
}
forcing to have one more on each direction could be a time consumer, but here you will be sure you have all voxels for the test with the triangle,

As there is more voxel around, I think that could also solve the trouble about hole (whena vertex of triangle is near a limit of th 3D grid of voxels) , but I don't have a good example for this. So people may be could put the precision to 0.0 (the one to solve holes).

Have a good day.

Output quads instead of triangles?

I was tinkering with this today. Really neat project.

It would have been nice to be able to get quads in the generated output instead of just triangles.

I saw it had some todos - such as "Triangle face merging". Would that be related?

Warnings with clang 6

voxelizer.h:793:49: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                            vx_triangle_t t1 = {v1, v2, boxcenter, {0.0f, 0.0f, 0.0f}};
                                                ^~~~~~~~~~~~~~~~~
                                                {                }
voxelizer.h:794:49: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                            vx_triangle_t t2 = {v2, v3, boxcenter, {0.0f, 0.0f, 0.0f}};
                                                ^~~~~~~~~~~~~~~~~
                                                {                }
voxelizer.h:795:69: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                            vx_triangle_t t3 = {v3, v1, boxcenter, {0.0f, 0.0f, 0.0f}};
                                                                    ^~~~~~~~~~~~~~~~
                                                                    {               }
voxelizer.h:842:23: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    vx_vertex_t vs = {voxelsizex, voxelsizey, voxelsizez};
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      {                                 }
voxelizer.h:902:21: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    vx_vec3_t vs = {voxelsizex, voxelsizey, voxelsizez};
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    {                                 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.