gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
631 stars 49 forks source link

Torus knot X Torus intersections are incorrect #11

Closed gkjohnson closed 2 years ago

gkjohnson commented 2 years ago

image

gkjohnson commented 2 years ago

Similar happens with sphere:

image

gkjohnson commented 2 years ago

It seems that edge intersections are not being found somehow:

image

gkjohnson commented 2 years ago

Shows up with low complexity (0) sphere and torus:

image

at this position:

brush2.position.set( -0.5500082923892159, 0.7015423371475576, 0 );
brush2.scale.setScalar( 1 );
gkjohnson commented 2 years ago
image
            new THREE.Triangle(
                new THREE.Vector3( -0.800000011920929, 9.797174158936853e-17, 0 ),
                new THREE.Vector3( -0.4000000059604645, -0.6928203105926514, 0 ),
                new THREE.Vector3( -0.30000001192092896, -0.5196152329444885, 0.20000000298023224 ),
            ),
            new THREE.Triangle(
                new THREE.Vector3( -0.731643925500216, -0.1074746654349924, 0.5690170025825501 ),
                new THREE.Vector3( -1.1377935363772531, -0.1074746654349924, 0.01 ),
                new THREE.Vector3( -0.5500082923892159, -0.29845766285244235, 0.010000000000000116 ),
            )
gkjohnson commented 2 years ago

Looks like it works in three-mesh-bvh, though...

Next steps: log the intersection checks

image
gkjohnson commented 2 years ago

Looks like this is a bug in bvhcast. Returning that the bounds always intersect results in correct results:

image
gkjohnson commented 2 years ago

Fixed in https://github.com/gkjohnson/three-mesh-bvh/pull/437