Skip to content

Commit e60cfc9

Browse files
committed
Refactor out unnecessary virtuals
1 parent b22632c commit e60cfc9

File tree

8 files changed

+64
-62
lines changed

8 files changed

+64
-62
lines changed

App/Core/renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace Baikal
9494

9595

9696
/**
97-
Forbidden stuff.
97+
Disallow copies and moves.
9898
*/
9999
Renderer(Renderer const&) = delete;
100100
Renderer& operator = (Renderer const&) = delete;

App/Scene/Collector/collector.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ namespace Baikal
6868
virtual ~Collector();
6969

7070
// Clear collector state (CreateIterator returns invalid iterator if the collector is empty)
71-
virtual void Clear();
71+
void Clear();
7272
// Create an iterator of objects
73-
virtual Iterator* CreateIterator() const;
73+
Iterator* CreateIterator() const;
7474
// Collect objects and their dependencies
75-
virtual void Collect(Iterator* iter, ExpandFunc expand_func);
75+
void Collect(Iterator* iter, ExpandFunc expand_func);
7676
// Commit collected objects
77-
virtual void Commit();
77+
void Commit();
7878
// Given a budnle check if all collected objects are in the bundle and do not require update
79-
virtual bool NeedsUpdate(Bundle const* bundle, ChangedFunc cahnged_func) const;
79+
bool NeedsUpdate(Bundle const* bundle, ChangedFunc cahnged_func) const;
8080
// Get number of objects in the collection
81-
virtual std::size_t GetNumItems() const;
81+
std::size_t GetNumItems() const;
8282
// Create serialised bundle (randomly accessible dump of objects)
83-
virtual Bundle* CreateBundle() const;
83+
Bundle* CreateBundle() const;
8484
// Get item index within a collection
85-
virtual std::uint32_t GetItemIndex(void const* item) const;
85+
std::uint32_t GetItemIndex(void const* item) const;
8686
// Finalization function
87-
virtual void Finalize(FinalizeFunc finalize_func);
87+
void Finalize(FinalizeFunc finalize_func);
8888

89-
// Forbidden stuff
89+
// Disallow copies and moves
9090
Collector(Collector const&) = delete;
9191
Collector& operator = (Collector const&) = delete;
9292

App/Scene/iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace Baikal
5757
// Retrieve with uncoditional cast: caller is responsible of all the implications, no type check here
5858
template <typename T> T* ItemAs() const { return reinterpret_cast<T*>(Item()); }
5959

60-
// TODO: support these later
60+
// Disable copies and moves
6161
Iterator(Iterator const&) = delete;
6262
Iterator& operator = (Iterator const&) = delete;
6363
};

App/Scene/light.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ namespace Baikal
5959
//virtual RadeonRays::float3 GetRadiantPower() const = 0;
6060

6161
// Set and get position
62-
virtual RadeonRays::float3 GetPosition() const;
63-
virtual void SetPosition(RadeonRays::float3 const& p);
62+
RadeonRays::float3 GetPosition() const;
63+
void SetPosition(RadeonRays::float3 const& p);
6464

6565
// Set and get direction
66-
virtual RadeonRays::float3 GetDirection() const;
67-
virtual void SetDirection(RadeonRays::float3 const& d);
66+
RadeonRays::float3 GetDirection() const;
67+
void SetDirection(RadeonRays::float3 const& d);
6868

6969
// Set and get emitted radiance (differential)
70-
virtual RadeonRays::float3 GetEmittedRadiance() const;
71-
virtual void SetEmittedRadiance(RadeonRays::float3 const& e);
70+
RadeonRays::float3 GetEmittedRadiance() const;
71+
void SetEmittedRadiance(RadeonRays::float3 const& e);
7272

7373
// Iterator for all the textures used by the light
7474
virtual Iterator* CreateTextureIterator() const;
@@ -123,8 +123,8 @@ namespace Baikal
123123
SpotLight();
124124
// Get and set inner and outer falloff angles: they are set as cosines of angles between light direction
125125
// and cone opening.
126-
virtual void SetConeShape(RadeonRays::float2 angles);
127-
virtual RadeonRays::float2 GetConeShape() const;
126+
void SetConeShape(RadeonRays::float2 angles);
127+
RadeonRays::float2 GetConeShape() const;
128128

129129
private:
130130
// Opening angles (x - inner, y - outer)
@@ -146,13 +146,13 @@ namespace Baikal
146146
public:
147147
ImageBasedLight();
148148
// Get and set illuminant texture
149-
virtual void SetTexture(Texture const* texture);
150-
virtual Texture const* GetTexture() const;
149+
void SetTexture(Texture const* texture);
150+
Texture const* GetTexture() const;
151151

152152
// Get and set multiplier.
153153
// Multiplier is used to adjust emissive power.
154-
virtual float GetMultiplier() const;
155-
virtual void SetMultiplier(float m);
154+
float GetMultiplier() const;
155+
void SetMultiplier(float m);
156156

157157
// Iterator for all the textures used by the light
158158
Iterator* CreateTextureIterator() const override;
@@ -170,9 +170,9 @@ namespace Baikal
170170
public:
171171
AreaLight(Shape const* shape, std::size_t idx);
172172
// Get parent shape
173-
virtual Shape const* GetShape() const;
173+
Shape const* GetShape() const;
174174
// Get parent prim idx
175-
virtual std::size_t GetPrimitiveIdx() const;
175+
std::size_t GetPrimitiveIdx() const;
176176

177177
private:
178178
// Parent shape

App/Scene/material.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,21 @@ namespace Baikal
102102
virtual Iterator* CreateTextureIterator() const;
103103
// Iterator of inputs
104104
virtual Iterator* CreateInputIterator() const;
105+
// Check if material has emissive components
106+
virtual bool HasEmission() const;
105107

106108
// Set input value
107109
// If specific data type is not supported throws std::runtime_error
108-
virtual void SetInputValue(std::string const& name, RadeonRays::float4 const& value);
109-
virtual void SetInputValue(std::string const& name, Texture const* texture);
110-
virtual void SetInputValue(std::string const& name, Material const* material);
110+
void SetInputValue(std::string const& name, RadeonRays::float4 const& value);
111+
void SetInputValue(std::string const& name, Texture const* texture);
112+
void SetInputValue(std::string const& name, Material const* material);
111113

112-
virtual InputValue GetInputValue(std::string const& name) const;
114+
InputValue GetInputValue(std::string const& name) const;
113115

114116
// Check if material is two-sided (normal direction does not matter and can be reversed)
115-
virtual bool IsTwoSided() const;
117+
bool IsTwoSided() const;
116118
// Set two-sidedness
117-
virtual void SetTwoSided(bool twosided);
118-
119-
// Check if material has emissive components
120-
virtual bool HasEmission() const;
119+
void SetTwoSided(bool twosided);
121120

122121
protected:
123122
// Register specific input
@@ -126,7 +125,6 @@ namespace Baikal
126125
void ClearInputs();
127126

128127
private:
129-
130128
class InputIterator;
131129

132130
using InputMap = std::map<std::string, Input>;
@@ -165,8 +163,8 @@ namespace Baikal
165163

166164
SingleBxdf(BxdfType type);
167165

168-
virtual BxdfType GetBxdfType() const;
169-
virtual void SetBxdfType(BxdfType type);
166+
BxdfType GetBxdfType() const;
167+
void SetBxdfType(BxdfType type);
170168

171169
// Check if material has emissive components
172170
bool HasEmission() const override;
@@ -187,8 +185,8 @@ namespace Baikal
187185

188186
MultiBxdf(Type type);
189187

190-
virtual Type GetType() const;
191-
virtual void SetType(Type type);
188+
Type GetType() const;
189+
void SetType(Type type);
192190

193191
// Check if material has emissive components
194192
bool HasEmission() const override;

App/Scene/scene_object.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ namespace Baikal
4141
virtual ~SceneObject() = 0;
4242

4343
// Check if the object has been changed since last reset
44-
virtual bool IsDirty() const;
44+
bool IsDirty() const;
4545
// Set dirty flag
46-
virtual void SetDirty(bool dirty) const;
46+
void SetDirty(bool dirty) const;
4747

4848
// Set & get name
49-
virtual void SetName(std::string const& name);
50-
virtual std::string GetName() const;
49+
void SetName(std::string const& name);
50+
std::string GetName() const;
5151

5252
SceneObject(SceneObject const&) = delete;
5353
SceneObject& operator = (SceneObject const&) = delete;

App/Scene/scene_tracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Baikal
6161
virtual ~SceneTracker();
6262

6363
// Given a scene this method produces (or loads from cache) corresponding GPU representation.
64-
virtual ClwScene& CompileScene(Scene1 const& scene, Collector& mat_collector, Collector& tex_collector) const;
64+
ClwScene& CompileScene(Scene1 const& scene, Collector& mat_collector, Collector& tex_collector) const;
6565

6666

6767
// Get underlying intersection API.

App/Scene/shape.h

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ namespace Baikal
5353
virtual ~Shape() = 0;
5454

5555
// Get and set material
56-
virtual void SetMaterial(Material const* material);
57-
virtual Material const* GetMaterial() const;
56+
void SetMaterial(Material const* material);
57+
Material const* GetMaterial() const;
5858

5959
// Forbidden stuff
6060
Shape(Shape const&) = delete;
@@ -75,27 +75,31 @@ namespace Baikal
7575
Mesh();
7676

7777
// Set and get index array
78-
virtual void SetIndices(std::uint32_t const* indices, std::size_t num_indices);
79-
virtual std::size_t GetNumIndices() const;
80-
virtual std::uint32_t const* GetIndices() const;
78+
void SetIndices(std::uint32_t const* indices, std::size_t num_indices);
79+
std::size_t GetNumIndices() const;
80+
std::uint32_t const* GetIndices() const;
8181

8282
// Set and get vertex array
83-
virtual void SetVertices(RadeonRays::float3 const* vertices, std::size_t num_vertices);
84-
virtual void SetVertices(float const* vertices, std::size_t num_vertices);
85-
virtual std::size_t GetNumVertices() const;
86-
virtual RadeonRays::float3 const* GetVertices() const;
83+
void SetVertices(RadeonRays::float3 const* vertices, std::size_t num_vertices);
84+
void SetVertices(float const* vertices, std::size_t num_vertices);
85+
std::size_t GetNumVertices() const;
86+
RadeonRays::float3 const* GetVertices() const;
8787

8888
// Set and get normal array
89-
virtual void SetNormals(RadeonRays::float3 const* normals, std::size_t num_normals);
90-
virtual void SetNormals(float const* normals, std::size_t num_normals);
91-
virtual std::size_t GetNumNormals() const;
92-
virtual RadeonRays::float3 const* GetNormals() const;
89+
void SetNormals(RadeonRays::float3 const* normals, std::size_t num_normals);
90+
void SetNormals(float const* normals, std::size_t num_normals);
91+
std::size_t GetNumNormals() const;
92+
RadeonRays::float3 const* GetNormals() const;
9393

9494
// Set and get UV array
95-
virtual void SetUVs(RadeonRays::float2 const* uvs, std::size_t num_uvs);
96-
virtual void SetUVs(float const* uvs, std::size_t num_uvs);
97-
virtual std::size_t GetNumUVs() const;
98-
virtual RadeonRays::float2 const* GetUVs() const;
95+
void SetUVs(RadeonRays::float2 const* uvs, std::size_t num_uvs);
96+
void SetUVs(float const* uvs, std::size_t num_uvs);
97+
std::size_t GetNumUVs() const;
98+
RadeonRays::float2 const* GetUVs() const;
99+
100+
// Forbidden stuff
101+
Mesh(Mesh const&) = delete;
102+
Mesh& operator = (Mesh const&) = delete;
99103

100104
private:
101105
std::unique_ptr<RadeonRays::float3[]> m_vertices;

0 commit comments

Comments
 (0)