//----------------------------------------------------------------// float USBox::GetRadius () const { USVec3D spans = mMax; spans.Sub ( mMin ); spans.Scale ( 0.5f ); return spans.Length (); }
USVec3D SeekSteering::GetSteeringArrive( Character* character, const USVec3D& targetPos ) { USVec3D newDir = targetPos - character->GetLoc(); float radius = character->GetDstRadius(); float distance = newDir.Length(); newDir.Norm(); if( distance > radius ) newDir *= character->GetMaxVel(); else newDir *= character->GetMaxVel() * ( distance / radius ); USVec3D speed = newDir - character->GetLinearVelocity(); speed.Norm(); return speed * character->GetMaxAcc(); }