diff options
| author | tech kaczynski <tk@techkaczynski.dev> | 2026-10-19 01:47:08 +1000 |
|---|---|---|
| committer | tech kaczynski <tk@techkaczynski.dev> | 2026-10-19 01:47:08 +1000 |
| commit | edc50a43a0ab064472aa7fde90f14cf456d92076 (patch) | |
| tree | c0281123898ddfa2d94683cbcd4cd85dd0d6ad6b /save.c | |
| parent | cc4ba95edf2927eda63af1aeb79a503bc6fe6182 (diff) | |
lots of editor work. Improved editor camera controls.
Diffstat (limited to 'save.c')
| -rw-r--r-- | save.c | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -772,8 +772,8 @@ read_physics_joint(FILE *fp, PhysicsJoint *joint, u32 body_cnt) { !read_u32_le(fp, &joint->flags) || !read_vec3(fp, &joint->anchor_a) || !read_vec3(fp, &joint->anchor_b) || - !read_vec3(fp, &joint->axis_a) || - !read_vec3(fp, &joint->axis_b) || + !read_quat(fp, &joint->frame_rot_a) || + !read_quat(fp, &joint->frame_rot_b) || !read_f32_le(fp, &joint->lower) || !read_f32_le(fp, &joint->upper) || !read_f32_le(fp, &joint->spring_hz) || @@ -800,8 +800,8 @@ write_physics_joint(FILE *fp, PhysicsJoint *joint, u32 body_cnt) { write_u32_le(fp, joint->flags) && write_vec3(fp, joint->anchor_a) && write_vec3(fp, joint->anchor_b) && - write_vec3(fp, joint->axis_a) && - write_vec3(fp, joint->axis_b) && + write_quat(fp, joint->frame_rot_a) && + write_quat(fp, joint->frame_rot_b) && write_f32_le(fp, joint->lower) && write_f32_le(fp, joint->upper) && write_f32_le(fp, joint->spring_hz) && @@ -832,6 +832,17 @@ read_physics_chunk(FILE *fp, SaveLoadContext *ctx) { return false; } + u32 root_body; + if (!read_u32_le(fp, &root_body)) { + return false; + } + + if ((body_cnt && root_body >= body_cnt) || + (!body_cnt && root_body != 0)) { + return false; + } + + ent->phys.root_body = root_body; ent->phys.body_cnt = body_cnt; if (body_cnt) { @@ -902,9 +913,12 @@ write_physics_chunk(FILE *fp) { } if ((phys->body_cnt && !phys->bodies) || - (phys->joint_cnt && !phys->joints) || - !write_u64_le(fp, ent->pid) || - !write_u32_le(fp, phys->body_cnt)) { + (phys->joint_cnt && !phys->joints) || + (phys->body_cnt && phys->root_body >= phys->body_cnt) || + (!phys->body_cnt && phys->root_body != 0) || + !write_u64_le(fp, ent->pid) || + !write_u32_le(fp, phys->body_cnt) || + !write_u32_le(fp, phys->root_body)) { return false; } |
