MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / do_walking_sim

Function do_walking_sim

physics/physics.cpp:1914–2421  ·  view source on GitHub ↗

----------------------------------------------------------------------------------------------------------- Simulate a physics object for this frame

Source from the content-addressed store, hash-verified

1912// -----------------------------------------------------------------------------------------------------------
1913// Simulate a physics object for this frame
1914void 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 }

Callers 1

ObjDoFrameFunction · 0.85

Calls 15

ObjSetPosFunction · 0.85
ObjSetOrientFunction · 0.85
GetTerrainRoomFromPosFunction · 0.85
PhysValidateGroundPathFunction · 0.85
fvi_FindIntersectionFunction · 0.85
GetTerrainCellFromPosFunction · 0.85
SetObjectDeadFlagFunction · 0.85
vm_NormalizeVectorFunction · 0.85
collide_object_with_wallFunction · 0.85
vm_MakeZeroFunction · 0.85
collide_two_objectsFunction · 0.85

Tested by

no test coverage detected