DayZ
1.30
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
◆
DetectFlippedUsingSurface()
bool
map::DetectFlippedUsingSurface
(
VehicleFlippedContext
ctx
,
float
angleTolerance
)
inline
protected
См. определение в файле
Transport.c
строка
522
523
{
524
vector
corners
[4];
525
GetTightlyPackedCorners
(
ETransformationAxis
.BOTTOM,
corners
);
526
527
// compute the average position to find the lowest "center-most" position
528
vector
avgPosition
=
vector
.Zero;
529
for
(
int
i
= 0;
i
< 4;
i
++)
530
{
531
avgPosition
=
avgPosition
+
corners
[
i
];
532
}
533
534
avgPosition
=
avgPosition
* 0.25;
535
536
// get depth of the water to determine if we should use the roadway surface normal or just up vector
537
float
depth
=
g_Game
.GetWaterDepth(
avgPosition
);
538
539
vector
normal
=
vector
.Up;
540
vector
dirUp
=
GetDirectionUp
();
541
542
bool
testLand
=
depth
< -1.0;
543
544
// iterate over the corners to find the average normal
545
if
(
testLand
)
546
{
547
// trace roadway, incase the vehicle is on a rock, or bridge
548
ctx
.m_SurfaceParams.type =
SurfaceDetectionType
.Roadway;
549
550
// ignore expensive water computation, we already know we are above land
551
ctx
.m_SurfaceParams.includeWater =
false
;
552
553
// ignore this vehicle, it may have a roadway LOD
554
ctx
.m_SurfaceParams.ignore =
this
;
555
556
// detect closest to the given point
557
ctx
.m_SurfaceParams.rsd =
RoadSurfaceDetection
.CLOSEST;
558
559
for
(
i
= 0;
i
< 4;
i
++)
560
{
561
ctx
.m_SurfaceParams.position =
corners
[
i
];
562
563
g_Game
.GetSurface(
ctx
.m_SurfaceParams,
ctx
.m_SurfaceResult);
564
565
corners
[
i
][1] =
ctx
.m_SurfaceResult.height;
566
}
567
568
vector
d0
=
vector
.Direction(
corners
[0],
corners
[1]);
569
vector
d1
=
vector
.Direction(
corners
[0],
corners
[2]);
570
571
d0
.Normalize();
572
d1
.Normalize();
573
574
// cross product the two directions to get the normal vector of the land
575
normal
=
d0
*
d1
;
576
}
577
578
bool
isFlipped
=
vector
.Dot(
normal
,
dirUp
) <
Math
.Cos(
angleTolerance
*
Math
.DEG2RAD);
579
580
#ifdef DIAG_DEVELOPER
581
if
(
ctx
.IsDebug())
582
{
583
int
color
= 0xFF00FF00;
584
if
(
isFlipped
)
585
color
= 0xFFFF0000;
586
587
ctx
.AddShape(
Shape
.Create(
ShapeType
.LINE,
color
,
ShapeFlags
.NOZBUFFER,
corners
[0],
corners
[0] +
normal
));
588
ctx
.AddShape(
Shape
.Create(
ShapeType
.LINE,
color
,
ShapeFlags
.NOZBUFFER,
corners
[1],
corners
[1] +
normal
));
589
ctx
.AddShape(
Shape
.Create(
ShapeType
.LINE,
color
,
ShapeFlags
.NOZBUFFER,
corners
[2],
corners
[2] +
normal
));
590
ctx
.AddShape(
Shape
.Create(
ShapeType
.LINE,
color
,
ShapeFlags
.NOZBUFFER,
corners
[3],
corners
[3] +
normal
));
591
}
592
#endif
593
594
return
isFlipped
;
595
}
map
Определения
Transport.c:70
map< Class TKey, Class TValue >
Создано системой
1.13.2