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

Function do_physics_sim

physics/physics.cpp:681–1609  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

679// -----------------------------------------------------------------------------------------------------------
680// Simulate a physics object for this frame
681void 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

Callers 3

MultiDoAdjustPositionFunction · 0.85
MultiDoRequestToMoveFunction · 0.85
ObjDoFrameFunction · 0.85

Calls 15

fvi_FindIntersectionFunction · 0.85
ObjSetPosFunction · 0.85
PhysicsDoSimRotFunction · 0.85
ObjSetOrientFunction · 0.85
PhysicsDoSimLinearFunction · 0.85
vm_MakeZeroFunction · 0.85
ObjSetAABBFunction · 0.85
vm_NormalizeVectorFunction · 0.85
ObjCreateFunction · 0.85
GetTerrainCellFromPosFunction · 0.85
SetObjectDeadFlagFunction · 0.85
collide_object_with_wallFunction · 0.85

Tested by

no test coverage detected