Skip to content

Commit 1a02548

Browse files
committed
Cleaned code, made many functions const and inline
1 parent f455f92 commit 1a02548

22 files changed

+70
-70
lines changed

CENTRAL 3D/Source/Component.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Component::ComponentType Component::GetType() const
4646
return type;
4747
}
4848

49-
GameObject * Component::GetContainerGameObject()
49+
GameObject * Component::GetContainerGameObject() const
5050
{
5151
return GO;
5252
}

CENTRAL 3D/Source/Component.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Component
2727

2828
// --- Getters ---
2929
ComponentType GetType() const;
30-
GameObject* GetContainerGameObject();
30+
GameObject* GetContainerGameObject() const;
3131
bool& GetActive();
3232
bool IsEnabled() const;
3333

CENTRAL 3D/Source/ComponentRenderer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ComponentRenderer::~ComponentRenderer()
1818

1919
}
2020

21-
void ComponentRenderer::Draw()
21+
void ComponentRenderer::Draw() const
2222
{
2323
ComponentMesh * mesh = this->GO->GetComponent<ComponentMesh>(Component::ComponentType::Mesh);
2424

@@ -30,9 +30,8 @@ void ComponentRenderer::Draw()
3030
}
3131
}
3232

33-
void ComponentRenderer::DrawMesh(ComponentMesh& mesh) const
33+
inline void ComponentRenderer::DrawMesh(ComponentMesh& mesh) const
3434
{
35-
3635
// --- Draw Texture ---
3736
glEnableClientState(GL_TEXTURE_COORD_ARRAY); // enable gl capability
3837
glEnableClientState(GL_VERTEX_ARRAY); // enable client-side capability
@@ -74,7 +73,7 @@ void ComponentRenderer::DrawMesh(ComponentMesh& mesh) const
7473

7574
}
7675

77-
void ComponentRenderer::DrawNormals(const ComponentMesh& mesh) const
76+
inline void ComponentRenderer::DrawNormals(const ComponentMesh& mesh) const
7877
{
7978
// --- Draw Mesh Normals ---
8079
glBegin(GL_LINES);
@@ -124,7 +123,7 @@ void ComponentRenderer::DrawNormals(const ComponentMesh& mesh) const
124123

125124
}
126125

127-
void ComponentRenderer::DrawAxis() const
126+
inline void ComponentRenderer::DrawAxis() const
128127
{
129128
// --- Draw Axis ---
130129
glLineWidth(2.0f);

CENTRAL 3D/Source/ComponentRenderer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class ComponentRenderer : public Component
1515
ComponentRenderer(GameObject* ContainerGO);
1616
virtual ~ComponentRenderer();
1717

18-
void Draw();
18+
void Draw() const;
1919

2020
private:
2121
// --- Draw Functiions accessed by main Draw ---
22-
void DrawMesh(ComponentMesh& mesh) const;
23-
void DrawNormals(const ComponentMesh& mesh) const;
24-
void DrawAxis() const;
22+
inline void DrawMesh(ComponentMesh& mesh) const;
23+
inline void DrawNormals(const ComponentMesh& mesh) const;
24+
inline void DrawAxis() const;
2525

2626
public:
2727
bool draw_vertexnormals = false;

CENTRAL 3D/Source/ComponentTransform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ComponentTransform::~ComponentTransform()
88
{
99
}
1010

11-
float3 ComponentTransform::GetPosition()
11+
float3 ComponentTransform::GetPosition() const
1212
{
1313
float3 position;
1414
/*Local_transform.TransformPos(position);
@@ -22,7 +22,7 @@ float3 ComponentTransform::GetPosition()
2222
return position;
2323
}
2424

25-
float3 ComponentTransform::GetScale()
25+
float3 ComponentTransform::GetScale() const
2626
{
2727
float3 scale;
2828

@@ -33,7 +33,7 @@ float3 ComponentTransform::GetScale()
3333
return scale;
3434
}
3535

36-
float3 ComponentTransform::GetRotation()
36+
float3 ComponentTransform::GetRotation() const
3737
{
3838
float3 rotation = float3::zero;
3939

@@ -43,7 +43,7 @@ float3 ComponentTransform::GetRotation()
4343
return rotation;
4444
}
4545

46-
float4x4 ComponentTransform::GetLocalTransform()
46+
float4x4 ComponentTransform::GetLocalTransform() const
4747
{
4848
return Local_transform;
4949
}

CENTRAL 3D/Source/ComponentTransform.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class ComponentTransform : public Component
1212
virtual ~ComponentTransform();
1313

1414
// --- Getters ---
15-
float3 GetPosition();
16-
float3 GetScale();
17-
float3 GetRotation();
18-
float4x4 GetLocalTransform();
15+
float3 GetPosition() const;
16+
float3 GetScale() const;
17+
float3 GetRotation() const;
18+
float4x4 GetLocalTransform() const;
1919

2020
// --- Setters ---
2121
void SetPosition(float x, float y, float z);

CENTRAL 3D/Source/GameObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void GameObject::RemoveComponent(Component::ComponentType type)
9393
}
9494
}
9595

96-
bool GameObject::HasComponent(Component::ComponentType type)
96+
bool GameObject::HasComponent(Component::ComponentType type) const
9797
{
9898
// --- Search for given type of component ---
9999

CENTRAL 3D/Source/GameObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GameObject
4545

4646
Component* AddComponent(Component::ComponentType type);
4747
void RemoveComponent(Component::ComponentType type);
48-
bool HasComponent(Component::ComponentType type);
48+
bool HasComponent(Component::ComponentType type) const;
4949

5050
// --- Setters ---
5151
void SetName(const char* name);

CENTRAL 3D/Source/ModuleGui.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,17 +354,17 @@ void ModuleGui::LoadStatus(const json & file)
354354
LOG("|[error]: Could not find sub-node %s in GUI JSON Node, please check JSON EditorConfig", panels[i]->GetName());
355355
}
356356
}
357-
void ModuleGui::HandleInput(SDL_Event * event)
357+
void ModuleGui::HandleInput(SDL_Event * event) const
358358
{
359359
ImGui_ImplSDL2_ProcessEvent(event);
360360
}
361361

362-
bool ModuleGui::IsKeyboardCaptured()
362+
bool ModuleGui::IsKeyboardCaptured() const
363363
{
364364
return capture_keyboard;
365365
}
366366

367-
bool ModuleGui::IsMouseCaptured()
367+
bool ModuleGui::IsMouseCaptured() const
368368
{
369369
return capture_mouse;
370370
}

CENTRAL 3D/Source/ModuleGui.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class ModuleGui : public Module
3838

3939
void LoadStatus(const json & file) override;
4040

41-
void HandleInput(SDL_Event* event);
41+
void HandleInput(SDL_Event* event) const;
4242

43-
bool IsKeyboardCaptured();
44-
bool IsMouseCaptured();
43+
bool IsKeyboardCaptured() const;
44+
bool IsMouseCaptured() const;
4545
public:
4646

4747
PanelSettings* panelSettings = nullptr;

0 commit comments

Comments
 (0)