Forge test
This commit is contained in:
@@ -171,6 +171,16 @@ function transform_compute_radius(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") {
|
||||
let mo: mesh_object_t = raw.object.ext;
|
||||
let aabb: vec4_t = mesh_data_calculate_aabb(mo.data);
|
||||
let o: object_t = raw.object;
|
||||
o.raw = {};
|
||||
o.raw.dimensions = f32_array_create_xyz(aabb.x, aabb.y, aabb.z);
|
||||
}
|
||||
///end
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,11 @@ function base_ext_render() {
|
||||
|
||||
function base_ext_init_config(raw: config_t) {
|
||||
raw.layer_res = texture_res_t.RES8192;
|
||||
raw.undo_steps = 1;
|
||||
}
|
||||
|
||||
function base_ext_update() {
|
||||
if (keyboard_down("control") && keyboard_started("d")) {
|
||||
sim_duplicate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,17 @@ function sim_update() {
|
||||
render_path_raytrace_ready = false;
|
||||
|
||||
if (sim_running) {
|
||||
if (render_path_raytrace_frame != 1) {
|
||||
return;
|
||||
}
|
||||
// if (render_path_raytrace_frame != 1) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
let world: physics_world_t = physics_world_active;
|
||||
physics_world_update(world);
|
||||
|
||||
iron_delay_idle_sleep();
|
||||
|
||||
let record: bool = true;
|
||||
// let record: bool = true;
|
||||
let record: bool = false;
|
||||
if (record) {
|
||||
let rt: render_target_t = map_get(render_path_render_targets, "taa");
|
||||
let pixels: buffer_t = image_get_pixels(rt._image);
|
||||
@@ -68,3 +69,25 @@ function sim_add(o: object_t, shape: physics_shape_t, mass: f32) {
|
||||
body.mass = mass;
|
||||
physics_body_init(body, o);
|
||||
}
|
||||
|
||||
function sim_duplicate() {
|
||||
// Mesh
|
||||
let so: mesh_object_t = context_raw.selected_object.ext;
|
||||
let dup: mesh_object_t = scene_add_mesh_object(so.data, so.materials, so.base.parent);
|
||||
transform_set_matrix(dup.base.transform, so.base.transform.local);
|
||||
array_push(project_paint_objects, dup);
|
||||
dup.base.name = so.base.name;
|
||||
|
||||
app_notify_on_next_frame(function() {
|
||||
util_mesh_merge();
|
||||
});
|
||||
|
||||
// Physics
|
||||
let pb: physics_body_t = map_get(physics_body_object_map, so.base.uid);
|
||||
if (pb != null) {
|
||||
let pbdup: physics_body_t = physics_body_create();
|
||||
pbdup.shape = pb.shape;
|
||||
pbdup.mass = pb.mass;
|
||||
physics_body_init(pbdup, dup.base);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,16 @@
|
||||
let tab_scene_line_counter: i32 = 0;
|
||||
|
||||
function tab_scene_select_object(mo: mesh_object_t) {
|
||||
if (mo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
context_raw.selected_object = mo.base;
|
||||
|
||||
if (mo.base.ext_type != "mesh_object_t") {
|
||||
return;
|
||||
}
|
||||
|
||||
context_raw.paint_object = mo;
|
||||
if (context_raw.merged_object != null) {
|
||||
context_raw.merged_object.base.visible = false;
|
||||
@@ -14,6 +23,10 @@ function tab_scene_import_mesh_done() {
|
||||
let mo: mesh_object_t = project_paint_objects[project_paint_objects.length - 1];
|
||||
object_set_parent(mo.base, null);
|
||||
tab_scene_select_object(mo);
|
||||
|
||||
app_notify_on_next_frame(function() {
|
||||
util_mesh_merge();
|
||||
});
|
||||
}
|
||||
|
||||
function tab_scene_draw_list(ui: ui_t, list_handle: ui_handle_t, current_object: object_t) {
|
||||
@@ -282,17 +295,15 @@ function tab_scene_draw(htab: ui_handle_t) {
|
||||
}
|
||||
|
||||
if (ui_button("Duplicate")) {
|
||||
let so: mesh_object_t = context_raw.selected_object.ext;
|
||||
let dup: mesh_object_t = scene_add_mesh_object(so.data, so.materials, so.base.parent);
|
||||
transform_set_matrix(dup.base.transform, so.base.transform.local);
|
||||
array_push(project_paint_objects, dup);
|
||||
dup.base.name = so.base.name;
|
||||
sim_duplicate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ui_button("Play")) {
|
||||
sim_play();
|
||||
|
||||
context_raw.selected_object = scene_camera.base;
|
||||
}
|
||||
if (ui_button("Stop")) {
|
||||
sim_stop();
|
||||
|
||||
@@ -561,7 +561,8 @@ function render_path_paint_commands_symmetry() {
|
||||
function render_path_paint_paint_enabled(): bool {
|
||||
let fill_layer: bool = context_raw.layer.fill_layer != null && context_raw.tool != workspace_tool_t.PICKER && context_raw.tool != workspace_tool_t.MATERIAL && context_raw.tool != workspace_tool_t.COLORID;
|
||||
let group_layer: bool = slot_layer_is_group(context_raw.layer);
|
||||
return !fill_layer && !group_layer && !context_raw.foreground_event;
|
||||
let gizmo: bool = context_raw.tool == workspace_tool_t.GIZMO;
|
||||
return !fill_layer && !group_layer && !context_raw.foreground_event && !gizmo;
|
||||
}
|
||||
|
||||
function render_path_paint_live_brush_dirty() {
|
||||
|
||||
@@ -144,7 +144,7 @@ void _jolt_world_create() {
|
||||
|
||||
void _jolt_world_update() {
|
||||
#ifdef is_forge
|
||||
const int cCollisionSteps = 16;
|
||||
const int cCollisionSteps = 2;
|
||||
#else
|
||||
const int cCollisionSteps = 1;
|
||||
#endif
|
||||
@@ -228,6 +228,10 @@ void *_jolt_body_create(int shape, float mass, float dimx, float dimy, float dim
|
||||
BodyCreationSettings settings(shape_c, RVec3(x, y, z), Quat::sIdentity(), mass == 0 ? EMotionType::Static : EMotionType::Dynamic,
|
||||
mass == 0 ? Layers::NON_MOVING : Layers::MOVING);
|
||||
|
||||
#ifdef is_forge
|
||||
settings.mAllowSleeping = false;
|
||||
#endif
|
||||
|
||||
// if (ccd) {
|
||||
if (shape != 2) { // != Mesh
|
||||
settings.mMotionQuality = EMotionQuality::LinearCast;
|
||||
|
||||
@@ -428,7 +428,14 @@ function context_create(): context_t {
|
||||
c.brush_opacity = 1.0;
|
||||
c.brush_opacity_handle = ui_handle_create();
|
||||
c.brush_opacity_handle.value = 1.0;
|
||||
///if is_forge
|
||||
let atlas_w: i32 = 8192; // config_get_texture_res();
|
||||
let item_w: i32 = 4096;
|
||||
let atlas_stride: i32 = atlas_w / item_w;
|
||||
c.brush_scale = atlas_stride;
|
||||
///else
|
||||
c.brush_scale = 1.0;
|
||||
///end
|
||||
c.brush_angle = 0.0;
|
||||
c.brush_angle_handle = ui_handle_create();
|
||||
c.brush_angle_handle.value = 0.0;
|
||||
|
||||
@@ -307,11 +307,6 @@ function gizmo_update() {
|
||||
if (context_raw.gizmo_started) {
|
||||
context_raw.gizmo_drag_last = context_raw.gizmo_drag;
|
||||
}
|
||||
|
||||
///if is_forge
|
||||
util_mesh_remove_merged();
|
||||
render_path_raytrace_ready = false;
|
||||
///end
|
||||
}
|
||||
|
||||
_input_occupied = (context_raw.translate_x || context_raw.translate_y || context_raw.translate_z || context_raw.scale_x || context_raw.scale_y || context_raw.scale_z || context_raw.rotate_x || context_raw.rotate_y || context_raw.rotate_z) && mouse_view_x() < base_w();
|
||||
|
||||
@@ -195,9 +195,11 @@ function render_path_base_commands(draw_commands: ()=>void) {
|
||||
render_path_paint_draw();
|
||||
|
||||
///if (arm_direct3d12 || arm_vulkan || arm_metal)
|
||||
if (context_raw.viewport_mode == viewport_mode_t.PATH_TRACE) {
|
||||
if (context_raw.viewport_mode == viewport_mode_t.PATH_TRACE) {
|
||||
let use_live_layer: bool = context_raw.tool == workspace_tool_t.MATERIAL;
|
||||
render_path_raytrace_draw(use_live_layer);
|
||||
context_raw.foreground_event = false; // render_path_paint_end();
|
||||
render_path_base_end();
|
||||
return;
|
||||
}
|
||||
///end
|
||||
|
||||
Reference in New Issue
Block a user