RigsofRods
Soft-body Physics Simulation
AddonPartFileFormat.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2023 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #pragma once
23 
24 #include "Application.h"
25 #include "GenericFileFormat.h"
26 #include "RefCountingObject.h"
27 #include "RigDef_File.h" // Document
28 
29 #include <OgreResourceManager.h>
30 
31 #include <memory>
32 #include <string>
33 #include <unordered_set>
34 #include <vector>
35 
36 namespace RoR {
37 
39 {
42  std::string atc_keyword;
43  int atc_element_id = -1;
44 
45  AddonPartConflict(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, std::string keyword, int element_id):
46  atc_addonpart1(addonpart1),
47  atc_addonpart2(addonpart2),
49  atc_element_id(element_id)
50  {}
51 };
52 
53 typedef std::vector<AddonPartConflict> AddonPartConflictVec;
54 
57 {
58 public:
59  AddonPartUtility(bool silent_mode = false);
61 
64  std::shared_ptr<RigDef::Document::Module> TransformToRigDefModule(CacheEntryPtr& addonpart_entry);
65 
68  void ResolveUnwantedAndTweakedElements(TuneupDefPtr& tuneup, CacheEntryPtr& addonpart_entry);
69 
70  static void ResetUnwantedAndTweakedElements(TuneupDefPtr& tuneup);
71 
72  static void RecordAddonpartConflicts(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, AddonPartConflictVec& conflicts);
73 
74  static bool CheckForAddonpartConflict(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, AddonPartConflictVec& conflicts);
75 
76  static bool DoubleCheckForAddonpartConflict(ActorPtr target_actor, CacheEntryPtr addonpart_entry);
77 
78 private:
79  // Helpers of `TransformToRigDefModule()`, they expect `m_context` to be in position:
82  void ProcessProp();
83  void ProcessFlexbody();
84  void ProcessFlare();
85  void ProcessFlare2();
86 
87  // Helpers of `ResolveUnwantedAndTweakedElements()`, they expect `m_context` to be in position:
88  void ProcessTweakWheel();
89  void ProcessTweakNode();
90  void ProcessTweakFlexbody();
91  void ProcessTweakProp();
93  void ProcessUnwantedProp();
95  void ProcessUnwantedFlare();
98 
99  void Log(const std::string& text);
100 
101  // Shared state:
105  // TransformToRigDefModule() state:
106  std::shared_ptr<RigDef::Document::Module> m_module;
108  // ResolveUnwantedAndTweakedElements() state:
111 };
112 
113 }; // namespace RoR
RoR::AddonPartUtility::ResolveUnwantedAndTweakedElements
void ResolveUnwantedAndTweakedElements(TuneupDefPtr &tuneup, CacheEntryPtr &addonpart_entry)
Evaluates 'addonpart_unwanted_*' elements, respecting 'protected_*' directives in the tuneup.
Definition: AddonPartFileFormat.cpp:132
RoR::AddonPartUtility::m_module
std::shared_ptr< RigDef::Document::Module > m_module
Definition: AddonPartFileFormat.h:106
RoR::AddonPartUtility::m_document
GenericDocumentPtr m_document
Definition: AddonPartFileFormat.h:102
RoR::AddonPartUtility::ProcessUnwantedFlare
void ProcessUnwantedFlare()
Definition: AddonPartFileFormat.cpp:493
RoR::AddonPartUtility::ProcessUnwantedExhaust
void ProcessUnwantedExhaust()
Definition: AddonPartFileFormat.cpp:517
RoR::AddonPartConflict::AddonPartConflict
AddonPartConflict(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, std::string keyword, int element_id)
Definition: AddonPartFileFormat.h:45
RoR::AddonPartConflict::atc_keyword
std::string atc_keyword
Definition: AddonPartFileFormat.h:42
RoR::AddonPartUtility::m_context
GenericDocContextPtr m_context
Definition: AddonPartFileFormat.h:103
RoR::AddonPartUtility::ProcessUnwantedManagedMat
void ProcessUnwantedManagedMat()
Definition: AddonPartFileFormat.cpp:541
RoR::AddonPartUtility::TransformToRigDefModule
std::shared_ptr< RigDef::Document::Module > TransformToRigDefModule(CacheEntryPtr &addonpart_entry)
transforms the addonpart to RigDef::File::Module (fake 'section/end_section') used for spawning.
Definition: AddonPartFileFormat.cpp:49
RoR::AddonPartUtility::m_silent_mode
bool m_silent_mode
Definition: AddonPartFileFormat.h:110
RoR::AddonPartUtility::ProcessTweakProp
void ProcessTweakProp()
Definition: AddonPartFileFormat.cpp:713
RoR::AddonPartConflictVec
std::vector< AddonPartConflict > AddonPartConflictVec
Definition: AddonPartFileFormat.h:53
RefCountingObjectPtr< CacheEntry >
RoR::AddonPartUtility::ProcessTweakNode
void ProcessTweakNode()
Definition: AddonPartFileFormat.cpp:614
RoR::AddonPartUtility::ProcessManagedMaterial
void ProcessManagedMaterial()
Definition: AddonPartFileFormat.cpp:210
RoR::AddonPartConflict::atc_addonpart2
CacheEntryPtr atc_addonpart2
Definition: AddonPartFileFormat.h:41
RoR::AddonPartUtility::m_tuneup
TuneupDefPtr m_tuneup
Definition: AddonPartFileFormat.h:109
RoR::AddonPartUtility::ProcessDirectiveSetManagedMaterialsOptions
void ProcessDirectiveSetManagedMaterialsOptions()
Definition: AddonPartFileFormat.cpp:239
RoR::AddonPartUtility::ProcessUnwantedProp
void ProcessUnwantedProp()
Definition: AddonPartFileFormat.cpp:445
RoR::AddonPartUtility::ResetUnwantedAndTweakedElements
static void ResetUnwantedAndTweakedElements(TuneupDefPtr &tuneup)
Definition: AddonPartFileFormat.cpp:190
RoR::AddonPartUtility::RecordAddonpartConflicts
static void RecordAddonpartConflicts(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, AddonPartConflictVec &conflicts)
Definition: AddonPartFileFormat.cpp:812
keyword
static int keyword
Definition: Bench_TruckParser_IdentifyKeyword.cpp:1448
RoR::AddonPartUtility::ProcessTweakWheel
void ProcessTweakWheel()
Definition: AddonPartFileFormat.cpp:566
RoR::AddonPartUtility::m_addonpart_entry
CacheEntryPtr m_addonpart_entry
Definition: AddonPartFileFormat.h:104
RefCountingObject.h
Application.h
Central state/object manager and communications hub.
RoR::AddonPartConflict
< Conflict between two addonparts tweaking the same element
Definition: AddonPartFileFormat.h:38
RoR::AddonPartUtility::DoubleCheckForAddonpartConflict
static bool DoubleCheckForAddonpartConflict(ActorPtr target_actor, CacheEntryPtr addonpart_entry)
Definition: AddonPartFileFormat.cpp:910
RoR::AddonPartUtility::Log
void Log(const std::string &text)
Definition: AddonPartFileFormat.cpp:902
RoR::AddonPartUtility::ProcessTweakFlexbody
void ProcessTweakFlexbody()
Definition: AddonPartFileFormat.cpp:659
RoR::AddonPartUtility::CheckForAddonpartConflict
static bool CheckForAddonpartConflict(CacheEntryPtr addonpart1, CacheEntryPtr addonpart2, AddonPartConflictVec &conflicts)
Definition: AddonPartFileFormat.cpp:884
RoR::AddonPartUtility::m_managedmaterials_options
RigDef::ManagedMaterialsOptions m_managedmaterials_options
Definition: AddonPartFileFormat.h:107
RoR::AddonPartUtility::ProcessFlare2
void ProcessFlare2()
Definition: AddonPartFileFormat.cpp:404
RoR::AddonPartUtility::ProcessUnwantedFlexbody
void ProcessUnwantedFlexbody()
Definition: AddonPartFileFormat.cpp:469
RoR::AddonPartUtility::ProcessProp
void ProcessProp()
Definition: AddonPartFileFormat.cpp:248
RoR::AddonPartUtility::AddonPartUtility
AddonPartUtility(bool silent_mode=false)
Definition: AddonPartFileFormat.cpp:39
RoR::AddonPartUtility
NOTE: Modcache processes this format directly using RoR::GenericDocument, see RoR::CacheSystem::FillA...
Definition: AddonPartFileFormat.h:56
RoR::AddonPartConflict::atc_addonpart1
CacheEntryPtr atc_addonpart1
Definition: AddonPartFileFormat.h:40
RoR::AddonPartUtility::~AddonPartUtility
~AddonPartUtility()
Definition: AddonPartFileFormat.cpp:44
GenericFileFormat.h
Generic text file parser.
RigDef_File.h
Data structures representing 'truck' file format, see https://docs.rigsofrods.org/vehicle-creation/fi...
RoR
Definition: AppContext.h:36
RigDef::ManagedMaterialsOptions
Definition: RigDef_File.h:1016
RoR::AddonPartUtility::ProcessFlexbody
void ProcessFlexbody()
Definition: AddonPartFileFormat.cpp:314
RoR::AddonPartUtility::ProcessFlare
void ProcessFlare()
Definition: AddonPartFileFormat.cpp:366
RoR::AddonPartConflict::atc_element_id
int atc_element_id
Definition: AddonPartFileFormat.h:43
RoR::AddonPartUtility::ProcessTweakManagedMat
void ProcessTweakManagedMat()
Definition: AddonPartFileFormat.cpp:770