dabroz / csgjs-cpp Goto Github PK
View Code? Open in Web Editor NEWCSG library for C++, port of https://github.com/evanw/csg.js/
CSG library for C++, port of https://github.com/evanw/csg.js/
Line 377 in 76d7ff2
csgjs_vector pos;
csgjs_vector normal;
csgjs_vector uv;****
If I have a cube that has a uniform scale of 1.0 and perform a union with a smaller cube that only intersects with one plane (side) of the first cube, the opposite side of the first cube also ends up with added vertices despite having no intersection. Is there a way to restrain the algorithm to the plane or planes that intersect?
The splits seem OK on the faces that required splitting, so I feel the algorithm could be improved instead of adding any post functions to reduce excessive vertices on a plane.
Hi !
I experienced csgjs to get stuck in build trying to split one polygon against itself over and over because the coplanar test fails in splitPolygon() because of precision issues. I was able to enhance it by making epsilon larger. But what solved it for me was not trying to split the polygon against itself at all. So in csgjs_csgnode::build() I replaced
for (size_t i = 1; i < list.size(); i++)
me->plane.splitPolygon(list[i], me->polygons, me->polygons, list_front, list_back);
with
me->polygons.push_back(list[0]);
for (size_t i = 1; i < list.size(); i++)
me->plane.splitPolygon(list[i], me->polygons, me->polygons, list_front, list_back);
splitPolygons() would theoretically add the polygon list[0] to me->polygons if there weren't precision errors. So I just do this upfront and start with i = 1. I'm not sure if this breaks somethign else but it still looks good to me and I don't get these infinite loops.
I just want to say, thanks for this library, even if it's just a port from other language. You really saved me many hours of work (even though I already been struggling with CSG for past month). Because I found a bug in it - float variables makes too large meshes to crash on boolean operations - soon I will make some pull request to your library, even fork it with some examples. So for now - thanks from other Warsaw dweller! :) (I owe you a big beer)
Cheshire Cat
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.