-
Notifications
You must be signed in to change notification settings - Fork 181
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
Conversation
341bc52
to
3a02667
Compare
d5aeb16
to
371c19f
Compare
d70150c
to
7be0daf
Compare
This comment was marked as outdated.
This comment was marked as outdated.
59c9ae3
to
2d3f7e8
Compare
The import wizzard doesn't pop up automatically anymore. Requested by Mike on GitHub: RigsOfRods#3199 (review) at the bottom.
@CuriousMike56 I added a button to launch the import wizzard. I'll tackle the rotations next. |
@CuriousMike56 Rotations should be good now. I haven't tested RaceMax though, I channeled all energy into further evolving the editor mode. |
This comment was marked as resolved.
This comment was marked as resolved.
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.
Consistency++;
Consistency++;
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.
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.
Only works for: * static object lines * procedural points * procedural points imported from old-style (rortoolkit) roads.
Codechanges: * the EditorObject struct was converted to RefCountingObject<TerrainEditorObject> * Code setting position+rotation was moved from UpdateInputEvents() to member funcs setPosition()/setRotation() which will be exported to script. * a lot of find&replace (replacing operator. with operator->)
This lets script enumerate all static objects currently on terrain. Docs+Example script included. The object can be moved and rotated, just like in the builtin terrain-editor mode.
Previously objects spawned via TOBJ file mostly didn't have instance names (optional), so this script function couldn't be used with them. Now, all objects without custom instancename get one generated, as "auto^filename.tobj(line#)". These auto^ names are not saved when exporting TOBJ from terrain editor. The 'example_terrn_editorObjects.as' file was updated to showcase this.
Problem1: removing object while being active in terrain editor caused glitches, as the editor just jumped to the next object (and would probably crash if last object was active). Fix1: Properly reset terrain editor mode on object removal. Problem2: moving object via `game.moveObjectVisuals` wouldn't update the editor object. Fix2: remove `struct StaticObject` altogether, use just TerrainEditorObject to track static objects. Positive side effect: destroyed objects are now really removed, instead of just setting `enabled = false`. Additional code change: TerrainObjectManager funcs renamed to match those in script API.
The import wizzard doesn't pop up automatically anymore. Requested by Mike on GitHub: RigsOfRods#3199 (review) at the bottom.
The predefined actors on terrain (types 'truck/load/boat/machine/truck2') are now included in the 'editor objects' array, which means: * they are included in angelscript function `game.getTerrainEditorObjects()` * TBD: `game.spawnObject()` or `game.destroyObject()` is not integrated yet. * The classic editor mode will pick them like any other object, you can move/rotate it and the changes will be saved. * TBD movement and rotation is not visually updated yet. * The position+rotation is now written out to TOBJ precisely how it was read (it's not being reconstructed from actual actor position) - this eliminates any subtle shifts observed with the previous solution. Code changes: * TerrainObjectManager: `struct PredefinedActor` was eliminated - it's role was substituted by `TerrainEditorObject`. * Application: enum SpecialObject was moved from TObjFileFormat.h to reduce header dependencies. * TerrainAngelscript: enum SpecialObject was registered, TerrainEditorObjectClass was extended with SpecialObject get/set funcs. * TerrainEditor: also reconstruct TOBJ predefined actors.
Major changes: * ActorSpawnRequest can now contain pre-obtained actorInstanceID, the same way as FreeForce request can have pre-obtained ID, the functions are named the same. * TerrainEditorObject can now reference a live actor instance - used for visualization in editor mode. * Initial visualization logic for preloaded actors - The visualization still doesn't work for some reason, I tried `RESET_ON_SPOT` paired with `requestTranslation()` but that was created for LiveRepair (aka interactive reset) and doesn't work as needed. Time: * This stretched to 2 hours instead of expected 1 and didn't even get the job done.
Rotating still TBD. To do this, 2 new 'types' had to be added to `MSG_SIM_MODIFY_ACTOR_REQUESTED`: * SOFT_RESPAWN, //!< Like hard reset, but positions the actor like spawn process does - using the relative positions from rig-def file (respecting Tuning system tweaks). * REFRESH_VISUALS //!< Forces a synchronous update of visuals from any context - i.e. from terrain editor mode or with sleeping/physicspaused actor. Time spent: 90min
rotations now work
TerrainEditor.h - fixed comments, variables moved for clarity, renamed `node` to static_object_node TerrainEditor.cpp - fixed direct manipulations with `node` (caused crash when pressing middle mouse button in editor) TerrainObjectManager.cpp - `destroyObject()` - handle preloaded actors correctly
Terrain editor is done. Not perfect - preloaded actor is visually off-center when moving/rotating, so what you see is not what you get, but I can fix that in later PR. Crash on MMB is fixed. |
The import wizzard doesn't pop up automatically anymore. Requested by Mike on GitHub: #3199 (review) at the bottom.
Major changes
Notes to code reviewers: