From da5910e73224a0f7aea83879fa568d008fd83000 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 30 Oct 2022 15:32:41 -0600 Subject: [PATCH] tests: first steps on a light test case --- include/light/light.hh | 1 + light/light.cc | 10 ++++++ testmaps/q2_lightmap_custom_scale.map | 13 ++++++++ tests/test_ltface.cc | 46 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/include/light/light.hh b/include/light/light.hh index 9f7fa9ee..32467a03 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -472,3 +472,4 @@ const img::texture *Face_Texture(const mbsp_t *bsp, const mface_t *face); const qvec3b &Face_LookupTextureColor(const mbsp_t *bsp, const mface_t *face); const qvec3d &Face_LookupTextureBounceColor(const mbsp_t *bsp, const mface_t *face); int light_main(int argc, const char **argv); +int light_main(const std::vector &args); diff --git a/light/light.cc b/light/light.cc index e045502a..e376f33d 100644 --- a/light/light.cc +++ b/light/light.cc @@ -1475,3 +1475,13 @@ int light_main(int argc, const char **argv) return 0; } + +int light_main(const std::vector &args) +{ + std::vector argPtrs; + for (const std::string &arg : args) { + argPtrs.push_back(arg.data()); + } + + return light_main(argPtrs.size(), argPtrs.data()); +} diff --git a/testmaps/q2_lightmap_custom_scale.map b/testmaps/q2_lightmap_custom_scale.map index d4f3c6df..6ce8e512 100644 --- a/testmaps/q2_lightmap_custom_scale.map +++ b/testmaps/q2_lightmap_custom_scale.map @@ -123,6 +123,19 @@ ( 0 -172 112 ) ( 128 -184 120 ) ( 0 -184 120 ) e1u1/color1_6 [ 1 0 0 0 ] [ 0 -0.8320502943378437 0.5547001962252291 0 ] 0 1 1 ( 16 -144 48 ) ( 16 -144 49 ) ( 16 -143 48 ) e1u1/color1_6 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 } +// brush 13 +{ +( -136 -201.37258300203052 -1.9411254969542853 ) ( -136 -173.0883117545686 3.715728752538098 ) ( -136 -184.40202025355336 15.02943725152285 ) e1u1/color1_6 [ 0.7071067811865477 0.5000000000000002 0.5 -29.892334 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 31.399715 1 1 0 0 0 +( -120 -212.68629150101526 -13.254833995939052 ) ( -136 -190.05887450304573 -13.254833995939038 ) ( -136 -201.37258300203052 -1.9411254969542853 ) e1u1/color1_6 [ -0.7071067811865477 0.5000000000000002 0.5 -30.225405 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 32.6499 1 1 0 0 0 +( -120 -173.08831175456856 26.343145750507603 ) ( -136 -173.0883117545686 3.715728752538098 ) ( -120 -161.77460325558383 15.029437251522836 ) e1u1/color1_6 [ 0.7071067811865477 0.5000000000000002 0.5 -29.89235 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 32.6499 1 1 0 0 0 +( -80 -961.3725830018886 792 ) ( -120 -950.058874502904 803.3137084991148 ) ( -96 -950.058874502904 803.3137084991148 ) e1u1/color1_6 [ 1 0 0 32 ] [ 0 -0.7071067811865477 -0.7071067811865474 0.23550415 ] 0 1 1 0 0 0 +( -96 -212.68629150101526 -13.254833995939052 ) ( -120 -201.37258300203052 -24.568542494923804 ) ( -120 -212.68629150101526 -13.254833995939052 ) e1u1/color1_6 [ -0.7071067811865477 0.5000000000000002 0.5 -30.225407 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 0 1 1 0 0 0 +( -96 -173.08831175456856 26.343145750507603 ) ( -120 -161.77460325558383 15.029437251522836 ) ( -96 -161.77460325558383 15.029437251522836 ) e1u1/color1_6 [ 0.7071067811865477 -0.5000000000000002 -0.5 15.362465 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 0 1 1 0 0 0 +( -80 -53.6568542494953 -115.71572875253534 ) ( -96 -81.9411254969572 -144 ) ( -80 -70.62741699797243 -132.68629150101248 ) e1u1/color1_6 [ -1 0 0 -32 ] [ 0 -0.7071067811865477 -0.7071067811865474 0.23550415 ] 0 1 1 0 0 0 +( -80 -201.37258300203052 -1.9411254969542853 ) ( -96 -201.37258300203052 -24.568542494923804 ) ( -96 -212.68629150101526 -13.254833995939052 ) e1u1/color1_6 [ -0.7071067811865477 -0.5000000000000002 -0.5 30.225388 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 327.3501 1 1 0 0 0 +( -96 -161.77460325558383 15.029437251522836 ) ( -80 -184.40202025355336 15.02943725152285 ) ( -96 -173.08831175456856 26.343145750507603 ) e1u1/color1_6 [ 0.7071067811865477 -0.5000000000000002 -0.5 15.362471 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 327.3501 1 1 0 0 0 +( -80 -184.40202025355336 15.02943725152285 ) ( -80 -190.05887450304573 -13.254833995939038 ) ( -80 -201.37258300203052 -1.9411254969542853 ) e1u1/color1_6 [ -0.7071067811865477 -0.5000000000000002 -0.5 30.225403 ] [ 0 0.7071067811865475 -0.7071067811865478 29.019348 ] 328.60028 1 1 0 0 0 +} } // entity 1 { diff --git a/tests/test_ltface.cc b/tests/test_ltface.cc index e69de29b..e8b5f77a 100644 --- a/tests/test_ltface.cc +++ b/tests/test_ltface.cc @@ -0,0 +1,46 @@ +#include + +#include +#include +#include + +static void LoadTestmap(const std::filesystem::path &name, std::vector extra_args) +{ + auto map_path = std::filesystem::path(testmaps_dir) / name; + + auto bsp_path = fs::path(test_quake2_maps_dir) / name.filename(); + bsp_path.replace_extension(".bsp"); + + auto wal_metadata_path = std::filesystem::path(testmaps_dir) / "q2_wal_metadata"; + + std::vector args{ + "", // the exe path, which we're ignoring in this case + "-noverbose", + "-q2bsp", + "-path", + wal_metadata_path.string() + }; + for (auto &arg : extra_args) { + args.push_back(arg); + } + args.push_back(map_path.string()); + args.push_back(bsp_path.string()); + + // run qbsp + + InitQBSP(args); + ProcessFile(); + + // run light + { + std::vector light_args{ + "", // the exe path, which we're ignoring in this case + bsp_path.string() + }; + light_main(light_args); + } +} + +TEST_CASE("TestLight") { + LoadTestmap("q2_lightmap_custom_scale.map", {}); +}