fix dbg drag local point
This commit is contained in:
parent
f000bd7e65
commit
110e28119c
14
src/sim.c
14
src/sim.c
@ -393,6 +393,12 @@ void sim_update(struct sim_ctx *ctx, i64 target_dt_ns)
|
|||||||
{
|
{
|
||||||
__prof;
|
__prof;
|
||||||
|
|
||||||
|
{
|
||||||
|
__profscope(sim_update_sleep);
|
||||||
|
sleep_frame(ctx->last_tick_ns, target_dt_ns);
|
||||||
|
ctx->last_tick_ns = sys_time_ns();
|
||||||
|
}
|
||||||
|
|
||||||
struct temp_arena scratch = scratch_begin_no_conflict();
|
struct temp_arena scratch = scratch_begin_no_conflict();
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
@ -542,8 +548,8 @@ void sim_update(struct sim_ctx *ctx, i64 target_dt_ns)
|
|||||||
struct sim_control *control = &client->control;
|
struct sim_control *control = &client->control;
|
||||||
|
|
||||||
client->dbg_drag_start = false;
|
client->dbg_drag_start = false;
|
||||||
client->dbg_drag_stop = false;
|
|
||||||
|
|
||||||
|
client->dbg_drag_stop = false;
|
||||||
for (struct sim_cmd *cmd = cmds.first; cmd; cmd = cmd->next) {
|
for (struct sim_cmd *cmd = cmds.first; cmd; cmd = cmd->next) {
|
||||||
enum sim_cmd_kind kind = cmd->kind;
|
enum sim_cmd_kind kind = cmd->kind;
|
||||||
b32 start = cmd->state == SIM_CMD_STATE_START;
|
b32 start = cmd->state == SIM_CMD_STATE_START;
|
||||||
@ -1087,7 +1093,7 @@ void sim_update(struct sim_ctx *ctx, i64 target_dt_ns)
|
|||||||
|
|
||||||
if (sim_ent_is_valid_and_active(target_ent)) {
|
if (sim_ent_is_valid_and_active(target_ent)) {
|
||||||
if (!sim_ent_is_valid_and_active(joint_ent)) {
|
if (!sim_ent_is_valid_and_active(joint_ent)) {
|
||||||
/* FIXME: Joint ent never released */
|
/* FIXME: Joint ent may never release */
|
||||||
joint_ent = sim_ent_alloc(root);
|
joint_ent = sim_ent_alloc(root);
|
||||||
joint_ent->mass_unscaled = F32_INFINITY;
|
joint_ent->mass_unscaled = F32_INFINITY;
|
||||||
joint_ent->inertia_unscaled = F32_INFINITY;
|
joint_ent->inertia_unscaled = F32_INFINITY;
|
||||||
@ -1100,7 +1106,9 @@ void sim_update(struct sim_ctx *ctx, i64 target_dt_ns)
|
|||||||
|
|
||||||
struct phys_mouse_joint_def def = ZI;
|
struct phys_mouse_joint_def def = ZI;
|
||||||
def.target = target_ent->handle;
|
def.target = target_ent->handle;
|
||||||
if (!sim_ent_handle_eq(joint_ent->mouse_joint_data.target, target_ent->handle)) {
|
if (sim_ent_handle_eq(joint_ent->mouse_joint_data.target, target_ent->handle)) {
|
||||||
|
def.point_local_start = joint_ent->mouse_joint_data.point_local_start;
|
||||||
|
} else {
|
||||||
def.point_local_start = xform_invert_mul_v2(xf, cursor);
|
def.point_local_start = xform_invert_mul_v2(xf, cursor);
|
||||||
}
|
}
|
||||||
def.point_local_end = xform_invert_mul_v2(xf, cursor);
|
def.point_local_end = xform_invert_mul_v2(xf, cursor);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ struct host_startup_receipt;
|
|||||||
struct sim_ctx {
|
struct sim_ctx {
|
||||||
struct arena arena;
|
struct arena arena;
|
||||||
|
|
||||||
|
i64 last_tick_ns;
|
||||||
u64 last_phys_iteration;
|
u64 last_phys_iteration;
|
||||||
|
|
||||||
struct sprite_scope *sprite_frame_scope;
|
struct sprite_scope *sprite_frame_scope;
|
||||||
|
|||||||
31
src/user.c
31
src/user.c
@ -129,29 +129,13 @@ GLOBAL READONLY enum user_bind_kind g_binds[SYS_BTN_COUNT] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ========================== *
|
|
||||||
* Sim thread
|
|
||||||
* ========================== */
|
|
||||||
|
|
||||||
INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_sim_thread_entry_point, arg)
|
|
||||||
{
|
|
||||||
struct sim_ctx *ctx = (struct sim_ctx *)arg;
|
|
||||||
i64 last_frame_ns = 0;
|
|
||||||
i64 target_dt_ns = NS_FROM_SECONDS(1) / SIM_FPS;;
|
|
||||||
while (!atomic_i32_eval(&G.sim_thread_shutdown)) {
|
|
||||||
__profscope(sim_update_w_sleep);
|
|
||||||
sleep_frame(last_frame_ns, target_dt_ns);
|
|
||||||
last_frame_ns = sys_time_ns();
|
|
||||||
sim_update(ctx, target_dt_ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Startup
|
* Startup
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(user_shutdown);
|
INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(user_shutdown);
|
||||||
INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_thread_entry_point, arg);
|
INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_thread_entry_point, arg);
|
||||||
|
INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_sim_thread_entry_point, arg);
|
||||||
INTERNAL SYS_WINDOW_EVENT_CALLBACK_FUNC_DEF(window_event_callback, event);
|
INTERNAL SYS_WINDOW_EVENT_CALLBACK_FUNC_DEF(window_event_callback, event);
|
||||||
|
|
||||||
struct user_startup_receipt user_startup(struct work_startup_receipt *work_sr,
|
struct user_startup_receipt user_startup(struct work_startup_receipt *work_sr,
|
||||||
@ -1862,3 +1846,16 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_thread_entry_point, arg)
|
|||||||
user_update();
|
user_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Sim thread entry point
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_sim_thread_entry_point, arg)
|
||||||
|
{
|
||||||
|
struct sim_ctx *ctx = (struct sim_ctx *)arg;
|
||||||
|
i64 target_dt_ns = NS_FROM_SECONDS(1) / SIM_FPS;;
|
||||||
|
while (!atomic_i32_eval(&G.sim_thread_shutdown)) {
|
||||||
|
sim_update(ctx, target_dt_ns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user