fix xcode __block error

This commit is contained in:
2019-01-16 22:41:48 +01:00
parent 0e3ac922af
commit ca9ed74108
2 changed files with 11 additions and 7 deletions

View File

@@ -80,7 +80,7 @@ kEventResult NodePanelBrush::handle_event(Event* e)
if (!m_mouse_inside) if (!m_mouse_inside)
{ {
mouse_release(); mouse_release();
destroy(); parent->remove_child(this);
} }
break; break;
default: default:

View File

@@ -252,13 +252,13 @@ void NodePanelGrid::bake_uvs()
// bake normal // bake normal
ShaderManager::u_int(kShaderUniform::Mode, 0); ShaderManager::u_int(kShaderUniform::Mode, 0);
m_hm_plane.draw_fill(); m_hm_plane.draw_fill();
__block std::unique_ptr<float[]> data_nor(fb.readTextureDataFloat()); std::unique_ptr<float[]> data_nor(fb.readTextureDataFloat());
//stbi_write_png("bake-nor.png", fb.getWidth(), fb.getHeight(), 4, fb.readTextureData(), 0); //stbi_write_png("bake-nor.png", fb.getWidth(), fb.getHeight(), 4, fb.readTextureData(), 0);
// bake position // bake position
ShaderManager::u_int(kShaderUniform::Mode, 1); ShaderManager::u_int(kShaderUniform::Mode, 1);
m_hm_plane.draw_fill(); m_hm_plane.draw_fill();
__block std::unique_ptr<float[]> data_pos(fb.readTextureDataFloat()); std::unique_ptr<float[]> data_pos(fb.readTextureDataFloat());
//stbi_write_png("bake-pos.png", fb.getWidth(), fb.getHeight(), 4, fb.readTextureData(), 0); //stbi_write_png("bake-pos.png", fb.getWidth(), fb.getHeight(), 4, fb.readTextureData(), 0);
fb.unbindFramebuffer(); fb.unbindFramebuffer();
@@ -289,9 +289,12 @@ void NodePanelGrid::bake_uvs()
std::atomic_int pb_value(0); std::atomic_int pb_value(0);
__block auto data_out = std::make_unique<uint8_t[]>(fb.getWidth() * fb.getHeight() * 4); auto data_out = std::make_unique<uint8_t[]>(fb.getWidth() * fb.getHeight() * 4);
std::thread worker([&] std::thread worker([&]
{ {
__block float* d_pos = data_pos.get();
__block float* d_nor = data_nor.get();
__block glm::i8vec4* d_out = reinterpret_cast<glm::i8vec4*>(data_out.get());
#if _WIN32 #if _WIN32
concurrency::parallel_for(int(0), fb.getHeight(), [&](int y) concurrency::parallel_for(int(0), fb.getHeight(), [&](int y)
#elif __IOS__ || __OSX__ #elif __IOS__ || __OSX__
@@ -304,9 +307,9 @@ void NodePanelGrid::bake_uvs()
for (int x = 0; x < fb.getWidth(); x++) for (int x = 0; x < fb.getWidth(); x++)
{ {
int i = y * fb.getHeight() + x; int i = y * fb.getHeight() + x;
auto nor = glm::make_vec3(&data_nor[i * 4]); auto nor = glm::make_vec3(&d_nor[i * 4]);
auto pos = glm::make_vec3(&data_pos[i * 4]); auto pos = glm::make_vec3(&d_pos[i * 4]);
auto& out = *reinterpret_cast<glm::i8vec4*>(&data_out[i * 4]); auto& out = d_out[i];
if (glm::dot(nor, light_dir) <= 0.f) if (glm::dot(nor, light_dir) <= 0.f)
{ {
@@ -355,4 +358,5 @@ void NodePanelGrid::bake_uvs()
//stbi_write_jpg("bake-out.jpg", fb.getWidth(), fb.getHeight(), 4, data_out.get(), 75); //stbi_write_jpg("bake-out.jpg", fb.getWidth(), fb.getHeight(), 4, data_out.get(), 75);
m_texture.update(data_out.get()); m_texture.update(data_out.get());
m_texture.create_mipmaps(); m_texture.create_mipmaps();
App::I.async_redraw();
} }