Garux / netradiant-custom

The open-source, cross-platform level editor for id Tech based games.
https://garux.github.io/NRC/
Other
299 stars 52 forks source link

mbspc.exe not working with de_dust2.bsp #87

Closed UnrealKaraulov closed 1 year ago

UnrealKaraulov commented 2 years ago

Output map220 or map is broken and look like :

image

Garux commented 2 years ago

I have no idea how it's broken from the screenshot, only can notice misaligned crates. This may be due to using non original textures, as 220 alignment depends on tex size.

UnrealKaraulov commented 2 years ago

I have no idea how it's broken from the screenshot, only can notice misaligned crates. This may be due to using non original textures, as 220 alignment depends on tex size.

@Garux where this tool search original textures ? How to set path to textures ?

UnrealKaraulov commented 2 years ago
c:\Users\Admin\Downloads\netradiant-custom-windows-x86_64>mbspc.exe -bsp2map220 C:\Projects\CounterStrikeTools\UNIXMACCS\cstrike\maps\de_dust2.bsp
Opened log bspc.log
BSPC version 2.2, Jan  9 2022 19:31:53
bsp2map: C:\Projects\CounterStrikeTools\UNIXMACCS\cstrike\maps\de_dust2.bsp to C:\Projects\CounterStrikeTools\UNIXMACCS\cstrike\maps\de_dust2_decompiled.map
allocated 101 MB and 55 KB and 990 bytes of BSP memory
-- HL_LoadMapFromBSP --
loading map from C:\Projects\CounterStrikeTools\UNIXMACCS\cstrike\maps\de_dust2.bsp at 0
creating Half-Life brushes
placing textures correctly
brush size: -2848,-1696, -352 to  2080, 3968,  672
HL_SplitBrush: only on front
HL_CreateBrushes_r: WARNING node not splitting brush
texturing brushes
 3109 brushes
 1408 brushes merged
converting brushes to map brushes
 1700 brushes
 1755 map brushes
   28 clip brushes
freed 101 MB and 55 KB and 990 bytes of BSP memory
writing C:\Projects\CounterStrikeTools\UNIXMACCS\cstrike\maps\de_dust2_decompiled.map
written 1755 brushes
map file written in     0 seconds
BSPC run time is     2 seconds
Closed log bspc.log

I tried to export again without additional parameters (map220):

Problems with textures: image image image

And map is broken:


Valve Hammer Editor

For your information, 74 solids were not loaded due to errors in the file.

ОК

image image

Errors:

The face has a texture axis that is perpendicular to the face, probably caused by rotating an object with texture locking disabled. This could also indicate an invalid face caused by vertex manipulation.

And

The solid has invalid structure, probably as a result of vertex manipulation.
UnrealKaraulov commented 2 years ago

@Garux I see very big error count in mbspc! I just replace extension from c to cpp an except error of pointers (default for c -> c++) i got many error of types, example "using vec3_t instead of vec3_t *, using plane_t * instead of vec3_t *" and many other, very big count of errors.

Garux commented 2 years ago

where this tool search original textures ? How to set path to textures ?

It does not need textures, as sizing info is baked to the bsp. Textures are baked to hl bsp too.

Decompilation result is not guaranteed to be 100% correct, 99% is expected to be handled well. To fix these misalignments and broken brushes bspc's bsp parsing algorithms must be improved. Note, hl bsp doesn't store original brushes, so working with such data is more error prone. As for decompilation part of code, i think it's okay.

The face has a texture axis that is perpendicular to the face

Looks like exclusive to culled faces, where default tex projection is written, might write something more correct, but this makes no much sense.

I just replace extension from c to cpp an except error of pointers (default for c -> c++) i got many error of types, example "using vec3_t instead of vec3_t , using plane_t instead of vec3_t *" and many other, very big count of errors.

In the first place it's C code, C++ is possible just after some fixes. Which tool gives you these errors? Build works, while following build instructions https://github.com/Garux/netradiant-custom/blob/master/COMPILING, remote build works too: https://github.com/Garux/netradiant-custom/actions.

UnrealKaraulov commented 2 years ago

@Garux code has many misprints hidden by power of C language. For example passing plane_t struct pointer instead of vect, and function names misprints....

Garux commented 2 years ago

I'm up to fixing these, if you point them out. Incompatible pointer type is a warning at least: https://godbolt.org/z/fG7rv8c4z function names misprints wdym here? Misnaming doesn't work, wrong signature is an error.

UnrealKaraulov commented 2 years ago

@Garux okay I can write example, but with using C language all errors is hidden. You can try to port it to C++ and then see all misprints (CopyWinding instead of CopyWindingAccu, ConvertAccuToRegular instead of ConvertRegularToAccu, and etc, sometime passing pointer to vec3t instead of same struct, passing plane instead of vec3, and many other hidden by C language syntax)

Garux commented 2 years ago

I can write example

Yes, please.

CopyWinding instead of CopyWindingAccu

whole codebase has no CopyWindingAccu

ConvertAccuToRegular instead of ConvertRegularToAccu

CopyWindingAccuToRegular is only used in q3map2, mentioned funcs do not exist

passing pointer to vec3t instead of same struct

vec3t is typedef float[3], not struct; array and taken array address are interchangeable https://stackoverflow.com/questions/2528318/how-come-an-arrays-address-is-equal-to-its-value-in-c

passing plane instead of vec3

this is warning with default warning level even (unless cast explicitly) https://godbolt.org/z/fG7rv8c4z and i've got no such ones

UnrealKaraulov commented 2 years ago

You can't see warning because this is default behaviour of C language

ensiform commented 2 years ago

Isn't there a compiler tool shipped with valve tools to decompile maps? I thought mbspc was mostly for AAS bot file generation.

Garux commented 2 years ago

You can't see warning because this is default behaviour of C language

Do you follow? https://godbolt.org/z/fG7rv8c4z shows warning in the named case, even w/o -Wall.

Isn't there a compiler tool shipped with valve tools to decompile maps? I thought mbspc was mostly for AAS bot file generation.

I've only seen 3rd party tools to decompile, and only this mbspc is capable of restoring texture alignments.

UnrealKaraulov commented 2 years ago

@Garux no warnings when compile full mbspc project?

I can't because has only visual studio microsoft compiler.

If problem not in errors, why I got problem with decompile de_dust2.bsp and other maps?

Garux commented 2 years ago

no warnings when compile full mbspc project?

Build works, while following build instructions https://github.com/Garux/netradiant-custom/blob/master/COMPILING, remote build works too: https://github.com/Garux/netradiant-custom/actions. passing plane instead of vec3 is warning with default warning level even (unless cast explicitly) https://godbolt.org/z/fG7rv8c4z and i've got no such ones

If problem not in errors, why I got problem with decompile de_dust2.bsp and other maps?

Decompilation result is not guaranteed to be 100% correct, 99% is expected to be handled well. To fix these misalignments and broken brushes bspc's bsp parsing algorithms must be improved. Note, hl bsp doesn't store original brushes, so working with such data is more error prone. As for decompilation part of code, i think it's okay.

Garux commented 1 year ago

Addressed texturing issues, algorithm implementation was not quite correct. I had not exactly shown problems, but had other mistexturings due to this. Can test with autobuild binaries https://github.com/Garux/netradiant-custom/releases/tag/latest As for ignored brushes, your editor is too picky it looks like. Texturing warnings is worthy information, but in this case they are not related to visible stuff.