qbism / q2tools-220

Quake 2 map compiler tools with v220 map support, automatic phong, enhancements, and fixes.
GNU General Public License v2.0
61 stars 20 forks source link

Surface cracks in visible geometry (regression?) #33

Closed RaZeR-RBI closed 1 year ago

RaZeR-RBI commented 1 year ago

I've encountered disappearing triangles bug with recent versions of the compiler. After bisecting, the offending commit seems to be b23900e6c14237dbb5900cfd74d45f2cd89abf00.

Before that commit everything is good:

Screenshot

On this commit (and on the current version) the result looks like this:

Screenshot

Here's how it looks in the editor (TrenchBroom):

Screenshot

A sample map for reproduction:

``` // Game: Quake 2 // Format: Quake2 // entity 0 { "classname" "worldspawn" "_tb_textures" "textures/e1u1;textures/testing" // brush 0 { ( -512 -64 -16 ) ( -512 -63 -16 ) ( -512 -64 -15 ) e1u1/florr2_8 0 0 0 1 1 ( -64 -512 -16 ) ( -64 -512 -15 ) ( -63 -512 -16 ) e1u1/florr2_8 0 0 0 1 1 ( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) e1u1/florr2_8 0 0 0 1 1 ( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) e1u1/florr2_8 0 0 0 1 1 ( 64 512 16 ) ( 65 512 16 ) ( 64 512 17 ) e1u1/florr2_8 0 0 0 1 1 ( 512 64 16 ) ( 512 64 17 ) ( 512 65 16 ) e1u1/florr2_8 0 0 0 1 1 } // brush 1 { ( -209 133 96 ) ( -209 101 96 ) ( -209 101 16 ) e1u1/florr1_2 0 0 0 -1 1 ( -189 81 96 ) ( -177 69 62 ) ( -177 69 16 ) e1u1/florr1_2 0 0 179.99998 -1 -1 ( -193 149 16 ) ( -193 149 96 ) ( -209 133 96 ) e1u1/florr1_2 0 0 180 -1 -1 ( -177 69 62 ) ( -145 69 50 ) ( -145 69 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -145 69 16 ) ( -129 117 16 ) ( -145 133 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -169 141 96 ) ( -151 87 96 ) ( -189 81 96 ) e1u1/florr1_2 0 0 -179.99998 -1 -1 ( -189 81 96 ) ( -139 86 91 ) ( -177 69 62 ) e1u1/florr1_2 -3.0517578e-05 -7.6293945e-06 180 -1.0000001 -1.0000001 ( -151 87 96 ) ( -139 86 91 ) ( -189 81 96 ) e1u1/florr1_2 0 0 180 -1 -1 ( -177 69 62 ) ( -139 86 91 ) ( -145 69 50 ) e1u1/florr1_2 0 0 -180 -1 -1 ( -145 133 16 ) ( -145 133 72 ) ( -169 141 96 ) e1u1/florr1_2 0 0 1.3660378e-05 -1 1 ( -169 141 96 ) ( -145 133 72 ) ( -149 134 88 ) e1u1/florr1_2 -4.5776367e-05 -1.1444092e-05 1.0245286e-05 -0.99999976 1.0000002 ( -169 141 96 ) ( -139 86 91 ) ( -151 87 96 ) e1u1/florr1_2 3.0517578e-05 -1.5258789e-05 -179.99998 -0.9999999 -1.0000001 ( -149 134 88 ) ( -139 86 91 ) ( -169 141 96 ) e1u1/florr1_2 0 0 180 -1 -1 ( -149 134 88 ) ( -136 96 88 ) ( -139 86 91 ) e1u1/florr1_2 4.5776367e-05 1.5258789e-05 180 -0.99999976 -0.9999999 ( -129 117 16 ) ( -129 117 24 ) ( -145 133 72 ) e1u1/florr1_2 0 0 180 -1 -1 ( -145 133 72 ) ( -136 96 88 ) ( -149 134 88 ) e1u1/florr1_2 0 0 180 -1 -1 ( -145 133 72 ) ( -129 117 24 ) ( -136 96 88 ) e1u1/florr1_2 0 0 180 -1 -1 ( -145 69 50 ) ( -139 86 91 ) ( -145 69 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -139 86 91 ) ( -129 117 16 ) ( -145 69 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -139 86 91 ) ( -129 117 24 ) ( -129 117 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -136 96 88 ) ( -129 117 24 ) ( -139 86 91 ) e1u1/florr1_2 0 0 179.99998 -1 -1 } // brush 2 { ( -200 152 16 ) ( -212 196 16 ) ( -212 196 130 ) e1u1/florr1_2 0 0 0 -1 1 ( -196 224 16 ) ( -196 224 130 ) ( -212 196 130 ) e1u1/florr1_2 0 0 0 -1 1 ( -200 152 130 ) ( -165 131 130 ) ( -200 152 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -165 131 130 ) ( -144 119 16 ) ( -200 152 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -165 131 130 ) ( -144 119 82 ) ( -144 119 16 ) e1u1/florr1_2 3.0517578e-05 0 -179.99998 -0.9999999 -1 ( -100 131 16 ) ( -96 203 16 ) ( -124 219 16 ) e1u1/florr1_2 1.5258789e-05 0 180 -0.9999999 -1 ( -160 222 130 ) ( -114 153 130 ) ( -165 131 130 ) e1u1/florr1_2 0 0 180 -1 -1 ( -196 224 16 ) ( -160 222 130 ) ( -196 224 130 ) e1u1/florr1_2 0 0 0 -1 1 ( -196 224 16 ) ( -130 220 119 ) ( -160 222 130 ) e1u1/florr1_2 0 1.9073486e-06 0 -1 1.0000001 ( -196 224 16 ) ( -124 219 16 ) ( -130 220 119 ) e1u1/florr1_2 0 0 0 -1 1 ( -124 219 16 ) ( -124 219 96 ) ( -130 220 119 ) e1u1/florr1_2 0 0 0 -1 1 ( -144 119 82 ) ( -100 131 65 ) ( -100 131 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -160 222 130 ) ( -98 157 123 ) ( -114 153 130 ) e1u1/florr1_2 0 0 -179.99998 -1 -1 ( -130 220 119 ) ( -98 157 123 ) ( -160 222 130 ) e1u1/florr1_2 0 0 179.99998 -1 -1 ( -165 131 130 ) ( -114 153 130 ) ( -144 119 82 ) e1u1/florr1_2 0 0 180 -1 -1 ( -114 153 130 ) ( -98 157 123 ) ( -144 119 82 ) e1u1/florr1_2 0 0 180 -1 -1 ( -144 119 82 ) ( -98 157 123 ) ( -100 131 65 ) e1u1/florr1_2 0 0 -180 -1 -1 ( -130 220 119 ) ( -98 171 119 ) ( -98 157 123 ) e1u1/florr1_2 -4.5776367e-05 -6.1035156e-05 179.99998 -1.0000002 -1.0000002 ( -96 203 16 ) ( -96 203 27 ) ( -124 219 96 ) e1u1/florr1_2 0 0 0 -1 1 ( -124 219 96 ) ( -96 203 27 ) ( -130 220 119 ) e1u1/florr1_2 0 0 180 -1 -1 ( -130 220 119 ) ( -96 203 27 ) ( -98 171 119 ) e1u1/florr1_2 0 0 180 -1 -1 ( -100 131 65 ) ( -98 157 123 ) ( -100 131 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -98 157 123 ) ( -96 203 16 ) ( -100 131 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -98 157 123 ) ( -96 203 27 ) ( -96 203 16 ) e1u1/florr1_2 0 0 180 -1 -1 ( -98 171 119 ) ( -96 203 27 ) ( -98 157 123 ) e1u1/florr1_2 0 -7.6293945e-06 -179.99998 -1 -1.0000001 } // brush 3 { ( -64 -64 32 ) ( -64 64 16 ) ( -64 64 32 ) e1u1/florr1_2 0 0 0 1 1 ( -32 -64 32 ) ( -64 -32 32 ) ( -64 -32 160 ) e1u1/florr1_2 0 0 0 1 1 ( -64 32 32 ) ( -32 64 32 ) ( -32 64 160 ) e1u1/florr1_2 0 0 0 1 1 ( 64 -64 32 ) ( -64 -64 16 ) ( -64 -64 32 ) e1u1/florr1_2 0 0 0 1 1 ( 64 64 16 ) ( -64 -64 16 ) ( 64 -64 16 ) e1u1/florr1_2 0 0 0 1 1 ( 64 64 32 ) ( -64 -64 32 ) ( -64 64 32 ) e1u1/florr1_2 0 0 0 1 1 ( 64 64 32 ) ( -64 64 16 ) ( 64 64 16 ) e1u1/florr1_2 0 0 0 1 1 ( 64 -32 32 ) ( 32 -64 32 ) ( 32 -64 160 ) e1u1/florr1_2 0 0 0 1 1 ( 32 64 32 ) ( 64 32 32 ) ( 64 32 160 ) e1u1/florr1_2 0 0 0 1 1 ( 64 64 32 ) ( 64 -64 16 ) ( 64 -64 32 ) e1u1/florr1_2 0 0 0 1 1 } // brush 4 { ( -512 -64 368 ) ( -512 -63 368 ) ( -512 -64 369 ) e1u1/sky1 0 0 0 1 1 0 132 0 ( -64 -512 368 ) ( -64 -512 369 ) ( -63 -512 368 ) e1u1/sky1 0 0 0 1 1 0 132 0 ( -64 -64 368 ) ( -63 -64 368 ) ( -64 -63 368 ) e1u1/sky1 0 0 0 1 1 0 132 0 ( 64 64 400 ) ( 64 65 400 ) ( 65 64 400 ) e1u1/sky1 0 0 0 1 1 0 132 0 ( 64 512 400 ) ( 65 512 400 ) ( 64 512 401 ) e1u1/sky1 0 0 0 1 1 0 132 0 ( 512 64 400 ) ( 512 64 401 ) ( 512 65 400 ) e1u1/sky1 0 0 0 1 1 0 132 0 } // brush 5 { ( -512 -512 368 ) ( -512 512 16 ) ( -512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -480 -512 368 ) ( -512 -512 16 ) ( -512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -480 512 16 ) ( -512 -512 16 ) ( -480 -512 16 ) e1u1/florr2_8 0 0 0 1 1 ( -480 512 368 ) ( -512 -512 368 ) ( -512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -480 512 368 ) ( -512 512 16 ) ( -480 512 16 ) e1u1/florr2_8 0 0 0 1 1 ( -480 512 368 ) ( -480 -512 16 ) ( -480 -512 368 ) e1u1/florr2_8 0 0 0 1 1 } // brush 6 { ( -512 480 368 ) ( -512 512 16 ) ( -512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( 512 480 368 ) ( -512 480 16 ) ( -512 480 368 ) e1u1/florr2_8 0 0 0 1 1 ( 512 480 16 ) ( -512 512 16 ) ( -512 480 16 ) e1u1/florr2_8 0 0 0 1 1 ( 512 480 368 ) ( -512 512 368 ) ( 512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -512 512 368 ) ( 512 512 16 ) ( 512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( 512 480 368 ) ( 512 512 16 ) ( 512 480 16 ) e1u1/florr2_8 0 0 0 1 1 } // brush 7 { ( -512 -480 368 ) ( -512 -512 16 ) ( -512 -480 16 ) e1u1/florr2_8 0 0 0 1 1 ( 512 -512 368 ) ( -512 -512 16 ) ( -512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -512 -480 16 ) ( 512 -512 16 ) ( 512 -480 16 ) e1u1/florr2_8 0 0 0 1 1 ( -512 -480 368 ) ( 512 -512 368 ) ( -512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 ( -512 -480 368 ) ( 512 -480 16 ) ( 512 -480 368 ) e1u1/florr2_8 0 0 0 1 1 ( 512 -480 368 ) ( 512 -512 16 ) ( 512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 } // brush 8 { ( 480 -512 368 ) ( 480 512 16 ) ( 480 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( 480 -512 368 ) ( 512 -512 16 ) ( 480 -512 16 ) e1u1/florr2_8 0 0 0 1 1 ( 480 -512 16 ) ( 512 512 16 ) ( 480 512 16 ) e1u1/florr2_8 0 0 0 1 1 ( 480 -512 368 ) ( 512 512 368 ) ( 512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 ( 480 512 368 ) ( 512 512 16 ) ( 512 512 368 ) e1u1/florr2_8 0 0 0 1 1 ( 512 512 368 ) ( 512 -512 16 ) ( 512 -512 368 ) e1u1/florr2_8 0 0 0 1 1 } } // entity 1 { "classname" "info_player_start" "origin" "0 0 56" "angle" "135" } // entity 2 { "classname" "light" "origin" "-24 72 120" "target" "" "targetname" "" "light" "1000" } ```

I'm aware that floating-point coordinates is a potential source for bugs and already tried snapping to both integer and grid, but nothing helps.

Sadly I'm also encountering these issues with way simpler and more 'regular' geometry than the one I'm showing here (without those long skinny triangles) like rotated arches.

I'll investigate further and report my findings, and hopefully a pull request to fix that.

RaZeR-RBI commented 1 year ago

Lowering the BOGUS_RANGE back to (1 << 14) instead of (1 << 20) inside mathlib.h fixes the issue for me.

Is there any specific reason why it was increased? Is it possible to revert this change?

qbism commented 1 year ago

BOGUS_RANGE is used multiple places for different things. I raised it for purpose of higher map limits with unintended consequences. Solution will be to regress and use a different one for map range.

qbism commented 1 year ago

Try the exe under 'Artifacts' at bottom of https://github.com/qbism/q2tools-220/actions/runs/4094825113

https://github.com/qbism/q2tools-220/commit/0ea7ffc6bc3663c70074551ad286a43971a52266