//----------------------- Calculate -------------------------------------- // // calculates the accumulated steering force according to the method set // in m_SummingMethod //------------------------------------------------------------------------ Vector2D SteeringBehavior::Calculate(float dt) { switch (m_SummingMethod) { case weighted_average: return CalculateWeightedSum(dt); case prioritized: return CalculatePrioritized(dt); default: return Vector2D(0,0); } }
Vector2D SteeringBehavior::Calculate() { m_vSteeringForce = Vector2D(0.0f, 0.0f); ////use space partitioning to calculate the neighbours of this vehicle ////if switched on. If not, use the standard tagging system //if (!isSpacePartitioningOn()) //{ ////tag neighbors if any of the following 3 group behaviors are switched on //if (On(separation) || On(allignment) || On(cohesion)) //{ // m_pVehicle->World()->TagVehiclesWithinViewRange(m_pVehicle, m_dViewDistance); //} //} //else //{ // //calculate neighbours in cell-space if any of the following 3 group // //behaviors are switched on // if (On(separation) || On(allignment) || On(cohesion)) // { // m_pVehicle->World()->CellSpace()->CalculateNeighbors(m_pVehicle->Pos(), m_dViewDistance); // } //} switch (m_SummingMethod) { case weighted_average: m_vSteeringForce = CalculateWeightedSum(); break; case prioritized: m_vSteeringForce = CalculatePrioritized(); break; case dithered: m_vSteeringForce = CalculateDithered();break; default:m_vSteeringForce = Vector2D(0,0); }//end switch return m_vSteeringForce; }
Vector2D B020612E_Steering::Calculate() { _pSteeringForce.Zero(); switch (_pSummingMethod) { case PRIORITIZED: _pSteeringForce = CalculatePrioritised(); break; case WEIGHTED_AVERAGE: _pSteeringForce = CalculateWeightedSum(); break; case DITHERED: _pSteeringForce = CalculateDithered(); break; default: _pSteeringForce = Vector2D(0.0f, 0.0f); break; } return _pSteeringForce; }