paint: add script_append_mesh_obj

This commit is contained in:
luboslenco
2026-08-24 08:32:08 +02:00
parent 94a9ffdd81
commit 2225d489bd
4 changed files with 30 additions and 3 deletions
+11
View File
@@ -65,6 +65,17 @@ void import_mesh_run(char *path, bool _clear_layers, bool replace_existing, bool
#endif
}
void import_mesh_run_obj(char *data) {
import_mesh_clear_layers = false;
import_mesh_no_reset = true;
import_mesh_append = true;
g_context->layer_filter = 0;
buffer_t *b = buffer_create_from_raw((u8 *)data, strlen(data));
import_obj_parse(b, false);
free(b);
}
i32 import_mesh_finish_import_sort(void **pa, void **pb) {
mesh_object_t *a = *(pa);
mesh_object_t *b = *(pb);
+6 -3
View File
@@ -2,12 +2,16 @@
#include "../global.h"
void import_obj_run(char *path, bool replace_existing) {
buffer_t *b = data_get_blob(path);
import_obj_parse(b, replace_existing);
data_delete_blob(path);
}
void import_obj_parse(buffer_t *b, bool replace_existing) {
split_type_t i = g_context->split_by;
bool is_udim = i == SPLIT_TYPE_UDIM;
i32 split_code = (i == SPLIT_TYPE_OBJECT || is_udim) ? 'o' : 'u'; // usemtl
buffer_t *b = data_get_blob(path);
if (is_udim) {
raw_mesh_t *part = obj_parse(b, split_code, 0, is_udim);
char *name = part->name;
@@ -217,5 +221,4 @@ void import_obj_run(char *path, bool replace_existing) {
array_free(discarded);
free(discarded);
}
data_delete_blob(path);
}
+1
View File
@@ -1199,6 +1199,7 @@ void minic_register_builtins() {
R(script_project_open, "v(p:char path)");
R(script_import_asset, "v(p:char path,i hdr_as_envmap)");
R(script_append_mesh, "v(p:char path)");
R(script_append_mesh_obj, "v(p:char data)");
R(script_export_mesh, "v(p:char path)");
R(script_export_material, "v(p:char path)");
R(project_filepath_get, "p:char()");
+12
View File
@@ -388,6 +388,18 @@ void script_append_mesh(char *path) {
g_context->ddirty = 2;
}
void script_append_mesh_obj(char *data) {
if (data == NULL || data[0] == '\0') {
return;
}
gpu_texture_t *current;
bool in_use;
script_gpu_begin(&current, &in_use);
import_mesh_run_obj(data);
script_gpu_end(current, in_use);
g_context->ddirty = 2;
}
void script_export_mesh(char *path) {
if (path == NULL) {
return;