Skip to content

Commit f9e6fd2

Browse files
Code cleanup (#1217) (#1219)
(cherry picked from commit 7ac8abc) Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com> Co-authored-by: Maksim Derbasov <ntfs.hard@gmail.com>
1 parent 2f3d866 commit f9e6fd2

File tree

78 files changed

+241
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+241
-264
lines changed

examples/actor_animation/GlutWindow.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ void updatePose(double _time)
250250
for (auto &v : g_visuals)
251251
{
252252
//! [update pose]
253-
std::map<std::string, gz::math::Matrix4d> animFrames;
254-
animFrames = g_skelAnim->PoseAt(_time, true);
253+
std::map<std::string, gz::math::Matrix4d> animFrames =
254+
g_skelAnim->PoseAt(_time, true);
255255
std::map<std::string, gz::math::Matrix4d> skinFrames;
256-
for (auto pair : animFrames)
256+
for (const auto &pair : animFrames)
257257
{
258-
std::string animNodeName = pair.first;
259-
auto animTf = pair.second;
258+
const auto &animNodeName = pair.first;
259+
const auto &animTf = pair.second;
260260

261261
std::string skinName =
262262
g_skel->NodeNameAnimToSkin(g_animIdx, animNodeName);

examples/actor_animation/Main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ int main(int _argc, char** _argv)
209209
std::vector<VisualPtr> visuals;
210210
ic::SkeletonPtr skel = nullptr;
211211

212-
for (auto engineName : engineNames)
212+
for (const auto &engineName : engineNames)
213213
{
214214
std::cout << "Starting engine [" << engineName << "]" << std::endl;
215215
try
216216
{
217217
std::map<std::string, std::string> params;
218-
if (engineName.compare("ogre2") == 0
218+
if (engineName == "ogre2"
219219
&& graphicsApi == GraphicsAPI::METAL)
220220
{
221221
params["metal"] = "1";

examples/boundingbox_camera/Main.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ int main(int _argc, char** _argv)
263263
const std::string type3d = "3D";
264264
const std::string type2dVisible = "2D_visible";
265265
const std::string type2dFull = "2D_full";
266-
if (type2dVisible.compare(_argv[1]) == 0)
266+
if (type2dVisible == _argv[1])
267267
{
268268
bboxType = BoundingBoxType::BBT_VISIBLEBOX2D;
269269
}
270-
else if (type2dFull.compare(_argv[1]) == 0)
270+
else if (type2dFull == _argv[1])
271271
{
272272
bboxType = BoundingBoxType::BBT_FULLBOX2D;
273273
}
274-
else if (type3d.compare(_argv[1]) != 0)
274+
else if (type3d != _argv[1])
275275
{
276276
gzerr << "Invalid bounding box type given. Valid options are: "
277277
<< type3d << ", " << type2dVisible << ", or "
@@ -298,7 +298,7 @@ int main(int _argc, char** _argv)
298298
try
299299
{
300300
std::map<std::string, std::string> params;
301-
if (engineName.compare("ogre2") == 0
301+
if (engineName == "ogre2"
302302
&& graphicsApi == GraphicsAPI::METAL)
303303
{
304304
params["metal"] = "1";

examples/camera_tracking/Main.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ int main(int _argc, char** _argv)
140140

141141
engineNames.push_back(ogreEngineName);
142142

143-
for (auto engineName : engineNames)
143+
for (const auto &engineName : engineNames)
144144
{
145145
try
146146
{
147147
std::map<std::string, std::string> params;
148-
if (engineName.compare("ogre2") == 0
148+
if (engineName == "ogre2"
149149
&& graphicsApi == GraphicsAPI::METAL)
150150
{
151151
params["metal"] = "1";
@@ -163,7 +163,6 @@ int main(int _argc, char** _argv)
163163
}
164164
catch (...)
165165
{
166-
// std::cout << ex.what() << std::endl;
167166
std::cerr << "Error starting up: " << engineName << std::endl;
168167
}
169168
}

examples/custom_scene_viewer/ManualSceneDemo.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ CameraPtr ManualSceneDemo::CurrentCamera()
153153
//////////////////////////////////////////////////
154154
void ManualSceneDemo::Run()
155155
{
156-
for (auto builder : this->builders)
156+
for (auto &builder : this->builders)
157157
{
158158
builder->SetScenes(this->scenes);
159159
builder->SetCameras(this->cameras);
@@ -199,7 +199,7 @@ int main(int _argc, char** _argv)
199199
}
200200

201201
std::map<std::string, std::string> params;
202-
if (ogreEngineName.compare("ogre2") == 0
202+
if (ogreEngineName == "ogre2"
203203
&& graphicsApi == GraphicsAPI::METAL)
204204
{
205205
params["metal"] = "1";

examples/custom_scene_viewer/SceneBuilder.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void SceneBuilder::SetCameras(const CameraList &_cameras)
5555
//////////////////////////////////////////////////
5656
void SceneBuilder::BuildScenes()
5757
{
58-
for (auto scene : this->scenes)
58+
for (auto &scene : this->scenes)
5959
{
6060
this->ClearScene(scene);
6161
this->BuildScene(scene);
@@ -65,7 +65,7 @@ void SceneBuilder::BuildScenes()
6565
//////////////////////////////////////////////////
6666
void SceneBuilder::ResetCameras()
6767
{
68-
for (auto camera : this->cameras)
68+
for (auto &camera : this->cameras)
6969
{
7070
this->ResetCamera(camera);
7171
}
@@ -74,7 +74,7 @@ void SceneBuilder::ResetCameras()
7474
//////////////////////////////////////////////////
7575
void SceneBuilder::UpdateScenes()
7676
{
77-
for (auto scene : this->scenes)
77+
for (auto &scene : this->scenes)
7878
{
7979
this->UpdateScene(scene);
8080
}
@@ -110,7 +110,7 @@ void SceneBuilder::UpdateScene(ScenePtr)
110110
//////////////////////////////////////////////////
111111
void SceneBuilder::RegisterMaterials()
112112
{
113-
for (auto scene : this->scenes)
113+
for (auto &scene : this->scenes)
114114
{
115115
this->RegisterMaterials(scene);
116116
}
@@ -139,7 +139,6 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
139139
mat->SetReflectivity(0);
140140
}
141141

142-
143142
if (!_scene->MaterialRegistered("Green"))
144143
{
145144
MaterialPtr mat = _scene->CreateMaterial("Green");
@@ -170,14 +169,15 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
170169
mat->SetReflectivity(0);
171170
}
172171

173-
std::vector<std::string> baseNames;
174-
baseNames.push_back("Blue");
175-
baseNames.push_back("Green");
176-
baseNames.push_back("Red");
177-
baseNames.push_back("White");
178-
baseNames.push_back("Yellow");
172+
std::vector<std::string> baseNames = {
173+
"Blue",
174+
"Green",
175+
"Red",
176+
"White",
177+
"Yellow"
178+
};
179179

180-
for (auto baseName : baseNames)
180+
for (const auto &baseName : baseNames)
181181
{
182182
std::string parentName = baseName;
183183
std::string childName = "Texture" + baseName;
@@ -189,7 +189,7 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
189189
}
190190
}
191191

192-
for (auto baseName : baseNames)
192+
for (const auto &baseName : baseNames)
193193
{
194194
std::string parentName = "Texture" + baseName;
195195
std::string childName = "Normal" + baseName;
@@ -202,7 +202,7 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
202202
}
203203
}
204204

205-
for (auto baseName : baseNames)
205+
for (const auto &baseName : baseNames)
206206
{
207207
std::string parentName = "Texture" + baseName;
208208
std::string childName = "Reflect" + baseName;
@@ -214,7 +214,7 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
214214
}
215215
}
216216

217-
for (auto baseName : baseNames)
217+
for (const auto &baseName : baseNames)
218218
{
219219
std::string parentName = "Normal" + baseName;
220220
std::string childName = "NormalReflect" + baseName;
@@ -226,7 +226,7 @@ void SceneBuilder::RegisterMaterials(ScenePtr _scene)
226226
}
227227
}
228228

229-
for (auto baseName : baseNames)
229+
for (const auto &baseName : baseNames)
230230
{
231231
std::string parentName = baseName;
232232
std::string childName = "Trans" + baseName;

examples/custom_shaders_uniforms/Main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ int main(int _argc, char** _argv)
179179

180180
engineNames.push_back(ogreEngineName);
181181

182-
for (auto engineName : engineNames)
182+
for (const auto &engineName : engineNames)
183183
{
184184
try
185185
{
186186
std::map<std::string, std::string> params;
187-
if (engineName.compare("ogre2") == 0
187+
if (engineName == "ogre2"
188188
&& graphicsApi == GraphicsAPI::METAL)
189189
{
190190
params["metal"] = "1";

examples/depth_camera/Main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int main(int _argc, char** _argv)
176176
try
177177
{
178178
std::map<std::string, std::string> params;
179-
if (engineName.compare("ogre2") == 0
179+
if (engineName == "ogre2"
180180
&& graphicsApi == GraphicsAPI::METAL)
181181
{
182182
params["metal"] = "1";

examples/frustum_visual/Main.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ int main(int _argc, char** _argv)
155155

156156
engineNames.push_back(ogreEngineName);
157157

158-
for (auto engineName : engineNames)
158+
for (const auto &engineName : engineNames)
159159
{
160160
try
161161
{
162162
std::map<std::string, std::string> params;
163-
if (engineName.compare("ogre2") == 0
163+
if (engineName == "ogre2"
164164
&& graphicsApi == GraphicsAPI::METAL)
165165
{
166166
params["metal"] = "1";
@@ -178,7 +178,6 @@ int main(int _argc, char** _argv)
178178
}
179179
catch (...)
180180
{
181-
// std::cout << ex.what() << std::endl;
182181
std::cerr << "Error starting up: " << engineName << std::endl;
183182
}
184183
}

examples/global_illumination/Main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ int main(int _argc, char **_argv)
363363
std::vector<CameraPtr> cameras;
364364

365365
std::map<std::string, std::string> params;
366-
if (engineName.compare("ogre2") == 0
366+
if (engineName == "ogre2"
367367
&& graphicsApi == GraphicsAPI::VULKAN)
368368
{
369369
params["vulkan"] = "1";

0 commit comments

Comments
 (0)