Commit b38fb1db authored by Lotrado's avatar Lotrado
Browse files

Fixed build on MSVC.

parent e9432e3d
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#ifdef _WIN32
#include "SDL_syswm.h"
#endif
extern void ref_embedded_assets_mirrage_gui(); extern void ref_embedded_assets_mirrage_gui();
...@@ -274,7 +278,7 @@ namespace mirrage::gui { ...@@ -274,7 +278,7 @@ namespace mirrage::gui {
int display_w, display_h; int display_w, display_h;
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
SDL_GL_GetDrawableSize(window, &display_w, &display_h); SDL_GL_GetDrawableSize(window, &display_w, &display_h);
io.DisplaySize = ImVec2(w, h); io.DisplaySize = ImVec2(static_cast<float>(w), static_cast<float>(h));
if(w > 0 && h > 0) if(w > 0 && h > 0)
io.DisplayFramebufferScale = io.DisplayFramebufferScale =
ImVec2(static_cast<float>(display_w) / w, static_cast<float>(display_h) / h); ImVec2(static_cast<float>(display_w) / w, static_cast<float>(display_h) / h);
......
...@@ -53,7 +53,9 @@ namespace mirrage::renderer { ...@@ -53,7 +53,9 @@ namespace mirrage::renderer {
_spawn_entry_timer = 0; _spawn_entry_timer = 0;
} }
auto pps = std::normal_distribution<float>(entry.particles_per_second, entry.stddev)(rand); auto pps = (entry.stddev > 0.0f)
? std::normal_distribution<float>(entry.particles_per_second, entry.stddev)(rand)
: entry.particles_per_second;
auto spawn = static_cast<std::int32_t>(_time_accumulator * pps); auto spawn = static_cast<std::int32_t>(_time_accumulator * pps);
...@@ -83,8 +85,8 @@ namespace mirrage::renderer { ...@@ -83,8 +85,8 @@ namespace mirrage::renderer {
, _loaded(_cfg.ready()) , _loaded(_cfg.ready())
, _emitters(!_loaded ? Emitter_list{} , _emitters(!_loaded ? Emitter_list{}
: util::build_vector( : util::build_vector(
_cfg->emitters.size(), _cfg->emitters.size(),
[&](auto idx) { return Particle_emitter(_cfg->emitters[idx]); })) [&](auto idx) { return Particle_emitter(_cfg->emitters[idx]); }))
, _effectors(!_loaded ? Effector_list{} : _cfg->effectors) , _effectors(!_loaded ? Effector_list{} : _cfg->effectors)
, _position(position) , _position(position)
, _rotation(rotation) , _rotation(rotation)
...@@ -162,8 +164,8 @@ namespace mirrage::renderer { ...@@ -162,8 +164,8 @@ namespace mirrage::renderer {
auto desc_sets = std::array<vk::DescriptorSetLayout, 2>{shared_desc_set, storage_buffer}; auto desc_sets = std::array<vk::DescriptorSetLayout, 2>{shared_desc_set, storage_buffer};
auto push_constants = vk::PushConstantRange{vk::ShaderStageFlagBits::eCompute, 0, 4 * 4 * 4 * 2}; auto push_constants = vk::PushConstantRange{vk::ShaderStageFlagBits::eCompute, 0, 4 * 4 * 4 * 2};
return device.vk_device()->createPipelineLayoutUnique( return device.vk_device()->createPipelineLayoutUnique(vk::PipelineLayoutCreateInfo{
vk::PipelineLayoutCreateInfo{{}, desc_sets.size(), desc_sets.data(), 1, &push_constants}); {}, gsl::narrow<std::uint32_t>(desc_sets.size()), desc_sets.data(), 1, &push_constants});
} }
} // namespace mirrage::renderer } // namespace mirrage::renderer
...@@ -201,12 +203,13 @@ namespace mirrage::asset { ...@@ -201,12 +203,13 @@ namespace mirrage::asset {
{ {
auto r = renderer::Particle_system_config(); auto r = renderer::Particle_system_config();
sf2::deserialize_json(in, sf2::deserialize_json(
[&](auto& msg, uint32_t row, uint32_t column) { in,
LOG(plog::error) << "Error parsing JSON from " << in.aid().str() << " at " [&](auto& msg, uint32_t row, uint32_t column) {
<< row << ":" << column << ": " << msg; LOG(plog::error) << "Error parsing JSON from " << in.aid().str() << " at " << row << ":"
}, << column << ": " << msg;
r); },
r);
auto loads = std::vector<async::task<void>>(); auto loads = std::vector<async::task<void>>();
loads.reserve(r.emitters.size() * 2u); loads.reserve(r.emitters.size() * 2u);
...@@ -229,12 +232,13 @@ namespace mirrage::asset { ...@@ -229,12 +232,13 @@ namespace mirrage::asset {
{ {
auto r = renderer::Particle_type_config(); auto r = renderer::Particle_type_config();
sf2::deserialize_json(in, sf2::deserialize_json(
[&](auto& msg, uint32_t row, uint32_t column) { in,
LOG(plog::error) << "Error parsing JSON from " << in.aid().str() << " at " [&](auto& msg, uint32_t row, uint32_t column) {
<< row << ":" << column << ": " << msg; LOG(plog::error) << "Error parsing JSON from " << in.aid().str() << " at " << row << ":"
}, << column << ": " << msg;
r); },
r);
auto script = in.manager().load<renderer::Particle_script>(r.update_script_id); auto script = in.manager().load<renderer::Particle_script>(r.update_script_id);
r.update_script = script; r.update_script = script;
......
...@@ -103,7 +103,7 @@ namespace mirrage::renderer { ...@@ -103,7 +103,7 @@ namespace mirrage::renderer {
} else { } else {
auto position = transform.position + bb.offset; auto position = transform.position + bb.offset;
if(bb.active && bb.material.ready() if(bb.active && bb.material.ready()
&& is_visible(viewers.front(), position, bb.size.length())) { && is_visible(viewers.front(), position, glm::length(bb.size))) {
frame.billboard_queue.emplace_back(bb); frame.billboard_queue.emplace_back(bb);
frame.billboard_queue.back().offset = position; frame.billboard_queue.back().offset = position;
} }
......
...@@ -293,7 +293,7 @@ namespace mirrage::renderer { ...@@ -293,7 +293,7 @@ namespace mirrage::renderer {
for(auto i = std::size_t(0); i < frame.particle_queue.size(); i++) { for(auto i = std::size_t(0); i < frame.particle_queue.size(); i++) {
auto& p = frame.particle_queue[i]; auto& p = frame.particle_queue[i];
effector_count += p.effectors.size(); effector_count += gsl::narrow<std::int32_t>(p.effectors.size());
auto spawn = p.emitter->spawn(_rand); auto spawn = p.emitter->spawn(_rand);
if(particle_count + spawn >= max_particles) { if(particle_count + spawn >= max_particles) {
......
...@@ -516,7 +516,7 @@ namespace mirrage::renderer { ...@@ -516,7 +516,7 @@ namespace mirrage::renderer {
{vk::DeviceSize(particle.emitter->particle_offset()) {vk::DeviceSize(particle.emitter->particle_offset())
* vk::DeviceSize(sizeof(Particle))}); * vk::DeviceSize(sizeof(Particle))});
dpc.light_data2.w = mip_level; dpc.light_data2.w = static_cast<float>(mip_level);
dpc.model = glm::mat4(1); dpc.model = glm::mat4(1);
if(particle.type_cfg->geometry == Particle_geometry::billboard) { if(particle.type_cfg->geometry == Particle_geometry::billboard) {
dpc.model = glm::inverse(_renderer.global_uniforms().view_mat); dpc.model = glm::inverse(_renderer.global_uniforms().view_mat);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment