arx-tools / arx-level-generator

A tool for creating Arx Fatalis maps
MIT License
6 stars 0 forks source link

certain polygons viewed from a steep angle vanish in-game #4

Closed meszaros-lajos-gyorgy closed 6 months ago

meszaros-lajos-gyorgy commented 6 months ago

Importing an existing level and exporting it without any changes will result in a lot of pointy triangles not always visible. A good example are with the stairs close to Gary's shop at level 11: image image

const map = await ArxMap.fromOriginalLevel(11, settings)
map.finalize()
await map.saveToDisk(settings)
meszaros-lajos-gyorgy commented 6 months ago

It also happens when noclipping: image image

meszaros-lajos-gyorgy commented 6 months ago

Making all polygons double sided solves this issue, but that wasn't a requirement for the original level file

meszaros-lajos-gyorgy commented 6 months ago

That polygon on the stairway is actually a twisted quad: image

meszaros-lajos-gyorgy commented 6 months ago

Maybe the issue is that polygon.norm and polygon.norm2 are not preserved: image left one is the original, while the right one is the generated

meszaros-lajos-gyorgy commented 6 months ago

This might be the cause of the issue: https://github.com/arx-tools/arx-level-generator/blob/main/src/Polygon.ts#L162

meszaros-lajos-gyorgy commented 6 months ago

Yes, that fixed it. I will leave generating the normals to another ticket, preserving them when loading existing levels was the bigger issue.

Commit that fixes this: https://github.com/arx-tools/arx-level-generator/commit/9a80023ab7efb23a55964e1b2d66fde528fc566f