float angle_from (Stuff::Vector3D &v1, Stuff::Vector3D &v2) { float mag_product = v1.GetLength() * v2.GetLength(); if (mag_product == 0.0) return mag_product; // 0; else { float vecResult = v1 * v2; return (my_acos(vecResult / mag_product) * RADS_TO_DEGREES); } }
void Team::markRadiusSeenToTeams(Stuff::Vector3D& location, float radius, bool shrinkForNight) { if(radius < 0.0) radius = fireVisualRange; if(shrinkForNight) radius -= (radius * 0.25f); bool didTeam[MAX_TEAMS] = {false, false, false, false, false, false, false, false}; for(size_t i = 0; i < ObjectManager->getNumMovers(); i++) { MoverPtr mover = ObjectManager->getMover(i); if(mover->getTeam() && !didTeam[mover->getTeamId()] && !isFriendly(mover->getTeam())) { Stuff::Vector3D result; result.x = location.x - mover->getPosition().x; result.y = location.y - mover->getPosition().y; result.z = 0.0; float dist = result.GetLength() * metersPerWorldUnit; if(dist < maxVisualRange) { markRadiusSeen(location, radius); didTeam[mover->getTeamId()] = true; } } } }
void MoverGroup::sortMovers( int32_t numMoversInGroup, MoverPtr* moverList, Stuff::Vector3D destination) { Mover::sortList->clear(); for (size_t i = 0; i < numMoversInGroup; i++) { int32_t index = -1; float dist = (float)3.48E+37; if (moverList[i]) { index = i; Stuff::Vector3D resultVector; resultVector.Subtract(moverList[i]->getPosition(), destination); dist = resultVector.GetLength(); } Mover::sortList->setId(i, index); Mover::sortList->setValue(i, dist); } Mover::sortList->sort(false); for (i = 0; i < numMoversInGroup; i++) { int32_t moverIndex = Mover::sortList->getId(i); if (moverIndex != -1) moverList[moverIndex]->selectionIndex = i; } }
float distance_from (Stuff::Vector3D &v1, Stuff::Vector3D &v2) { Stuff::Vector3D result; result.x = v2.x - v1.x; result.y = v2.y - v1.y; result.z = v2.z - v1.z; float dist = result.GetLength(); return (dist); }