void SingleEvent () { real vvSum; int n; NextEvent (); if (evIdB < MOL_LIMIT) { ProcessCollision (); ++ collCount; } else if (evIdB >= MOL_LIMIT + 100) { ProcessCellCrossing (); ++ crossCount; } else if (evIdB == MOL_LIMIT + 7) { UpdateSystem (); EvalRdf (); nextRdfTime += intervalRdf; ScheduleEvent (0, MOL_LIMIT + 7, nextRdfTime); } else if (evIdB == MOL_LIMIT + 6) { UpdateSystem (); nextSumTime += intervalSum; ScheduleEvent (0, MOL_LIMIT + 6, nextSumTime); VZero (vSum); vvSum = 0.; DO_MOL { VVAdd (vSum, mol[n].rv); vvSum += VLenSq (mol[n].rv); } kinEnVal = vvSum * 0.5 / nMol; PrintSummary (stdout); }
int GetKey() { UpdateSystem(); while (KeyQueue.empty() == true) UpdateSystem(); int key = KeyQueue.front(); KeyQueue.pop(); return key; }
int GetMouseWheelEvent() { UpdateSystem(); while (MouseWheelQueue.empty() == true) UpdateSystem(); int mw_event = MouseWheelQueue.front(); MouseWheelQueue.pop(); return mw_event; }
bool RefreshInput() { UpdateSystem(); // update modifier keys ModKeyStates[MODKEY_CAPSLOCK] = GetKeyState(VK_CAPITAL) & 0xFFFF; ModKeyStates[MODKEY_NUMLOCK] = GetKeyState(VK_NUMLOCK) & 0xFFFF; ModKeyStates[MODKEY_SCROLLOCK] = GetKeyState(VK_SCROLL) & 0xFFFF; // update currently pressed keys memcpy(KeyBuffer, CurrentKeyBuffer, MAX_KEY); // update joysticks for (unsigned int i = 0; i < Joysticks.size(); ++i) { Joystick &j = Joysticks[i]; JOYINFOEX jinfo_ex; jinfo_ex.dwSize = sizeof(jinfo_ex); jinfo_ex.dwFlags = JOY_RETURNBUTTONS | JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR |JOY_RETURNU | JOY_RETURNV; if (joyGetPosEx(j.id, &jinfo_ex) == JOYERR_NOERROR) { j.axes[JOYSTICK_AXIS_X] = float(jinfo_ex.dwXpos - j.minX) / (j.maxX - j.minX) * 2 - 1; j.axes[JOYSTICK_AXIS_Y] = float(jinfo_ex.dwYpos - j.minY) / (j.maxY - j.minY) * 2 - 1; j.axes[JOYSTICK_AXIS_Z] = float(jinfo_ex.dwZpos - j.minZ) / (j.maxZ - j.minZ) * 2 - 1; j.axes[JOYSTICK_AXIS_R] = float(jinfo_ex.dwRpos - j.minR) / (j.maxR - j.minR) * 2 - 1; j.axes[JOYSTICK_AXIS_U] = float(jinfo_ex.dwUpos - j.minU) / (j.maxU - j.minU) * 2 - 1; j.axes[JOYSTICK_AXIS_V] = float(jinfo_ex.dwVpos - j.minV) / (j.maxV - j.minV) * 2 - 1; j.buttons = jinfo_ex.dwButtons; } } return true; }
void SingleEvent () { real vvSum; real sp; int n; NextEvent (); if (evIdB < MOL_LIMIT) { ProcessCollision (); ++ collCount; } else if (evIdB < MOL_LIMIT + NDIM * 2 || evIdB >= MOL_LIMIT + 100) { ProcessCellCrossing (); ++ crossCount; } else if (evIdB == MOL_LIMIT + 6) { UpdateSystem (); nextSumTime += intervalSum; ScheduleEvent (0, MOL_LIMIT + 6, nextSumTime); VZero (vSum); vvSum = 0.; sp = 0.; DO_MOL { VVAdd (vSum, mol[n].rv); vvSum += VLenSq (mol[n].rv); sp += VDot (mol[n].r, gravField); } kinEnVal = vvSum * 0.5 / nMol; totEnVal = kinEnVal - sp / nMol; PrintSummary (stdout); } else if (evIdB == MOL_LIMIT + 7) {
void GetKeyStates(bool keys[MAX_KEY]) { UpdateSystem(); for (int i = MAX_KEY -1 ; i>=0 ; --i) { keys[i] = (KeyBuffer[i] != 0); } }
// draws all particles belonging to this system bool CParticleSystem::DrawSystem( void ) { if (TestSystem() == false) { return false; } UpdateSystem(); m_flLastDraw = gEngfuncs.GetClientTime(); return true; }
bool CParticleSystem::RenderSystem( void ) { // heres where we loop through the system and render it if( TestSystem( ) ) { // if test works update it UpdateSystem( ); //now we loop thorugh the parts in the system and render them Particle_s *pPart = m_pHeadPart; int iCount = 0; PreRender( ); while( pPart ) { // first we need to test if the particle should still be living Particle_s *pTmp = pPart->pNext; if( TestPart( pPart ) ) { UpdatePart( pPart ); if( TestVisability( pPart ) ) { // then we should update the particle // now draw it RenderPart( pPart ); iCount ++; } } else { // test show no need for particle remove it ReturnToPool( pPart ); } //move to the next part pPart = pTmp; } // turn it off PostRender( ); // if( iCount >= 5000 ) /*{ gEngfuncs.Con_Printf( "Parts: %i\n", iCount ); }*/ } else { //we can break out system doesnt need to be around any more return false; } //every thing was successfull return true; }
void ngen_mainloop(void* v_cntx) { Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); cycle_counter = 0; for (;;) { cycle_counter = SH4_TIMESLICE; do { DynarecCodeEntryPtr rcb = bm_GetCode(ctx->cntx.pc); rcb(); } while (cycle_counter > 0); if (UpdateSystem()) { rdv_DoInterrupts_pc(ctx->cntx.pc); } } }
LTBOOL CLineSystemFX::Update() { if (!m_hObject || !m_pClientDE || m_bWantRemove) return LTFALSE; LTFLOAT fTime = m_pClientDE->GetTime(); // Hide/show the line system if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); m_fLastTime = fTime; return LTTRUE; } else { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } } // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } if (m_bFirstUpdate) { m_fLastTime = fTime; m_bFirstUpdate = LTFALSE; } else { UpdateSystem(); } // Make sure it is time to update... if (fTime < m_fLastTime + m_fNextUpdate) { return LTTRUE; } // Ok, how many to add this frame.... float fTimeDelta = fTime - m_fLastTime; // Make sure delta time is no less than 15 frames/sec if we're // continuously adding lines... if (m_bContinuous) { fTimeDelta = fTimeDelta > 0.0666f ? 0.0666f : fTimeDelta; } int nToAdd = (int) floor(m_cs.fLinesPerSecond * fTimeDelta); nToAdd = LTMIN(nToAdd, (int)(MAX_LINES_PER_SECOND * fTimeDelta)); // Add new lines... AddLines(nToAdd); // Determine when next update should occur... if (m_cs.fBurstWait > 0.001f) { m_fNextUpdate = m_cs.fBurstWait * GetRandom(m_cs.fBurstWaitMin, m_cs.fBurstWaitMax); } else { m_fNextUpdate = 0.001f; } m_fLastTime = fTime; return LTTRUE; }
int GetNumMouseWheelEvents() { UpdateSystem(); return MouseWheelQueue.size(); }
int GetMouseY() { UpdateSystem(); return MouseY; }
int GetMouseX() { UpdateSystem(); return MouseX; }
bool AreKeysLeft() { UpdateSystem(); return (!KeyQueue.empty()); }
int UpdateSystem_INTC() { UpdateSystem(); return UpdateINTC(); }