khanghugo / gchimp

A collection of GoldSrc mapping tools in one application
GNU General Public License v3.0
7 stars 1 forks source link

Improve polygon/convex hull clipping algorithm #19

Open khanghugo opened 3 hours ago

khanghugo commented 3 hours ago

Works for most cases but the algorithm is pretty messy since it is very original.

Convex hull clipping algorithm is fine. Polygon clipping is not. If anything, convex hull clipping algorithm should be based on that polygon clipping. Right now, they are both different and independent.

khanghugo commented 3 hours ago

At the moment, polygon clipping algorithm is copied straight from ChatGPT (with tons of modification of course) but it doesn't quite work

7dd6c569afa0aaaa77f3615584be3bd0978976be

That is why there is this line

https://github.com/khanghugo/gchimp/blob/7dd6c569afa0aaaa77f3615584be3bd0978976be/src/modules/blender_lightmap_baker_helper.rs#L314-L316

Convex hull clipping algorithm looks like it works but the current problem is that the new face from result of clipping does not have sorted vertices. In the original algorithm generated by ChatGPT, it does not even account for that face (in another word, the algorithm is bogus along with explanation).