----------------------------------------------------------------------------------------------------------- Simulate a physics object for this frame
| 1912 | // ----------------------------------------------------------------------------------------------------------- |
| 1913 | // Simulate a physics object for this frame |
| 1914 | void do_walking_sim(object *obj) { |
| 1915 | // Since we might not call FVI, set this here |
| 1916 | Fvi_num_recorded_faces = 0; |
| 1917 | |
| 1918 | int n_ignore_objs = 0; // The number of ignored objects |
| 1919 | int ignore_obj_list[MAX_IGNORE_OBJS + 1]; // List of ignored objects |
| 1920 | |
| 1921 | int fate; // Collision type for response code |
| 1922 | vector movement_vec; // Movement in this frame |
| 1923 | vector movement_pos; // End point of the movement |
| 1924 | |
| 1925 | int count = 0; // Simulation loop counter |
| 1926 | int sim_loop_limit = (obj->type == OBJ_PLAYER) ? MAX_PLAYER_SIM_LOOPS : MAX_NON_PLAYER_SIM_LOOPS; |
| 1927 | |
| 1928 | int objnum = OBJNUM(obj); // Simulated object's index |
| 1929 | fvi_info hit_info; // Hit information |
| 1930 | fvi_query fq; // Movement query |
| 1931 | |
| 1932 | float sim_time_remaining = Frametime; // Amount of simulation time remaining (current iteration) |
| 1933 | float old_sim_time_remaining = Frametime; // Amount of simulation time remaining (previous iteration) |
| 1934 | |
| 1935 | vector init_pos = obj->pos; // Initial position |
| 1936 | int init_room = obj->roomnum; // Initial room |
| 1937 | |
| 1938 | vector start_pos = obj->pos; // Values at the start of current simulation loop |
| 1939 | vector start_vel = obj->mtype.phys_info.velocity; |
| 1940 | int start_room = obj->roomnum; |
| 1941 | |
| 1942 | float moved_time; // How long objected moved before hit something |
| 1943 | physics_info *pi = &obj->mtype.phys_info; // Simulated object's physics information |
| 1944 | |
| 1945 | int bounced = 0; // Did the object bounce? |
| 1946 | |
| 1947 | vector total_force = Zero_vector; // Constant force acting on an object |
| 1948 | |
| 1949 | bool f_continue_sim; // Should we run another simulation loop |
| 1950 | bool f_start_fvi_record = true; // Records the rooms that are passed thru |
| 1951 | |
| 1952 | poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num]; |
| 1953 | |
| 1954 | // Assert conditions |
| 1955 | ASSERT(obj->type != OBJ_NONE); |
| 1956 | ASSERT(obj->movement_type == MT_WALKING); |
| 1957 | ASSERT(!(obj->mtype.phys_info.flags & PF_USES_THRUST) || obj->mtype.phys_info.drag != 0.0); |
| 1958 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 1959 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 1960 | ASSERT(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault. |
| 1961 | |
| 1962 | #ifdef _DEBUG |
| 1963 | if (!Game_do_walking_sim) { |
| 1964 | return; |
| 1965 | } |
| 1966 | #endif |
| 1967 | |
| 1968 | // Instant bail cases |
| 1969 | if ((obj->flags & (OF_DEAD | OF_ATTACHED)) || (Frametime <= 0.0) || (obj->type == OBJ_DUMMY)) { |
| 1970 | return; |
| 1971 | } |
no test coverage detected