void NPC::MoveAction(void) { if ((g_waypoint->g_waypointPointFlag[m_currentWaypointIndex] & WAYPOINT_LADDER && GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_currentWaypointIndex]) <= 10.0f) || (m_oldNavIndex != -1 && g_waypoint->g_waypointPointFlag[m_oldNavIndex] & WAYPOINT_LADDER && GetDistance2D(pev->origin, g_waypoint->g_waypointPointOrigin[m_oldNavIndex]) <= 10.0f)) pev->movetype = MOVETYPE_FLY; else pev->movetype = MOVETYPE_PUSHSTEP; float oldSpeed = pev->speed; pev->speed = m_moveSpeed; if (m_moveSpeed == 0.0f || !IsAlive (GetEntity ())) { if (!IsOnLadder(GetEntity()) && pev->solid != SOLID_NOT) DROP_TO_FLOOR(GetEntity()); return; } if (IsOnLadder(GetEntity()) || pev->solid == SOLID_NOT) { pev->velocity = GetSpeedVector(pev->origin, m_destOrigin, pev->speed); if (pev->solid == SOLID_NOT) goto lastly; } else { Vector vecMove = m_destOrigin - pev->origin; Vector vecFwd, vecAng; VEC_TO_ANGLES(vecMove, vecAng); vecAng = Vector(0.0f, vecAng.y, 0.0f); UTIL_MakeVectorsPrivate(vecAng, vecFwd, null, null); pev->velocity.x = vecFwd.x * pev->speed; pev->velocity.y = vecFwd.y * pev->speed; } if (m_jumpAction) { pev->velocity.z = (270.0f * pev->gravity) + 32.0f; // client gravity 1 = 270.0f , and jump+duck + 32.0f m_jumpAction = false; } CheckStuck(oldSpeed); lastly: float speed = GetDistance2D(pev->velocity); if (speed > 10.0f || speed < -10.0f) g_npcAS |= ASC_MOVE; MakeVectors(pev->angles); }
void BoatAnalysisDlg::ComputeSurfSpeeds(double *Mu, double *Sigma) { int p; CVector C; for (p=0; p<m_MatSize; p++) { if(m_bCancel) return; C = s_pPanel[p].CollPt;//+ s_pPanel[p].Normal*s_pPanel[p].Size/100.0; C += s_pPanel[p].Normal*0.001; GetSpeedVector(C, Mu, Sigma, m_Speed[p]); m_Speed[p] += m_VInf * m_pBoatPolar->WindFactor(C.z); } }
void BoatAnalysisDlg::Forces(double *Mu, double *Sigma, double alpha, double *VInf, CVector &Force, CVector &Moment, bool bTilted, bool bTrace) { // Calculates the forces using a farfield method // Calculates the moments by a near field method, i.e. direct summation on the panels // Downwash is evaluated at a distance 100 times the span downstream (i.e. infinite) // if(!s_pPanel||!m_pBoatPolar) return; static int j, k, l, p, pp, m, nw, iTA, iTB; static double StripArea; static double GammaStrip; static CVector C, PanelLeverArm, Wg; static CVector Velocity, StripForce, dF, PanelForce, PanelForcep1; // QSail7 *pSail7= (QSail7*)s_pSail7; int coef = 1; p=m=0; Force.Set( 0.0, 0.0, 0.0); Moment.Set(0.0, 0.0, 0.0); for(j=0; j<m_pBoat->m_poaSail.size(); j++) { QSail *pSail = (QSail*)m_pBoat->m_poaSail.at(j); for(k=0; k<pSail->m_NZPanels; k++) { //Get the strip area pp=p; StripArea = 0.0; for (l=0; l<coef*pSail->m_NXPanels; l++) { StripArea += s_pPanel[pp].Area; pp++; } //Get the strip's lifting force if(s_pPanel[p].m_Pos!=MIDSURFACE) { StripArea /=2.0; //FF force nw = s_pPanel[p].m_iWake; iTA = s_pWakePanel[nw].m_iTA; iTB = s_pWakePanel[nw].m_iTB; C = (s_pWakeNode[iTA] + s_pWakeNode[iTB])/2.0; GetSpeedVector(C, Mu, Sigma, Wg, false); Wg.x += VInf[p ]; Wg.y += VInf[p+m_MatSize ]; Wg.z += VInf[p+2*m_MatSize]; GammaStrip = (-Mu[p+coef*pSail->m_NXPanels-1] + Mu[p]) *4.0*PI; StripForce = s_pPanel[p].Vortex * Wg; StripForce *= GammaStrip; //Newtons/rho Force += StripForce; Velocity.x = *(VInf +p); Velocity.y = *(VInf + m_MatSize +p); Velocity.z = *(VInf + 2*m_MatSize +p); p += pSail->m_NXPanels*coef; } else { //iPos=0, VLM type panel StripForce.Set(0.0,0.0,0.0); for(l=0; l<pSail->m_NXPanels; l++) { Velocity.x = *(VInf +p); Velocity.y = *(VInf + m_MatSize +p); Velocity.z = *(VInf + 2*m_MatSize +p); //FF force if(m_pBoatPolar->m_bVLM1 || s_pPanel[p].m_bIsTrailing) { C = s_pPanel[p].CtrlPt; C.x = m_pBoatPolar->m_Span * 100.0; GetSpeedVector(C, Mu, Sigma, Wg, false); Wg += Velocity; //total speed vector //induced force dF = Wg * s_pPanel[p].Vortex; dF *= Mu[p]; // N/rho Force += dF; // N/rho StripForce += dF; } //On-Body moment PanelForce = Velocity * s_pPanel[p].Vortex; PanelForce *= Mu[p]; //Newtons/rho if(!m_pBoatPolar->m_bVLM1 && !s_pPanel[p].m_bIsLeading) { PanelForcep1 = Velocity * s_pPanel[p].Vortex; PanelForcep1 *= Mu[p+1]; //Newtons/rho PanelForce -= PanelForcep1; } PanelLeverArm = s_pPanel[p].VortexPos - m_pBoatPolar->m_CoG; Moment += PanelLeverArm * PanelForce; // N.m/rho p++; } } m++; } } Force -= m_WindDirection*Force.dot(m_WindDirection)/2.0; Force *= m_pBoatPolar->m_Density; // N Moment *= m_pBoatPolar->m_Density; // N.m }