Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1608 for code/trunk/src/util


Ignore:
Timestamp:
Jun 17, 2008, 3:33:03 PM (16 years ago)
Author:
landauf
Message:
  • added a backlight to all SpaceShips, leaving a trail behind (configurable)
  • changed some lines in SpaceShipAI, AI seems to be more fair now…
  • fixed a bug in Math.cc algorithms to calculate radar positions and AI movement (division by zero and acos of 1.000001)
  • added destroy() and destroydelay to ParticleSpawner, so the smoketrail of a destroyed enemy stays visible for some seconds
  • added 2 lines to Orxonox.cc to make the length of the backlight-trail independend of the gamespeed

########################
# !!! MEDIA UPDATE !!! #
########################

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/util/Math.cc

    r1566 r1608  
    7575{
    7676    orxonox::Vector3 distance = otherposition - myposition;
    77     return acos(mydirection.dotProduct(distance) / distance.length());
     77    float distancelength = distance.length();
     78    if (distancelength == 0)
     79        return 0;
     80    else
     81        return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1));
    7882}
    7983
     
    8488    // project difference vector on our plane
    8589    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
    86     float angle = acos(myorthonormal.dotProduct(projection) / projection.length());
     90
     91    float projectionlength = projection.length();
     92    if (projectionlength == 0) return orxonox::Vector2(0, 0);
     93    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
    8794
    8895    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
     
    98105    // project difference vector on our plane
    99106    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
    100     float angle = acos(myorthonormal.dotProduct(projection) / projection.length());
    101     float radius = acos(mydirection.dotProduct(distance) / distance.length()) / Ogre::Math::PI;
     107
     108    float projectionlength = projection.length();
     109    if (projectionlength == 0) return orxonox::Vector2(0, 0);
     110    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
     111
     112    float distancelength = distance.length();
     113    if (distancelength == 0) return orxonox::Vector2(0, 0);
     114    float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;
    102115
    103116    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
Note: See TracChangeset for help on using the changeset viewer.