Skip to content

Commit ed9ae39

Browse files
committed
· Refactoring
1 parent 925af62 commit ed9ae39

11 files changed

+84
-84
lines changed

source/scener/content/content_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using scener::io::file_stream;
1818

1919
content_manager::content_manager(gsl::not_null<service_container*> serviceprovider
2020
, const std::string& rootdirectory) noexcept
21-
: _service_provider ( serviceprovider )
21+
: _service_provider { serviceprovider }
2222
, _root_directory { rootdirectory }
2323
{
2424
}

source/scener/content/content_reader.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class content_reader final
110110

111111
private:
112112
std::string _asset_name;
113-
scener::io::binary_reader _asset_reader;
113+
io::binary_reader _asset_reader;
114114
content::content_manager* _content_manager;
115115
json11::Json _root;
116116

source/scener/content/dds/surface.cpp

+33-33
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,67 @@ void surface::load(const std::string& filename) noexcept
1616
Expects(scener::io::file::exists(filename));
1717

1818
file_stream stream(filename);
19-
header ddsheader;
20-
std::size_t blocksize = 16;
19+
header dds_header;
20+
std::size_t block_size = 16;
2121

22-
Ensures(stream.length() >= sizeof ddsheader);
22+
Ensures(stream.length() >= sizeof dds_header);
2323

24-
stream.read(reinterpret_cast<char*>(&ddsheader), 0, sizeof ddsheader);
24+
stream.read(reinterpret_cast<char*>(&dds_header), 0, sizeof dds_header);
2525

2626
// ensure contents are in DDS format
27-
Ensures(ddsheader.magic == 0x20534444);
27+
Ensures(dds_header.magic == 0x20534444);
2828

2929
// ensure required flags are meet
30-
Ensures((ddsheader.flags & header_flags::pixelformat) == header_flags::pixelformat);
31-
Ensures((ddsheader.flags & header_flags::caps) == header_flags::caps);
32-
Ensures((ddsheader.flags & header_flags::height) == header_flags::height);
33-
Ensures((ddsheader.flags & header_flags::width) == header_flags::width);
30+
Ensures((dds_header.flags & header_flags::pixelformat) == header_flags::pixelformat);
31+
Ensures((dds_header.flags & header_flags::caps) == header_flags::caps);
32+
Ensures((dds_header.flags & header_flags::height) == header_flags::height);
33+
Ensures((dds_header.flags & header_flags::width) == header_flags::width);
3434

35-
if (ddsheader.mipmap_count > 0)
35+
if (dds_header.mipmap_count > 0)
3636
{
37-
Ensures((ddsheader.flags & header_flags::mipmapcount) == header_flags::mipmapcount);
38-
Ensures((ddsheader.flags & header_flags::linearsize) == header_flags::linearsize);
37+
Ensures((dds_header.flags & header_flags::mipmapcount) == header_flags::mipmapcount);
38+
Ensures((dds_header.flags & header_flags::linearsize) == header_flags::linearsize);
3939
}
4040

4141
// ensure pixel format size is correct
42-
Ensures(ddsheader.pixel_format.size == 32);
42+
Ensures(dds_header.pixel_format.size == 32);
4343

4444
// ensure the texture is in compressed format
45-
Ensures((ddsheader.pixel_format.flags & pixel_format_flags::fourcc) == pixel_format_flags::fourcc);
45+
Ensures((dds_header.pixel_format.flags & pixel_format_flags::fourcc) == pixel_format_flags::fourcc);
4646

4747
// check DXTn format
48-
Ensures(ddsheader.pixel_format.fourcc == fourcc::dxt1
49-
|| ddsheader.pixel_format.fourcc == fourcc::dxt3
50-
|| ddsheader.pixel_format.fourcc == fourcc::dxt5);
48+
Ensures(dds_header.pixel_format.fourcc == fourcc::dxt1
49+
|| dds_header.pixel_format.fourcc == fourcc::dxt3
50+
|| dds_header.pixel_format.fourcc == fourcc::dxt5);
5151

5252
// process dds contents
53-
_height = ddsheader.height;
54-
_width = ddsheader.width;
53+
_height = dds_header.height;
54+
_width = dds_header.width;
5555

56-
if (ddsheader.pixel_format.fourcc == fourcc::dxt1)
56+
if (dds_header.pixel_format.fourcc == fourcc::dxt1)
5757
{
5858
_format = surface_format::dxt1;
59-
blocksize = 8;
59+
block_size = 8;
6060
}
61-
else if (ddsheader.pixel_format.fourcc == fourcc::dxt3)
61+
else if (dds_header.pixel_format.fourcc == fourcc::dxt3)
6262
{
6363
_format = surface_format::dxt3;
6464
}
65-
else if (ddsheader.pixel_format.fourcc == fourcc::dxt5)
65+
else if (dds_header.pixel_format.fourcc == fourcc::dxt5)
6666
{
6767
_format = surface_format::dxt5;
6868
}
6969

70-
auto mipmapwidth = _width;
71-
auto mipmapheight = _height;
72-
auto position = size_type { 0 };
73-
auto length = stream.length() - sizeof ddsheader;
70+
auto mipmap_width = _width;
71+
auto mipmap_height = _height;
72+
auto position = size_type { 0 };
73+
auto length = stream.length() - sizeof dds_header;
7474

7575
_mipmaps.clear();
7676
_buffer.clear();
7777
_view = { };
7878

79-
_mipmaps.reserve(ddsheader.mipmap_count);
79+
_mipmaps.reserve(dds_header.mipmap_count);
8080
_buffer.reserve(length);
8181

8282
auto readed = stream.read(reinterpret_cast<char*>(_buffer.data()), 0, length);
@@ -85,15 +85,15 @@ void surface::load(const std::string& filename) noexcept
8585

8686
_view = gsl::span<std::uint8_t>(_buffer.data(), static_cast<std::ptrdiff_t>(length));
8787

88-
for (size_type level = 0; level < ddsheader.mipmap_count; ++level)
88+
for (size_type level = 0; level < dds_header.mipmap_count; ++level)
8989
{
90-
auto size = std::max<size_type>(4, mipmapwidth) / 4 * std::max<size_type>(4, mipmapheight) / 4 * blocksize;
90+
auto size = std::max<size_type>(4, mipmap_width) / 4 * std::max<size_type>(4, mipmap_height) / 4 * block_size;
9191
auto view = _view.subspan(static_cast<std::ptrdiff_t>(position), static_cast<std::ptrdiff_t>(size));
9292

93-
_mipmaps.push_back({ level, mipmapwidth, mipmapheight, view });
93+
_mipmaps.push_back({ level, mipmap_width, mipmap_height, view });
9494

95-
mipmapwidth = std::max<std::size_t>(1, mipmapwidth >>= 1);
96-
mipmapheight = std::max<std::size_t>(1, mipmapheight >>= 1);
95+
mipmap_width = std::max<std::size_t>(1, mipmap_width >>= 1);
96+
mipmap_height = std::max<std::size_t>(1, mipmap_height >>= 1);
9797

9898
position += size;
9999
}

source/scener/content/gltf/node.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ using scener::math::quaternion;
1010
using scener::math::vector3;
1111

1212
node::node() noexcept
13-
: name ()
14-
, camera ()
13+
: name { }
14+
, camera { }
1515
, instance_skin { nullptr }
1616
, joint { nullptr }
17-
, light ()
17+
, light { }
1818
, matrix { matrix4::identity() }
19-
, meshes ()
19+
, meshes { }
2020
, rotation { quaternion::identity() }
2121
, scale { vector3::one() }
2222
, translation { vector3::zero() }
23-
, children ()
23+
, children { }
2424
{
2525
}
2626

source/scener/graphics/component.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace scener { namespace graphics {
99

1010
component::component(gsl::not_null<graphics::renderer*> renderer) noexcept
11-
: _renderer ( renderer )
11+
: _renderer { renderer }
1212
{
1313
}
1414

source/scener/graphics/effect_technique.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ effect_technique::effect_technique(gsl::not_null<graphics_device*> device) noexc
1717
: graphics_resource { device }
1818
, _alpha { 1.0 }
1919
, _ambient_light_color { vector3::zero() }
20-
, _bone_transforms ( 0 )
20+
, _bone_transforms { }
2121
, _diffuse_color { vector3::one() }
2222
, _light_0 { }
2323
, _light_1 { }
@@ -29,12 +29,12 @@ effect_technique::effect_technique(gsl::not_null<graphics_device*> device) noexc
2929
, _specular_color { vector3::one() }
3030
, _specular_power { 16.0f }
3131
, _texture_enabled { false }
32-
, _textures ( 0 )
32+
, _textures { }
3333
, _view { matrix4::identity() }
3434
, _world { matrix4::identity() }
3535
, _dirty_flags { effect_dirty_flags::all }
36-
, _passes ()
37-
, _parameters ()
36+
, _passes { }
37+
, _parameters { }
3838
{
3939
}
4040

source/scener/graphics/model.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace scener { namespace graphics {
1313
using scener::math::matrix4;
1414

1515
model::model() noexcept
16-
: _meshes (0)
17-
, _name ()
16+
: _meshes { }
17+
, _name { }
1818
{
1919
}
2020

source/scener/graphics/opengl/display_surface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace scener { namespace graphics { namespace opengl {
1616

1717
display_surface::display_surface(display_device* display)
18-
: _display(display)
18+
: _display { display }
1919
{
2020
}
2121

source/scener/io/binary_reader.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ char16_t binary_reader::read() noexcept
3333
// Decode UTF-8.
3434
if (buffer & 0x80)
3535
{
36-
std::uint32_t bytecount = 1;
36+
std::uint32_t byte_count = 1;
3737

38-
while (buffer & (0x80 >> bytecount))
38+
while (buffer & (0x80 >> byte_count))
3939
{
40-
bytecount++;
40+
byte_count++;
4141
}
4242

43-
buffer &= (1 << (8 - bytecount)) - 1;
43+
buffer &= (1 << (8 - byte_count)) - 1;
4444

45-
while (--bytecount)
45+
while (--byte_count)
4646
{
4747
buffer <<= 6;
4848
buffer |= _stream.read_byte() & 0x3F;
@@ -169,34 +169,34 @@ double binary_reader::read() noexcept
169169

170170
std::int32_t binary_reader::peek_char() noexcept
171171
{
172-
std::int32_t nextchar = -1;
172+
std::int32_t next_char = -1;
173173

174174
if (_stream.can_seek())
175175
{
176176
auto position = _stream.position();
177177

178178
if (position != _stream.length())
179179
{
180-
nextchar = _stream.read_byte();
180+
next_char = _stream.read_byte();
181181

182182
_stream.seek(position, std::ios::beg);
183183
}
184184
}
185185

186-
return nextchar;
186+
return next_char;
187187
}
188188

189189
std::uint32_t binary_reader::read_7_bit_encoded_int() noexcept
190190
{
191-
std::uint32_t result = 0;
192-
std::uint32_t bitsread = 0;
193-
std::uint32_t value = 0;
191+
std::uint32_t result = 0;
192+
std::uint32_t bits_read = 0;
193+
std::uint32_t value = 0;
194194

195195
do
196196
{
197197
value = read<std::uint8_t>();
198-
result |= (value & 0x7f) << bitsread;
199-
bitsread += 7;
198+
result |= (value & 0x7f) << bits_read;
199+
bits_read += 7;
200200
} while (value & 0x80);
201201

202202
return result;

source/scener/io/path.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ class path
2727
/// \returns the directory information for the specified path string.
2828
static std::string get_directory_name(const std::string& path) noexcept
2929
{
30-
auto position = path.find_last_of(path::directory_separator());
31-
auto directoryName = path;
30+
auto position = path.find_last_of(path::directory_separator());
31+
auto directory_name = path;
3232

3333
if (position != std::string::npos)
3434
{
35-
directoryName.erase(position);
35+
directory_name.erase(position);
3636
}
3737

38-
return directoryName;
38+
return directory_name;
3939
}
4040

4141
/// Returns the file name of the specified path string without the extension.
4242
/// \param path The path of the file.
4343
/// \returns the file name of the specified path string without the extension.
4444
static std::string get_file_name_without_extension(const std::string& path) noexcept
4545
{
46-
auto position = path.find_last_of('.');
47-
auto pathWithoutExtension = path;
46+
auto position = path.find_last_of('.');
47+
auto path_without_extension = path;
4848

4949
if (position != std::string::npos)
5050
{
51-
pathWithoutExtension.erase(position);
51+
path_without_extension.erase(position);
5252
}
5353

54-
return pathWithoutExtension;
54+
return path_without_extension;
5555
}
5656

5757
/// Combines two strings into a path.

source/scener/timespan.hpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ namespace scener {
1515
class timespan final
1616
{
1717
public:
18-
using clock = std::chrono::high_resolution_clock;
19-
using days_duration = std::chrono::duration<double , std::ratio<86400>>;
20-
using hours_duration = std::chrono::duration<double , std::ratio<3600>>;
21-
using minutes_duration = std::chrono::duration<double , std::ratio<60>>;
22-
using seconds_duration = std::chrono::duration<double>;
23-
using milli_seconds_duration = std::chrono::duration<double , std::ratio<1, 1000>>;
24-
using micro_seconds_duration = std::chrono::duration<double , std::ratio<1, 1000000>>;
25-
using ticks_duration = std::chrono::duration<std::int64_t, std::ratio<1, 10000000>>;
18+
using clock = std::chrono::high_resolution_clock;
19+
using days_duration = std::chrono::duration<double , std::ratio<86400>>;
20+
using hours_duration = std::chrono::duration<double , std::ratio<3600>>;
21+
using minutes_duration = std::chrono::duration<double , std::ratio<60>>;
22+
using seconds_duration = std::chrono::duration<double>;
23+
using milliseconds_duration = std::chrono::duration<double , std::ratio<1, 1000>>;
24+
using microseconds_duration = std::chrono::duration<double , std::ratio<1, 1000000>>;
25+
using ticks_duration = std::chrono::duration<std::int64_t, std::ratio<1, 10000000>>;
2626

2727
public:
2828
/// Represents the number of ticks in 1 day.
@@ -88,7 +88,7 @@ class timespan final
8888
/// \returns a TimeSpan that represents a specified number of milliseconds.
8989
constexpr static timespan from_milliseconds(double value) noexcept
9090
{
91-
return { std::chrono::duration_cast<ticks_duration>(milli_seconds_duration(value)).count() };
91+
return { std::chrono::duration_cast<ticks_duration>(milliseconds_duration(value)).count() };
9292
}
9393

9494
/// Returns a TimeSpan that represents a specified number of minutes.
@@ -149,15 +149,15 @@ class timespan final
149149
/// \param seconds number of seconds.
150150
/// \param milliseconds number of milliseconds.
151151
constexpr timespan(std::int32_t days
152-
, std::int32_t hours
153-
, std::int32_t minutes
154-
, std::int32_t seconds
155-
, std::int32_t milliseconds) noexcept
152+
, std::int32_t hours
153+
, std::int32_t minutes
154+
, std::int32_t seconds
155+
, std::int32_t milliseconds) noexcept
156156
: _ticks { std::chrono::duration_cast<ticks_duration>(days_duration(days))
157157
+ std::chrono::duration_cast<ticks_duration>(hours_duration(hours))
158158
+ std::chrono::duration_cast<ticks_duration>(minutes_duration(minutes))
159159
+ std::chrono::duration_cast<ticks_duration>(seconds_duration(seconds))
160-
+ std::chrono::duration_cast<ticks_duration>(milli_seconds_duration(milliseconds)) }
160+
+ std::chrono::duration_cast<ticks_duration>(milliseconds_duration(milliseconds)) }
161161
{
162162
}
163163

@@ -236,7 +236,7 @@ class timespan final
236236
/// \returns the value of the current TimeSpan structure expressed in whole and fractional milliseconds.
237237
constexpr double total_milli_seconds() const noexcept
238238
{
239-
return std::chrono::duration_cast<milli_seconds_duration>(_ticks).count();
239+
return std::chrono::duration_cast<milliseconds_duration>(_ticks).count();
240240
}
241241

242242
/// Gets the value of the current TimeSpan structure expressed in whole and fractional minutes.

0 commit comments

Comments
 (0)