Skip to content

Commit bef849b

Browse files
authored
large code cleanup (#8364)
* Remove redundant qualifiers in filament public headers * remove redundant qualifiers in filament implementation * remove redundant qualifiers in libutils public headers * remove redundant qualifier for libutils implementation * remove redundant qualifiers for libmath * use is_same_v<> instead of is_same<> * bring back Builder::name() we keep Builder::name() on all object, and forward to the MixIn class that does the implementation, so that we have correct documentation, and better IDE completion. * add missing const parameters in filament's implementation * various source cleanup - missing includes - missing const - C cast style - superfluous inline keyword
1 parent 1747ae8 commit bef849b

File tree

169 files changed

+1982
-1910
lines changed

Some content is hidden

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

169 files changed

+1982
-1910
lines changed

filament/include/filament/Box.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ struct UTILS_PUBLIC Aabb {
183183
* Returns the 8 corner vertices of the AABB.
184184
*/
185185
Corners getCorners() const {
186-
return Aabb::Corners{ .vertices = {
186+
return Corners{ .vertices = {
187187
{ min.x, min.y, min.z },
188188
{ max.x, min.y, min.z },
189189
{ min.x, max.y, min.z },

filament/include/filament/BufferObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class UTILS_PUBLIC BufferObject : public FilamentAPI {
7373

7474
/**
7575
* The binding type for this buffer object. (defaults to VERTEX)
76-
* @param BindingType Distinguishes between SSBO, VBO, etc. For now this must be VERTEX.
76+
* @param bindingType Distinguishes between SSBO, VBO, etc. For now this must be VERTEX.
7777
* @return A reference to this Builder for chaining calls.
7878
*/
7979
Builder& bindingType(BindingType bindingType) noexcept;
@@ -91,7 +91,7 @@ class UTILS_PUBLIC BufferObject : public FilamentAPI {
9191
* @param len Length of name, should be less than or equal to 128
9292
* @return This Builder, for chaining calls.
9393
*/
94-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
94+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
9595

9696
/**
9797
* Creates the BufferObject and returns a pointer to it. After creation, the buffer

filament/include/filament/Camera.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@ class UTILS_PUBLIC Camera : public FilamentAPI {
400400
* engine.getTransformManager().getInstance(camera->getEntity()), model);
401401
* ~~~~~~~~~~~
402402
*
403-
* @param model The camera position and orientation provided as a rigid transform matrix.
403+
* @param modelMatrix The camera position and orientation provided as a rigid transform matrix.
404404
*
405405
* @note The Camera "looks" towards its -z axis
406406
*
407407
* @warning \p model must be a rigid transform
408408
*/
409-
void setModelMatrix(const math::mat4& model) noexcept;
410-
void setModelMatrix(const math::mat4f& model) noexcept; //!< @overload
409+
void setModelMatrix(const math::mat4& modelMatrix) noexcept;
410+
void setModelMatrix(const math::mat4f& modelMatrix) noexcept; //!< @overload
411411

412412
/** Set the position of an eye relative to this Camera (head).
413413
*

filament/include/filament/Color.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ inline sRGBColorA Color::toSRGB<ACCURATE>(LinearColorA const& color) {
194194
}
195195

196196
inline LinearColor Color::toLinear(RgbType type, math::float3 color) {
197-
return (type == RgbType::LINEAR) ? color : Color::toLinear<ACCURATE>(color);
197+
return (type == RgbType::LINEAR) ? color : toLinear<ACCURATE>(color);
198198
}
199199

200200
// converts an RGBA color to linear space
201201
// the conversion depends on the specified type
202202
inline LinearColorA Color::toLinear(RgbaType type, math::float4 color) {
203203
switch (type) {
204204
case RgbaType::sRGB:
205-
return Color::toLinear<ACCURATE>(color) * math::float4{color.a, color.a, color.a, 1.0f};
205+
return toLinear<ACCURATE>(color) * math::float4{color.a, color.a, color.a, 1.0f};
206206
case RgbaType::LINEAR:
207207
return color * math::float4{color.a, color.a, color.a, 1.0f};
208208
case RgbaType::PREMULTIPLIED_sRGB:
209-
return Color::toLinear<ACCURATE>(color);
209+
return toLinear<ACCURATE>(color);
210210
case RgbaType::PREMULTIPLIED_LINEAR:
211211
return color;
212212
}

filament/include/filament/Engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class UTILS_PUBLIC Engine {
537537
Platform* UTILS_NULLABLE platform = nullptr,
538538
void* UTILS_NULLABLE sharedContext = nullptr,
539539
const Config* UTILS_NULLABLE config = nullptr) {
540-
return Engine::Builder()
540+
return Builder()
541541
.backend(backend)
542542
.platform(platform)
543543
.sharedContext(sharedContext)
@@ -557,7 +557,7 @@ class UTILS_PUBLIC Engine {
557557
Platform* UTILS_NULLABLE platform = nullptr,
558558
void* UTILS_NULLABLE sharedContext = nullptr,
559559
const Config* UTILS_NULLABLE config = nullptr) {
560-
Engine::Builder()
560+
Builder()
561561
.backend(backend)
562562
.platform(platform)
563563
.sharedContext(sharedContext)

filament/include/filament/IndexBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class UTILS_PUBLIC IndexBuffer : public FilamentAPI {
9696
* @param len Length of name, should be less than or equal to 128
9797
* @return This Builder, for chaining calls.
9898
*/
99-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
99+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
100100

101101
/**
102102
* Creates the IndexBuffer object and returns a pointer to it. After creation, the index

filament/include/filament/InstanceBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class UTILS_PUBLIC InstanceBuffer : public FilamentAPI {
8383
* @param len Length of name, should be less than or equal to 128
8484
* @return This Builder, for chaining calls.
8585
*/
86-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
86+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8787

8888
/**
8989
* Creates the InstanceBuffer object and returns a pointer to it.

filament/include/filament/Material.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ class UTILS_PUBLIC Material : public FilamentAPI {
118118
Builder& package(const void* UTILS_NONNULL payload, size_t size);
119119

120120
template<typename T>
121-
using is_supported_constant_parameter_t = typename std::enable_if<
122-
std::is_same<int32_t, T>::value ||
123-
std::is_same<float, T>::value ||
124-
std::is_same<bool, T>::value>::type;
121+
using is_supported_constant_parameter_t = std::enable_if_t<
122+
std::is_same_v<int32_t, T> ||
123+
std::is_same_v<float, T> ||
124+
std::is_same_v<bool, T>>;
125125

126126
/**
127127
* Specialize a constant parameter specified in the material definition with a concrete
@@ -177,7 +177,7 @@ class UTILS_PUBLIC Material : public FilamentAPI {
177177
* memory or other resources.
178178
* @exception utils::PreConditionPanic if a parameter to a builder function was invalid.
179179
*/
180-
Material* UTILS_NULLABLE build(Engine& engine);
180+
Material* UTILS_NULLABLE build(Engine& engine) const;
181181
private:
182182
friend class FMaterial;
183183
};

filament/include/filament/MaterialInstance.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,35 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
5656
};
5757

5858
public:
59-
using CullingMode = filament::backend::CullingMode;
60-
using TransparencyMode = filament::TransparencyMode;
61-
using DepthFunc = filament::backend::SamplerCompareFunc;
62-
using StencilCompareFunc = filament::backend::SamplerCompareFunc;
63-
using StencilOperation = filament::backend::StencilOperation;
64-
using StencilFace = filament::backend::StencilFace;
59+
using CullingMode = backend::CullingMode;
60+
using TransparencyMode = TransparencyMode;
61+
using DepthFunc = backend::SamplerCompareFunc;
62+
using StencilCompareFunc = backend::SamplerCompareFunc;
63+
using StencilOperation = backend::StencilOperation;
64+
using StencilFace = backend::StencilFace;
6565

6666
template<typename T>
67-
using is_supported_parameter_t = typename std::enable_if<
68-
std::is_same<float, T>::value ||
69-
std::is_same<int32_t, T>::value ||
70-
std::is_same<uint32_t, T>::value ||
71-
std::is_same<math::int2, T>::value ||
72-
std::is_same<math::int3, T>::value ||
73-
std::is_same<math::int4, T>::value ||
74-
std::is_same<math::uint2, T>::value ||
75-
std::is_same<math::uint3, T>::value ||
76-
std::is_same<math::uint4, T>::value ||
77-
std::is_same<math::float2, T>::value ||
78-
std::is_same<math::float3, T>::value ||
79-
std::is_same<math::float4, T>::value ||
80-
std::is_same<math::mat4f, T>::value ||
67+
using is_supported_parameter_t = std::enable_if_t<
68+
std::is_same_v<float, T> ||
69+
std::is_same_v<int32_t, T> ||
70+
std::is_same_v<uint32_t, T> ||
71+
std::is_same_v<math::int2, T> ||
72+
std::is_same_v<math::int3, T> ||
73+
std::is_same_v<math::int4, T> ||
74+
std::is_same_v<math::uint2, T> ||
75+
std::is_same_v<math::uint3, T> ||
76+
std::is_same_v<math::uint4, T> ||
77+
std::is_same_v<math::float2, T> ||
78+
std::is_same_v<math::float3, T> ||
79+
std::is_same_v<math::float4, T> ||
80+
std::is_same_v<math::mat4f, T> ||
8181
// these types are slower as they need a layout conversion
82-
std::is_same<bool, T>::value ||
83-
std::is_same<math::bool2, T>::value ||
84-
std::is_same<math::bool3, T>::value ||
85-
std::is_same<math::bool4, T>::value ||
86-
std::is_same<math::mat3f, T>::value
87-
>::type;
82+
std::is_same_v<bool, T> ||
83+
std::is_same_v<math::bool2, T> ||
84+
std::is_same_v<math::bool3, T> ||
85+
std::is_same_v<math::bool4, T> ||
86+
std::is_same_v<math::mat3f, T>
87+
>;
8888

8989
/**
9090
* Creates a new MaterialInstance using another MaterialInstance as a template for initialization.
@@ -121,13 +121,13 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
121121

122122
/** inline helper to provide the name as a null-terminated string literal */
123123
template<typename T, typename = is_supported_parameter_t<T>>
124-
inline void setParameter(StringLiteral name, T const& value) {
124+
void setParameter(StringLiteral name, T const& value) {
125125
setParameter<T>(name.data, name.size, value);
126126
}
127127

128128
/** inline helper to provide the name as a null-terminated C string */
129129
template<typename T, typename = is_supported_parameter_t<T>>
130-
inline void setParameter(const char* UTILS_NONNULL name, T const& value) {
130+
void setParameter(const char* UTILS_NONNULL name, T const& value) {
131131
setParameter<T>(name, strlen(name), value);
132132
}
133133

@@ -148,14 +148,14 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
148148

149149
/** inline helper to provide the name as a null-terminated string literal */
150150
template<typename T, typename = is_supported_parameter_t<T>>
151-
inline void setParameter(StringLiteral name, const T* UTILS_NONNULL values, size_t count) {
151+
void setParameter(StringLiteral name, const T* UTILS_NONNULL values, size_t count) {
152152
setParameter<T>(name.data, name.size, values, count);
153153
}
154154

155155
/** inline helper to provide the name as a null-terminated C string */
156156
template<typename T, typename = is_supported_parameter_t<T>>
157-
inline void setParameter(const char* UTILS_NONNULL name,
158-
const T* UTILS_NONNULL values, size_t count) {
157+
void setParameter(const char* UTILS_NONNULL name,
158+
const T* UTILS_NONNULL values, size_t count) {
159159
setParameter<T>(name, strlen(name), values, count);
160160
}
161161

@@ -176,14 +176,14 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
176176
Texture const* UTILS_NULLABLE texture, TextureSampler const& sampler);
177177

178178
/** inline helper to provide the name as a null-terminated string literal */
179-
inline void setParameter(StringLiteral name,
180-
Texture const* UTILS_NULLABLE texture, TextureSampler const& sampler) {
179+
void setParameter(StringLiteral name,
180+
Texture const* UTILS_NULLABLE texture, TextureSampler const& sampler) {
181181
setParameter(name.data, name.size, texture, sampler);
182182
}
183183

184184
/** inline helper to provide the name as a null-terminated C string */
185-
inline void setParameter(const char* UTILS_NONNULL name,
186-
Texture const* UTILS_NULLABLE texture, TextureSampler const& sampler) {
185+
void setParameter(const char* UTILS_NONNULL name,
186+
Texture const* UTILS_NULLABLE texture, TextureSampler const& sampler) {
187187
setParameter(name, strlen(name), texture, sampler);
188188
}
189189

@@ -202,12 +202,12 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
202202
RgbType type, math::float3 color);
203203

204204
/** inline helper to provide the name as a null-terminated string literal */
205-
inline void setParameter(StringLiteral name, RgbType type, math::float3 color) {
205+
void setParameter(StringLiteral name, RgbType type, math::float3 color) {
206206
setParameter(name.data, name.size, type, color);
207207
}
208208

209209
/** inline helper to provide the name as a null-terminated C string */
210-
inline void setParameter(const char* UTILS_NONNULL name, RgbType type, math::float3 color) {
210+
void setParameter(const char* UTILS_NONNULL name, RgbType type, math::float3 color) {
211211
setParameter(name, strlen(name), type, color);
212212
}
213213

@@ -226,12 +226,12 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
226226
RgbaType type, math::float4 color);
227227

228228
/** inline helper to provide the name as a null-terminated string literal */
229-
inline void setParameter(StringLiteral name, RgbaType type, math::float4 color) {
229+
void setParameter(StringLiteral name, RgbaType type, math::float4 color) {
230230
setParameter(name.data, name.size, type, color);
231231
}
232232

233233
/** inline helper to provide the name as a null-terminated C string */
234-
inline void setParameter(const char* UTILS_NONNULL name, RgbaType type, math::float4 color) {
234+
void setParameter(const char* UTILS_NONNULL name, RgbaType type, math::float4 color) {
235235
setParameter(name, strlen(name), type, color);
236236
}
237237

@@ -251,13 +251,13 @@ class UTILS_PUBLIC MaterialInstance : public FilamentAPI {
251251

252252
/** inline helper to provide the name as a null-terminated C string */
253253
template<typename T, typename = is_supported_parameter_t<T>>
254-
inline T getParameter(StringLiteral name) const {
254+
T getParameter(StringLiteral name) const {
255255
return getParameter<T>(name.data, name.size);
256256
}
257257

258258
/** inline helper to provide the name as a null-terminated C string */
259259
template<typename T, typename = is_supported_parameter_t<T>>
260-
inline T getParameter(const char* UTILS_NONNULL name) const {
260+
T getParameter(const char* UTILS_NONNULL name) const {
261261
return getParameter<T>(name, strlen(name));
262262
}
263263

filament/include/filament/MorphTargetBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class UTILS_PUBLIC MorphTargetBuffer : public FilamentAPI {
7676
* @param len Length of name, should be less than or equal to 128
7777
* @return This Builder, for chaining calls.
7878
*/
79-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
79+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8080

8181
/**
8282
* Creates the MorphTargetBuffer object and returns a pointer to it.

filament/include/filament/RenderableManager.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class UTILS_PUBLIC RenderableManager : public FilamentAPI {
220220
* the renderable are immutable.
221221
* STATIC geometry has the same restrictions as STATIC_BOUNDS, but in addition disallows
222222
* skinning, morphing and changing the VertexBuffer or IndexBuffer in any way.
223-
* @param enable whether this renderable has static bounds. false by default.
223+
* @param type type of geometry.
224224
*/
225225
Builder& geometryType(GeometryType type) noexcept;
226226

@@ -454,7 +454,7 @@ class UTILS_PUBLIC RenderableManager : public FilamentAPI {
454454
*
455455
* @param primitiveIndex zero-based index of the primitive, must be less than the primitive
456456
* count passed to Builder constructor
457-
* @param indicesAndWeightsVectors pairs of bone index and bone weight for all vertices of
457+
* @param indicesAndWeightsVector pairs of bone index and bone weight for all vertices of
458458
* the primitive sequentially
459459
*
460460
* @return Builder reference for chaining calls.
@@ -501,7 +501,7 @@ class UTILS_PUBLIC RenderableManager : public FilamentAPI {
501501
* @param primitiveIndex zero-based index of the primitive, must be less than the count passed to Builder constructor
502502
* @param offset specifies where in the morph target buffer to start reading (expressed as a number of vertices)
503503
*/
504-
RenderableManager::Builder& morphing(uint8_t level,
504+
Builder& morphing(uint8_t level,
505505
size_t primitiveIndex, size_t offset) noexcept;
506506

507507

@@ -852,20 +852,20 @@ class UTILS_PUBLIC RenderableManager : public FilamentAPI {
852852
/*! \cond PRIVATE */
853853
template<typename T>
854854
struct is_supported_vector_type {
855-
using type = typename std::enable_if<
856-
std::is_same<math::float4, T>::value ||
857-
std::is_same<math::half4, T>::value ||
858-
std::is_same<math::float3, T>::value ||
859-
std::is_same<math::half3, T>::value
860-
>::type;
855+
using type = std::enable_if_t<
856+
std::is_same_v<math::float4, T> ||
857+
std::is_same_v<math::half4, T> ||
858+
std::is_same_v<math::float3, T> ||
859+
std::is_same_v<math::half3, T>
860+
>;
861861
};
862862

863863
template<typename T>
864864
struct is_supported_index_type {
865-
using type = typename std::enable_if<
866-
std::is_same<uint16_t, T>::value ||
867-
std::is_same<uint32_t, T>::value
868-
>::type;
865+
using type = std::enable_if_t<
866+
std::is_same_v<uint16_t, T> ||
867+
std::is_same_v<uint32_t, T>
868+
>;
869869
};
870870
/*! \endcond */
871871

filament/include/filament/Renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class UTILS_PUBLIC Renderer : public FilamentAPI {
105105
* @param historySize requested history size. The returned vector could be smaller.
106106
* @return A vector of FrameInfo.
107107
*/
108-
utils::FixedCapacityVector<Renderer::FrameInfo> getFrameInfoHistory(
108+
utils::FixedCapacityVector<FrameInfo> getFrameInfoHistory(
109109
size_t historySize = 1) const noexcept;
110110

111111
/**

filament/include/filament/SkinningBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class UTILS_PUBLIC SkinningBuffer : public FilamentAPI {
8282
* @param len Length of name, should be less than or equal to 128
8383
* @return This Builder, for chaining calls.
8484
*/
85-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
85+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
8686

8787
/**
8888
* Creates the SkinningBuffer object and returns a pointer to it.

filament/include/filament/Stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class UTILS_PUBLIC Stream : public FilamentAPI {
149149
* @param len Length of name, should be less than or equal to 128
150150
* @return This Builder, for chaining calls.
151151
*/
152-
// Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept; // inherited
152+
Builder& name(const char* UTILS_NONNULL name, size_t len) noexcept;
153153

154154
/**
155155
* Creates the Stream object and returns a pointer to it.

0 commit comments

Comments
 (0)