/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; edict_t *ent; if (sv.state != ss_game) return; if (sv.old_time) { // don't bother running a frame if sv_mintic seconds haven't passed sv_frametime = sv.time - sv.old_time; if (sv_frametime < sv_mintic.value) return; if (sv_frametime > sv_maxtic.value) sv_frametime = sv_maxtic.value; sv.old_time = sv.time; } else sv_frametime = 0.1; // initialization frame if (pr_nqprogs) NQP_Reset (); PR_GLOBAL(frametime) = sv_frametime; SV_ProgStartFrame (); // // treat each object in turn // even the world gets a chance to think // ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (!ent->inuse) continue; if (PR_GLOBAL(force_retouch)) SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= MAX_CLIENTS) continue; // clients are run directly from packets SV_RunEntity (ent); SV_RunNewmis (); } if (PR_GLOBAL(force_retouch)) PR_GLOBAL(force_retouch)--; SV_RunBots (); }
void SV_PostRunCmd(void) { // run post-think if (!host_client->spectator) { pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram (pr_global_struct->PlayerPostThink); SV_RunNewmis (); } else if (SpectatorThink) { pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram (SpectatorThink); } }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; edict_t *ent; static double old_time; // don't bother running a frame if sys_ticrate seconds haven't passed host_frametime = realtime - old_time; if (host_frametime < sv_mintic.value) return; if (host_frametime > sv_maxtic.value) host_frametime = sv_maxtic.value; old_time = realtime; pr_global_struct->frametime = host_frametime; SV_ProgStartFrame (); // // treat each object in turn // even the world gets a chance to think // ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; if (pr_global_struct->force_retouch) SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= MAX_CLIENTS) continue; // clients are run directly from packets SV_RunEntity (ent); SV_RunNewmis (); } if (pr_global_struct->force_retouch) pr_global_struct->force_retouch--; }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; static double old_time; byte *ent_global_ptr = (byte *) sv.edicts; DEBUGPRINT(PHYSICS,MEDIUM) printf("GAJA: In Physics parallel\n"); // don't bother running a frame if sys_ticrate seconds haven't passed host_frametime = realtime - old_time; if (host_frametime < sv_mintic.value) return; if (host_frametime > sv_maxtic.value) host_frametime = sv_maxtic.value; old_time = realtime; pr_global_struct->frametime = host_frametime; SV_ProgStartFrame (); // // treat each object in turn // even the world gets a chance to think // if (pr_global_struct->force_retouch) { // GAJA: RUN SERIAL edict_t *ent; ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= MAX_CLIENTS) continue; // clients are run directly from packets SV_RunEntity (ent); SV_RunNewmis (); } } else { // GAJA: RUN PARALLEL omp_set_num_threads(NoThreads); #pragma omp parallel for schedule(dynamic,1) private(i) shared(svs, sv, sv_areanodes, pr_global_struct, realtime, movevars) for (i=0 ; i<sv.num_edicts ; i++) { edict_t *ent = (edict_t *) (ent_global_ptr + pr_edict_size * i); if (ent->free || i <= MAX_CLIENTS) continue; DEBUGPRINT(PHYSICS,HIGH) printf("Thread= %d\t\tBefore Transaction\n", omp_get_thread_num()); inTransaction = true; // ~+~+~+~+~+ // StartTransaction LOCK(global_lock) TRANSACTION //if (pr_global_struct->force_retouch) // SV_LinkEdict (ent, true); // force retouch even for stationary //if (i > MAX_CLIENTS) // don't run client entities (clients are run directly from packets) //{ SV_RunEntity (ent); SV_RunNewmis (); //} TRANSACTION_END UNLOCK(global_lock) // EndTransaction inTransaction = false; DEBUGPRINT(PHYSICS,HIGH) printf("Thread= %d\t\tAfter Transaction\n", omp_get_thread_num()); // send messages and packets generated during transaction FlushTMOutput(); } // end for } //end if if (pr_global_struct->force_retouch) pr_global_struct->force_retouch--; }