Skip to content

Commit

Permalink
clang-format: apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rokups committed Oct 21, 2017
1 parent af839cc commit 4a4a7df
Show file tree
Hide file tree
Showing 671 changed files with 16,173 additions and 21,247 deletions.
16 changes: 8 additions & 8 deletions Source/Extras/OgreBatchConverter/OgreBatchConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ int main(int argc, char** argv)
String ogreImporterName = fileSystem->GetProgramDir() + "OgreImporter";

printf("\n\nOgreBatchConverter requires OgreImporter.exe on same directory");
printf("\nSearching Ogre file in Xml format in %s\n" ,currentDir.CString());
printf("\nSearching Ogre file in Xml format in %s\n", currentDir.CString());
fileSystem->ScanDir(files, currentDir, "*.xml", SCAN_FILES, true);
printf("\nFound %d files\n", files.Size());
#ifdef WIN32
if (files.Size()) fileSystem->SystemCommand("pause");
#endif
#ifdef WIN32
if (files.Size())
fileSystem->SystemCommand("pause");
#endif

for (unsigned i = 0 ; i < files.Size(); i++)
for (unsigned i = 0; i < files.Size(); i++)
{
Vector<String> cmdArgs;
cmdArgs.Push(files[i]);
Expand All @@ -46,10 +47,9 @@ int main(int argc, char** argv)
}

printf("\nExit\n");
#ifdef WIN32
#ifdef WIN32
fileSystem->SystemCommand("pause");
#endif
#endif

return 0;
}

10 changes: 5 additions & 5 deletions Source/Samples/01_HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
// Expands to this example's entry-point
URHO3D_DEFINE_APPLICATION_MAIN(HelloWorld)

HelloWorld::HelloWorld(Context* context) :
Sample(context)
HelloWorld::HelloWorld(Context* context)
: Sample(context)
{
}

Expand All @@ -47,9 +47,9 @@ void HelloWorld::Start()
// Create "Hello World" Text
CreateText();

// Finally subscribe to the update event. Note that by subscribing events at this point we have already missed some events
// like the ScreenMode event sent by the Graphics subsystem when opening the application window. To catch those as well we
// could subscribe in the constructor instead.
// Finally subscribe to the update event. Note that by subscribing events at this point we have already missed some
// events like the ScreenMode event sent by the Graphics subsystem when opening the application window. To catch
// those as well we could subscribe in the constructor instead.
SubscribeToEvents();

// Set the mouse mode to use in the sample
Expand Down
13 changes: 7 additions & 6 deletions Source/Samples/01_HelloWorld/HelloWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ class HelloWorld : public Sample

protected:
/// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
virtual String GetScreenJoystickPatchString() const override { return
"<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
virtual String GetScreenJoystickPatchString() const override
{
return "<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
}

private:
Expand Down
11 changes: 6 additions & 5 deletions Source/Samples/02_HelloGUI/HelloGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@

URHO3D_DEFINE_APPLICATION_MAIN(HelloGUI)

HelloGUI::HelloGUI(Context* context) :
Sample(context),
uiRoot_(GetSubsystem<UI>()->GetRoot()),
dragBeginPosition_(IntVector2::ZERO)
HelloGUI::HelloGUI(Context* context)
: Sample(context)
, uiRoot_(GetSubsystem<UI>()->GetRoot())
, dragBeginPosition_(IntVector2::ZERO)
{
}

Expand Down Expand Up @@ -166,7 +166,8 @@ void HelloGUI::CreateDraggableFish()
// Add a tooltip to Fish button
ToolTip* toolTip = new ToolTip(context_);
draggableFish->AddChild(toolTip);
toolTip->SetPosition(IntVector2(draggableFish->GetWidth() + 5, draggableFish->GetWidth() / 2)); // slightly offset from close button
toolTip->SetPosition(
IntVector2(draggableFish->GetWidth() + 5, draggableFish->GetWidth() / 2)); // slightly offset from close button
BorderImage* textHolder = new BorderImage(context_);
toolTip->AddChild(textHolder);
textHolder->SetStyle("ToolTipBorderImage");
Expand Down
17 changes: 7 additions & 10 deletions Source/Samples/02_HelloGUI/HelloGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

namespace Urho3D
{

class Window;

}

/// A simple 'HelloWorld' GUI created purely from code.
Expand All @@ -53,12 +51,13 @@ class HelloGUI : public Sample

protected:
/// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
virtual String GetScreenJoystickPatchString() const override { return
"<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
virtual String GetScreenJoystickPatchString() const override
{
return "<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
}

private:
Expand Down Expand Up @@ -86,5 +85,3 @@ class HelloGUI : public Sample
/// Remembered drag begin position.
IntVector2 dragBeginPosition_;
};


4 changes: 2 additions & 2 deletions Source/Samples/03_Sprites/Sprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ static const StringHash VAR_VELOCITY("Velocity");

URHO3D_DEFINE_APPLICATION_MAIN(Sprites)

Sprites::Sprites(Context* context) :
Sample(context)
Sprites::Sprites(Context* context)
: Sample(context)
{
}

Expand Down
15 changes: 8 additions & 7 deletions Source/Samples/03_Sprites/Sprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ class Sprites : public Sample

protected:
/// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
virtual String GetScreenJoystickPatchString() const override { return
"<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
virtual String GetScreenJoystickPatchString() const override
{
return "<patch>"
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
" <attribute name=\"Is Visible\" value=\"false\" />"
" </add>"
"</patch>";
}

private:
Expand All @@ -62,5 +63,5 @@ class Sprites : public Sample
void HandleUpdate(StringHash eventType, VariantMap& eventData);

/// Vector to store the sprites for iterating through them.
Vector<SharedPtr<Sprite> > sprites_;
Vector<SharedPtr<Sprite>> sprites_;
};
43 changes: 22 additions & 21 deletions Source/Samples/04_StaticScene/StaticScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

URHO3D_DEFINE_APPLICATION_MAIN(StaticScene)

StaticScene::StaticScene(Context* context) :
Sample(context)
StaticScene::StaticScene(Context* context)
: Sample(context)
{
}

Expand Down Expand Up @@ -74,35 +74,35 @@ void StaticScene::CreateScene()

scene_ = new Scene(context_);

// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing will
// show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world coordinates; it
// is also legal to place objects outside the volume but their visibility can then not be checked in a hierarchically
// optimizing manner
// Create the Octree component to the scene. This is required before adding any drawable components, or else nothing
// will show up. The default octree volume will be from (-1000, -1000, -1000) to (1000, 1000, 1000) in world
// coordinates; it is also legal to place objects outside the volume but their visibility can then not be checked in
// a hierarchically optimizing manner
scene_->CreateComponent<Octree>();

// Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a simple
// plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node larger
// (100 x 100 world units)
// Create a child scene node (at world origin) and a StaticModel component into it. Set the StaticModel to show a
// simple plane mesh with a "stone" material. Note that naming the scene nodes is optional. Scale the scene node
// larger (100 x 100 world units)
Node* planeNode = scene_->CreateChild("Plane");
planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
StaticModel* planeObject = planeNode->CreateComponent<StaticModel>();
planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));

// Create a directional light to the world so that we can see something. The light scene node's orientation controls the
// light direction; we will use the SetDirection() function which calculates the orientation from a forward direction vector.
// The light will use default settings (white light, no shadows)
// Create a directional light to the world so that we can see something. The light scene node's orientation controls
// the light direction; we will use the SetDirection() function which calculates the orientation from a forward
// direction vector. The light will use default settings (white light, no shadows)
Node* lightNode = scene_->CreateChild("DirectionalLight");
lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f)); // The direction vector does not need to be normalized
Light* light = lightNode->CreateComponent<Light>();
light->SetLightType(LIGHT_DIRECTIONAL);

// Create more StaticModel objects to the scene, randomly positioned, rotated and scaled. For rotation, we construct a
// quaternion from Euler angles where the Y angle (rotation about the Y axis) is randomized. The mushroom model contains
// LOD levels, so the StaticModel component will automatically select the LOD level according to the view distance (you'll
// see the model get simpler as it moves further away). Finally, rendering a large number of the same object with the
// same material allows instancing to be used, if the GPU supports it. This reduces the amount of CPU work in rendering the
// scene.
// Create more StaticModel objects to the scene, randomly positioned, rotated and scaled. For rotation, we construct
// a quaternion from Euler angles where the Y angle (rotation about the Y axis) is randomized. The mushroom model
// contains LOD levels, so the StaticModel component will automatically select the LOD level according to the view
// distance (you'll see the model get simpler as it moves further away). Finally, rendering a large number of the
// same object with the same material allows instancing to be used, if the GPU supports it. This reduces the amount
// of CPU work in rendering the scene.
const unsigned NUM_OBJECTS = 200;
for (unsigned i = 0; i < NUM_OBJECTS; ++i)
{
Expand Down Expand Up @@ -144,9 +144,10 @@ void StaticScene::SetupViewport()
{
Renderer* renderer = GetSubsystem<Renderer>();

// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the camera
// at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward / deferred) to
// use, but now we just use full screen and default render path configured in the engine command line options
// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen. We need to define the scene and the
// camera at minimum. Additionally we could configure the viewport screen size and the rendering path (eg. forward /
// deferred) to use, but now we just use full screen and default render path configured in the engine command line
// options
SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
renderer->SetViewport(0, viewport);
}
Expand Down
2 changes: 0 additions & 2 deletions Source/Samples/04_StaticScene/StaticScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@

namespace Urho3D
{

class Node;
class Scene;

}

/// Static 3D scene example.
Expand Down
25 changes: 13 additions & 12 deletions Source/Samples/05_AnimatingScene/AnimatingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

URHO3D_DEFINE_APPLICATION_MAIN(AnimatingScene)

AnimatingScene::AnimatingScene(Context* context) :
Sample(context)
AnimatingScene::AnimatingScene(Context* context)
: Sample(context)
{
// Register an object factory for our custom Rotator component so that we can create them to scene nodes
context->RegisterFactory<Rotator>();
Expand Down Expand Up @@ -82,9 +82,10 @@ void AnimatingScene::CreateScene()
// (-1000, -1000, -1000) to (1000, 1000, 1000)
scene_->CreateComponent<Octree>();

// Create a Zone component into a child scene node. The Zone controls ambient lighting and fog settings. Like the Octree,
// it also defines its volume with a bounding box, but can be rotated (so it does not need to be aligned to the world X, Y
// and Z axes.) Drawable objects "pick up" the zone they belong to and use it when rendering; several zones can exist
// Create a Zone component into a child scene node. The Zone controls ambient lighting and fog settings. Like the
// Octree, it also defines its volume with a bounding box, but can be rotated (so it does not need to be aligned to
// the world X, Y and Z axes.) Drawable objects "pick up" the zone they belong to and use it when rendering; several
// zones can exist
Node* zoneNode = scene_->CreateChild("Zone");
Zone* zone = zoneNode->CreateComponent<Zone>();
// Set same volume as the Octree, set a close bluish fog and some ambient light
Expand All @@ -106,17 +107,17 @@ void AnimatingScene::CreateScene()
boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));

// Add our custom Rotator component which will rotate the scene node each frame, when the scene sends its update event.
// The Rotator component derives from the base class LogicComponent, which has convenience functionality to subscribe
// to the various update events, and forward them to virtual functions that can be implemented by subclasses. This way
// writing logic/update components in C++ becomes similar to scripting.
// Now we simply set same rotation speed for all objects
// Add our custom Rotator component which will rotate the scene node each frame, when the scene sends its update
// event. The Rotator component derives from the base class LogicComponent, which has convenience functionality
// to subscribe to the various update events, and forward them to virtual functions that can be implemented by
// subclasses. This way writing logic/update components in C++ becomes similar to scripting. Now we simply set
// same rotation speed for all objects
Rotator* rotator = boxNode->CreateComponent<Rotator>();
rotator->SetRotationSpeed(Vector3(10.0f, 20.0f, 30.0f));
}

// Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance, we can
// bring the far clip plane closer for more effective culling of distant objects
// Create the camera. Let the starting position be at the world origin. As the fog limits maximum visible distance,
// we can bring the far clip plane closer for more effective culling of distant objects
cameraNode_ = scene_->CreateChild("Camera");
Camera* camera = cameraNode_->CreateComponent<Camera>();
camera->SetFarClip(100.0f);
Expand Down
2 changes: 0 additions & 2 deletions Source/Samples/05_AnimatingScene/AnimatingScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@

namespace Urho3D
{

class Node;
class Scene;

}

/// Animating 3D scene example.
Expand Down
15 changes: 6 additions & 9 deletions Source/Samples/05_AnimatingScene/Rotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,19 @@

#include <Urho3D/DebugNew.h>

Rotator::Rotator(Context* context) :
LogicComponent(context),
rotationSpeed_(Vector3::ZERO)
Rotator::Rotator(Context* context)
: LogicComponent(context)
, rotationSpeed_(Vector3::ZERO)
{
// Only the scene update event is needed: unsubscribe from the rest for optimization
SetUpdateEventMask(USE_UPDATE);
}

void Rotator::SetRotationSpeed(const Vector3& speed)
{
rotationSpeed_ = speed;
}
void Rotator::SetRotationSpeed(const Vector3& speed) { rotationSpeed_ = speed; }

void Rotator::Update(float timeStep)
{
// Components have their scene node as a member variable for convenient access. Rotate the scene node now: construct a
// rotation quaternion from Euler angles, scale rotation speed with the scene update time step
// Components have their scene node as a member variable for convenient access. Rotate the scene node now: construct
// a rotation quaternion from Euler angles, scale rotation speed with the scene update time step
node_->Rotate(Quaternion(rotationSpeed_.x_ * timeStep, rotationSpeed_.y_ * timeStep, rotationSpeed_.z_ * timeStep));
}
8 changes: 4 additions & 4 deletions Source/Samples/05_AnimatingScene/Rotator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ using namespace Urho3D;
class Rotator : public LogicComponent
{
URHO3D_OBJECT(Rotator, LogicComponent);

public:
/// Construct.
Rotator(Context* context);

/// Set rotation speed about the Euler axes. Will be scaled with scene update time step.
void SetRotationSpeed(const Vector3& speed);
/// Handle scene update. Called by LogicComponent base class.
virtual void Update(float timeStep) override;

/// Return rotation speed.
const Vector3& GetRotationSpeed() const { return rotationSpeed_; }

private:
/// Rotation speed.
Vector3 rotationSpeed_;
Expand Down

0 comments on commit 4a4a7df

Please sign in to comment.