Fix mesh and material previews along with asset selection
This commit is contained in:
parent
7835c93510
commit
2ba9beefad
2 changed files with 17 additions and 8 deletions
|
@ -762,8 +762,10 @@ void CommonEditor::drawAssets() {
|
||||||
|
|
||||||
int column = 0;
|
int column = 0;
|
||||||
for(auto& [p, type] : asset_files) {
|
for(auto& [p, type] : asset_files) {
|
||||||
|
ImGui::PushID(&p);
|
||||||
|
|
||||||
if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64)))
|
if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64)))
|
||||||
asset_selected(p, type);
|
asset_selected(file::app_domain / p, type);
|
||||||
|
|
||||||
if(ImGui::BeginPopupContextItem()) {
|
if(ImGui::BeginPopupContextItem()) {
|
||||||
ImGui::TextDisabled("%s", p.string().c_str());
|
ImGui::TextDisabled("%s", p.string().c_str());
|
||||||
|
@ -784,6 +786,8 @@ void CommonEditor::drawAssets() {
|
||||||
} else {
|
} else {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,7 +885,7 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene) {
|
||||||
scene.add<Light>(light).type = Light::Type::Sun;
|
scene.add<Light>(light).type = Light::Type::Sun;
|
||||||
|
|
||||||
auto probe = scene.add_object();
|
auto probe = scene.add_object();
|
||||||
scene.add<EnvironmentProbe>(probe);
|
scene.add<EnvironmentProbe>(probe).is_sized = false;
|
||||||
scene.get<Transform>(probe).position = Vector3(3);
|
scene.get<Transform>(probe).position = Vector3(3);
|
||||||
|
|
||||||
engine->update_scene(scene);
|
engine->update_scene(scene);
|
||||||
|
@ -952,6 +956,12 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene) {
|
||||||
|
|
||||||
command_buffer->set_render_pass(begin_info);
|
command_buffer->set_render_pass(begin_info);
|
||||||
|
|
||||||
|
Viewport viewport = {};
|
||||||
|
viewport.width = thumbnail_resolution;
|
||||||
|
viewport.height = thumbnail_resolution;
|
||||||
|
|
||||||
|
command_buffer->set_viewport(viewport);
|
||||||
|
|
||||||
command_buffer->set_pipeline(renderer->renderToUnormTexturePipeline);
|
command_buffer->set_pipeline(renderer->renderToUnormTexturePipeline);
|
||||||
|
|
||||||
command_buffer->bind_texture(offscreen_color_texture, 1);
|
command_buffer->bind_texture(offscreen_color_texture, 1);
|
||||||
|
@ -961,13 +971,9 @@ GFXTexture* CommonEditor::generate_common_preview(Scene& scene) {
|
||||||
|
|
||||||
struct PostPushConstants {
|
struct PostPushConstants {
|
||||||
Vector4 viewport;
|
Vector4 viewport;
|
||||||
float fade;
|
Vector4 options;
|
||||||
unsigned int performGammaCorrection;
|
|
||||||
unsigned int performAA;
|
|
||||||
} pc;
|
} pc;
|
||||||
pc.fade = 0.0;
|
pc.options.w = 1.0;
|
||||||
pc.performGammaCorrection = true;
|
|
||||||
pc.performAA = false;
|
|
||||||
pc.viewport = Vector4(1.0 / (float)thumbnail_resolution, 1.0 / (float)thumbnail_resolution, thumbnail_resolution, thumbnail_resolution);
|
pc.viewport = Vector4(1.0 / (float)thumbnail_resolution, 1.0 / (float)thumbnail_resolution, thumbnail_resolution, thumbnail_resolution);
|
||||||
|
|
||||||
command_buffer->set_push_constant(&pc, sizeof(PostPushConstants));
|
command_buffer->set_push_constant(&pc, sizeof(PostPushConstants));
|
||||||
|
|
|
@ -70,6 +70,9 @@ void recompile(Material* material) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialEditor::draw(CommonEditor* editor) {
|
void MaterialEditor::draw(CommonEditor* editor) {
|
||||||
|
if(!material)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
if (ImGui::BeginMenu("File")) {
|
if (ImGui::BeginMenu("File")) {
|
||||||
if(ImGui::MenuItem("Save", "CTRL+S")) {
|
if(ImGui::MenuItem("Save", "CTRL+S")) {
|
||||||
|
|
Reference in a new issue