Skip to content

Commit

Permalink
bsp: add option to compile fastfile + reload map in-game; git workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed Dec 28, 2023
1 parent b0b9cc8 commit 222ac50
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 32 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- "develop"
paths:
- 'src/**'

jobs:
build:
Expand Down Expand Up @@ -40,26 +42,30 @@ jobs:
- name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master

- name: Build ${{matrix.configuration}} binaries
- name: Build ${{matrix.configuration}}-binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/iw3xo-radiant.sln

- name: Upload ${{matrix.configuration}} binaries
- name: Move build files
run: |
move build/bin/${{matrix.configuration}}/iw3r.dll ./assets/bin
move build/bin/${{matrix.configuration}}/iw3r.pdb ./assets/bin
move build/bin/${{matrix.configuration}}/PhysX_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXCommon_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXCooking_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXFoundation_32.dll ./assets/bin
- name: Upload ${{matrix.configuration}}-binaries
uses: actions/upload-artifact@v2
with:
name: ${{matrix.configuration}} binaries
name: ${{matrix.configuration}}-binaries
path: |
build/bin/${{matrix.configuration}}/iw3r.dll
build/bin/${{matrix.configuration}}/iw3r.pdb
build/bin/${{matrix.configuration}}/PhysX_32.dll
build/bin/${{matrix.configuration}}/PhysXCommon_32.dll
build/bin/${{matrix.configuration}}/PhysXCooking_32.dll
build/bin/${{matrix.configuration}}/PhysXFoundation_32.dll
./assets/*
webbook:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tag String
Expand All @@ -79,5 +85,5 @@ jobs:
embed-author-name: "iw3xo-radiant"
embed-author-url: "https://github.com/xoxor4d/iw3xo-radiant"
embed-title: "Successful build (debug)"
embed-color: 0xc680ff
embed-description: "${{ env.GIT_TAG }} [nightly link](https://nightly.link/xoxor4d/iw3xo-radiant/workflows/build-debug/develop/Debug%20binaries.zip)"
embed-color: 0xef5443
embed-description: "${{ env.GIT_TAG }} [nightly link](https://nightly.link/xoxor4d/iw3xo-radiant/workflows/build-debug/develop/Debug-binaries.zip)"
30 changes: 18 additions & 12 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- "develop"
paths:
- 'src/**'

jobs:
build:
Expand Down Expand Up @@ -40,26 +42,30 @@ jobs:
- name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master

- name: Build ${{matrix.configuration}} binaries
- name: Build ${{matrix.configuration}}-binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/iw3xo-radiant.sln

- name: Upload ${{matrix.configuration}} binaries
- name: Move build files
run: |
move build/bin/${{matrix.configuration}}/iw3r.dll ./assets/bin
move build/bin/${{matrix.configuration}}/iw3r.pdb ./assets/bin
move build/bin/${{matrix.configuration}}/PhysX_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXCommon_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXCooking_32.dll ./assets/bin
move build/bin/${{matrix.configuration}}/PhysXFoundation_32.dll ./assets/bin
- name: Upload ${{matrix.configuration}}-binaries
uses: actions/upload-artifact@v2
with:
name: ${{matrix.configuration}} binaries
name: ${{matrix.configuration}}-binaries
path: |
build/bin/${{matrix.configuration}}/iw3r.dll
build/bin/${{matrix.configuration}}/iw3r.pdb
build/bin/${{matrix.configuration}}/PhysX_32.dll
build/bin/${{matrix.configuration}}/PhysXCommon_32.dll
build/bin/${{matrix.configuration}}/PhysXCooking_32.dll
build/bin/${{matrix.configuration}}/PhysXFoundation_32.dll
./assets/*
webbook:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tag String
Expand All @@ -79,5 +85,5 @@ jobs:
embed-author-name: "iw3xo-radiant"
embed-author-url: "https://github.com/xoxor4d/iw3xo-radiant"
embed-title: "Successful build (release)"
embed-color: 0x82ff80
embed-description: "${{ env.GIT_TAG }} [nightly link](https://nightly.link/xoxor4d/iw3xo-radiant/workflows/build-release/develop/Release%20binaries.zip)"
embed-color: 0xef5443
embed-description: "${{ env.GIT_TAG }} [nightly link](https://nightly.link/xoxor4d/iw3xo-radiant/workflows/build-release/develop/Release-binaries.zip)"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ___
+ [play](https://xoxor4d.github.io/tutorials/iw3xradiant-using-effects/) && [edit / create](https://xoxor4d.github.io/tutorials/iw3xradiant-effects-editor/) && [export effects as CreateFX](https://xoxor4d.github.io/tutorials/iw3xradiant-createfx/) files right from within radiant (__makes effectsEd completely obsolete__)
+ Nvidia PhysX integration for [dynamic placement of prefabs](https://xoxor4d.github.io/tutorials/iw3xradiant-physx-prefabs) or [physics-enabled effects](https://xoxor4d.github.io/tutorials/iw3xradiant-physx-effects) (can be turned into misc_models)
+ Nvidia PhysX enabled character movement with cod4 movement mechanics (bouncing) [character movement](https://xoxor4d.github.io/tutorials/iw3xradiant-physx-movement)
+ [d3dbsp loading](https://xoxor4d.github.io/tutorials/iw3xradiant-d3dbsp) and bsp/light compilation from within radiant
+ [d3dbsp loading](https://xoxor4d.github.io/tutorials/iw3xradiant-d3dbsp) and bsp/light compilation from within radiant (+ option to compile fastfile)
+ [automatically generate reflections](https://xoxor4d.github.io/tutorials/iw3xradiant-d3dbsp-reflections) within radiant when compiling the maps bsp
+ [live link](https://xoxor4d.github.io/tutorials/iw3xradiant-livelink) (sync. brushes (with collision), camera and worldspawn settings between cod4 and radiant)
+ [mesh painting](https://xoxor4d.github.io/tutorials/iw3xradiant-mesh-painting) (xmodels/prefabs) with per object settings, random size, angles, weight etc.
Expand Down
37 changes: 37 additions & 0 deletions assets/bin/IW3xRadiant/batch/compile_ff.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@echo off

set LANG=%1
shift

chdir ...\zone_source\english\

echo [CSTATUS] Building Fastfile
echo.

IF EXIST ..\zone_source\%1_load.csv (
SET MYFASTFILES=%1 %1_load %2 %3 %4 %5 %6 %7 %8 %9
) ELSE (
SET MYFASTFILES=%1 %2 %3 %4 %5 %6 %7 %8 %9
)

linker_pc.exe -language english %MYFASTFILES%

chdir ..\zone\
set DIR_ENG=%CD%\english
set DIR_LANG=%CD%\%LANG%

IF NOT "%LANG%" == "english" (
echo language is not english
echo copying fast files to %LANG% folder
mkdir %DIR_LANG%
IF EXIST "%DIR_ENG%\%1.ff" move "%DIR_ENG%\%1.ff" "%DIR_LANG%\%1.ff"
IF EXIST "%DIR_ENG%\%1_load.ff" move "%DIR_ENG%\%1_load.ff" "%DIR_LANG%\%1_load.ff"
IF EXIST "%DIR_ENG%\%2.ff" move "%DIR_ENG%\%2.ff" "%DIR_LANG%\%2.ff"
IF EXIST "%DIR_ENG%\%3.ff" move "%DIR_ENG%\%3.ff" "%DIR_LANG%\%3.ff"
IF EXIST "%DIR_ENG%\%4.ff" move "%DIR_ENG%\%4.ff" "%DIR_LANG%\%4.ff"
IF EXIST "%DIR_ENG%\%5.ff" move "%DIR_ENG%\%5.ff" "%DIR_LANG%\%5.ff"
IF EXIST "%DIR_ENG%\%6.ff" move "%DIR_ENG%\%6.ff" "%DIR_LANG%\%6.ff"
IF EXIST "%DIR_ENG%\%7.ff" move "%DIR_ENG%\%7.ff" "%DIR_LANG%\%7.ff"
IF EXIST "%DIR_ENG%\%8.ff" move "%DIR_ENG%\%8.ff" "%DIR_LANG%\%8.ff"
IF EXIST "%DIR_ENG%\%9.ff" move "%DIR_ENG%\%9.ff" "%DIR_LANG%\%9.ff"
)
56 changes: 55 additions & 1 deletion src/components/modules/d3dbsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,44 @@ namespace components
}
}

void d3dbsp::compile_fastfile(const std::string& bsp_name)
{
game::printf_to_console("[BSP] Compiling fastfile for map: %s ... \n", bsp_name.c_str());

const auto egui = GET_GUI(ggui::entity_dialog);

const char* base_path = egui->get_value_for_key_from_epairs(game::g_qeglobals->d_project_entity->epairs, "basepath");

std::string args;

// batch
args += R"(")"s + base_path + R"(\bin\IW3xRadiant\batch\compile_ff.bat")"s + " ";

// args
args += R"(english )"s + bsp_name;

const auto process = components::process::get();

process->set_process_type(process::PROC_TYPE_BATCH);
process->set_indicator(process::INDICATOR_TYPE_SPINNER);
process->set_output(true);
process->set_arguments(args);

if (game::glob::live_connected)
{
process->set_post_process_callback([bsp_name]
{
game::printf_to_console("[!] Sending devmap cmd to game\n");
remote_net::Cmd_SendDvar(utils::va("{\n\"dvarname\" \"%s\"\n\"value\" \"%s\"\n}",
"devmap",
bsp_name.c_str()));

}, true);
}

process->create_process();
}

/**
* @brief run batch to compile bsp
* @param bsp_name plain map name with no extension or pathing
Expand Down Expand Up @@ -811,7 +849,7 @@ namespace components
process->set_indicator(process::INDICATOR_TYPE_SPINNER);
process->set_output(true);
process->set_arguments(args);
process->set_post_process_callback([bsp_path, generate_createfx]
process->set_post_process_callback([bsp_name, bsp_path, generate_createfx]
{
game::printf_to_console("^2[PROCESS] Post-Process Callback");

Expand All @@ -829,6 +867,15 @@ namespace components
command::execute("toggle_bsp_radiant");
dvars::set_bool(dvars::r_draw_bsp, dvars::bsp_show_bsp_after_compile->current.enabled);
}

// slightly delay process generation
exec::on_gui_once([bsp_name]
{
if (dvars::bsp_gen_fastfile_on_compile->current.enabled)
{
d3dbsp::compile_fastfile(bsp_name);
}
});
}
}

Expand All @@ -849,6 +896,7 @@ namespace components
{
std::string d3dbsp_name = std::string(game::current_map_filepath).substr(std::string(game::current_map_filepath).find_last_of("\\") + 1);
utils::erase_substring(d3dbsp_name, ".map");
d3dbsp::last_compiled_map = d3dbsp_name;

components::d3dbsp::compile_bsp(d3dbsp_name, dvars::bsp_gen_createfx_on_compile->current.enabled);
}
Expand Down Expand Up @@ -935,6 +983,12 @@ namespace components
/* flags */ game::dvar_flags::saved,
/* desc */ "automatically build reflections when compiling the bsp");

dvars::bsp_gen_fastfile_on_compile = dvars::register_bool(
/* name */ "bsp_gen_fastfile_on_compile",
/* default */ false,
/* flags */ game::dvar_flags::saved,
/* desc */ "automatically build the maps fastfile after compiling the bsp\n+ reload map (devmap) in-game if livelink is established");

dvars::bsp_gen_createfx_on_compile = dvars::register_bool(
/* name */ "bsp_gen_createfx_on_compile",
/* default */ true,
Expand Down
2 changes: 2 additions & 0 deletions src/components/modules/d3dbsp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace components
};

static std::string loaded_bsp_path;
static inline std::string last_compiled_map;
static bspGlob_s comBspGlob;
static game::clipMap_t cm;
static game::GfxLight scene_lights[255];
Expand All @@ -135,6 +136,7 @@ namespace components
static bool radiant_load_bsp(const char* bsppath, bool reload = false);
static void reload_bsp();

static void compile_fastfile(const std::string& bsp_name);
static void compile_bsp(const std::string& bsp_name, bool generate_createfx = false);
static void compile_current_map();

Expand Down
8 changes: 4 additions & 4 deletions src/components/modules/main_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ DWORD WINAPI update_check(LPVOID)

if (doc.Parse(game::glob::gh_update_releases_json.c_str()).HasParseError())
{
#if DEBUG
auto err = doc.GetParseError();
__debugbreak();
#endif
//#if DEBUG
// auto err = doc.GetParseError();
// __debugbreak();
//#endif
return TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace components
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

if (!process->m_disable_callback)
if (process->m_post_process_callback && !process->m_disable_callback)
{
// execute callback on main thread
exec::on_gui_once([]
Expand Down
14 changes: 13 additions & 1 deletion src/components/modules/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,11 +2148,23 @@ namespace components
reflectionprobes::generate_reflections_for_bsp();
dvars::set_bool(dvars::r_reflectionprobe_generate, false);

if (!dvars::bsp_show_bsp_after_compile->current.enabled)
if (dvars::bsp_show_bsp_after_compile->current.enabled)
{
command::execute("toggle_bsp_radiant");
dvars::set_bool(dvars::r_draw_bsp, dvars::bsp_show_bsp_after_compile->current.enabled);
}

if (dvars::bsp_gen_fastfile_on_compile->current.enabled)
{
// slightly delay process generation
exec::on_gui_once([]
{
if (dvars::bsp_gen_fastfile_on_compile->current.enabled && !d3dbsp::last_compiled_map.empty())
{
d3dbsp::compile_fastfile(d3dbsp::last_compiled_map);
}
});
}
}

static int skip_frame = 0;
Expand Down
1 change: 1 addition & 0 deletions src/game/dvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace dvars
game::dvar_s* bsp_show_bsp_after_compile = nullptr;
game::dvar_s* bsp_gen_reflections_on_compile = nullptr;
game::dvar_s* bsp_gen_createfx_on_compile = nullptr;
game::dvar_s* bsp_gen_fastfile_on_compile = nullptr;

game::dvar_s* bsp_compile_bsp = nullptr;
game::dvar_s* bsp_compile_onlyents = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/game/dvars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace dvars
extern game::dvar_s* bsp_show_bsp_after_compile;
extern game::dvar_s* bsp_gen_reflections_on_compile;
extern game::dvar_s* bsp_gen_createfx_on_compile;
extern game::dvar_s* bsp_gen_fastfile_on_compile;

extern game::dvar_s* bsp_compile_bsp;
extern game::dvar_s* bsp_compile_onlyents;
Expand Down
2 changes: 2 additions & 0 deletions src/ggui/camera_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ namespace ggui

imgui::Checkbox("Automatically compile reflections when building bsp", &dvars::bsp_gen_reflections_on_compile->current.enabled); TT(dvars::bsp_gen_reflections_on_compile->description);
imgui::Checkbox("Automatically turn on bsp-view after compiling", &dvars::bsp_show_bsp_after_compile->current.enabled); TT(dvars::bsp_show_bsp_after_compile->description);
imgui::Checkbox("Automatically compile fastfile after bulding the bsp", &dvars::bsp_gen_fastfile_on_compile->current.enabled); TT(dvars::bsp_gen_fastfile_on_compile->description);

/*if (imgui::Button("Generate Reflections", ImVec2(-style.FramePadding.x, imgui::GetFrameHeight())))
{
Expand Down Expand Up @@ -578,6 +579,7 @@ namespace ggui

if (imgui::Button(button_str.c_str(), ImVec2(-style.FramePadding.x, imgui::GetFrameHeight())))
{
components::d3dbsp::last_compiled_map = d3dbsp_name;
components::d3dbsp::compile_bsp(d3dbsp_name, dvars::bsp_gen_createfx_on_compile->current.enabled);
}

Expand Down

0 comments on commit 222ac50

Please sign in to comment.