|
@@ -402,6 +402,8 @@ void Model2DData::removeModell()
|
|
|
|
|
|
bool Model2DData::calcHitPoint( Vertex pos, Vertex dir, const char *polygonName, Vertex &hitpoint, Vertex &moveSpeed, float &rotSpeed ) const
|
|
|
{
|
|
|
+ if( dir.x == 0 && dir.y == 0 )
|
|
|
+ return 0;
|
|
|
bool ret = 0;
|
|
|
for( auto polygon = polygons->getIterator(); polygon; polygon++ )
|
|
|
{
|
|
@@ -417,9 +419,17 @@ bool Model2DData::calcHitPoint( Vertex pos, Vertex dir, const char *polygonName,
|
|
|
if( dir.y != 0 && dir.x != 0 )
|
|
|
offset = ( ( a.y - pos.y ) / dir.y - ( a.x - pos.x ) / dir.x ) / ( b.x / dir.x - b.y / dir.y );
|
|
|
else if( dir.y == 0 )
|
|
|
+ {
|
|
|
+ if( b.y == 0 )
|
|
|
+ continue;
|
|
|
offset = ( pos.y - a.y ) / b.y;
|
|
|
+ }
|
|
|
else if( dir.x == 0 )
|
|
|
+ {
|
|
|
+ if( b.x == 0 )
|
|
|
+ continue;
|
|
|
offset = ( pos.x - a.x ) / b.x;
|
|
|
+ }
|
|
|
Vertex point = a + ( b * offset );
|
|
|
if( offset >= 0 && offset <= 1 )
|
|
|
{
|
|
@@ -435,6 +445,8 @@ bool Model2DData::calcHitPoint( Vertex pos, Vertex dir, const char *polygonName,
|
|
|
Vertex rotKraft = normal * ( normal * kNorm ) * dir.getLength();
|
|
|
rotSpeed = ( (float)sqrt( rotKraft.getLength() * ( point - *polygon._.schwerpunkt ).getLength() ) / 180.f ) * 3.14f * ( normal * kNorm );
|
|
|
hitpoint = point;
|
|
|
+ if( isnan( moveSpeed.x ) || isnan( moveSpeed.y ) || isnan( rotSpeed ) )
|
|
|
+ return 0;
|
|
|
ret = 1;
|
|
|
}
|
|
|
}
|