void FCE_AxisAlignedBoundingBox::AddBox( const FCE_AxisAlignedBoundingBox* pBox ){ if ( pBox->isNull ) return; AddPoints(1, &minPos); AddPoints(1, &maxPos); }
void SkGlyphCache::findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos, bool yAxis, SkGlyph* glyph, SkScalar* array, int* count) { const SkGlyph::Intercept* match = MatchBounds(glyph, bounds); if (match) { if (match->fInterval[0] < match->fInterval[1]) { OffsetResults(match, scale, xPos, array, count); } return; } SkGlyph::Intercept* intercept = (SkGlyph::Intercept* ) fGlyphAlloc.allocThrow(sizeof(SkGlyph::Intercept)); intercept->fNext = glyph->fPathData->fIntercept; intercept->fBounds[0] = bounds[0]; intercept->fBounds[1] = bounds[1]; intercept->fInterval[0] = SK_ScalarMax; intercept->fInterval[1] = SK_ScalarMin; glyph->fPathData->fIntercept = intercept; const SkPath* path = glyph->fPathData->fPath; const SkRect& pathBounds = path->getBounds(); if (*(&pathBounds.fBottom - yAxis) < bounds[0] || bounds[1] < *(&pathBounds.fTop - yAxis)) { return; } SkPath::Iter iter(*path, false); SkPoint pts[4]; SkPath::Verb verb; while (SkPath::kDone_Verb != (verb = iter.next(pts))) { switch (verb) { case SkPath::kMove_Verb: break; case SkPath::kLine_Verb: AddLine(pts, bounds[0], yAxis, intercept); AddLine(pts, bounds[1], yAxis, intercept); AddPoints(pts, 2, bounds, yAxis, intercept); break; case SkPath::kQuad_Verb: if (!quad_in_bounds(&pts[0].fY - yAxis, bounds)) { break; } AddQuad(pts, bounds[0], yAxis, intercept); AddQuad(pts, bounds[1], yAxis, intercept); AddPoints(pts, 3, bounds, yAxis, intercept); break; case SkPath::kConic_Verb: SkASSERT(0); // no support for text composed of conics break; case SkPath::kCubic_Verb: if (!cubic_in_bounds(&pts[0].fY - yAxis, bounds)) { break; } AddCubic(pts, bounds[0], yAxis, intercept); AddCubic(pts, bounds[1], yAxis, intercept); AddPoints(pts, 4, bounds, yAxis, intercept); break; case SkPath::kClose_Verb: break; default: SkASSERT(0); break; } } if (intercept->fInterval[0] >= intercept->fInterval[1]) { intercept->fInterval[0] = SK_ScalarMax; intercept->fInterval[1] = SK_ScalarMin; return; } OffsetResults(intercept, scale, xPos, array, count); }
void mitk::BulgeTool::MovePointsInMouseMovementDirection() { //std::cout << "hi from " << __FUNCSIG__ << std::endl; // Add Points to Mesh? if(m_RefinementTechnique != 0) { AddPoints(); } // Create new vtk poly data that will substitutes the old vtkPolyData* newData = vtkPolyData::New(); newData->DeepCopy(m_Ext->GetSurfacePolyData()); // Use direction of the mouse movement vtkIdType inputNumPoints = m_Ext->GetSurfacePolyData()->GetPoints()->GetNumberOfPoints(); // Get center of the ball interactor pdp::Pt center = m_Ext->GetBall()->GetVtkPolyData()->GetCenter(); // Mouse Movement m_MouseMovementVector = center - m_OldVOICenterVector; // Mouse Movement with multiple vectors pdp::Pt oldVOICenterVectorSum(0.0); for(int i = 0; i < m_MouseMovementVectorSumLength; i++) { oldVOICenterVectorSum[0] += m_OldVOICenterVectors[0+i*3]; oldVOICenterVectorSum[1] += m_OldVOICenterVectors[1+i*3]; oldVOICenterVectorSum[2] += m_OldVOICenterVectors[2+i*3]; } m_MouseMovementVectorSum = center - oldVOICenterVectorSum / m_MouseMovementVectorSumLength; // Move Points for (vtkIdType ptId = 0; ptId < inputNumPoints; ptId++) { pdp::Pt pt; m_Ext->GetSurfacePolyData()->GetPoints()->GetPoint(ptId, pt.toVtk()); // Use distance pdp::Pt centerToPointVector = pt - center; double centerToPointVectorLength = sqrt((centerToPointVector[0])*(centerToPointVector[0])+(centerToPointVector[1])*(centerToPointVector[1])+(centerToPointVector[2])*(centerToPointVector[2])); double radius = m_Ext->GetRadius(); if(centerToPointVectorLength < radius) { // Calculate dot product between mouse movement vector and center to point vector. (Skalarprodukt) double dotProduct = m_MouseMovementVector[0]*centerToPointVector[0] + m_MouseMovementVector[1]*centerToPointVector[1] + m_MouseMovementVector[2]*centerToPointVector[2]; //std::cout << "Dot Product: " << dotProduct << "\n"; // Calculate length of Mouse Movement Vector double mouseMovementVectorLength = sqrt(m_MouseMovementVector[0]*m_MouseMovementVector[0]+m_MouseMovementVector[1]*m_MouseMovementVector[1]+m_MouseMovementVector[2]*m_MouseMovementVector[2]); // Calculate angle between mouse movement vector and center to point vector. (beta) double beta = asin(/*-*/(dotProduct / (centerToPointVectorLength*mouseMovementVectorLength))); // FIXME: What about the minus? cos(a+90) = -sin(a) ??? //std::cout << "Beta: " << beta << "\n"; // Calculate angle between mouse movement vector and center to NEW point vector. (beta') double newBeta = acos((cos(beta) * centerToPointVectorLength) / radius); //std::cout << "Beta': " << newBeta << "\n"; // Calculate translation length between old point and translated point. double oldPointToNewPointLength = (sin(newBeta) * radius) - (sin(beta) * centerToPointVectorLength); //test //double oldPointToNewPointLength = mouseMovementVectorLength; // Calculate translation vector. pdp::Pt translationVector; translationVector = m_MouseMovementVector * oldPointToNewPointLength / mouseMovementVectorLength; // Calculate translated point. pt += translationVector; newData->GetPoints()->SetPoint(ptId, pt[0], pt[1], pt[2]); m_SurfaceChanged = true; } } // Mouse Movement m_OldVOICenterVector = center; // Mouse Movement with multiple vectors m_OldVOICenterVectors[0+m_OldVoidCenterVectorIndex] = center[0]; m_OldVOICenterVectors[1+m_OldVoidCenterVectorIndex] = center[1]; m_OldVOICenterVectors[2+m_OldVoidCenterVectorIndex] = center[2]; // Increase m_OldVoidCenterVectorIndex appropriate if(m_OldVoidCenterVectorIndex == m_MouseMovementVectorSumLength*3) { m_OldVoidCenterVectorIndex = 0; } else { m_OldVoidCenterVectorIndex += 3; } //std::cout << "OldVoidCenterVectorIndex: " << m_OldVoidCenterVectorIndex << "\n"; m_Ext->GetSurface()->SetVtkPolyData(newData); m_Ext->UpdateRenderer(); //std::cout << "ciao from " << __FUNCSIG__ << std::endl; }
void CFDE_Path::LineTo(FX_FLOAT fx, FX_FLOAT fy) { FX_PATHPOINT* pPoint = AddPoints(1); pPoint->m_PointX = fx; pPoint->m_PointY = fy; pPoint->m_Flag = FXPT_LINETO; }
void BattlegroundEY::Update(uint32 diff) { Battleground::Update(diff); if (GetStatus() == STATUS_IN_PROGRESS) { m_PointAddingTimer -= diff; if (m_PointAddingTimer <= 0) { m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME; if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0) AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]); if (m_TeamPointsCount[BG_TEAM_HORDE] > 0) AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]); } if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND) { m_FlagsTimer -= diff; if (m_FlagsTimer < 0) { m_FlagsTimer = 0; if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN) RespawnFlag(true); else RespawnFlagAfterDrop(); } } m_TowerCapCheckTimer -= diff; if (m_TowerCapCheckTimer <= 0) { //check if player joined point /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times but we can count of players on current point in CheckSomeoneLeftPoint */ this->CheckSomeoneJoinedPoint(); //check if player left point this->CheckSomeoneLeftPoint(); this->UpdatePointStatuses(); m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; } } if (GetStatus() == STATUS_WAIT_JOIN) { m_CheatersCheckTimer -= diff; if(m_CheatersCheckTimer <= 0) { for(BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { Player * plr = sObjectMgr->GetPlayer(itr->first); if (!plr || !plr->IsInWorld()) continue; if (plr->GetPositionZ() < 1249) { if (plr->GetTeam() == HORDE) plr->TeleportTo(566, 1807.73f, 1539.41f, 1267.63f, plr->GetOrientation(), 0); else plr->TeleportTo(566, 2523.68f, 1596.59f, 1269.35f, plr->GetOrientation(), 0); } } m_CheatersCheckTimer = 3000; } } }
void CChartSerie::SetPoints(double *X, double *Y, int Count) { m_vPoints.clear(); AddPoints(X, Y, Count); }
void BattleGroundEY::Update(time_t diff) { BattleGround::Update(diff); // after bg start we get there (once) if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) { ModifyStartDelayTime(diff); if(!(m_Events & 0x01)) { m_Events |= 0x01; SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY); SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_IMMEDIATELY); for(uint32 i = BG_EY_OBJECT_A_BANNER_FEL_REALVER_CENTER; i < BG_EY_OBJECT_MAX; ++i) SpawnBGObject(i, RESPAWN_ONE_DAY); SetStartDelayTime(START_DELAY0); } // After 1 minute, warning is signalled else if(GetStartDelayTime() <= START_DELAY1 && !(m_Events & 0x04)) { m_Events |= 0x04; SendMessageToAll(GetMangosString(LANG_BG_EY_ONE_MINUTE)); } // After 1,5 minute, warning is signalled else if(GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x08)) { m_Events |= 0x08; SendMessageToAll(GetMangosString(LANG_BG_EY_HALF_MINUTE)); } // After 2 minutes, gates OPEN ! x) else if(GetStartDelayTime() < 0 && !(m_Events & 0x10)) { m_Events |= 0x10; SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_ONE_DAY); SpawnBGObject(BG_EY_OBJECT_DOOR_H, RESPAWN_ONE_DAY); for(uint32 i = BG_EY_OBJECT_N_BANNER_FEL_REALVER_CENTER; i <= BG_EY_OBJECT_FLAG_NETHERSTORM; ++i) SpawnBGObject(i, RESPAWN_IMMEDIATELY); for(uint32 i = 0; i < EY_POINTS_MAX; ++i) { //randomly spawn buff uint8 buff = urand(0, 2); SpawnBGObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REALVER + buff + i * 3, RESPAWN_IMMEDIATELY); } SendMessageToAll(GetMangosString(LANG_BG_EY_BEGIN)); PlaySoundToAll(SOUND_BG_START); SetStatus(STATUS_IN_PROGRESS); for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if(Player *plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); } } else if(GetStatus() == STATUS_IN_PROGRESS) { m_PointAddingTimer -= diff; if(m_PointAddingTimer <= 0) { m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME; if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0) AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]); if (m_TeamPointsCount[BG_TEAM_HORDE] > 0) AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]); } if(m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND) { m_FlagsTimer -= diff; if(m_FlagsTimer < 0) { m_FlagsTimer = 0; if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN) RespawnFlag(true); else RespawnFlagAfterDrop(); } } m_TowerCapCheckTimer -= diff; if(m_TowerCapCheckTimer <= 0) { //check if player joined point /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times but we can count of players on current point in CheckSomeoneLeftPoint */ this->CheckSomeoneJoinedPoint(); //check if player left point this->CheckSomeoneLeftPoint(); this->UpdatePointStatuses(); m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; } } }
void BattlegroundEY::PostUpdateImpl(uint32 diff) { if (GetStatus() == STATUS_IN_PROGRESS) { m_PointAddingTimer -= diff; if (m_PointAddingTimer <= 0) { m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME; if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0) AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]); if (m_TeamPointsCount[BG_TEAM_HORDE] > 0) AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]); } if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND) { m_FlagsTimer -= diff; if (m_FlagsTimer < 0) { m_FlagsTimer = 0; if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN) RespawnFlag(true); else RespawnFlagAfterDrop(); } } m_TowerCapCheckTimer -= diff; if (m_TowerCapCheckTimer <= 0) { // Check if the player joined the point. CheckSomeoneJoinedPoint(); // Check if the player left the point. CheckSomeoneLeftPoint(); UpdatePointStatuses(); m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; } } // Check for players below map / cheaters. if (GetStatus() == STATUS_WAIT_JOIN) { m_CheatersCheckTimer -= diff; if (m_CheatersCheckTimer <= 0) { if (!GetPlayers().empty()) { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { Player * plr = ObjectAccessor::FindPlayer(itr->first); if (!plr || !plr->IsInWorld()) continue; if (plr->GetPositionZ() < 1244.0f) { if (plr->GetBGTeam() == HORDE) plr->TeleportTo(566, 1807.98f, 1539.42f, 1247.52f, plr->GetOrientation(), 0); else plr->TeleportTo(566, 2527.18f, 1597.31f, 1248.78f, plr->GetOrientation(), 0); } } } m_CheatersCheckTimer = 4000; } } }
void PlayLoop (void) { id0_int_t give; void (*think)(struct objstruct *); // REFKEEN: C++ patch ingame = true; SD_SetTimeCount(0); playstate = (exittype)0; //playstate = TimeCount = 0; gamestate.shotpower = handheight = 0; pointcount = pointsleft = 0; DrawLevelNumber (gamestate.mapon); DrawBars (); #ifndef PROFILE fizzlein = true; // fizzle fade in the first refresh #endif /*TimeCount = */lasttimecount = lastnuke = 0; PollControls (); // center mouse StartMusic (); do { #ifndef PROFILE PollControls(); #else c.xaxis = 1; // if (++TimeCount == 300) // return; SD_SetTimeCount(SD_GetTimeCount()+1); if (SD_GetTimeCount() == 300) return; #endif for (obj = player;obj;obj = obj->next) if (obj->active) { if (obj->ticcount) { obj->ticcount-=tics; while ( obj->ticcount <= 0) { think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) { RemoveObj (obj); goto nextactor; } } obj->state = obj->state->next; if (!obj->state) { RemoveObj (obj); goto nextactor; } if (!obj->state->tictime) { obj->ticcount = 0; goto nextactor; } if (obj->state->tictime>0) obj->ticcount += obj->state->tictime; } } think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) RemoveObj (obj); } nextactor:; } if (bordertime) { bordertime -= tics; if (bordertime<=0) { bordertime = 0; VW_ColorBorder (3); } } if (pointcount) { pointcount -= tics; if (pointcount <= 0) { pointcount += POINTTICS; give = (pointsleft > 1000)? 1000 : ( (pointsleft > 100)? 100 : ((pointsleft < 20)? pointsleft : 20) ); SD_PlaySound (GETPOINTSSND); AddPoints (give); pointsleft -= give; if (!pointsleft) pointcount = 0; } } ThreeDRefresh (); CheckKeys(); // (REFKEEN) SPECIAL - Without this the game // can run very fast, even if it's not noticeable // (a lot of PlayLoop iterations and consumed CPU power) // // Notes: // 1. Should NOT be called from ThreeDRefresh/CalcTics, // because we don't always want that to be done // (e.g., FizzleFade effect right after loading C4 saved game). // 2. SHOULD be called AFTER CheckKeys. That function resets // lasttimecount (just like CalcTics) if the debug key modifier // (F10 in Cat. 3-D/Abyss, Backspace in Armageddon/Apocalypse) // is held. As a consequence, if the wait is done before the // call to CheckKeys then the game may seem to get stuck while // the debug key modifier is held. BE_ST_TimeCountWaitFromSrc(SD_GetTimeCount(), 1); // if (singlestep) { VW_WaitVBL(14); lasttimecount = SD_GetTimeCount(); } if (extravbls) VW_WaitVBL(extravbls); }while (!playstate); StopMusic (); ingame = false; if (bordertime) { bordertime = 0; VW_ColorBorder (3); } if (!abortgame) AddPoints (pointsleft); else abortgame = false; }