Merge forge
This commit is contained in:
@@ -415,14 +415,7 @@ function context_create(): context_t {
|
|||||||
c.brush_opacity = 1.0;
|
c.brush_opacity = 1.0;
|
||||||
c.brush_opacity_handle = ui_handle_create();
|
c.brush_opacity_handle = ui_handle_create();
|
||||||
c.brush_opacity_handle.value = 1.0;
|
c.brush_opacity_handle.value = 1.0;
|
||||||
///if is_forge
|
|
||||||
let atlas_w: i32 = config_get_scene_atlas_res();
|
|
||||||
let item_w: i32 = config_get_layer_res();
|
|
||||||
let atlas_stride: i32 = atlas_w / item_w;
|
|
||||||
c.brush_scale = atlas_stride;
|
|
||||||
///else
|
|
||||||
c.brush_scale = 1.0;
|
c.brush_scale = 1.0;
|
||||||
///end
|
|
||||||
c.brush_angle = 0.0;
|
c.brush_angle = 0.0;
|
||||||
c.brush_angle_handle = ui_handle_create();
|
c.brush_angle_handle = ui_handle_create();
|
||||||
c.brush_angle_handle.value = 0.0;
|
c.brush_angle_handle.value = 0.0;
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ function gizmo_update() {
|
|||||||
|
|
||||||
let paint_object: object_t = context_raw.paint_object.base;
|
let paint_object: object_t = context_raw.paint_object.base;
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO && context_raw.selected_object != null) {
|
||||||
if (context_raw.selected_object != null) {
|
|
||||||
paint_object = context_raw.selected_object;
|
paint_object = context_raw.selected_object;
|
||||||
}
|
}
|
||||||
///end
|
|
||||||
|
|
||||||
if (is_object) {
|
if (is_object) {
|
||||||
gizmo.transform.loc = vec4_clone(paint_object.transform.loc);
|
gizmo.transform.loc = vec4_clone(paint_object.transform.loc);
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ function import_asset_run(path: string, drop_x: f32 = -1.0, drop_y: f32 = -1.0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path_is_mesh(path)) {
|
if (path_is_mesh(path)) {
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
project_import_mesh_box(path, false, false, tab_meshes_import_mesh_done);
|
// project_import_mesh_box(path, false, false, tab_meshes_import_mesh_done);
|
||||||
///else
|
project_import_mesh_box(path, false, false, tab_scene_import_mesh_done);
|
||||||
|
}
|
||||||
|
else {
|
||||||
show_box ? project_import_mesh_box(path) : import_mesh_run(path);
|
show_box ? project_import_mesh_box(path) : import_mesh_run(path);
|
||||||
///end
|
}
|
||||||
if (drop_x > 0) {
|
if (drop_x > 0) {
|
||||||
ui_box_click_to_hide = false; // Prevent closing when going back to window after drag and drop
|
ui_box_click_to_hide = false; // Prevent closing when going back to window after drag and drop
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,9 +216,9 @@ function _import_mesh_number_ext(i: i32): string {
|
|||||||
function _import_mesh_add_mesh(mesh: raw_mesh_t) {
|
function _import_mesh_add_mesh(mesh: raw_mesh_t) {
|
||||||
let raw: mesh_data_t = import_mesh_raw_mesh(mesh);
|
let raw: mesh_data_t = import_mesh_raw_mesh(mesh);
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
util_mesh_ext_pack_uvs(mesh.texa);
|
util_mesh_ext_pack_uvs(mesh.texa);
|
||||||
///end
|
}
|
||||||
|
|
||||||
let md: mesh_data_t = mesh_data_create(raw);
|
let md: mesh_data_t = mesh_data_create(raw);
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ function transform_compute_radius(raw: transform_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transform_compute_dim(raw: transform_t) {
|
function transform_compute_dim(raw: transform_t) {
|
||||||
///if is_forge
|
|
||||||
if (raw.object.raw == null && raw.object.ext_type == "mesh_object_t") {
|
if (raw.object.raw == null && raw.object.ext_type == "mesh_object_t") {
|
||||||
let mo: mesh_object_t = raw.object.ext;
|
let mo: mesh_object_t = raw.object.ext;
|
||||||
let aabb: vec4_t = mesh_data_calculate_aabb(mo.data);
|
let aabb: vec4_t = mesh_data_calculate_aabb(mo.data);
|
||||||
@@ -167,7 +166,6 @@ function transform_compute_dim(raw: transform_t) {
|
|||||||
o.raw = {};
|
o.raw = {};
|
||||||
o.raw.dimensions = f32_array_create_xyz(aabb.x, aabb.y, aabb.z);
|
o.raw.dimensions = f32_array_create_xyz(aabb.x, aabb.y, aabb.z);
|
||||||
}
|
}
|
||||||
///end
|
|
||||||
|
|
||||||
if (raw.object.raw == null || raw.object.raw.dimensions == null) {
|
if (raw.object.raw == null || raw.object.raw.dimensions == null) {
|
||||||
raw.dim = vec4_create(2 * raw.scale.x, 2 * raw.scale.y, 2 * raw.scale.z);
|
raw.dim = vec4_create(2 * raw.scale.x, 2 * raw.scale.y, 2 * raw.scale.z);
|
||||||
|
|||||||
@@ -510,9 +510,9 @@ function layers_new_group(): slot_layer_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function layers_create_fill_layer(uv_type: uv_type_t = uv_type_t.UVMAP, decal_mat: mat4_t = mat4nan, position: i32 = -1) {
|
function layers_create_fill_layer(uv_type: uv_type_t = uv_type_t.UVMAP, decal_mat: mat4_t = mat4nan, position: i32 = -1) {
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
return;
|
return;
|
||||||
///end
|
}
|
||||||
|
|
||||||
_layers_uv_type = uv_type;
|
_layers_uv_type = uv_type;
|
||||||
_layers_decal_mat = decal_mat;
|
_layers_decal_mat = decal_mat;
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ function render_path_raytrace_commands(use_live_layer: bool) {
|
|||||||
render_path_raytrace_ready = true;
|
render_path_raytrace_ready = true;
|
||||||
render_path_raytrace_is_bake = false;
|
render_path_raytrace_is_bake = false;
|
||||||
let ext: string = "";
|
let ext: string = "";
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
ext = "forge_";
|
ext = "forge_";
|
||||||
///end
|
}
|
||||||
let mode: string = config_raw.pathtrace_mode == pathtrace_mode_t.FAST ? "core" : "full";
|
let mode: string = config_raw.pathtrace_mode == pathtrace_mode_t.FAST ? "core" : "full";
|
||||||
render_path_raytrace_raytrace_init("raytrace_brute_" + ext + mode + render_path_raytrace_ext);
|
render_path_raytrace_raytrace_init("raytrace_brute_" + ext + mode + render_path_raytrace_ext);
|
||||||
render_path_raytrace_last_envmap = null;
|
render_path_raytrace_last_envmap = null;
|
||||||
@@ -135,9 +135,9 @@ function render_path_raytrace_commands(use_live_layer: bool) {
|
|||||||
|
|
||||||
// context_raw.ddirty = 1; // _RENDER
|
// context_raw.ddirty = 1; // _RENDER
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
context_raw.ddirty = 1;
|
context_raw.ddirty = 1;
|
||||||
///end
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_path_raytrace_raytrace_init(shader_name: string, build: bool = true, bake: bool = false) {
|
function render_path_raytrace_raytrace_init(shader_name: string, build: bool = true, bake: bool = false) {
|
||||||
@@ -158,7 +158,7 @@ function render_path_raytrace_raytrace_init(shader_name: string, build: bool = t
|
|||||||
{
|
{
|
||||||
iron_raytrace_as_init();
|
iron_raytrace_as_init();
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
for (let i: i32 = 0; i < project_paint_objects.length; ++i) {
|
for (let i: i32 = 0; i < project_paint_objects.length; ++i) {
|
||||||
let po: mesh_object_t = project_paint_objects[i];
|
let po: mesh_object_t = project_paint_objects[i];
|
||||||
if (!po.base.visible) {
|
if (!po.base.visible) {
|
||||||
@@ -166,9 +166,10 @@ function render_path_raytrace_raytrace_init(shader_name: string, build: bool = t
|
|||||||
}
|
}
|
||||||
iron_raytrace_as_add(po.data._.vertex_buffer, po.data._.index_buffer, po.base.transform.world_unpack);
|
iron_raytrace_as_add(po.data._.vertex_buffer, po.data._.index_buffer, po.base.transform.world_unpack);
|
||||||
}
|
}
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
iron_raytrace_as_add(render_path_raytrace_vb, render_path_raytrace_ib, render_path_raytrace_transform);
|
iron_raytrace_as_add(render_path_raytrace_vb, render_path_raytrace_ib, render_path_raytrace_transform);
|
||||||
///end
|
}
|
||||||
|
|
||||||
let vb_full: gpu_buffer_t = context_raw.merged_object.data._.vertex_buffer;
|
let vb_full: gpu_buffer_t = context_raw.merged_object.data._.vertex_buffer;
|
||||||
let ib_full: gpu_buffer_t = context_raw.merged_object.data._.index_buffer;
|
let ib_full: gpu_buffer_t = context_raw.merged_object.data._.index_buffer;
|
||||||
@@ -188,11 +189,12 @@ function render_path_raytrace_build_data(bake: bool = false) {
|
|||||||
let mo: mesh_object_t = scene_meshes[0];
|
let mo: mesh_object_t = scene_meshes[0];
|
||||||
///end
|
///end
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
render_path_raytrace_transform = mo.base.transform.world_unpack;
|
render_path_raytrace_transform = mo.base.transform.world_unpack;
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
render_path_raytrace_transform = mat4_identity();
|
render_path_raytrace_transform = mat4_identity();
|
||||||
///end
|
}
|
||||||
|
|
||||||
if (!bake) {
|
if (!bake) {
|
||||||
let sc: f32 = mo.base.transform.scale.x * mo.data.scale_pos;
|
let sc: f32 = mo.base.transform.scale.x * mo.data.scale_pos;
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
else if (link == "_brush_scale") {
|
else if (link == "_brush_scale") {
|
||||||
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
|
let atlas_w: i32 = config_get_scene_atlas_res();
|
||||||
|
let item_w: i32 = config_get_layer_res();
|
||||||
|
let atlas_stride: i32 = atlas_w / item_w;
|
||||||
|
return atlas_stride;
|
||||||
|
}
|
||||||
|
|
||||||
let fill: bool = context_raw.layer.fill_layer != null;
|
let fill: bool = context_raw.layer.fill_layer != null;
|
||||||
let val: f32 = (fill ? context_raw.layer.scale : context_raw.brush_scale) * context_raw.brush_nodes_scale;
|
let val: f32 = (fill ? context_raw.layer.scale : context_raw.brush_scale) * context_raw.brush_nodes_scale;
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ let util_mesh_unwrappers: map_t<string, any> = map_create(); // JSValue * -> ((a
|
|||||||
|
|
||||||
function util_mesh_merge(paint_objects: mesh_object_t[] = null) {
|
function util_mesh_merge(paint_objects: mesh_object_t[] = null) {
|
||||||
if (paint_objects == null) {
|
if (paint_objects == null) {
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
paint_objects = util_mesh_ext_get_unique();
|
paint_objects = util_mesh_ext_get_unique();
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
paint_objects = project_paint_objects;
|
paint_objects = project_paint_objects;
|
||||||
///end
|
}
|
||||||
}
|
}
|
||||||
if (paint_objects.length == 0) {
|
if (paint_objects.length == 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -52,14 +52,15 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t
|
|||||||
draw_set_pipeline(null);
|
draw_set_pipeline(null);
|
||||||
draw_end();
|
draw_end();
|
||||||
|
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
// Do not multiply basecol by alpha
|
// Do not multiply basecol by alpha
|
||||||
draw_begin(layers_expa); // Copy to temp
|
draw_begin(layers_expa); // Copy to temp
|
||||||
draw_set_pipeline(pipes_copy);
|
draw_set_pipeline(pipes_copy);
|
||||||
draw_image(l1.texpaint, 0, 0);
|
draw_image(l1.texpaint, 0, 0);
|
||||||
draw_set_pipeline(null);
|
draw_set_pipeline(null);
|
||||||
draw_end();
|
draw_end();
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
_gpu_begin(layers_expa);
|
_gpu_begin(layers_expa);
|
||||||
gpu_set_pipeline(pipes_merge);
|
gpu_set_pipeline(pipes_merge);
|
||||||
gpu_set_texture(pipes_tex0, l1.texpaint);
|
gpu_set_texture(pipes_tex0, l1.texpaint);
|
||||||
@@ -73,7 +74,7 @@ function layers_ext_flatten(height_to_normal: bool = false, layers: slot_layer_t
|
|||||||
gpu_set_index_buffer(const_data_screen_aligned_ib);
|
gpu_set_index_buffer(const_data_screen_aligned_ib);
|
||||||
gpu_draw();
|
gpu_draw();
|
||||||
gpu_end();
|
gpu_end();
|
||||||
///end
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l1.paint_nor) {
|
if (l1.paint_nor) {
|
||||||
|
|||||||
@@ -250,13 +250,14 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
|||||||
node_shader_write_frag(kong, "var height: float = " + height + ";");
|
node_shader_write_frag(kong, "var height: float = " + height + ";");
|
||||||
node_shader_write_frag(kong, "var mat_opacity: float = " + opac + ";");
|
node_shader_write_frag(kong, "var mat_opacity: float = " + opac + ";");
|
||||||
node_shader_write_frag(kong, "var opacity: float = mat_opacity;");
|
node_shader_write_frag(kong, "var opacity: float = mat_opacity;");
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
node_shader_write_frag(kong, "opacity = 1.0;");
|
node_shader_write_frag(kong, "opacity = 1.0;");
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
if (context_raw.layer.fill_layer == null) {
|
if (context_raw.layer.fill_layer == null) {
|
||||||
node_shader_write_frag(kong, "opacity *= constants.brush_opacity;");
|
node_shader_write_frag(kong, "opacity *= constants.brush_opacity;");
|
||||||
}
|
}
|
||||||
///end
|
}
|
||||||
if (context_raw.material.paint_emis) {
|
if (context_raw.material.paint_emis) {
|
||||||
node_shader_write_frag(kong, "var emis: float = " + emis + ";");
|
node_shader_write_frag(kong, "var emis: float = " + emis + ";");
|
||||||
}
|
}
|
||||||
@@ -441,11 +442,12 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
|||||||
node_shader_add_texture(kong, "texpaint_pack_undo", "_texpaint_pack_undo");
|
node_shader_add_texture(kong, "texpaint_pack_undo", "_texpaint_pack_undo");
|
||||||
node_shader_write_frag(kong, "var sample_nor_undo: float4 = sample_lod(texpaint_nor_undo, sampler_linear, sample_tc, 0.0);");
|
node_shader_write_frag(kong, "var sample_nor_undo: float4 = sample_lod(texpaint_nor_undo, sampler_linear, sample_tc, 0.0);");
|
||||||
node_shader_write_frag(kong, "var sample_pack_undo: float4 = sample_lod(texpaint_pack_undo, sampler_linear, sample_tc, 0.0);");
|
node_shader_write_frag(kong, "var sample_pack_undo: float4 = sample_lod(texpaint_pack_undo, sampler_linear, sample_tc, 0.0);");
|
||||||
///if is_forge
|
if (context_raw.tool == tool_type_t.GIZMO) {
|
||||||
node_shader_write_frag(kong, "output[0] = float4(" + make_material_blend_mode(kong, context_raw.brush_blending, "sample_undo.rgb", "basecol", "str") + ", mat_opacity);");
|
node_shader_write_frag(kong, "output[0] = float4(" + make_material_blend_mode(kong, context_raw.brush_blending, "sample_undo.rgb", "basecol", "str") + ", mat_opacity);");
|
||||||
///else
|
}
|
||||||
|
else {
|
||||||
node_shader_write_frag(kong, "output[0] = float4(" + make_material_blend_mode(kong, context_raw.brush_blending, "sample_undo.rgb", "basecol", "str") + ", max(str, sample_undo.a));");
|
node_shader_write_frag(kong, "output[0] = float4(" + make_material_blend_mode(kong, context_raw.brush_blending, "sample_undo.rgb", "basecol", "str") + ", max(str, sample_undo.a));");
|
||||||
///end
|
}
|
||||||
node_shader_write_frag(kong, "output[1] = float4(lerp3(sample_nor_undo.rgb, nortan, str), matid);");
|
node_shader_write_frag(kong, "output[1] = float4(lerp3(sample_nor_undo.rgb, nortan, str), matid);");
|
||||||
if (context_raw.material.paint_height && make_material_height_used) {
|
if (context_raw.material.paint_height && make_material_height_used) {
|
||||||
node_shader_write_frag(kong, "output[2] = lerp4(sample_pack_undo, float4(occlusion, roughness, metallic, height), str);");
|
node_shader_write_frag(kong, "output[2] = lerp4(sample_pack_undo, float4(occlusion, roughness, metallic, height), str);");
|
||||||
|
|||||||
@@ -117,10 +117,8 @@ function sim_duplicate() {
|
|||||||
physics_body_init(pbdup, dup.base);
|
physics_body_init(pbdup, dup.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
///if is_forge
|
|
||||||
_tab_scene_paint_object_length++;
|
_tab_scene_paint_object_length++;
|
||||||
tab_scene_sort();
|
tab_scene_sort();
|
||||||
///end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sim_delete() {
|
function sim_delete() {
|
||||||
@@ -129,8 +127,6 @@ function sim_delete() {
|
|||||||
mesh_object_remove(so);
|
mesh_object_remove(so);
|
||||||
sim_remove_body(so.base.uid);
|
sim_remove_body(so.base.uid);
|
||||||
|
|
||||||
///if is_forge
|
|
||||||
_tab_scene_paint_object_length--;
|
_tab_scene_paint_object_length--;
|
||||||
tab_scene_sort();
|
tab_scene_sort();
|
||||||
///end
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user