paint: debug tab
This commit is contained in:
@@ -2063,6 +2063,10 @@ tab_draw_array_t_array_t *ui_base_init_hwnd_tabs() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_config->experimental) {
|
||||
any_array_push(a0, _draw_callback_create(tab_debug_draw));
|
||||
}
|
||||
|
||||
tab_draw_array_t_array_t *r = any_array_create_from_raw((void *[]){}, 0);
|
||||
any_array_push(r, a0);
|
||||
any_array_push(r, a1);
|
||||
|
||||
@@ -274,6 +274,7 @@ void history_delete_material_group(node_group_t *group);
|
||||
void tab_scripts_set(char *s);
|
||||
void tab_scripts_draw(ui_handle_t *htab);
|
||||
ui_text_coloring_t *tab_scripts_get_text_coloring();
|
||||
void tab_debug_draw(ui_handle_t *htab);
|
||||
void render_path_preview_init();
|
||||
void render_path_preview_commands_preview();
|
||||
void render_path_preview_commands_decal();
|
||||
@@ -562,9 +563,6 @@ void ui_box_show_custom(void (*commands)(void), i32 mw,
|
||||
void ui_box_hide();
|
||||
void tab_meshes_draw(ui_handle_t *htab);
|
||||
void tab_meshes_reset_preview_map();
|
||||
void tab_scene_select_object(mesh_object_t *mo);
|
||||
void tab_scene_sort();
|
||||
void tab_scene_import_mesh_done();
|
||||
void util_particle_init();
|
||||
void util_particle_init_physics();
|
||||
void tab_layers_draw(ui_handle_t *htab);
|
||||
|
||||
@@ -406,7 +406,6 @@ ui_handle_t *ui_box_hwnd;
|
||||
bool ui_box_click_to_hide = true;
|
||||
i32 ui_box_modalw = 400;
|
||||
i32 ui_box_modalh = 170;
|
||||
i32 _tab_scene_paint_object_length = 1;
|
||||
ui_handle_t *tab_layers_layer_name_handle;
|
||||
gpu_texture_t *util_uv_uvmap = NULL;
|
||||
bool util_uv_uvmap_cached = false;
|
||||
|
||||
@@ -168,13 +168,13 @@
|
||||
#include "tab_browser.c"
|
||||
#include "tab_brushes.c"
|
||||
#include "tab_console.c"
|
||||
#include "tab_debug.c"
|
||||
#include "tab_fonts.c"
|
||||
#include "tab_history.c"
|
||||
#include "tab_layers.c"
|
||||
#include "tab_materials.c"
|
||||
#include "tab_meshes.c"
|
||||
#include "tab_plugins.c"
|
||||
#include "tab_scene.c"
|
||||
#include "tab_scripts.c"
|
||||
#include "tab_swatches.c"
|
||||
#include "tab_textures.c"
|
||||
|
||||
@@ -121,9 +121,6 @@ void sim_duplicate() {
|
||||
pbdup->mass = pb->mass;
|
||||
physics_body_init(pbdup, dup->base);
|
||||
}
|
||||
|
||||
_tab_scene_paint_object_length++;
|
||||
tab_scene_sort();
|
||||
}
|
||||
|
||||
void sim_delete() {
|
||||
@@ -131,6 +128,4 @@ void sim_delete() {
|
||||
array_remove(project_paint_objects, so);
|
||||
mesh_object_remove(so);
|
||||
sim_remove_body(so->base->uid);
|
||||
_tab_scene_paint_object_length--;
|
||||
tab_scene_sort();
|
||||
}
|
||||
|
||||
@@ -309,8 +309,6 @@ void render_path_paint_commands_paint(bool dilation) {
|
||||
#endif
|
||||
i32 index = r_byte - 1;
|
||||
if (index >= 0 && index < project_paint_objects->length) {
|
||||
|
||||
// tab_scene_select_object(project_paint_objects->buffer[index]);
|
||||
g_context->paint_object = project_paint_objects->buffer[index];
|
||||
|
||||
// g_context->layer->object_mask = index + 1;
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
i32 tab_debug_line_counter = 0;
|
||||
|
||||
void tab_debug_draw_list(ui_handle_t *list_handle, object_t *current_object) {
|
||||
if (string_equals(char_at(current_object->name, 0), ".")) {
|
||||
return; // Hidden
|
||||
}
|
||||
|
||||
bool b = false;
|
||||
|
||||
// Highlight every other line
|
||||
if (tab_debug_line_counter % 2 == 0) {
|
||||
draw_set_color(ui->ops->theme->SEPARATOR_COL);
|
||||
draw_filled_rect(0, ui->_y, ui->_window_w, UI_ELEMENT_H());
|
||||
draw_set_color(0xffffffff);
|
||||
}
|
||||
|
||||
if (current_object->children->length > 0) {
|
||||
f32_array_t *row = f32_array_create_from_raw(
|
||||
(f32[]){
|
||||
1 / 13.0,
|
||||
12 / 13.0,
|
||||
},
|
||||
2);
|
||||
ui_row(row);
|
||||
ui_handle_t *h = ui_nest(list_handle, tab_debug_line_counter);
|
||||
if (h->init) {
|
||||
h->b = true;
|
||||
}
|
||||
b = ui_panel(h, "", true, false, false);
|
||||
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
}
|
||||
else {
|
||||
ui->_x += 18; // Sign offset
|
||||
|
||||
// Draw line that shows parent relations
|
||||
draw_set_color(ui->ops->theme->BUTTON_COL);
|
||||
draw_line(ui->_x - 10, ui->_y + UI_ELEMENT_H() / 2.0, ui->_x, ui->_y + UI_ELEMENT_H() / 2.0, 1.0);
|
||||
draw_set_color(0xffffffff);
|
||||
|
||||
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
ui->_x -= 18;
|
||||
}
|
||||
|
||||
tab_debug_line_counter++;
|
||||
|
||||
// Undo applied offset for row drawing caused by end_element()
|
||||
ui->_y -= UI_ELEMENT_OFFSET();
|
||||
|
||||
if (b) {
|
||||
i32 current_y = ui->_y;
|
||||
for (i32 i = 0; i < current_object->children->length; ++i) {
|
||||
object_t *child = current_object->children->buffer[i];
|
||||
ui->_x += 8;
|
||||
tab_debug_draw_list(list_handle, child);
|
||||
ui->_x -= 8;
|
||||
}
|
||||
|
||||
// Draw line that shows parent relations
|
||||
draw_set_color(ui->ops->theme->BUTTON_COL);
|
||||
draw_line(ui->_x + 14, current_y, ui->_x + 14, ui->_y - UI_ELEMENT_H() / 2.0, 1.0);
|
||||
draw_set_color(0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
void tab_debug_draw(ui_handle_t *htab) {
|
||||
if (ui_tab(htab, tr("Debug"), false, -1, false)) {
|
||||
|
||||
ui_handle_t *h0 = ui_handle(__ID__);
|
||||
if (ui_panel(h0, "Render Targets", false, false, false)) {
|
||||
string_array_t *rt_keys = map_keys(render_path_render_targets);
|
||||
array_sort(rt_keys, NULL);
|
||||
for (i32 i = 0; i < rt_keys->length; ++i) {
|
||||
render_target_t *rt = any_map_get(render_path_render_targets, rt_keys->buffer[i]);
|
||||
ui_text(rt_keys->buffer[i], UI_ALIGN_LEFT, 0x00000000);
|
||||
ui_image(rt->_image, 0xffffffff, -1.0);
|
||||
}
|
||||
}
|
||||
|
||||
ui_handle_t *h1 = ui_handle(__ID__);
|
||||
if (ui_panel(h1, "Scene", false, false, false)) {
|
||||
tab_debug_line_counter = 0;
|
||||
|
||||
object_t *scene = _scene_root->children->buffer[0];
|
||||
for (i32 i = 0; i < scene->children->length; ++i) {
|
||||
object_t *c = scene->children->buffer[i];
|
||||
tab_debug_draw_list(ui_handle(__ID__), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,11 +335,6 @@ void tab_meshes_append_shape(char *mesh_name) {
|
||||
mo->base->raw = o;
|
||||
any_map_set(data_cached_meshes, md->_->handle, md);
|
||||
any_array_push(project_paint_objects, mo);
|
||||
|
||||
// tab_scene_import_mesh_done();
|
||||
// sys_notify_on_next_frame(function(mo: mesh_object_t) {
|
||||
// tab_scene_select_object(mo);
|
||||
// }, mo);
|
||||
}
|
||||
|
||||
void tab_meshes_draw_append_shape() {
|
||||
|
||||
@@ -27,16 +27,6 @@ void tab_plugins_draw(ui_handle_t *htab) {
|
||||
minic_ctx_call_fn(p->ctx, p->on_ui, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef is_debug
|
||||
string_array_t *rt_keys = map_keys(render_path_render_targets);
|
||||
array_sort(rt_keys, NULL);
|
||||
for (i32 i = 0; i < rt_keys->length; ++i) {
|
||||
render_target_t *rt = any_map_get(render_path_render_targets, rt_keys->buffer[i]);
|
||||
ui_text(rt_keys->buffer[i], UI_ALIGN_LEFT, 0x00000000);
|
||||
ui_image(rt->_image, 0xffffffff, -1.0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
i32 tab_scene_line_counter = 0;
|
||||
|
||||
void tab_scene_select_object(mesh_object_t *mo) {
|
||||
if (mo == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_context->selected_object = mo->base;
|
||||
|
||||
if (!string_equals(mo->base->ext_type, "mesh_object_t")) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_context->paint_object = mo;
|
||||
if (g_context->merged_object != NULL) {
|
||||
g_context->merged_object->base->visible = false;
|
||||
}
|
||||
context_select_paint_object(mo);
|
||||
}
|
||||
|
||||
i32 tab_scene_sort_compare(void **pa, void **pb) {
|
||||
object_t *a = *(pa);
|
||||
object_t *b = *(pb);
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
void tab_scene_sort() {
|
||||
object_t *scene = _scene_root->children->buffer[0];
|
||||
array_sort(scene->children, &tab_scene_sort_compare);
|
||||
}
|
||||
|
||||
void tab_scene_import_mesh_done_on_next_frame(void *_) {
|
||||
util_mesh_merge(NULL);
|
||||
tab_scene_select_object(g_context->selected_object->ext);
|
||||
tab_scene_sort();
|
||||
}
|
||||
|
||||
void tab_scene_import_mesh_done() {
|
||||
i32 count = project_paint_objects->length - _tab_scene_paint_object_length;
|
||||
_tab_scene_paint_object_length = project_paint_objects->length;
|
||||
|
||||
for (i32 i = 0; i < count; ++i) {
|
||||
mesh_object_t *mo = project_paint_objects->buffer[project_paint_objects->length - 1 - i];
|
||||
object_set_parent(mo->base, NULL);
|
||||
tab_scene_select_object(mo);
|
||||
}
|
||||
|
||||
sys_notify_on_next_frame(&tab_scene_import_mesh_done_on_next_frame, NULL);
|
||||
}
|
||||
|
||||
void tab_scene_draw_list_context_menu() {
|
||||
if (ui_menu_button(tr("Duplicate"), "ctrl+d", ICON_DUPLICATE)) {
|
||||
sim_duplicate();
|
||||
}
|
||||
if (ui_menu_button(tr("Delete"), "delete", ICON_DELETE)) {
|
||||
sim_delete();
|
||||
}
|
||||
}
|
||||
|
||||
void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) {
|
||||
if (string_equals(char_at(current_object->name, 0), ".")) {
|
||||
return; // Hidden
|
||||
}
|
||||
|
||||
bool b = false;
|
||||
|
||||
// Highlight every other line
|
||||
if (tab_scene_line_counter % 2 == 0) {
|
||||
draw_set_color(ui->ops->theme->SEPARATOR_COL);
|
||||
draw_filled_rect(0, ui->_y, ui->_window_w, UI_ELEMENT_H());
|
||||
draw_set_color(0xffffffff);
|
||||
}
|
||||
|
||||
// Highlight selected line
|
||||
if (current_object == g_context->selected_object) {
|
||||
draw_set_color(0xff205d9c);
|
||||
draw_filled_rect(0, ui->_y, ui->_window_w, UI_ELEMENT_H());
|
||||
draw_set_color(0xffffffff);
|
||||
}
|
||||
|
||||
if (current_object->children->length > 0) {
|
||||
f32_array_t *row = f32_array_create_from_raw(
|
||||
(f32[]){
|
||||
1 / 13.0,
|
||||
12 / 13.0,
|
||||
},
|
||||
2);
|
||||
ui_row(row);
|
||||
ui_handle_t *h = ui_nest(list_handle, tab_scene_line_counter);
|
||||
if (h->init) {
|
||||
h->b = true;
|
||||
}
|
||||
b = ui_panel(h, "", true, false, false);
|
||||
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
}
|
||||
else {
|
||||
ui->_x += 18; // Sign offset
|
||||
|
||||
// Draw line that shows parent relations
|
||||
draw_set_color(ui->ops->theme->BUTTON_COL);
|
||||
draw_line(ui->_x - 10, ui->_y + UI_ELEMENT_H() / 2.0, ui->_x, ui->_y + UI_ELEMENT_H() / 2.0, 1.0);
|
||||
draw_set_color(0xffffffff);
|
||||
|
||||
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
|
||||
ui->_x -= 18;
|
||||
}
|
||||
|
||||
tab_scene_line_counter++;
|
||||
// Undo applied offset for row drawing caused by end_element()
|
||||
ui->_y -= UI_ELEMENT_OFFSET();
|
||||
|
||||
if (ui->is_released) {
|
||||
tab_scene_select_object(current_object->ext);
|
||||
}
|
||||
|
||||
if (ui->is_hovered && ui->input_released_r) {
|
||||
tab_scene_select_object(current_object->ext);
|
||||
|
||||
ui_menu_draw(&tab_scene_draw_list_context_menu, -1, -1);
|
||||
}
|
||||
|
||||
if (b) {
|
||||
i32 current_y = ui->_y;
|
||||
for (i32 i = 0; i < current_object->children->length; ++i) {
|
||||
object_t *child = current_object->children->buffer[i];
|
||||
ui->_x += 8;
|
||||
tab_scene_draw_list(list_handle, child);
|
||||
ui->_x -= 8;
|
||||
}
|
||||
|
||||
// Draw line that shows parent relations
|
||||
draw_set_color(ui->ops->theme->BUTTON_COL);
|
||||
draw_line(ui->_x + 14, current_y, ui->_x + 14, ui->_y - UI_ELEMENT_H() / 2.0, 1.0);
|
||||
draw_set_color(0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
void tab_scene_draw(ui_handle_t *htab) {
|
||||
if (ui_tab(htab, tr("Scene"), false, -1, false)) {
|
||||
|
||||
tab_scene_line_counter = 0;
|
||||
|
||||
object_t *scene = _scene_root->children->buffer[0];
|
||||
for (i32 i = 0; i < scene->children->length; ++i) {
|
||||
object_t *c = scene->children->buffer[i];
|
||||
tab_scene_draw_list(ui_handle(__ID__), c);
|
||||
}
|
||||
|
||||
// Select object with arrow keys
|
||||
if (ui->is_key_pressed && ui->key_code == KEY_CODE_DOWN) {
|
||||
i32 i = array_index_of(project_paint_objects, g_context->selected_object->ext);
|
||||
if (i < project_paint_objects->length - 1) {
|
||||
tab_scene_select_object(project_paint_objects->buffer[i + 1]);
|
||||
}
|
||||
}
|
||||
if (ui->is_key_pressed && ui->key_code == KEY_CODE_UP) {
|
||||
i32 i = array_index_of(project_paint_objects, g_context->selected_object->ext);
|
||||
if (i > 1) {
|
||||
tab_scene_select_object(project_paint_objects->buffer[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user