----------------------------------------------------------------------------------------------------------- Simulate a physics object for this frame
| 679 | // ----------------------------------------------------------------------------------------------------------- |
| 680 | // Simulate a physics object for this frame |
| 681 | void do_physics_sim(object *obj) { |
| 682 | // Since we might not call FVI, set this here |
| 683 | Fvi_num_recorded_faces = 0; |
| 684 | |
| 685 | int n_ignore_objs = 0; // The number of ignored objects |
| 686 | int ignore_obj_list[MAX_IGNORE_OBJS + 1]; // List of ignored objects |
| 687 | |
| 688 | int fate; // Collision type for response code |
| 689 | vector movement_vec; // Movement in this frame |
| 690 | vector movement_pos; // End point of the movement |
| 691 | |
| 692 | int count = 0; // Simulation loop counter |
| 693 | int sim_loop_limit = (obj->type == OBJ_PLAYER) ? MAX_PLAYER_SIM_LOOPS : MAX_NON_PLAYER_SIM_LOOPS; |
| 694 | |
| 695 | int objnum = OBJNUM(obj); // Simulated object's index |
| 696 | fvi_info hit_info; // Hit information |
| 697 | fvi_query fq; // Movement query |
| 698 | |
| 699 | float sim_time_remaining = Frametime; // Amount of simulation time remaining (current iteration) |
| 700 | float old_sim_time_remaining = Frametime; // Amount of simulation time remaining (previous iteration) |
| 701 | |
| 702 | vector init_pos = obj->pos; // Initial position |
| 703 | int init_room = obj->roomnum; // Initial room |
| 704 | |
| 705 | vector start_pos; // Values at the start of current simulation loop |
| 706 | vector start_vel; |
| 707 | matrix start_orient; |
| 708 | vector start_rotvel; |
| 709 | angle start_turnroll; |
| 710 | int start_room; |
| 711 | |
| 712 | float moved_time; // How long objected moved before hit something |
| 713 | physics_info *pi = &obj->mtype.phys_info; // Simulated object's physics information |
| 714 | |
| 715 | int bounced = 0; // Did the object bounce? |
| 716 | |
| 717 | vector total_force; // Constant force acting on an object |
| 718 | |
| 719 | bool f_continue_sim; // Should we run another simulation loop |
| 720 | bool f_start_fvi_record = true; // Records the rooms that are passed thru |
| 721 | |
| 722 | bool f_turn_gravity_on = false; |
| 723 | |
| 724 | // Assert conditions |
| 725 | ASSERT(obj->type != OBJ_NONE); |
| 726 | ASSERT(obj->movement_type == MT_PHYSICS); |
| 727 | ASSERT(!(obj->mtype.phys_info.flags & PF_USES_THRUST) || obj->mtype.phys_info.drag != 0.0); |
| 728 | |
| 729 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 730 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 731 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 732 | |
| 733 | #ifdef _DEBUG |
| 734 | if (!Game_do_flying_sim) { |
| 735 | return; |
| 736 | } |
| 737 | #endif |
| 738 |
no test coverage detected