Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrain editor now edits *.tobj files in place #3199

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Nov 17, 2024

There are 3 major features:

  1. The terrain editor mode now edits `*.tobj`` files directly. The 'logs/editor_out.log' file is history. Just enter/exit the terrain editor mode and changes will persist. Note this works only if the terrain is unzipped in a directory (= a project), otherwise game will show a console/chatbox warning "cannot export - not a project".
  2. The game has integrated project importer script - just enter terrain editor on Zipped terrain and it will pop up. Closing the script will exit terrain editor and vice versa.
  3. Experimental: new [Races] section in terrn2, processed by the race system. Converting the classic races defined in scripts is done automatically by the importer. Under [Races], there is 1 file per race. I tested this on Auriga Proving Grounds.

Known issues:

  • preloaded actors rotations are off
  • the script editor may crash, reporting it received a C++ exception:
    23:17:20: [RoR|Script|Notice] Executing main() in road_editor_COLMESH_DEVEL.as(category:CUSTOM,unique ID:12)
    23:17:20: [RoR|Script|Notice] Road editor loaded! Enter terrain editing mode (hotkey: CTRL+Y) to use it.
    23:17:20: [RoR|Script|Notice] The script finished successfully.
    23:19:46: [RoR|Script|Notice] The script ended with exception; details below:
    23:19:46: [RoR|Script|Notice] 	context.ExceptionLineNumber: 1950
    23:19:46: [RoR|Script|Notice] 	context.ExceptionString: Caught an exception from the application
    23:19:46: [RoR|Script|Notice] 	context.ExceptionFunction.Declaration: void ScriptEditorTab::foldRegionInternal(string)
    23:19:46: [RoR|Script|Notice] 	context.ExceptionFunction.ModuleName: script_editor.as(category:CUSTOM,unique ID:1)
    23:19:46: [RoR|Script|Notice] 	context.ExceptionFunction.ScriptSectionName: script_editor.as
    23:19:46: [RoR|Script|Notice] 	context.ExceptionFunction.ObjectName: ScriptEditorTab
    23:19:46: [RoR|Script|Notice] ScriptEditor: Killing script 'script_editor.as' (NID 1) because it triggered an AngelScript exception;     you can disable this behavior in top menu 'Tools/Settings'.
    

Notes to code reviewers:

  • I did a roundup of file format handlers -> a lot of find&replace hapenned, see individual commit descriptions.
  • For convenience this branch builds on top of Script updates and fixes #3197 - when that is merged, it will become much leaner.

@ohlidalp ohlidalp force-pushed the terrn_export branch 3 times, most recently from 341bc52 to 3a02667 Compare November 30, 2024 20:26
Consistency++; Until now some document objects were named `^Document` (RigDef, GenericDocument), some `^File` (Odef, TObj) and some `^Def` (skin).

Principal changes are in file 'ForwardDeclarations.h' - all document types and smart pointer typedefs are now here. The rest is pretty much all find&replace.
The 'logs/editor_out.log' file is history. The game now edits *.tobj files directly, but only if the terrain is unzipped in a directory (= a project). Exiting terrain editor at a zipped terrain will show a console warning "cannot export - not a project".

Known issues:
* preloaded actors rotations are off
* procedural road bridge types are not preserved.
* The "Terrain editor mode" doesn't inform about projects. TBD: add a button to import zipped terrain as project (internals already exist, only UI needs to be updated).
In this mode, the road will automatically switch between solid base and bridge depending on current height above ground.
Internally, this mode already existed, but was only activated when importing legacy blocky-road into procedural road.

This fixes the new TOBJ export from terrain editor.
* 'terrain_project_importer.as' - Launched automatically with terrain-editor mode with a read-only (ZIPped) terrain, provides info and import controls.
How I could trigger it:
1. enter simple test Terrain (zipped)
2. load 'script_editor.as' script.
3. enter terrain-editor mode --> game launches 'terrain_project_importer.as' --> boom.

May be related: There are 2 messages "cannot run function with ID -1" that seem to appear when the terrain import script starts, I dont know where they come from.
Also Don't unload terrain when done (feels like crash).
other .terrn2 files in the project - typically FPS variants.
This is a messy commit as I reorganized the whole file into folding-regions to be able to work in script_editor.as.

New features:
* Road points now can be dragged using mouse (previously just moved with M hotkey).
* Road point gizmos now always indicate hover (previously just if unselected).
* Hover indication was changed - instead of changing color/size/thickness of the regular elements, it now draws extra elements around it.
* UI redesigned to be displayed at bottom center of screen, wide and not very tall (as opposed to previous narrow panel fixed to left side of screen) - much better for ultrawide monitors such as mine :)
* UI layout changed to accomodate new placement - multiple CollapsingHeader panels became their own tabs (mesh regen, AI waypoints).
This can disable generation of collision triangles, which can be useful while editing to speed up mesh regen.
Also in the future it will help creating decal meshes using the procedural geometry system.
Problem: The road mesh could not be removed from scene, so road editor's [rebuild mesh] button just piled up new meshes.
Cause: The `ProceduralRoad::snode` variable was never set - it should have been written in `finish()` but it was shadowed by the new parameter. Broken in faebbcd
Fix: rename the offending param and correctly create+assign child scene node.
There are 2 new methods in AngelScript `ProceduralManagerClass`:
* `void rebuildObjectMesh(ProceduralObjectClassPtr@)` - previously private `updateObject()`
* `void deleteObjectMesh(ProceduralObjectClassPtr@)` - previously private `deleteObject()`

script 'road_editor.as' updated to use this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant