16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 20:19:18 +02:00

minor camera refactoring, division by zero guards

This commit is contained in:
tmj-fstate
2018-08-03 16:07:50 +02:00
parent ff6bed67a9
commit ec1a625c12
20 changed files with 110 additions and 116 deletions

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "DynObj.h"
#include "simulation.h"
#include "camera.h"
#include "train.h"
#include "driver.h"
#include "Globals.h"
@@ -1061,19 +1062,19 @@ TDynamicObject * TDynamicObject::ABuFindNearestObject(TTrack *Track, TDynamicObj
if( CouplNr == -2 ) {
// wektor [kamera-obiekt] - poszukiwanie obiektu
if( Math3D::LengthSquared3( Global.pCameraPosition - dynamic->vPosition ) < 100.0 ) {
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vPosition ) < 100.0 ) {
// 10 metrów
return dynamic;
}
}
else {
// jeśli (CouplNr) inne niz -2, szukamy sprzęgu
if( Math3D::LengthSquared3( Global.pCameraPosition - dynamic->vCoulpler[ 0 ] ) < 25.0 ) {
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 0 ] ) < 25.0 ) {
// 5 metrów
CouplNr = 0;
return dynamic;
}
if( Math3D::LengthSquared3( Global.pCameraPosition - dynamic->vCoulpler[ 1 ] ) < 25.0 ) {
if( Math3D::LengthSquared3( Global.pCamera.Pos - dynamic->vCoulpler[ 1 ] ) < 25.0 ) {
// 5 metrów
CouplNr = 1;
return dynamic;