BoxCutter

I was toying around with the testbed code of SVN174. Which contains the wonderful raycast function. I used it to create a boxcutter:
Image
Exe+Src: http://daid.webhop.net/pub/BoxCutter.zip

There are still a few bugs, it can create shapes which don't pass the assert tests. It also does not respect joints correctly, or bodies build from multiple shapes. But it might be a start if you want to create freeform destroyable solid objects.
This is
a cool idea !

😀
Looks cool. First time I've ever seen this error, after countless zip archives over the years -- it won't extract due to an unsupported compression method (tried 7-zip and winrar). What archive program are you using? I tried downloading a couple times with separate browsers too, so I don't think it's on my side.
kne wrote:
Looks cool. First time I've ever seen this error, after countless zip archives over the years -- it won't extract due to an unsupported compression method (tried 7-zip and winrar). What archive program are you using? I tried downloading a couple times with separate browsers too, so I don't think it's on my side.

Same problem here, on OS X (if it matters) - maybe try re-zipping with a different program?
God ****. I used winzip, I repacked it at work. Looks like the registered version I have there use defaults to an unsupported compression method. I've replaced it with a zip packed up with WinRar, that should work.
Neat. What's your algorithm for this? I had it freeze (infinite loop?) when I tried to cut a pentagon. Also I noticed you didn't set the velocities after cutting something moving (if it was falling and i cut it, it would have its velocity set to zero).
dc443 wrote:
Neat. What's your algorithm for this?
It's pretty simple, once you have the entry and exit points (gained by the raytrace function) you can compare each vertex of the shape with the dot product of the line between the entry and exit point.

This is the magic line:
Code:
if (b2Dot(b2Cross(localHitLoc2-localHitLoc1, 1), vertices[i]-localHitLoc1) > 0)

The cross product create a vector with a 90 degree angle compared to the entry and exit points, then the Dot product will be positive or negative depending on the location of the vertex of the shape.


Quote:
I had it freeze (infinite loop?) when I tried to cut a pentagon.
Yeah, I had the same yesterday. Not sure why, it might keep looping trough the "find exit point" code, cause that part sucks.

Quote:
Also I noticed you didn't set the velocities after cutting something moving (if it was falling and i cut it, it would have its velocity set to zero).
Oh, that should be an easy fix I guess. It's more of a proof of concept then finished code 😉


(Sidenote: seems like google 'safebrowsing' reports my site as malware serving. A little investigation shows that it does that for the whole "mine.nu" domain, which is one of the dyndns domains. Of I cannot find a single way to report this screw up to google, so ignore the warning for now, if you trust me 😉)
EDIT: I updated the URLs to point to a different domain (which points to the same IP) that solved this for now.
Works great and sure is fun to mess around with!

Hope you don't mind, but I ported it over to Python (to be included with pybox2d -- http://code.google.com/p/pybox2d/source/detail?r=72. Requires SVN build >= 72)
Daid wrote:
It's pretty simple, once you have the entry and exit points (gained by the raytrace function) you can compare each vertex of the shape with the dot product of the line between the entry and exit point.

This is the magic line:
Code:
if (b2Dot(b2Cross(localHitLoc2-localHitLoc1, 1), vertices[i]-localHitLoc1) > 0)

The cross product create a vector with a 90 degree angle compared to the entry and exit points, then the Dot product will be positive or negative depending on the location of the vertex of the shape.



Cool. I have to at some point look through my own breakage code to see if something like that is applicable anywhere....
kne wrote:
Hope you don't mind, but I ported it over to Python
of course I don't mind. That's the whole open source idea, together we make great things. I just had the idea, someone else can expand on that. (If someone uses it, adding someone to the "special thanks" creates warm fuzzy feelings inside 😉 )

But I might make an updated version, where I move the split code into the shape class, I think I noticed a private function in there that I could use to make my life easier.

Original thread: https://box2d.org/forum/viewtopic.php?t=1473