Skip to content

Commit d0f7da3

Browse files
committed
Added -> operator to iterators and renamed Material Destroy function
1 parent 2286b2c commit d0f7da3

File tree

7 files changed

+48
-14
lines changed

7 files changed

+48
-14
lines changed

engine/render/renderer/platform/vulkan/Material.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,20 @@ Material::~Material()
107107

108108
for (auto it = propertiesSlots.CreateFIterator(); it; ++it)
109109
{
110-
vkDestroyDescriptorSetLayout(device, (*it).layout, nullptr);
110+
vkDestroyDescriptorSetLayout(device, it->layout, nullptr);
111111
}
112112
}
113113

114-
void Material::Destroy()
114+
void Material::Free()
115115
{
116116
auto device = Vulkan::Context::GetVkLogicalDevice();
117117

118118
Buffer::DestroyBuffer(buffer);
119119

120120
for (auto it = propertiesSlots.CreateFIterator(); it; ++it)
121121
{
122-
auto& prop = *it;
123-
vkDestroyDescriptorSetLayout(device, prop.layout, nullptr);
124-
prop.layout = nullptr;
122+
vkDestroyDescriptorSetLayout(device, it->layout, nullptr);
123+
it->layout = nullptr;
125124
}
126125

127126
vertexShader.Destroy();
@@ -373,7 +372,7 @@ int32_t Material::FindPropertyIndex(Hash::StringId id, PropertiesSlot& slot)
373372
int32_t foundIdx {-1};
374373
for (auto it = slot.properties.CreateIterator(); it; ++it)
375374
{
376-
if ((*it).id == id)
375+
if (it->id == id)
377376
{
378377
foundIdx = it.GetIndex();
379378
break;

engine/render/renderer/platform/vulkan/Material.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Material
6363
*/
6464
~Material();
6565

66-
void Destroy();
66+
void Free();
6767

6868
/**
6969
* A movement assignment operator

engine/render/renderer/platform/vulkan/Pipeline.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,10 @@ Pipeline Pipeline::Builder::Build()
102102

103103
for (auto vertIt = vertShaderVertices.CreateIterator(); vertIt; ++vertIt)
104104
{
105-
auto index = vertIt.GetIndex();
106105
auto& binding = *vertIt;
107-
inputDescriptions[index] = {static_cast<uint32_t>(index),
108-
binding.stride,
109-
VK_VERTEX_INPUT_RATE_VERTEX};
106+
inputDescriptions[vertIt.GetIndex()] = {static_cast<uint32_t>(vertIt.GetIndex()),
107+
binding.stride,
108+
VK_VERTEX_INPUT_RATE_VERTEX};
110109

111110
auto& attributes = binding.attributes;
112111

engine/render/renderer/renderer/DebugRenderer3D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void DebugRenderer3D::Initialise(const String& globalDataAttributeName,
3939

4040
void DebugRenderer3D::Destroy()
4141
{
42-
lineMaterial.Destroy();
42+
lineMaterial.Free();
4343
lineModel.DestroyModel();
4444
}
4545

engine/render/renderer/renderer/LightRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void LightRenderer::Initialise(const String& globalDataAttributeName,
3535

3636
void LightRenderer::Destroy()
3737
{
38-
lightMaterial.Destroy();
38+
lightMaterial.Free();
3939
lightModel.DestroyModel();
4040
}
4141

engine/render/renderer/renderer/Renderer2D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void Renderer2D::DestroyRenderer2D()
102102
{
103103
quadModel.DestroyModel();
104104
defaultTexture.Free();
105-
defaultMaterial.Destroy();
105+
defaultMaterial.Free();
106106
}
107107

108108
void Renderer2D::Flush()

engine/utils/collections/Iterators.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ class Iter
8888
return ptr->Data() != other.ptr->Data() && index != other.index;
8989
}
9090

91+
/**
92+
* A de-referencing operator. Accesses a pointer to the current element
93+
* @return a pointer to the element pointed to by the iterator
94+
*/
95+
inline constexpr T* operator->() const
96+
{
97+
return ptr->Data() + index;
98+
}
99+
91100
/**
92101
* Returns the index currently held by the iterator
93102
* @return returns the current index the iterator is on
@@ -183,6 +192,15 @@ class ConstIter
183192
return ptr->Data() != other.ptr->Data() && index != other.index;
184193
}
185194

195+
/**
196+
* A de-referencing operator. Accesses a pointer to the current element
197+
* @return a pointer to the element pointed to by the iterator
198+
*/
199+
inline constexpr const T* operator->() const
200+
{
201+
return ptr->Data() + index;
202+
}
203+
186204
/**
187205
* Returns the index currently held by the iterator
188206
* @return returns the current index the iterator is on
@@ -288,6 +306,15 @@ class MIter
288306
return ptr->Data() != other.ptr->Data() && index != other.index;
289307
}
290308

309+
/**
310+
* A de-referencing operator. Accesses a pointer to the current element
311+
* @return a pointer to the element pointed to by the iterator
312+
*/
313+
inline constexpr T* operator->() const
314+
{
315+
return ptr->Data() + index;
316+
}
317+
291318
/**
292319
* Returns the index currently held by the iterator
293320
* @return returns the current index the iterator is on
@@ -395,6 +422,15 @@ class CMIter
395422
return ptr->Data() != other.ptr->Data() && index != other.index;
396423
}
397424

425+
/**
426+
* A de-referencing operator. Accesses a pointer to the current element
427+
* @return a pointer to the element pointed to by the iterator
428+
*/
429+
inline constexpr const T* operator->() const
430+
{
431+
return ptr->Data() + index;
432+
}
433+
398434
/**
399435
* Returns the index currently held by the iterator
400436
* @return returns the current index the iterator is on

0 commit comments

Comments
 (0)